/* ================================================================
   searweb — Claude Design System CSS
   Based on Claude.ai design tokens: warm cream canvas, coral primary,
   Copernicus/Inter typography, hairline borders, color-block elevation.
   ================================================================ */

/* ---------- Design Tokens (CSS Custom Properties) ---------- */
:root {
  /* Brand & Accent */
  --primary: #cc785c;
  --primary-active: #a9583e;
  --primary-disabled: #e6dfd8;
  --on-primary: #ffffff;

  /* Text */
  --ink: #141413;
  --body-strong: #252523;
  --body: #3d3d3a;
  --muted: #6c6a64;
  --muted-soft: #8e8b82;

  /* Surface */
  --canvas: #faf9f5;
  --surface-soft: #f5f0e8;
  --surface-card: #efe9de;
  --surface-cream-strong: #e8e0d2;
  --surface-dark: #181715;
  --surface-dark-elevated: #252320;
  --surface-dark-soft: #1f1e1b;
  --on-dark: #faf9f5;
  --on-dark-soft: #a09d96;
  --hairline: #e6dfd8;
  --hairline-soft: #ebe6df;

  /* Chat-specific (from reference HTML) */
  --user-bubble-bg: #f3f0e9;
  --blue-accent: #2563eb;
  --green-accent: #16a34a;

  /* Semantic */
  --success: #5db872;
  --warning: #d4a017;
  --error: #c64545;

  /* Rounded */
  --rounded-xs: 4px;
  --rounded-sm: 6px;
  --rounded-md: 8px;
  --rounded-lg: 12px;
  --rounded-xl: 16px;
  --rounded-pill: 9999px;
  --rounded-full: 9999px;

  /* Spacing */
  --space-xxs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Cormorant Garamond", "EB Garamond", Garamond, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;

  --text-body: 16px;
  --text-body-sm: 14px;
  --text-caption: 13px;
  --text-caption-sm: 12px;

  /* Layout */
  --header-height: 56px;
  --nav-mobile-height: 56px;
  --content-max: 720px;
  --search-max: 760px;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.55;
  color: var(--body);
  background-color: var(--canvas);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ---------- Focus styles (accessible) ---------- */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  color: var(--ink);
  font-weight: 400;
}

h1 { font-family: var(--font-serif); font-size: 32px; line-height: 1.15; }
h2 { font-family: var(--font-serif); font-size: 24px; line-height: 1.2; margin-top: var(--space-lg); margin-bottom: var(--space-md); }
h3 { font-size: 16px; font-weight: 600; line-height: 1.4; margin-top: var(--space-lg); margin-bottom: var(--space-sm); }
h4 { font-size: 15px; font-weight: 600; line-height: 1.4; }

p { margin-bottom: var(--space-sm); }

a {
  color: var(--blue-accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--primary); text-decoration: underline; }
a:visited { color: #7c3aed; }

ul, ol { padding-left: 20px; margin-bottom: var(--space-md); }
li { margin-bottom: var(--space-xs); }

strong { font-weight: 600; color: var(--body-strong); }

code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface-soft);
  padding: 2px 6px;
  border-radius: var(--rounded-xs);
}

pre {
  background: var(--surface-dark);
  color: var(--on-dark);
  padding: var(--space-md);
  border-radius: var(--rounded-md);
  overflow-x: auto;
  margin-bottom: var(--space-md);
}
pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* ---------- App Layout ---------- */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Desktop: top header */
@media (min-width: 768px) {
  .app-main {
    padding-top: var(--header-height);
  }
}

/* Mobile: bottom nav padding */
@media (max-width: 767px) {
  .app-main {
    padding-bottom: var(--nav-mobile-height);
  }
}

/* ---------- Header / Navigation ---------- */
.header-top {
  display: none;
}
@media (min-width: 768px) {
  .header-top {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--canvas);
    border-bottom: 1px solid var(--hairline);
    z-index: 100;
    align-items: center;
    padding: 0 var(--space-lg);
  }
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
}

