:root {
  color-scheme: light;
  /* GNOME / Adwaita inspired palette */
  --bg: #f5f7f6;
  --surface: #ffffff;
  --text: #2e3436;
  --muted: #60666a;
  --border: #d8dee0;
  --accent: #3465a4; /* primary Adwaita blue */
  --accent-strong: #2b4f86;
  --adwaita-blue: #3465a4;
  --adwaita-blue-strong: #2b4f86;
  --success: #4e9a06;
  --warning: #f57900;
  --danger: #cc0000;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark variant tuned to Adwaita dark tones */
    --bg: #2e3436;
    --surface: #23292a;
    --text: #e6edf0;
    --muted: #9aa3a6;
    --border: #3a4143;
    --accent: #3465a4;
    --accent-strong: #2b4f86;
    --success: #73b574;
    --warning: #f6994b;
    --danger: #ff4c4c;
  }
}

body[data-theme="light"] {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --border: #d0d7e1;
}

body[data-theme="dark"] {
  --bg: #05070d;
  --surface: #0f111a;
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: #1e293b;
}

body {
  margin: 0;
  font-family: "Inter", "SF Pro Display", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-weight: 700;
  letter-spacing: 0.08em;
}

nav {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.site-header a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

/* Account dropdown */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 500;
  font-size: inherit;
  font-family: inherit;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  transition: background 0.15s ease;
}

.nav-dropdown-toggle:hover {
  background: var(--bg);
}

.nav-dropdown-toggle svg {
  transition: transform 0.2s ease;
}

.nav-dropdown-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  z-index: 100;
  overflow: hidden;
  display: none;
}

.nav-dropdown-menu.show {
  display: block;
}

.nav-dropdown-menu a {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s ease;
  border: none;
}

.nav-dropdown-menu a:hover {
  background: var(--bg);
}

.nav-dropdown-menu a:first-child {
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
}

.nav-dropdown-menu a:last-child {
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
}

.button {
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
  box-sizing: border-box;
}

.button.primary {
  background: var(--adwaita-blue);
  color: #fff;
}

.button.primary:hover {
  background: var(--adwaita-blue-strong);
}

.button.secondary {
  background: transparent;
  border: 1px solid var(--border);
}

/* Improve visibility of secondary buttons in dark theme (e.g. "Select images") */
body[data-theme="dark"] .button.secondary {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset;
}

body[data-theme="dark"] .button.secondary:hover {
  background: rgba(255, 255, 255, 0.06);
}

.button.large {
  font-size: 1rem;
  padding: 0.85rem 1.75rem;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem clamp(1rem, 4vw, 2rem);
  align-items: flex-start;
  flex-shrink: 0;
}

.hero .lede {
  max-width: 42rem;
  color: var(--muted);
}

main {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Two-column dashboard layout: left column for hero + generator, right column for gallery */
.two-column-wrap {
  padding: 0;
  box-sizing: border-box;
  max-width: 100%;
  overflow-x: hidden;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(260px, 380px) minmax(0, 1fr);
  gap: 1.5rem;
  max-width: 100%;
}

.left-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  min-width: 0;
}

