/* ============================================================
   RAG App — Visual System v3
   Bolder: glass surfaces, visible gradients, clear depth.
   ============================================================ */

/* Re-assert UA default — author rules like `.btn { display: inline-flex }`
   otherwise win against `[hidden]{display:none}` and leak elements that
   should be invisible (admin link, logout button). */
[hidden] { display: none !important; }

/* ── Font face ─────────────────────────────────────────────── */

@font-face {
  font-family: 'Inter';
  src: url('/lib/fonts/InterVariable.woff2') format('woff2-variations'),
       url('/lib/fonts/InterVariable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  font-style: normal;
}
@font-face {
  font-family: 'Inter';
  src: url('/lib/fonts/InterVariable-Italic.woff2') format('woff2-variations'),
       url('/lib/fonts/InterVariable-Italic.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  font-style: italic;
}

/* ── Design tokens ─────────────────────────────────────────── */

:root {
  /* Surfaces — neutral dark navy (harmoniert mit CF-Logo-Schwarz #00000F) */
  --bg:          #0A0F1A;
  --bg-elevated: #111827;
  --card:        #1A2232;
  --card-2:      #232C3F;
  --card-3:      #2E384D;

  --border:        #2A3347;
  --border-strong: #3A455F;
  --border-focus:  #6FCCD8;

  --text:       #F1F3FA;
  --text-dim:   #C2C7D6;
  --muted:      #878787;       /* Brand-Grau aus Claim */
  --text-soft:  #5A6275;

  /* Brand accent — CF-Teal #4BB4C3 */
  --accent:        #4BB4C3;
  --accent-hi:     #6FCCD8;
  --accent-lo:     #3A9AA8;
  --accent-bg:     rgba(75, 180, 195, 0.16);
  --accent-bg-hi:  rgba(75, 180, 195, 0.28);

  /* Secondary accent — heller Cyan (gleiche Farbfamilie, mehr Energie) */
  --accent-2:      #8ADCE6;
  --accent-2-bg:   rgba(138, 220, 230, 0.18);

  --gradient:      linear-gradient(135deg, #4BB4C3 0%, #6FCCD8 100%);
  --gradient-hi:   linear-gradient(135deg, #6FCCD8 0%, #8ADCE6 100%);
  --gradient-soft: linear-gradient(135deg, rgba(75,180,195,0.18) 0%, rgba(138,220,230,0.12) 100%);

  /* Semantics */
  --green:     #4ade80;
  --green-bg:  rgba(74, 222, 128, 0.15);
  --yellow:    #facc15;
  --yellow-bg: rgba(250, 204, 21, 0.15);
  --red:       #fb7185;
  --red-bg:    rgba(251, 113, 133, 0.15);

  /* Amber — warme Komplementärfarbe zum Teal (KPI-Tiles, Fragetyp vergleich) */
  --amber:     #F5A524;
  --amber-bg:  rgba(245, 165, 36, 0.18);

  /* Shape */
  --radius-sm: 6px;
  --radius:    12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* Depth */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow:    0 2px 6px rgba(0,0,0,0.35), 0 12px 32px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5), 0 32px 80px rgba(0,0,0,0.55);
  --glow:      0 0 0 3px var(--accent-bg);
  --glow-lg:   0 0 36px -6px rgba(75, 180, 195, 0.65);
  --glow-violet: 0 0 36px -6px rgba(138, 220, 230, 0.5);

  /* Motion */
  --ease:     cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur:      200ms;
  --dur-slow: 320ms;
}

/* ── Reset ─────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  -webkit-text-size-adjust: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* CF-Brand-Gradient: Teal-Atmosphäre */
  background:
    radial-gradient(800px 500px at 10% -5%, rgba(75, 180, 195, 0.32), transparent 55%),
    radial-gradient(900px 600px at 95% 10%, rgba(138, 220, 230, 0.18), transparent 60%),
    radial-gradient(700px 400px at 50% 110%, rgba(75, 180, 195, 0.15), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  position: relative;
}

button { font: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-bg-hi); color: var(--text); }

/* ── Typography ────────────────────────────────────────────── */

h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.015em; line-height: 1.2; }

code, pre, .mono {
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
}

/* ── Topbar / Bottombar ────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.75rem;
  background: rgba(15, 18, 32, 0.75);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0;
}
.topbar .brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: contain;
  box-shadow: 0 0 0 1px rgba(75, 180, 195, 0.25), var(--glow-lg);
}
.topbar .brand-name {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
}
.topbar h1 .sub {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.88rem;
}
.topbar .user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.75rem;
  color: var(--text-soft);
  font-size: 0.78rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
  background: rgba(10, 12, 22, 0.7);
  backdrop-filter: blur(10px);
}

/* ── Stage ─────────────────────────────────────────────────── */

.stage {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 2.25rem 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Card ──────────────────────────────────────────────────── */

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02) 0%, transparent 100%), var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.65rem;
  box-shadow: var(--shadow);
  transition: border-color var(--dur) var(--ease);
  position: relative;
}