.header-logo {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.3px;
}
.header-logo:hover { text-decoration: none; }

.header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-xxs);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--rounded-md);
  font-size: var(--text-body-sm);
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.15s ease;
  background: transparent;
  border: none;
  cursor: pointer;
  line-height: 1;
}

.nav-link:hover {
  color: var(--ink);
  text-decoration: none;
}

.nav-link.active {
  background: var(--surface-card);
  color: var(--ink);
}

.nav-link svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-left: var(--space-md);
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--rounded-full);
  background: var(--primary);
  color: var(--on-primary);
  font-size: 13px;
  font-weight: 500;
}

.user-name {
  font-size: var(--text-body-sm);
  color: var(--body-strong);
  font-weight: 500;
}

.btn-signin {
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  padding: 8px 16px;
  border-radius: var(--rounded-md);
  font-size: var(--text-body-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
  line-height: 1;
}
.btn-signin:hover { background: var(--primary-active); }

/* ---------- Mobile Bottom Navigation ---------- */
.nav-bottom {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-mobile-height);
  background: var(--canvas);
  border-top: 1px solid var(--hairline);
  z-index: 100;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
}

@media (min-width: 768px) {
  .nav-bottom { display: none; }
}

.nav-bottom .nav-link {
  flex-direction: column;
  gap: 2px;
  padding: 6px 18px;
  font-size: 11px;
  border-radius: var(--rounded-md);
}

.nav-bottom .nav-link svg {
  width: 22px;
  height: 22px;
}

/* ---------- Page Container ---------- */
.page-container {
  width: 100%;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
}

@media (min-width: 768px) {
  .page-container {
    padding: var(--space-xl) var(--space-lg);
  }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--rounded-md);
  font-size: var(--text-body-sm);
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  line-height: 1;
  font-family: inherit;
  white-space: nowrap;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-active); }
.btn-primary:disabled { background: var(--primary-disabled); color: var(--muted); }

.btn-secondary {
  background: var(--canvas);
  color: var(--ink);
  border: 1px solid var(--hairline);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-soft); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-soft); color: var(--ink); }

.btn-sm {
  padding: 6px 12px;
  font-size: var(--text-caption-sm);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--rounded-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--canvas);
  color: var(--ink);
  border: 1px solid var(--hairline);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-icon:hover { background: var(--surface-soft); }

.btn-icon svg {
  width: 16px;
  height: 16px;
}

/* ---------- Form Elements ---------- */
.input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-md);
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.5;
  transition: border-color 0.15s ease;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.15);
}

.input::placeholder {
  color: var(--muted-soft);
}

.textarea {
  resize: none;
  min-height: 44px;
  max-height: 160px;
  overflow-y: auto;
}

.label {
  display: block;
  font-size: var(--text-body-sm);
  font-weight: 500;
  color: var(--body-strong);
  margin-bottom: var(--space-xxs);
}

/* ---------- Pills / Tags ---------- */
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--rounded-pill);
  font-size: var(--text-caption);
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  transition: all 0.15s ease;
  font-family: inherit;
  line-height: 1.3;
}

.pill:hover {
  color: var(--ink);
}

.pill.active {
  background: var(--surface-card);
  color: var(--ink);
}

.pill-small {
  padding: 3px 10px;
  font-size: var(--text-caption-sm);
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface-card);
  border-radius: var(--rounded-lg);
  padding: var(--space-xl);
}

.card-hairline {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-lg);
  padding: var(--space-xl);
}

/* ---------- Badge (coral) ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--rounded-pill);
  font-size: var(--text-caption-sm);
  font-weight: 500;
  letter-spacing: 0.5px;
}
.badge-coral {
  background: var(--primary);
  color: var(--on-primary);
}
.badge-cream {
  background: var(--surface-card);
  color: var(--ink);
}

/* ---------- Search Page ---------- */
.search-centered {
  max-width: var(--search-max);
  margin: 0 auto;
  width: 100%;
}