.right-column {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

@media (max-width: 900px) {
  .two-column {
    display: block;
  }
  .two-column-wrap {
    padding: 1rem;
  }
}

.flash-grid {
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.flash {
  padding: 0.8rem 1rem;
  border-radius: 0.75rem;
  font-weight: 500;
}

.flash-success {
  background: rgba(78, 154, 6, 0.08);
  color: var(--success);
}

.flash-warning {
  background: rgba(251, 191, 36, 0.15);
  color: #92400e;
}

.flash-error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.flash-info {
  background: rgba(148, 163, 184, 0.14);
  color: var(--muted);
}

.site-footer {
  padding: 2rem clamp(1rem, 4vw, 2rem);
  color: var(--muted);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

.generate-card,
.gallery-section,
.account-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

/* Conversation panel: make the chat area fill available height and keep input docked to bottom */
.right-column > .generate-card {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  min-height: 420px;
  padding-bottom: 0.5rem;
}

.right-column .chat-area {
  flex: 1 1 auto;
  overflow: auto;
  padding: 0.75rem 0;
}

.chat-form {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  position: relative;
}

.chat-form textarea {
  flex: 1 1 auto;
  min-height: 48px;
  max-height: 160px;
  resize: vertical;
}

.icon-button {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  color: var(--muted);
}
.icon-button:hover { color: var(--text); }

/* Model selector is kept in the form but hidden until the menu is toggled */
.chat-model {
  display: none;
  position: absolute;
  right: 1.25rem;
  top: 3.25rem;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.5rem;
  box-shadow: 0 8px 20px rgba(15,23,42,0.08);
}
.right-column > .generate-card.menu-open .chat-model { display: block; }

.gallery-controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: 0 18px 35px rgba(15, 23, 42, 0.08);
}

.gallery-count {
  color: var(--muted);
  font-weight: 500;
}

.gallery-controls-inline .button.secondary {
  /* Make the "Select images" button use Adwaita blue (filled like primary) */
  background: var(--adwaita-blue);
  color: #fff;
  border: none;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  border-radius: 999px;
}

.gallery-controls-inline .button.secondary:hover {
  background: var(--adwaita-blue-strong);
}

.gallery-controls-inline {
  display: flex;
  align-items: center;
  gap: 0.6rem; /* small space between Select images and Delete selected */
}

.generate-card header,
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.generate-card form {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

textarea,
select {
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  padding: 0.75rem;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.generate-card .form-actions .button.secondary {
  /* Make the "New conversation" button match GTK-themed filled secondary buttons
     but keep slightly smaller padding to avoid layout overflow in narrow sidebars. */
  background: var(--adwaita-blue);
  color: #fff;
  border: none;
  padding: 0.45rem 0.9rem;
  font-size: 0.95rem;
  border-radius: 999px;
}
.generate-card .form-actions .button.secondary:hover {
  background: var(--adwaita-blue-strong);
}

.helper-text {
  color: var(--muted);
  font-size: 0.9rem;
}

.button.primary.generating {
  position: relative;
  z-index: 1;
}

.button.primary.generating::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff004c, #ff8a00, #ffd600, #00d084, #00aaff, #7a00ff, #ff004c);
  background-size: 300% 100%;
  filter: blur(6px);
  z-index: -1;
  animation: rainbow-move 2.5s linear infinite alternate;
  pointer-events: none;
}

@keyframes rainbow-move {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.gallery-card {
  position: relative;
  border-radius: 1rem;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

.gallery-card img {
  width: 100%;
  height: auto;
  object-fit: contain;
  background: var(--border);
  display: block;
}

.gallery-card img.zoomable {
  cursor: zoom-in;
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.gallery-card img.zoomable:hover {
  transform: scale(1.02);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
}

/* When selection mode is active, show pointer cursor and disable zoom hover */
body.selection-mode .gallery-card img.zoomable {
  cursor: pointer;
}

body.selection-mode .gallery-card img.zoomable:hover {
  transform: none;
  box-shadow: none;
}

.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  padding: 1.5rem;
}

.image-modal.open {
  display: flex;
}

.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: 1rem;
  max-width: 90vw;
  max-height: 90vh;
  padding: 1rem;
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.4);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
}

.modal-content img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 0.75rem;
  background: var(--border);
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: rgba(0,0,0,0.3);
  color: #fff;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  cursor: pointer;
  font-size: 20px;
  z-index: 2;
}

.modal-prev {
  left: 0.75rem;
}

.modal-next {
  right: 0.75rem;
}

.modal-nav:hover {
  background: rgba(0,0,0,0.45);
}

/* Visual state for selected cards (bulk delete) */
.gallery-card.selected {
  /* stronger visible border when selected */
  border: 3px solid var(--danger);
  box-shadow: 0 12px 40px rgba(239, 68, 68, 0.14);
  transform: translateY(-2px);
}

/* Show a subtle red overlay on the image when selected */
.gallery-card.selected img {
  outline: 8px solid rgba(239, 68, 68, 0.28);
  outline-offset: -6px;
}

.modal-prompt {
  margin: 0;
  width: 100%;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
  word-break: break-word;
}

.card-meta {
  padding: 0.85rem 1rem;
  /* Use a grid to create discrete rows: prompt (top) and footer (bottom) */
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0.4rem;
  /* allow card-meta to grow so footer can be pushed to the bottom */
  flex: 1 1 auto;
}

.card-footer {
  /* Create three logical rows inside footer:
     row 1 = (empty) reserved (prompt occupies above),
     row 1 = time/date,
     row 2 = labels + delete button (side-by-side) */
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.25rem 0.75rem;
  align-items: center;
  margin-top: auto;
}

.card-delete {
  margin-left: 0;
  /* place the delete form on the footer's second row and align it to the right */
  grid-row: 2;
  grid-column: 2;
  justify-self: end;
  flex: 0 0 auto;
  margin: 0;
}

.card-footer time {
  grid-row: 1;
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.85rem;
}

.card-footer .badge {
  grid-row: 2;
  grid-column: 1;
  justify-self: start;
}

.button.danger {
  /* Solid danger button to match filled primary style */
  background: var(--danger);
  color: #fff;
  border: none;
  box-shadow: none;
  transition: background 0.15s ease;
}

.button.danger:hover {
  filter: brightness(0.95);
}

.button.tiny {
  padding: 0.3rem 0.75rem;
  font-size: 0.75rem;
}

.prompt {
  margin: 0;
  font-weight: 500;
  color: var(--text);
}

.badge {
  align-self: flex-start;
  border-radius: 999px;
  /* make source badges filled like primary to match generate button */
  background: var(--adwaita-blue);
  color: #fff;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  /* prevent long prompts from pushing the delete button out of place */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
}

.empty-state {
  margin: 0;
  color: var(--muted);
}

.cta-card {
  background: linear-gradient(135deg, var(--adwaita-blue), var(--adwaita-blue-strong));
  border-radius: 1.5rem;
  padding: 2rem;
  color: #fff;
  text-align: center;
}

.cta-card .button {
  background: #fff;
  color: #2b2b2b;
}

.account-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.account-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.account-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.load-more-container {
  margin-top: 2rem;
  text-align: center;
}

.load-more-container .button {
  min-width: 180px;
}

.load-more-container .button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .hero {
    flex-direction: column;
  }

  nav {
    flex-wrap: wrap;
  }

  .gallery-card img {
    height: 200px;
  }
}

/* ==========================================================================
   ChatGPT-Style Chat Interface
   ========================================================================== */

/* Chat page layout - full viewport */
.chat-page {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bg);
  z-index: 1;
}