/* ── Label / Input / Textarea ──────────────────────────────── */

.label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  margin-bottom: 0.55rem;
}

textarea, input[type='text'], input[type='password'],
input[type='number'], input[type='email'], select {
  width: 100%;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
}
textarea { resize: vertical; min-height: 100px; }
textarea:focus, input:focus, select:focus {
  border-color: var(--border-focus);
  background: var(--card);
  box-shadow: var(--glow);
}
textarea::placeholder, input::placeholder { color: var(--text-soft); }

/* ── Ask block ─────────────────────────────────────────────── */

.ask textarea { font-size: 1rem; }

.actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 1.1rem;
  flex-wrap: wrap;
}

.status {
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.2em;
}
.status.err { color: var(--red); }
.status.ok  { color: var(--green); }

/* ── Buttons ───────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border-strong);
  background: var(--card-2);
  color: var(--text);
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.005em;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease);
  user-select: none;
}
.btn:hover:not(:disabled) {
  background: var(--card-3);
  border-color: var(--border-focus);
  color: var(--text);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: var(--gradient);
  border-color: transparent;
  color: #06252B;
  font-weight: 700;
  box-shadow:
    0 4px 14px rgba(75, 180, 195, 0.5),
    0 2px 6px rgba(138, 220, 230, 0.3),
    inset 0 1px 0 rgba(255,255,255,0.35);
  text-shadow: 0 1px 0 rgba(255,255,255,0.15);
}
.btn.primary:hover:not(:disabled) {
  background: var(--gradient-hi);
  box-shadow:
    0 6px 22px rgba(75, 180, 195, 0.65),
    0 2px 8px rgba(138, 220, 230, 0.4),
    inset 0 1px 0 rgba(255,255,255,0.4);
  transform: translateY(-1px);
}
.btn.primary:active:not(:disabled) {
  box-shadow: 0 2px 8px rgba(75, 180, 195, 0.45);
  transform: translateY(0);
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
}
.btn.ghost:hover:not(:disabled) { background: var(--card-2); }

.btn.sm { padding: 0.35rem 0.85rem; font-size: 0.82rem; }

/* ── Chips ─────────────────────────────────────────────────── */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}
.chips-label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  margin-right: 0.4rem;
}
.chip {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  padding: 0.38rem 0.95rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.chip:hover:not(:disabled) {
  color: var(--accent-hi);
  border-color: var(--accent);
  background: var(--accent-bg);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(75, 180, 195, 0.2);
}

/* ── Pipeline (query flow indicator) ───────────────────────── */

.pipeline {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.step {
  display: flex;
  gap: 0.7rem;
  align-items: baseline;
  padding: 0.75rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.step .ico { min-width: 1.1em; font-weight: 700; font-variant-numeric: tabular-nums; }
.step.pending             { opacity: 0.5; }
.step.pending  .ico       { color: var(--text-soft); }
.step.running             {
  background: var(--accent-bg);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 1px var(--accent-bg);
}
.step.running  .ico       { color: var(--accent-hi); animation: pulse 1.4s ease-in-out infinite; }
.step.done                { background: rgba(74, 222, 128, 0.07); border-color: rgba(74,222,128,0.25); }
.step.done     .ico       { color: var(--green); }
.step.error               { background: var(--red-bg); border-color: var(--red); }
.step.error    .ico       { color: var(--red); }
.step .detail             { color: var(--muted); font-size: 0.82rem; }

@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1; }
}

/* ── Result area ───────────────────────────────────────────── */

.result {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  animation: fadeIn 0.4s var(--ease-out);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.answer {
  line-height: 1.72;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 0.98rem;
}
.answer h1 { font-size: 1.5rem;  margin: 1.3em 0 0.45em; }
.answer h2 { font-size: 1.25rem; margin: 1.1em 0 0.4em; }
.answer h3 { font-size: 1.1rem;  margin: 1em 0 0.35em; }
.answer p  { margin: 0.7em 0; }
.answer ul, .answer ol { margin: 0.7em 0 0.7em 1.5em; }
.answer li { margin: 0.3em 0; }
.answer code {
  background: var(--card-2);
  border: 1px solid var(--border);
  padding: 0.14em 0.45em;
  border-radius: 5px;
  font-size: 0.88em;
  color: var(--accent-hi);
}
.answer pre {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 0.9em 0;
}
.answer pre code { background: transparent; border: none; padding: 0; color: var(--text); }
.answer strong { color: var(--text); font-weight: 700; }
.answer blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.2em 0 0.2em 1.1em;
  color: var(--text-dim);
  margin: 0.9em 0;
  background: var(--accent-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.answer a {
  color: var(--accent-hi);
  border-bottom: 1px dashed var(--accent);
}
.answer a:hover { border-bottom-style: solid; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.95rem 1.9rem;
  color: var(--muted);
  font-size: 0.82rem;
}
.meta strong {
  color: var(--text);
  font-weight: 700;
  margin-right: 0.45em;
}

.sources {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.sources h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.5rem;
  font-weight: 700;
}
.source {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.source:hover { border-color: var(--border-strong); transform: translateX(2px); }
.source summary {
  padding: 0.7rem 1rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.9rem;
  list-style: none;
  align-items: center;
  user-select: none;
  font-weight: 500;
}
.source summary::-webkit-details-marker { display: none; }
.source summary::before {
  content: '›';
  color: var(--accent);
  margin-right: 0.4rem;
  font-size: 1.3em;
  line-height: 0.8;
  transition: transform var(--dur) var(--ease);
  display: inline-block;
  font-weight: 700;
}
.source[open] summary::before { transform: rotate(90deg); }
.source summary .rel {
  color: var(--accent-hi);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.18rem 0.6rem;
  background: var(--accent-bg);
  border-radius: 999px;
}
.source[open] summary {
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.source .body {
  padding: 0.85rem 1rem;
  color: var(--text-dim);
  font-size: 0.87rem;
  white-space: pre-wrap;
  background: var(--card);
}

/* ── Tag chips for inline use ──────────────────────────────── */

.tag {
  display: inline-block;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.tag.info    { background: var(--accent-bg); color: var(--accent-hi); }
.tag.success { background: var(--green-bg);  color: var(--green); }
.tag.warn    { background: var(--yellow-bg); color: var(--yellow); }
.tag.danger  { background: var(--red-bg);    color: var(--red); }

/* ── Toast (shared) ────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border-strong);
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  animation: toastIn 0.28s var(--ease-out);
}
.toast.success { border-color: var(--green); color: var(--green); box-shadow: var(--shadow-lg), 0 0 20px rgba(74,222,128,0.2); }
.toast.error   { border-color: var(--red);   color: var(--red); box-shadow: var(--shadow-lg), 0 0 20px rgba(251,113,133,0.2); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbars (WebKit) ───────────────────────────────────── */

*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-soft); background-clip: content-box; }

/* ── Generic card variants ─────────────────────────────────── */

.card-flush { padding: 0; overflow: hidden; }

.filter-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}
.filter-bar input[type='text'] { flex: 1; min-width: 180px; }
.filter-bar select { width: auto; min-width: 130px; }
.filter-bar .label.inline {
  margin: 0;
  flex-shrink: 0;
}
.filter-bar .status { margin-left: auto; }

.label.inline {
  display: inline-block;
  margin-bottom: 0;
}

/* ── History list rows ─────────────────────────────────────── */

.history-row {
  display: grid;
  grid-template-columns: 120px 92px 1fr 80px 88px;
  gap: 0.85rem;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  align-items: center;
  transition: background var(--dur-fast) var(--ease);
}
.history-row:last-child { border-bottom: none; }
.history-row:hover { background: var(--card-2); }

.history-row .date {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
}
.history-row .ftype {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  width: max-content;
}
.history-row .ftype.mandant   { background: var(--accent-bg); color: var(--accent-hi); }
.history-row .ftype.thema     { background: var(--green-bg);  color: var(--green); }
.history-row .ftype.vergleich { background: var(--amber-bg);  color: var(--amber); }
.history-row .ftype.meta      { background: var(--yellow-bg); color: var(--yellow); }
.history-row .ftype.unknown   { background: var(--bg-elevated); color: var(--muted); }

.history-row .q {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
}
.history-row .docs {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.history-row .stars {
  color: var(--yellow);
  font-size: 0.85rem;
  text-align: right;
  letter-spacing: 0.05em;
}
.history-row .stars .empty { color: var(--text-soft); }

/* ── Rating stars control ──────────────────────────────────── */

.stars-ctrl {
  display: flex;
  gap: 0.25rem;
  font-size: 1.85rem;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}
.stars-ctrl span {
  color: var(--text-soft);
  transition: color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.stars-ctrl span:hover { transform: scale(1.15); }
.stars-ctrl span.on { color: var(--yellow); }

/* ── Login page ────────────────────────────────────────────── */

.login-stage {
  max-width: 460px;
  justify-content: center;
  align-items: center;
  padding-top: 4rem;
}
.login-wrap { width: 100%; text-align: center; }
.login-logo {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  margin: 0 auto 1.25rem;
  display: block;
  box-shadow:
    0 0 0 1px rgba(75, 180, 195, 0.35),
    0 0 48px -4px rgba(75, 180, 195, 0.55);
}
.login-title {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  margin-bottom: 0.3rem;
  line-height: 1.05;
}
.login-brand {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}
.login-sub {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}
.login-card {
  text-align: left;
  padding: 2rem;
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 50%),
    var(--card);
  box-shadow:
    var(--shadow-lg),
    0 0 60px -20px rgba(75, 180, 195, 0.55);
}
.login-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(135deg, rgba(75,180,195,0.7) 0%, transparent 40%, rgba(138,220,230,0.55) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}
.login-card .actions .btn.primary { min-width: 140px; justify-content: center; }

/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 720px) {
  html, body { font-size: 14.5px; }
  .stage { padding: 1.5rem 1rem; gap: 1.1rem; }
  .topbar, .bottombar { padding: 0.8rem 1.1rem; }
  .card { padding: 1.2rem; border-radius: var(--radius); }
  .actions { gap: 0.6rem; }
  .login-title { font-size: 1.85rem; }
}
@media (max-width: 480px) {
  .topbar h1 .sub { display: none; }
}

/* ============================================================
   v13 — Cinematic redesign (additive only)
   Aurora backdrop, hero typography, choreographed motion,
   editorial answer styles, source object polish.
   ============================================================ */

/* ── Aurora backdrop (animated atmosphere) ────────────────── */
body::before,
body::after {
  content: '';
  position: fixed;
  inset: -20%;
  z-index: -1;
  pointer-events: none;
  filter: blur(80px);
  opacity: 0.55;
  will-change: transform;
}
body::before {
  background:
    radial-gradient(40% 40% at 20% 30%, rgba(75, 180, 195, 0.55), transparent 60%),
    radial-gradient(35% 35% at 80% 20%, rgba(138, 220, 230, 0.40), transparent 60%);
  animation: aurora-drift-a 38s ease-in-out infinite alternate;
}
body::after {
  background:
    radial-gradient(45% 45% at 70% 80%, rgba(155, 122, 240, 0.32), transparent 60%),
    radial-gradient(40% 40% at 15% 85%, rgba(75, 180, 195, 0.30), transparent 60%);
  animation: aurora-drift-b 52s ease-in-out infinite alternate;
}
@keyframes aurora-drift-a {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg)   scale(1); }
  100% { transform: translate3d(6%, -4%, 0) rotate(8deg) scale(1.15); }
}
@keyframes aurora-drift-b {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg)    scale(1); }
  100% { transform: translate3d(-5%, 5%, 0) rotate(-10deg) scale(1.18); }
}