.search-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-xxl) 0 var(--space-lg);
  text-align: center;
}

.search-hero.has-results {
  padding: var(--space-md) 0;
}

.search-hero-title {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.5px;
  margin-bottom: var(--space-lg);
}

.search-bar-wrapper {
  width: 100%;
  position: relative;
  margin-bottom: var(--space-sm);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-soft);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-icon svg {
  width: 20px;
  height: 20px;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-lg);
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.5;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.15);
}

.search-input::placeholder {
  color: var(--muted-soft);
}

/* Engine selector pills */
.engine-selector {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
  justify-content: center;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-xxl) 0;
}

.empty-state-icon {
  margin-bottom: var(--space-md);
  color: var(--muted-soft);
}

.empty-state-icon svg {
  width: 48px;
  height: 48px;
}

.empty-state-text {
  font-size: var(--text-body);
  color: var(--muted);
}

/* Search results */
.search-results {
  max-width: var(--search-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.search-stats {
  font-size: var(--text-caption);
  color: var(--muted);
  margin-bottom: var(--space-xs);
}

.result-item {
  padding: 0 0 var(--space-lg);
  border-bottom: 1px solid var(--hairline-soft);
}

.result-item:last-child {
  border-bottom: none;
}

.result-title {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 4px;
}

.result-title a {
  color: #1a0dab;
  text-decoration: none;
}
.result-title a:hover { text-decoration: underline; }
.result-title a:visited { color: #681da8; }

.result-url {
  font-size: var(--text-caption);
  color: var(--success);
  margin-bottom: var(--space-xs);
  word-break: break-all;
}

.result-snippet {
  font-size: var(--text-body-sm);
  line-height: 1.55;
  color: var(--body);
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--hairline);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl) 0;
  gap: var(--space-sm);
}

.loading-text {
  color: var(--muted);
  font-size: var(--text-body-sm);
}

/* ---------- Chat Page ---------- */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--nav-mobile-height));
}

@media (min-width: 768px) {
  .chat-container {
    height: calc(100dvh - var(--header-height));
  }
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  scroll-behavior: smooth;
}

/* Scroll to bottom anchor */
.chat-messages-end {
  height: 1px;
}

/* ---------- User Message Bubble ---------- */
.user-message-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
}

