:root {
  --bg: #f7f4ef;
  --bg-elevated: rgba(255, 255, 255, 0.86);
  --surface: #ffffff;
  --surface-soft: #f7f2eb;
  --surface-strong: #fffdf9;
  --ink: #1f1a18;
  --muted: #6d645f;
  --line: rgba(31, 26, 24, 0.09);
  --line-strong: rgba(31, 26, 24, 0.16);
  --shadow-lg: 0 30px 80px rgba(44, 27, 10, 0.12);
  --shadow-md: 0 18px 38px rgba(44, 27, 10, 0.08);
  --accent: #ef7f47;
  --accent-soft: rgba(239, 127, 71, 0.14);
  --accent-plum: #8f54a1;
  --success: #2f9e68;
  --warn: #b96b1a;
  --danger: #c94848;
}

body[data-theme="dark"] {
  --bg: #121212;
  --bg-elevated: rgba(24, 24, 24, 0.82);
  --surface: #181818;
  --surface-soft: #202020;
  --surface-strong: #141414;
  --ink: #f3efe9;
  --muted: #b8afa8;
  --line: rgba(243, 239, 233, 0.10);
  --line-strong: rgba(243, 239, 233, 0.18);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.34);
  --shadow-md: 0 18px 38px rgba(0, 0, 0, 0.26);
  --accent-soft: rgba(239, 127, 71, 0.18);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(239, 127, 71, 0.08), transparent 28%),
    linear-gradient(180deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 86%, #f3ede7) 100%);
  transition: background-color 200ms ease, color 200ms ease;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(31, 26, 24, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 26, 24, 0.03) 1px, transparent 1px);
  background-size: 44px 44px;
  opacity: 0.55;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 78%);
}
body[data-theme="dark"]::before {
  background-image:
    linear-gradient(rgba(243, 239, 233, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(243, 239, 233, 0.04) 1px, transparent 1px);
}
button, input, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
.dashboard-app { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
.app-sidebar { position: sticky; top: 0; height: 100vh; padding: 22px; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 76%, transparent); backdrop-filter: blur(20px); }
.app-sidebar__brand { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow-md); }
.app-sidebar__logo { width: 46px; height: 46px; border-radius: 16px; }
.app-sidebar__brand strong { display: block; font-family: "Syne", "Inter", sans-serif; font-size: 1.1rem; }
.app-sidebar__brand span { color: var(--muted); font-size: 0.92rem; }
.app-nav { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.app-nav__item { width: 100%; text-align: left; padding: 14px 16px; border: 1px solid transparent; border-radius: 20px; background: transparent; color: var(--ink); cursor: pointer; transition: border-color 150ms ease, background-color 150ms ease, transform 150ms ease; }
.app-nav__item span, .app-nav__item small { display: block; }
.app-nav__item small { color: var(--muted); margin-top: 4px; }
.app-nav__item.is-active { border-color: var(--line); background: var(--surface); box-shadow: var(--shadow-md); }
.app-nav__item:hover { transform: translateX(2px); }
.app-sidebar__footer { position: absolute; inset: auto 22px 22px; display: flex; flex-direction: column; gap: 12px; }
.app-sidebar__workspace-status { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 6px rgba(47, 158, 104, 0.16); }
.app-sidebar__link { color: var(--muted); font-size: 0.94rem; }
.app-main { padding: 24px; }
.app-topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.app-topbar__eyebrow, .section-header__eyebrow, .workspace-gate__eyebrow { margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.78rem; font-weight: 700; }
.app-topbar h1, .workspace-gate h2, .section-header h2, .oauth-card h1 { margin: 0; font-family: "Syne", "Inter", sans-serif; letter-spacing: -0.05em; line-height: 0.98; }
.app-topbar h1 { font-size: clamp(2rem, 4vw, 3.2rem); }
.app-topbar__actions { display: flex; align-items: center; gap: 10px; }
.theme-toggle, .ghost-button, .primary-button, .prompt-chip, .sources-filter { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; border-radius: 999px; border: 1px solid var(--line); padding: 0 18px; cursor: pointer; }
.theme-toggle { min-width: 52px; background: var(--surface); color: var(--ink); }
.theme-toggle__icon { display: inline-grid; place-items: center; width: 18px; height: 18px; }
.theme-toggle__icon svg { width: 18px; height: 18px; }
.theme-toggle__icon--moon { display: none; }
body[data-theme="dark"] .theme-toggle__icon--sun { display: none; }
body[data-theme="dark"] .theme-toggle__icon--moon { display: inline-grid; }
.ghost-button, .sources-filter { background: var(--surface); color: var(--ink); }
.primary-button { background: #1f1a18; color: #fff8f1; border-color: #1f1a18; font-weight: 700; }
body[data-theme="dark"] .primary-button { background: #f3efe9; color: #111111; border-color: #f3efe9; }
.prompt-chip { min-height: 40px; padding-inline: 14px; background: rgba(143, 84, 161, 0.08); color: var(--accent-plum); }
.sources-filter { min-height: 38px; padding-inline: 14px; }
.sources-filter.is-active { background: #1f1a18; color: #fff8f1; border-color: #1f1a18; }
body[data-theme="dark"] .sources-filter.is-active { background: #f3efe9; color: #111111; border-color: #f3efe9; }
.workspace-gate { display: grid; place-items: center; min-height: calc(100vh - 140px); }
.workspace-gate.is-hidden, .app-panels.is-hidden, .install-banner.is-hidden, .ghost-button.is-hidden { display: none; }
.workspace-gate__card, .oauth-card { width: min(100%, 680px); padding: 32px; border-radius: 28px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.workspace-gate__card p, .oauth-card__copy, .oauth-footnote { color: var(--muted); }
.workspace-gate__form, .stack-form { display: flex; flex-direction: column; gap: 16px; }
.workspace-gate__form label, .stack-form label { display: flex; flex-direction: column; gap: 8px; font-weight: 600; }
.workspace-gate__form input, .stack-form input, .stack-form textarea { width: 100%; min-height: 52px; padding: 14px 16px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface-soft); color: var(--ink); }
.stack-form textarea { min-height: 120px; resize: vertical; }
.card-note { margin-top: 16px; padding: 14px 16px; border-radius: 18px; background: var(--surface-soft); color: var(--muted); line-height: 1.6; }
.card-note strong { color: var(--ink); }
.app-panels { display: flex; flex-direction: column; gap: 22px; }
.panel { padding: 28px; border-radius: 28px; background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow-md); }
.plan-banner { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 24px 28px; border-radius: 28px; border: 1px solid rgba(239, 127, 71, 0.18); background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(247, 242, 235, 0.92)); box-shadow: var(--shadow-md); }
body[data-theme="dark"] .plan-banner { background: linear-gradient(135deg, rgba(24,24,24,0.95), rgba(32,32,32,0.95)); }
.plan-banner__copy { max-width: 620px; }
.plan-banner__eyebrow, .section-header__meta { display: inline-flex; }
.plan-banner__eyebrow { margin-bottom: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.76rem; font-weight: 700; }
.plan-banner__copy strong { display: block; margin-bottom: 10px; font-family: "Syne", "Inter", sans-serif; font-size: clamp(1.5rem, 2.4vw, 2rem); line-height: 1; letter-spacing: -0.04em; }
.plan-banner__copy p { margin: 0; color: var(--muted); line-height: 1.7; }
.plan-banner__meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.plan-banner__stat { min-width: 132px; padding: 14px 16px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); }
.plan-banner__stat span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.84rem; }
.plan-banner__stat strong { display: block; font-size: 1rem; }
.sources-plan-note { margin-bottom: 18px; padding: 14px 18px; border-radius: 20px; background: rgba(143, 84, 161, 0.08); color: var(--accent-plum); border: 1px solid rgba(143, 84, 161, 0.14); line-height: 1.6; }
.panel-section.is-hidden { display: none; }
.section-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-header__badge, .pill { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 0 12px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); border: 1px solid var(--line); font-size: 0.86rem; font-weight: 700; }
.pill--soft { background: rgba(143, 84, 161, 0.08); color: var(--accent-plum); }
.pill--accent { background: var(--accent-soft); color: #ba5f2d; }
.stats-grid, .overview-grid, .ingest-grid, .ask-grid, .source-summary-grid { display: grid; gap: 18px; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.source-summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.overview-grid { grid-template-columns: 1.1fr 1fr; margin-top: 18px; }
.ingest-grid, .ask-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-card, .card, .mini-stat-card { padding: 22px; border-radius: 24px; background: var(--surface); border: 1px solid var(--line); }
.stat-card span, .stat-card small, .mini-stat-card span, .mini-stat-card small { color: var(--muted); }
.stat-card strong, .mini-stat-card strong { display: block; margin: 10px 0 8px; font-size: clamp(1.8rem, 3vw, 2.6rem); font-family: "Syne", "Inter", sans-serif; }
.mini-stat-card strong { font-size: clamp(1.5rem, 2.4vw, 2.1rem); }
.card--full { margin-top: 18px; }
.card__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.card__header h3 { margin: 0; font-size: 1.15rem; }
.progress-list, .activity-list, .answer-preview, .sources-table, .oauth-summary { display: flex; flex-direction: column; gap: 12px; }
.progress-list { margin: 0; padding-left: 18px; color: var(--muted); }
.empty-state, .empty-copy { margin: 0; color: var(--muted); }
.sources-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.sources-filter-group, .ask-prompt-row, .connection-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.sources-toolbar__hint { margin: 0; color: var(--muted); font-size: 0.92rem; }
.sources-table__row { display: grid; grid-template-columns: minmax(0, 1.35fr) 140px 130px 120px 90px auto; gap: 12px; align-items: center; padding: 16px; border-radius: 18px; background: var(--surface-soft); border: 1px solid transparent; }
.sources-table__row strong, .sources-table__row small { display: block; }
.sources-table__row small { color: var(--muted); }
.sources-table__empty { padding: 18px; border-radius: 18px; background: var(--surface-soft); color: var(--muted); }
.source-status { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; border-radius: 999px; padding: 0 10px; font-size: 0.82rem; font-weight: 700; }
.source-status--processing { background: rgba(185, 107, 26, 0.12); color: var(--warn); }
.source-status--indexed { background: rgba(47, 158, 104, 0.14); color: var(--success); }
.source-status--failed { background: rgba(201, 72, 72, 0.14); color: var(--danger); }
.source-action { border: 0; background: transparent; color: var(--danger); cursor: pointer; font-weight: 700; }
.activity-item, .citation-card, .install-banner { padding: 14px 16px; border-radius: 18px; background: var(--surface-soft); border: 1px solid var(--line); }
.install-banner { margin-bottom: 18px; background: rgba(47, 158, 104, 0.12); color: var(--success); border-color: rgba(47, 158, 104, 0.16); }
.activity-item strong, .citation-card strong { display: block; margin-bottom: 6px; }
.activity-item small, .citation-card small { color: var(--muted); }
.ask-preview-topline { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.ask-preview-topline__card { padding: 18px 20px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); }
.ask-preview-topline__card span, .ask-preview-topline__card small { color: var(--muted); }
.ask-preview-topline__card strong { display: block; margin: 10px 0 8px; font-size: 2rem; font-family: "Syne", "Inter", sans-serif; }
.ask-prompt-row { margin-bottom: 18px; }
.answer-preview__text { padding: 18px; border-radius: 20px; background: linear-gradient(180deg, var(--surface-soft), var(--surface)); border: 1px solid var(--line); line-height: 1.7; }
.answer-preview__meta { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.answer-preview__citations { display: flex; flex-direction: column; gap: 10px; }
.citation-match { display: inline-flex; margin-top: 10px; color: var(--accent-plum); font-size: 0.82rem; font-weight: 700; }
.connection-summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.connection-summary-grid span, .oauth-summary span { color: var(--muted); display: block; margin-bottom: 6px; }
.connection-summary-grid strong, .oauth-summary strong { display: block; }
.oauth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.oauth-card__logo { width: 56px; height: 56px; border-radius: 18px; margin-bottom: 18px; }
.oauth-summary { margin: 24px 0; }
.oauth-summary > div { padding: 14px 16px; border-radius: 18px; background: var(--surface-soft); border: 1px solid var(--line); }
.oauth-footnote { margin-top: 18px; }
@media (max-width: 1200px) {
  .dashboard-app { grid-template-columns: 1fr; }
  .app-sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .app-sidebar__footer { position: static; inset: auto; margin-top: 18px; }
  .stats-grid, .overview-grid, .ingest-grid, .ask-grid, .source-summary-grid, .ask-preview-topline, .connection-summary-grid { grid-template-columns: 1fr 1fr; }
  .sources-table__row { grid-template-columns: minmax(0, 1fr) 120px 120px 110px auto; }
}
@media (max-width: 860px) {
  .app-main, .oauth-page { padding: 18px; }
  .app-topbar, .section-header, .sources-toolbar { flex-direction: column; align-items: stretch; }
  .stats-grid, .overview-grid, .ingest-grid, .ask-grid, .source-summary-grid, .ask-preview-topline, .connection-summary-grid { grid-template-columns: 1fr; }
  .sources-table__row { grid-template-columns: 1fr; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