/* Subtle film grain — adds texture so flat areas don't look plastic */
body::before { mix-blend-mode: screen; }

/* ── Stage: more breathing room ─────────────────────────── */
.stage { max-width: 1080px; padding: 3.5rem 1.5rem 2rem; gap: 2rem; }

/* ── Hero (index.html only) ──────────────────────────────── */
.hero {
  text-align: center;
  margin: 1.5rem auto 0.5rem;
  max-width: 720px;
  animation: hero-rise 0.9s var(--ease-out) both;
}
.hero .eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0.4rem 0.95rem;
  border: 1px solid rgba(75, 180, 195, 0.35);
  border-radius: 999px;
  background: rgba(75, 180, 195, 0.08);
  backdrop-filter: blur(8px);
  margin-bottom: 1.4rem;
}
.hero h2 {
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 1.12;
  padding: 0.08em 0.05em 0.18em;
  margin-bottom: 0.85rem;
  background: linear-gradient(180deg, var(--text) 0%, var(--text) 50%, var(--text-dim) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  overflow: visible;
}
.hero h2 .accent {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-style: italic;
  font-weight: 800;
  padding-right: 0.06em;
}
.hero p.lede {
  color: var(--text-dim);
  font-size: 1.05rem;
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.6;
}
@keyframes hero-rise {
  from { opacity: 0; transform: translateY(20px); filter: blur(8px); }
  to   { opacity: 1; transform: translateY(0);    filter: blur(0); }
}

/* ── Ask block — spotlight, no card frame ───────────────── */
.ask.spotlight {
  background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.01) 100%), var(--card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  padding: 2rem 2.25rem 1.75rem;
  box-shadow:
    0 30px 80px -20px rgba(75, 180, 195, 0.25),
    0 12px 32px -8px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
  overflow: hidden;
  animation: ask-rise 0.95s var(--ease-out) 0.1s both;
}
.ask.spotlight::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg,
    rgba(75,180,195,0.45) 0%,
    rgba(255,255,255,0.05) 35%,
    rgba(138,220,230,0.4) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}