.user-bubble {
  background: var(--user-bubble-bg);
  padding: 12px 18px;
  border-radius: 20px 20px 4px 20px;
  font-size: var(--text-body);
  line-height: 1.5;
  max-width: 80%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.user-bubble-actions {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.user-message-wrapper:hover .user-bubble-actions {
  opacity: 1;
}

.user-bubble-actions .action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--muted);
  border-radius: var(--rounded-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.user-bubble-actions .action-btn:hover {
  color: var(--ink);
  background: rgba(0,0,0,0.04);
}

.user-bubble-actions .action-btn svg {
  width: 15px;
  height: 15px;
}

/* ---------- AI Response (no bubble) ---------- */
.ai-response-wrapper {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
}

/* ---------- AI Process Timeline ---------- */
.timeline-container {
  margin-left: 4px;
  margin-bottom: var(--space-lg);
}

.timeline-item {
  position: relative;
  padding-left: 28px;
  padding-bottom: 14px;
}

/* Vertical connecting line */
.timeline-item::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 14px;
  bottom: -6px;
  width: 1px;
  background: var(--hairline);
}

.timeline-item:last-child::before {
  display: none;
}

/* Small circle (9px hollow) */
.timeline-circle {
  position: absolute;
  left: 0;
  top: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: transparent;
  box-sizing: border-box;
  z-index: 2;
}

.timeline-item.thinking .timeline-circle {
  border: 2px solid var(--blue-accent);
}

.timeline-item.tool .timeline-circle {
  border: 2px solid var(--green-accent);
}

/* Timeline header — clickable area */
.timeline-header {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.timeline-type-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.timeline-item.thinking .timeline-type-icon svg {
  stroke: var(--blue-accent);
  color: var(--blue-accent);
}

.timeline-item.tool .timeline-type-icon svg {
  stroke: var(--green-accent);
  color: var(--green-accent);
}

.timeline-title {
  font-size: var(--text-body-sm);
  font-weight: 500;
  color: var(--muted);
}

.timeline-chevron {
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.timeline-item.open .timeline-chevron {
  transform: rotate(180deg);
}

/* Expand/collapse animation: CSS grid trick */
.timeline-content {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.timeline-item.open .timeline-content {
  grid-template-rows: 1fr;
}

.timeline-content-inner {
  min-height: 0;
  padding: 8px 0 4px 26px;
}

.timeline-details-box {
  font-size: var(--text-caption);
  line-height: 1.6;
  color: var(--muted);
  background: rgba(0,0,0,0.015);
  border-left: 2px solid var(--hairline);
  padding: 10px 14px;
  border-radius: 0 var(--rounded-sm) var(--rounded-sm) 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.timeline-date {
  font-size: var(--text-caption-sm);
  color: var(--muted-soft);
  margin-top: 4px;
}

/* ---------- AI Markdown Output ---------- */
.ai-markdown-output {
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--body);
}

.ai-markdown-output h1 {
  font-size: 22px;
  margin-top: 0;
  margin-bottom: var(--space-md);
  font-weight: 500;
  font-family: var(--font-sans);
}

.ai-markdown-output h2 {
  font-size: 20px;
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
  font-weight: 600;
  font-family: var(--font-sans);
}

.ai-markdown-output h3 {
  font-size: 16px;
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
  font-weight: 600;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: var(--space-xxs);
}

.ai-markdown-output ul,
.ai-markdown-output ol {
  margin: 0 0 var(--space-md) 0;
  padding-left: 20px;
}

.ai-markdown-output li {
  margin-bottom: var(--space-xs);
}

.ai-markdown-output strong {
  font-weight: 600;
}

.ai-markdown-output p {
  margin-bottom: var(--space-md);
}

.ai-markdown-output blockquote {
  border-left: 2px solid var(--hairline);
  padding: var(--space-xs) var(--space-md);
  margin: var(--space-md) 0;
  color: var(--muted);
  font-style: italic;
}

.ai-markdown-output table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-md) 0;
  font-size: var(--text-body-sm);
}

.ai-markdown-output th,
.ai-markdown-output td {
  border: 1px solid var(--hairline);
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
}

.ai-markdown-output th {
  background: var(--surface-soft);
  font-weight: 600;
}

/* Citation superscript inline */
.citation {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--user-bubble-bg);
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  min-width: 16px;
  height: 16px;
  border-radius: var(--rounded-xs);
  padding: 0 3px;
  vertical-align: super;
  text-decoration: none;
  margin-left: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.citation:hover {
  background: var(--surface-card);
  color: var(--blue-accent);
}

/* ---------- AI Footer (actions + sources) ---------- */
.ai-footer {
  margin-top: var(--space-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  border-top: 1px solid var(--hairline);
  padding-top: var(--space-md);
}

.ai-footer-left {
  display: flex;
  gap: var(--space-xs);
}

/* Sources capsule button */
.sources-capsule {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--user-bubble-bg);
  border: 1px solid var(--hairline);
  padding: 5px 12px;
  border-radius: 16px;
  font-size: var(--text-caption-sm);
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  font-family: inherit;
  white-space: nowrap;
}

.sources-capsule:hover {
  background: var(--hairline);
  color: var(--ink);
}

.sources-capsule svg {
  width: 13px;
  height: 13px;
}

/* ---------- Sources Popover ---------- */
.sources-popover {
  position: absolute;
  bottom: 50px;
  right: 0;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-lg);
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.03);
  width: 320px;
  max-width: calc(100vw - 32px);
  padding: var(--space-md);
  display: none;
  flex-direction: column;
  gap: var(--space-sm);
  z-index: 50;
  animation: popoverEnter 0.2s ease-out;
}