/* Position chat page below header */
body:has(.chat-page) {
  overflow: hidden;
}

body:has(.chat-page) .chat-page {
  top: var(--header-height, 60px);
  height: calc(100vh - var(--header-height, 60px));
}

/* Hide default main padding on chat page */
body:has(.chat-page) main {
  padding: 0 !important;
  margin: 0 !important;
  max-width: 100% !important;
  gap: 0 !important;
  position: relative;
  min-height: 100vh;
}

.chat-page ~ footer,
body:has(.chat-page) footer {
  display: none;
}

/* Sidebar */
.chat-sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.2s ease, width 0.2s ease;
}

.chat-sidebar.collapsed {
  width: 0;
  transform: translateX(-260px);
  border-right: none;
}

.sidebar-header {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-new-chat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.sidebar-new-chat:hover {
  background: var(--bg);
}

.sidebar-sessions {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.sidebar-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.75rem;
}

/* Session list in sidebar */
.chat-page .session-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: none;
  padding: 0;
}

.chat-page .session-item {
  display: flex;
  align-items: center;
  padding: 0.6rem 0.75rem;
  border-radius: 0.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.chat-page .session-item:hover {
  background: var(--bg);
}

.chat-page .session-item.active {
  background: var(--bg);
}

.chat-page .session-title {
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 0;
}

.chat-page .session-meta,
.chat-page .session-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.chat-page .session-timestamp {
  color: var(--muted);
  font-size: 0.85rem;
}
.chat-page .session-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-shrink: 0;
}