.ask.spotlight textarea {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  line-height: 1.55;
  padding: 0.5rem 0;
  min-height: 80px;
  font-weight: 400;
}
.ask.spotlight textarea:focus { box-shadow: none; background: transparent; }
.ask.spotlight textarea::placeholder {
  color: var(--text-soft);
  font-weight: 400;
}
.ask.spotlight .label { display: none; }
@keyframes ask-rise {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Submit button — bigger, glowy in the spotlight */
.ask.spotlight .btn.primary {
  padding: 0.85rem 1.8rem;
  font-size: 1rem;
  border-radius: 999px;
  letter-spacing: 0.005em;
}

/* ── Chips — feel like real "suggestions" ───────────────── */
.ask.spotlight .chips {
  margin-top: 1.5rem;
  padding-top: 1.3rem;
  border-color: rgba(255, 255, 255, 0.06);
  justify-content: center;
}
.chip {
  position: relative;
  overflow: hidden;
}
.chip::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(120px 60px at var(--mx, 50%) var(--my, 50%),
    rgba(138, 220, 230, 0.25), transparent 70%);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
  pointer-events: none;
}
.chip:hover::after { opacity: 1; }

/* ── Pipeline — choreographed states ────────────────────── */
.pipeline { animation: fadeIn 0.4s var(--ease-out); }