.sources-popover.show {
  display: flex;
}

.sources-popover-title {
  font-size: var(--text-caption);
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}

.source-link-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs);
  text-decoration: none;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
  transition: color 0.15s;
  word-break: break-all;
}

.source-link-item:hover {
  color: var(--blue-accent);
}

.source-link-index {
  background: var(--user-bubble-bg);
  font-size: 10px;
  min-width: 16px;
  height: 16px;
  border-radius: var(--rounded-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  flex-shrink: 0;
}

.source-link-url {
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes popoverEnter {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Chat Input Area ---------- */
.chat-input-container {
  border-top: 1px solid var(--hairline);
  padding: var(--space-sm) var(--space-md);
  background: var(--canvas);
}

.chat-input-wrapper {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.chat-input-controls {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.chat-input-row {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
}

.chat-input-textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-md);
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.5;
  resize: none;
  min-height: 44px;
  max-height: 160px;
  overflow-y: auto;
  transition: border-color 0.15s ease;
}

.chat-input-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.15);
}

.chat-input-textarea::placeholder {
  color: var(--muted-soft);
}

/* v2.1: Hide textarea scrollbar for cleaner mobile appearance */
.chat-input-textarea {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.chat-input-textarea::-webkit-scrollbar {
  display: none;
}

.chat-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--rounded-md);
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) { background: var(--primary-active); }
.chat-send-btn:disabled { background: var(--primary-disabled); color: var(--muted); cursor: not-allowed; }

.chat-send-btn svg {
  width: 20px;
  height: 20px;
}

/* Depth pills */
.depth-selector {
  display: flex;
  gap: var(--space-xxs);
}

/* ---------- Auth Modal / Overlay ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 19, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--canvas);
  border-radius: var(--rounded-lg);
  padding: var(--space-xl);
  width: 380px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
  animation: modalSlideIn 0.25s ease-out;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--ink);
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-xxs);
  color: var(--muted);
  border-radius: var(--rounded-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.modal-close svg {
  width: 20px;
  height: 20px;
}

.form-group {
  margin-bottom: var(--space-md);
}

.form-error {
  color: var(--error);
  font-size: var(--text-caption);
  margin-top: var(--space-xxs);
}

.auth-switch {
  text-align: center;
  margin-top: var(--space-md);
  font-size: var(--text-body-sm);
  color: var(--muted);
}

.auth-switch a {
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
}

.auth-switch a:hover { text-decoration: underline; }

/* ---------- Loading Dots (typing indicator) ---------- */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: var(--space-xs) 0;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-soft);
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ---------- Error Message ---------- */
.error-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--error);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--rounded-md);
  font-size: var(--text-body-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-xs);
}

.error-banner svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ---------- Utility ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-sm { font-size: var(--text-body-sm); }
.text-xs { font-size: var(--text-caption-sm); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.hidden { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 767px) {
  .search-hero-title { font-size: 24px; }

  .user-bubble { max-width: 90%; font-size: 15px; }

  .ai-markdown-output { font-size: 14.5px; }

  .sources-popover {
    width: 280px;
    right: -8px;
  }
}

@media (min-width: 768px) {
  .search-hero-title { font-size: 36px; }
}

/* ================================================================
   v2: Login Page (full-page, centered card)
   ================================================================ */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--space-lg);
  background: var(--canvas);
}

.login-card {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-lg);
  padding: var(--space-xxl);
  width: 420px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 1px 3px rgba(20,20,19,0.04);
}