/* Main chat area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

/* Top bar */
.chat-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1rem 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  /* Keep the top bar visible when the page scrolls */
  position: sticky;
  top: 0; /* Sticky within chat-main */
  z-index: 60;
}

.topbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.topbar-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.web-search-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
  padding: 0;
}

.web-search-toggle:hover {
  background: var(--bg);
  color: var(--text);
}

.web-search-toggle.active {
  color: var(--accent);
}

.web-search-toggle.active svg {
  stroke: var(--accent);
}

.think-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
  padding: 0;
}

.think-toggle:hover {
  background: var(--bg);
  color: var(--text);
}

.think-toggle.active {
  color: var(--accent);
}

.think-toggle.active svg {
  stroke: var(--accent);
}

/* Model selector */
.model-selector-wrap {
  position: relative;
}

.model-selector-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.model-selector-btn:hover {
  background: var(--bg);
}

.model-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  z-index: 100;
}

.model-dropdown[hidden] {
  display: none;
}

.model-option {
  display: block;
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: transparent;
  border: none;
  text-align: left;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.1s ease;
}

.model-option:hover {
  background: var(--bg);
}

.model-option.selected {
  background: var(--adwaita-blue);
  color: #fff;
}

/* Messages area */
.chat-messages-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  /* Ensure content doesn't scroll behind top bar */
  position: relative;
  /* Align content to top when there's not enough to scroll */
  display: flex;
  flex-direction: column;
}

.chat-messages {
  max-width: 768px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  /* Remove min-height so content starts at top when there's no scroll */
}

/* Empty state */
.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1rem;
  flex: 1;
  min-height: 50vh;
}

.chat-empty-state .empty-icon {
  color: var(--muted);
  margin-bottom: 1rem;
  opacity: 0.5;
}

.chat-empty-state h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 1.5rem 0;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  max-width: 500px;
}