.step {
  position: relative;
  overflow: hidden;
  transition:
    border-color var(--dur) var(--ease),
    background var(--dur) var(--ease),
    transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.step.running {
  transform: translateX(2px);
}
/* Wave shimmer travels through running step */
.step.running::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg,
    transparent 25%,
    rgba(138, 220, 230, 0.18) 50%,
    transparent 75%);
  background-size: 250% 100%;
  animation: step-wave 2.2s linear infinite;
  pointer-events: none;
}
@keyframes step-wave {
  0%   { background-position: 200% 0; }
  100% { background-position: -100% 0; }
}
.step.done {
  animation: step-done 0.45s var(--ease-out);
}
.step.done .ico {
  animation: check-pop 0.5s var(--ease-out);
  display: inline-block;
}
@keyframes step-done {
  0%   { background: rgba(74, 222, 128, 0.18); }
  100% { background: rgba(74, 222, 128, 0.07); }
}
@keyframes check-pop {
  0%   { transform: scale(0.4) rotate(-20deg); opacity: 0; }
  60%  { transform: scale(1.25) rotate(0deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}

/* Progress bar inside running step — smoother fill */
.progress-fill {
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%) !important;
  box-shadow: 0 0 12px rgba(138, 220, 230, 0.45);
  transition: width 0.4s var(--ease-out);
}
.progress-bar {
  background: rgba(255, 255, 255, 0.06) !important;
}

/* ── Result area — editorial answer ─────────────────────── */
.result { gap: 1.5rem; }

.answer {
  font-size: 1.05rem;
  line-height: 1.78;
  padding: 2.25rem 2.5rem;
}
/* Drop-cap on first letter of answer's first paragraph */
.answer > p:first-of-type::first-letter,
.answer > h1:first-child + p::first-letter {
  font-size: 3.6em;
  font-weight: 800;
  line-height: 0.85;
  float: left;
  padding: 0.05em 0.12em 0 0;
  margin: 0.05em 0.1em 0 0;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.answer blockquote {
  position: relative;
  padding: 0.9em 1em 0.9em 2.2em;
  font-style: italic;
}
.answer blockquote::before {
  content: '\201C';
  position: absolute;
  left: 0.45em;
  top: -0.05em;
  font-size: 3em;
  color: var(--accent);
  line-height: 1;
  font-style: normal;
  font-weight: 700;
  opacity: 0.6;
}

/* Code block window-chrome */
.answer pre {
  position: relative;
  padding-top: 2.4rem;
}
.answer pre::before {
  content: '';
  position: absolute;
  top: 0.85rem;
  left: 1rem;
  width: 38px;
  height: 8px;
  background:
    radial-gradient(circle 4px at 4px 4px,  #fb7185 99%, transparent 0),
    radial-gradient(circle 4px at 19px 4px, #facc15 99%, transparent 0),
    radial-gradient(circle 4px at 34px 4px, #4ade80 99%, transparent 0);
}

/* Meta line — premium pill row */
.meta {
  padding: 1.1rem 1.35rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent);
  border-radius: var(--radius);
  font-size: 0.85rem;
  gap: 0.6rem 1.5rem;
}
.meta > span {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}
.meta strong {
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-right: 0;
}

/* ── Sources — premium objects with stagger entry ───────── */
.sources h3 {
  font-size: 0.78rem;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.sources h3::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border) 0%, transparent 100%);
}

.source {
  background: linear-gradient(180deg, rgba(255,255,255,0.025), transparent), var(--card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.4);
  opacity: 0;
  animation: source-in 0.5s var(--ease-out) forwards;
}
.source:nth-child(2)  { animation-delay: 60ms; }
.source:nth-child(3)  { animation-delay: 120ms; }
.source:nth-child(4)  { animation-delay: 180ms; }
.source:nth-child(5)  { animation-delay: 240ms; }
.source:nth-child(6)  { animation-delay: 300ms; }
.source:nth-child(7)  { animation-delay: 360ms; }
.source:nth-child(8)  { animation-delay: 420ms; }
.source:nth-child(9)  { animation-delay: 480ms; }
.source:nth-child(10) { animation-delay: 540ms; }
.source:nth-child(n+11) { animation-delay: 600ms; }

.source:hover {
  border-color: rgba(75, 180, 195, 0.35);
  transform: translateY(-2px) translateX(2px);
  box-shadow: 0 12px 28px -8px rgba(75, 180, 195, 0.25),
              0 4px 12px -4px rgba(0, 0, 0, 0.5);
}
.source[open] {
  border-color: rgba(75, 180, 195, 0.4);
  box-shadow: 0 8px 24px -8px rgba(75, 180, 195, 0.2);
}
.source summary .rel {
  background: linear-gradient(135deg, var(--accent-bg-hi) 0%, var(--accent-bg) 100%);
  border: 1px solid rgba(75, 180, 195, 0.3);
  font-weight: 700;
}
@keyframes source-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Topbar — refined glass ─────────────────────────────── */
.topbar {
  background: rgba(15, 18, 32, 0.55);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.topbar .brand-logo {
  box-shadow:
    0 0 0 1px rgba(75, 180, 195, 0.3),
    0 0 24px -2px rgba(75, 180, 195, 0.5);
  transition: transform var(--dur) var(--ease);
}
.topbar:hover .brand-logo { transform: rotate(-8deg) scale(1.05); }

/* ── Status text — subtle live shimmer when busy ───────── */
.status {
  transition: color var(--dur) var(--ease);
}

/* ── Toast — softer, more confident ─────────────────────── */
.toast {
  background: rgba(26, 34, 50, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 500;
  padding: 0.95rem 1.4rem;
}

/* ── Reduced motion respect ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
  .step.running::before { animation: none; }
  .source { animation: none; opacity: 1; }
  .hero, .ask.spotlight { animation: none; }
}