.login-brand {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.login-brand-title {
  font-family: var(--font-serif);
  font-size: 36px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.5px;
  margin: 0 0 var(--space-xs);
}

.login-brand-sub {
  font-size: var(--text-body-sm);
  color: var(--muted);
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
}

.login-submit-btn {
  width: 100%;
  margin-top: var(--space-xs);
  padding: 12px 20px;
  font-size: var(--text-body);
  height: 44px;
}

.login-notice {
  text-align: center;
  margin-top: var(--space-lg);
  font-size: var(--text-body-sm);
  color: var(--muted);
}

.login-form .form-error {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ================================================================
   v2: Credits Display
   ================================================================ */

.credits-display {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-caption-sm);
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--rounded-pill);
  transition: background 0.15s ease;
  cursor: default;
}

.credits-display[role="button"] {
  cursor: pointer;
}

.credits-display[role="button"]:hover {
  background: var(--surface-soft);
}

.credits-compact {
  font-size: 12px;
  padding: 3px 8px;
  gap: 3px;
}

.credits-green {
  background: rgba(93, 184, 114, 0.12);
  color: #3a7d4a;
}
.credits-green svg { color: #3a7d4a; }

.credits-yellow {
  background: rgba(212, 160, 23, 0.12);
  color: #9a7514;
}
.credits-yellow svg { color: #9a7514; }

.credits-red {
  background: rgba(198, 69, 69, 0.12);
  color: var(--error);
}
.credits-red svg { color: var(--error); }

.credits-value {
  font-variant-numeric: tabular-nums;
}

.credits-separator {
  color: var(--muted-soft);
  margin: 0 1px;
}

/* ================================================================
   v2.1: Home Page Credits Card
   ================================================================ */

.credits-card {
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-lg);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-lg);
  max-width: 480px;
  width: 100%;
  transition: border-color 0.2s ease;
}

.credits-card.credits-green {
  border-color: rgba(93, 184, 114, 0.3);
  background: rgba(93, 184, 114, 0.04);
}
.credits-card.credits-yellow {
  border-color: rgba(212, 160, 23, 0.3);
  background: rgba(212, 160, 23, 0.04);
}
.credits-card.credits-red {
  border-color: rgba(198, 69, 69, 0.3);
  background: rgba(198, 69, 69, 0.04);
}

.credits-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.credits-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-caption);
  font-weight: 500;
  color: var(--body-strong);
}

.credits-card-title svg {
  width: 16px;
  height: 16px;
}

.credits-card-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--rounded-sm);
  border: none;
  background: transparent;
  color: var(--muted-soft);
  cursor: pointer;
  transition: all 0.15s;
}

.credits-card-close:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.credits-card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.credits-card-values {
  display: flex;
  justify-content: space-between;
  gap: var(--space-lg);
}

.credits-card-current,
.credits-card-limit {
  display: flex;
  flex-direction: column;
}

.credits-card-number {
  font-family: var(--font-sans);
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.credits-card-number-sm {
  font-size: 18px;
  font-weight: 500;
  color: var(--muted);
}

.credits-card-label {
  font-size: var(--text-caption-sm);
  color: var(--muted-soft);
}

.credits-card-progress-track {
  width: 100%;
  height: 6px;
  background: var(--surface-cream-strong);
  border-radius: var(--rounded-full);
  overflow: hidden;
}

.credits-card-progress-fill {
  height: 100%;
  border-radius: var(--rounded-full);
  transition: width 0.5s ease;
}

.credits-card.credits-green .credits-card-progress-fill {
  background: var(--success);
}
.credits-card.credits-yellow .credits-card-progress-fill {
  background: var(--warning);
}
.credits-card.credits-red .credits-card-progress-fill {
  background: var(--error);
}

.credits-card-progress-label {
  font-size: var(--text-caption-sm);
  color: var(--muted-soft);
  text-align: right;
}

/* ================================================================
   v2: Model Selector Dropdown
   ================================================================ */

.model-selector {
  position: relative;
}

.model-selector-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--rounded-md);
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--ink);
  font-size: var(--text-caption);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.3;
  transition: border-color 0.15s ease;
  white-space: nowrap;
}

.model-selector-trigger:hover:not(:disabled) {
  border-color: var(--primary);
}