.suggestion-chip {
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.suggestion-chip:hover {
  background: var(--bg);
  border-color: var(--adwaita-blue);
}

/* Message rows */
.chat-message {
  display: flex;
  gap: 1rem;
  max-width: 100%;
  animation: messageSlideIn 0.2s ease-out;
}

.chat-user {
  flex-direction: row-reverse;
  align-self: flex-end;
  max-width: 85%;
}

.chat-assistant {
  align-self: flex-start;
  max-width: 85%;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-avatar {
  display: none; /* Hide avatars for both user and assistant */
}

.chat-content {
  flex: 1;
  min-width: 0;
}

.chat-who {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.chat-user .chat-who {
  text-align: right;
}

.chat-user .chat-text {
  text-align: right;
  background: var(--adwaita-blue);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  display: inline-block;
  max-width: 100%;
  word-wrap: break-word;
}

.chat-assistant .chat-text {
  background: #e8ebed; /* Light gray from GTK/Adwaita */
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  display: inline-block;
  max-width: 100%;
  word-wrap: break-word;
}

body[data-theme="dark"] .chat-assistant .chat-text {
  background: #3a4143; /* Darker gray for dark theme */
}

@media (prefers-color-scheme: dark) {
  .chat-assistant .chat-text {
    background: #3a4143; /* Darker gray for dark theme */
  }
}

.chat-text {
  font-size: 0.95rem;
  line-height: 1.6;
}

.chat-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

/* Thinking bubble */
.chat-thinking {
  display: flex;
  gap: 1rem;
  max-width: 100%;
  margin-bottom: 0.5rem;
}

.chat-thinking .chat-avatar {
  display: none; /* Hide avatar in thinking bubbles too */
}

.chat-thinking-content {
  flex: 1;
}

.chat-thinking-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  padding: 0.35rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  transition: background 0.15s ease;
}

.chat-thinking-label:hover {
  background: var(--surface);
}

.chat-thinking-label::before {
  content: "▶";
  font-size: 0.6rem;
  transition: transform 0.15s ease;
}

.chat-thinking.open .chat-thinking-label::before {
  transform: rotate(90deg);
}

.chat-thinking-text {
  display: none;
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.chat-thinking.open .chat-thinking-text {
  display: block;
}

/* Tool call indicator */
.chat-tool-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 100%;
}

.tool-indicator-icon {
  display: flex;
  align-items: center;
  color: var(--accent);
  flex-shrink: 0;
}

.tool-indicator-icon svg {
  width: 16px;
  height: 16px;
}

.tool-indicator-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Code blocks in messages */
.chat-text pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.75rem 0;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
}

.chat-text code {
  background: rgba(0, 0, 0, 0.06);
  padding: 0.15rem 0.35rem;
  border-radius: 0.25rem;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 0.9em;
}

.chat-text pre code {
  background: transparent;
  padding: 0;
}

body[data-theme="dark"] .chat-text code {
  background: rgba(255, 255, 255, 0.1);
}

/* Other markdown in messages */
.chat-text p {
  margin: 0.5rem 0;
}

.chat-text p:first-child {
  margin-top: 0;
}

.chat-text p:last-child {
  margin-bottom: 0;
}

.chat-text ul,
.chat-text ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.chat-text li {
  margin: 0.25rem 0;
}

.chat-text a {
  color: var(--adwaita-blue);
}

.chat-text blockquote {
  border-left: 3px solid var(--border);
  margin: 0.75rem 0;
  padding: 0.5rem 1rem;
  color: var(--muted);
  background: var(--bg);
  border-radius: 0 0.5rem 0.5rem 0;
}

.chat-text table {
  border-collapse: collapse;
  margin: 0.75rem 0;
  width: 100%;
}

.chat-text th,
.chat-text td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.chat-text th {
  background: var(--bg);
  font-weight: 600;
}

/* Input area */
.chat-input-wrap {
  padding: 1rem;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.chat-input-form {
  max-width: 768px;
  margin: 0 auto;
}

.input-container {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-container:focus-within {
  border-color: var(--adwaita-blue);
  box-shadow: 0 0 0 2px rgba(52, 101, 164, 0.15);
}

.chat-input-form textarea {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 0.5rem 0;
  color: var(--text);
  font-family: inherit;
  max-height: 200px;
  min-height: 24px;
}

.chat-input-form textarea:focus {
  outline: none;
}

.chat-input-form textarea::placeholder {
  color: var(--muted);
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--adwaita-blue);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: var(--adwaita-blue-strong);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.send-btn svg {
  margin-left: 2px;
}

.input-footer {
  text-align: center;
  padding-top: 0.5rem;
}

.input-hint {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--muted);
  border-radius: 50%;
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-4px);
  }
}

/* Mobile responsive */
@media (max-width: 768px) {
  .chat-sidebar {
    position: fixed;
    left: 0;
    top: 60px;
    height: calc(100vh - 60px);
    z-index: 50;
    transform: translateX(-100%);
  }

  .chat-sidebar.open {
    transform: translateX(0);
  }

  .chat-sidebar.collapsed {
    transform: translateX(-100%);
  }

  .chat-messages {
    padding: 1rem;
  }

  .chat-message {
    gap: 0.75rem;
  }

  .chat-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
  }

  .suggestion-chips {
    flex-direction: column;
  }

  .suggestion-chip {
    width: 100%;
  }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: 60px;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
}

.sidebar-overlay.visible {
  display: block;
}

/* Sessions list legacy compat */
.chat-sessions-card {
  margin-top: 1rem;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 40vh;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.session-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  border-radius: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
}

.session-title {
  font-weight: 600;
  color: var(--text);
  margin-right: 0.5rem;
}

.session-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.session-timestamp {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1;
}

.session-actions .button.small {
  margin-left: 0.35rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
}

.button.small {
  border-radius: 0.5rem;
}