.model-selector-trigger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.model-selector-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-selector-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
  min-width: 240px;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-md);
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
  z-index: 1000;
  overflow: hidden;
  animation: popoverEnter 0.2s ease-out;
}

.model-selector-option {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.1s ease;
}

.model-selector-option:hover {
  background: var(--surface-soft);
}

.model-selector-option.selected {
  background: var(--surface-card);
}

.model-selector-option-name {
  font-size: var(--text-body-sm);
  font-weight: 500;
  color: var(--ink);
}

.model-selector-option-notes {
  font-size: var(--text-caption-sm);
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
}

.model-selector-empty {
  padding: var(--space-md);
  text-align: center;
  color: var(--muted);
  font-size: var(--text-caption);
}

/* ================================================================
   v2: Search Pagination
   ================================================================ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-lg) 0;
  margin-top: var(--space-md);
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--rounded-pill);
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--ink);
  font-size: var(--text-body-sm);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: var(--primary);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-info {
  font-size: var(--text-body-sm);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ================================================================
   v2: Chat Layout (sidebar + main)
   ================================================================ */

.chat-layout {
  display: flex;
  height: calc(100dvh - var(--nav-mobile-height));
  overflow: hidden;
}

@media (min-width: 768px) {
  .chat-layout {
    height: calc(100dvh - var(--header-height));
  }
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

/* Override old .chat-container when using .chat-layout */
.chat-layout .chat-container {
  height: auto;
  flex: 1;
}

/* Sidebar toggle button (mobile) */
.chat-sidebar-mobile-toggle {
  display: none;
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 30;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-md);
  padding: 6px;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}

.chat-sidebar-mobile-toggle:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

@media (max-width: 767px) {
  .chat-sidebar-mobile-toggle {
    display: flex;
  }
}

/* ================================================================
   v2: Chat Sidebar
   ================================================================ */

.chat-sidebar {
  width: 280px;
  min-width: 280px;
  border-right: 1px solid var(--hairline);
  background: var(--canvas);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-left 0.25s ease, opacity 0.25s ease;
  position: relative;
}

@media (max-width: 767px) {
  .chat-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    margin-left: -280px;
    box-shadow: none;
  }

  .chat-sidebar.open {
    margin-left: 0;
    box-shadow: 4px 0 15px rgba(0,0,0,0.08);
  }
}

/* v2.1: Mobile backdrop overlay */
.chat-sidebar-backdrop {
  display: none;
}

@media (max-width: 767px) {
  .chat-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 19, 0.3);
    z-index: 49;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .chat-sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }
}

/* v2.1: Mobile close button inside sidebar header */
.chat-sidebar-close-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--rounded-md);
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.chat-sidebar-close-btn:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

@media (max-width: 767px) {
  .chat-sidebar-close-btn {
    display: flex;
  }
}

.chat-sidebar-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--hairline-soft);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.chat-sidebar-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--rounded-md);
  border: 1px solid var(--hairline);
  background: var(--canvas);
  color: var(--ink);
  font-size: var(--text-body-sm);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  width: 100%;
  justify-content: center;
  transition: all 0.15s;
}

.chat-sidebar-new-btn:hover {
  background: var(--surface-soft);
  border-color: var(--primary);
}

.chat-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xs);
}

.chat-sidebar-empty {
  padding: var(--space-xl) var(--space-md);
  text-align: center;
  color: var(--muted);
  font-size: var(--text-caption);
}

.chat-sidebar-item {
  display: flex;
  align-items: stretch;
  border-radius: var(--rounded-md);
  margin-bottom: 2px;
  transition: background 0.1s;
}

.chat-sidebar-item:hover {
  background: var(--surface-soft);
}

.chat-sidebar-item.active {
  background: var(--surface-card);
}

.chat-sidebar-item-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--body);
  font-size: var(--text-body-sm);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  min-width: 0;
}

.chat-sidebar-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-sidebar-item-date {
  font-size: var(--text-caption-sm);
  color: var(--muted-soft);
  flex-shrink: 0;
}

.chat-sidebar-item-delete {
  display: flex;
  align-items: center;
  padding: 0 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s;
  flex-shrink: 0;
}

.chat-sidebar-item:hover .chat-sidebar-item-delete {
  opacity: 1;
}

.chat-sidebar-item-delete:hover {
  color: var(--error);
}

.chat-sidebar-toggle {
  display: none;
}

@media (max-width: 767px) {
  .chat-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 8px;
    right: -40px;
    width: 36px;
    height: 36px;
    border-radius: var(--rounded-full);
    border: 1px solid var(--hairline);
    background: var(--canvas);
    color: var(--muted);
    cursor: pointer;
  }
}

/* ================================================================
   v2: User Message Editing
   ================================================================ */

.user-bubble-editing {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-sm);
}

.user-edit-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--primary);
  border-radius: var(--rounded-md);
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.5;
  resize: vertical;
  min-height: 60px;
  outline: none;
}

.user-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-xs);
}

/* ================================================================
   v2: Admin Panel
   ================================================================ */

.admin-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md);
  width: 100%;
}

@media (min-width: 768px) {
  .admin-page {
    padding: var(--space-xl) var(--space-lg);
  }
}

.admin-header {
  margin-bottom: var(--space-lg);
}

.admin-title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.3px;
  margin: 0;
}

/* Admin tabs */
.admin-tabs {
  display: flex;
  gap: var(--space-xxs);
  border-bottom: 1px solid var(--hairline);
  margin-bottom: var(--space-xl);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: var(--text-body-sm);
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.admin-tab:hover {
  color: var(--ink);
}

.admin-tab.active {
  color: var(--ink);
  border-bottom-color: var(--primary);
}

/* Admin section header */
.admin-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.admin-section-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 400;
  color: var(--ink);
  margin: 0;
}

.admin-loading {
  text-align: center;
  padding: var(--space-xxl);
  color: var(--muted);
  font-size: var(--text-body);
}

/* Admin tables */
.admin-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-md);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-body-sm);
}

.admin-table th {
  background: var(--surface-soft);
  padding: 10px 14px;
  text-align: left;
  font-weight: 500;
  color: var(--body-strong);
  font-size: var(--text-caption);
  white-space: nowrap;
  border-bottom: 1px solid var(--hairline);
}

.admin-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline-soft);
  color: var(--body);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: rgba(0,0,0,0.01);
}

.admin-cell-strong {
  font-weight: 500;
  color: var(--body-strong);
}

/* Admin stats grid */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
}

.admin-stat-card {
  background: var(--surface-card);
  border-radius: var(--rounded-lg);
  padding: var(--space-lg);
}

.admin-stat-label {
  font-size: var(--text-caption);
  color: var(--muted);
  margin-bottom: var(--space-xs);
}

.admin-stat-value {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 400;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Auth loading screen */
.auth-loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  gap: var(--space-md);
  background: var(--canvas);
}

.auth-loading-text {
  font-size: var(--text-body);
  color: var(--muted);
}

/* ================================================================
   v2: Responsive tweaks
   ================================================================ */

@media (max-width: 767px) {
  .login-card {
    padding: var(--space-xl) var(--space-lg);
  }

  .login-brand-title {
    font-size: 28px;
  }

  .admin-tabs {
    gap: 0;
  }

  .admin-tab {
    padding: 8px 12px;
    font-size: var(--text-caption);
  }

  .admin-stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .model-selector-dropdown {
    position: fixed;
    bottom: calc(var(--nav-mobile-height) + 48px);
    top: auto;
    left: 16px;
    right: 16px;
    width: auto;
    max-height: 50vh;
    overflow-y: auto;
    margin-bottom: 0;
    border-radius: var(--rounded-lg);
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    z-index: 1000;
    transform: none;
  }
}
