/* AINA test site.

   A quiet product interface. The AI message parts (pixel loader, thinking
   trace, streamed text with sources and follow-ups, question card, context
   cards) are ported from Beautiful UI (https://www.beautifului.dev),
   © 2026 Beautiful UI, MIT License, and redrawn here in plain CSS in AINA's
   teal, gold and cream. No gradients for decoration, no glows: hairlines,
   small type, and motion only where something is actually happening. */

/* ---------- tokens ---------- */

:root {
  color-scheme: light;
  --canvas: oklch(97.3% 0.004 95);
  --surface: oklch(100% 0 0);
  --inset: oklch(98.3% 0.003 95);
  --hover: oklch(96% 0.004 95);
  --hover-2: oklch(93.6% 0.005 95);
  --line: oklch(92.6% 0.005 95);
  --line-soft: oklch(95.2% 0.004 95);
  --line-strong: oklch(88.4% 0.006 95);

  --ink: oklch(24% 0.014 205);
  --ink-2: oklch(47% 0.013 205);
  --ink-3: oklch(63.5% 0.011 205);

  --teal: #003c44;
  --accent: oklch(41% 0.07 178);
  --accent-ink: oklch(39% 0.072 178);
  --accent-tint: oklch(41% 0.07 178 / 0.08);
  --gold: #e5bd17;
  --gold-ink: oklch(52% 0.11 85);
  --mark: oklch(88% 0.17 95 / 0.55);

  --ok: oklch(52% 0.12 158);
  --warn: oklch(58% 0.13 70);
  --warn-tint: oklch(80% 0.13 80 / 0.16);
  --bad: oklch(55% 0.18 28);

  --av-fsc: oklch(41% 0.07 178);
  --av-pefc: oklch(52% 0.12 145);
  --av-int: oklch(70% 0.14 85);
  --av-expert: oklch(36% 0.03 230);

  --shadow-hairline: 0 0 0 1px var(--line);
  --shadow-btn: 0 0 0 1px var(--line-strong), 0 1px 1px oklch(20% 0.02 205 / 0.05);
  --shadow-card: 0 0 0 1px var(--line), 0 1px 2px oklch(20% 0.02 205 / 0.05);
  --shadow-raised: 0 0 0 1px var(--line), 0 4px 14px -4px oklch(20% 0.02 205 / 0.12);
  --shadow-overlay: 0 0 0 1px var(--line), 0 16px 40px -12px oklch(20% 0.02 205 / 0.22);
  --shadow-field: inset 0 1px 2px oklch(20% 0.02 205 / 0.06);

  --sans: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Fira Sans", sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --serif: "New York", Charter, "Iowan Old Style", Georgia, serif;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-link: cubic-bezier(0.65, 0, 0.35, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas: oklch(19.5% 0.012 210);
    --surface: oklch(22.6% 0.013 210);
    --inset: oklch(20.8% 0.012 210);
    --hover: oklch(25.4% 0.014 210);
    --hover-2: oklch(28.4% 0.015 210);
    --line: oklch(29.5% 0.014 210);
    --line-soft: oklch(26% 0.013 210);
    --line-strong: oklch(34.5% 0.015 210);
    --ink: oklch(95.5% 0.006 200);
    --ink-2: oklch(74% 0.012 200);
    --ink-3: oklch(56.5% 0.013 205);
    --accent: oklch(75% 0.1 178);
    --accent-ink: oklch(80% 0.09 178);
    --accent-tint: oklch(75% 0.1 178 / 0.12);
    --gold-ink: oklch(86% 0.14 92);
    --mark: oklch(86% 0.17 95 / 0.28);
    --ok: oklch(76% 0.13 158);
    --warn: oklch(80% 0.12 75);
    --warn-tint: oklch(80% 0.12 75 / 0.12);
    --bad: oklch(72% 0.15 28);
    --av-fsc: oklch(62% 0.09 178);
    --av-pefc: oklch(64% 0.12 145);
    --av-int: oklch(78% 0.14 88);
    --av-expert: oklch(55% 0.03 230);
    --shadow-btn: 0 0 0 1px oklch(100% 0 0 / 0.1), 0 1px 2px oklch(0% 0 0 / 0.3);
    --shadow-card: 0 0 0 1px oklch(100% 0 0 / 0.08), 0 1px 2px oklch(0% 0 0 / 0.25);
    --shadow-raised: 0 0 0 1px oklch(100% 0 0 / 0.1), 0 6px 18px -6px oklch(0% 0 0 / 0.45);
    --shadow-overlay: 0 0 0 1px oklch(100% 0 0 / 0.12), 0 18px 44px -12px oklch(0% 0 0 / 0.6);
    --shadow-field: inset 0 1px 2px oklch(0% 0 0 / 0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: oklch(19.5% 0.012 210);
  --surface: oklch(22.6% 0.013 210);
  --inset: oklch(20.8% 0.012 210);
  --hover: oklch(25.4% 0.014 210);
  --hover-2: oklch(28.4% 0.015 210);
  --line: oklch(29.5% 0.014 210);
  --line-soft: oklch(26% 0.013 210);
  --line-strong: oklch(34.5% 0.015 210);
  --ink: oklch(95.5% 0.006 200);
  --ink-2: oklch(74% 0.012 200);
  --ink-3: oklch(56.5% 0.013 205);
  --accent: oklch(75% 0.1 178);
  --accent-ink: oklch(80% 0.09 178);
  --accent-tint: oklch(75% 0.1 178 / 0.12);
  --gold-ink: oklch(86% 0.14 92);
  --mark: oklch(86% 0.17 95 / 0.28);
  --ok: oklch(76% 0.13 158);
  --warn: oklch(80% 0.12 75);
  --warn-tint: oklch(80% 0.12 75 / 0.12);
  --bad: oklch(72% 0.15 28);
  --av-fsc: oklch(62% 0.09 178);
  --av-pefc: oklch(64% 0.12 145);
  --av-int: oklch(78% 0.14 88);
  --av-expert: oklch(55% 0.03 230);
  --shadow-btn: 0 0 0 1px oklch(100% 0 0 / 0.1), 0 1px 2px oklch(0% 0 0 / 0.3);
  --shadow-card: 0 0 0 1px oklch(100% 0 0 / 0.08), 0 1px 2px oklch(0% 0 0 / 0.25);
  --shadow-raised: 0 0 0 1px oklch(100% 0 0 / 0.1), 0 6px 18px -6px oklch(0% 0 0 / 0.45);
  --shadow-overlay: 0 0 0 1px oklch(100% 0 0 / 0.12), 0 18px 44px -12px oklch(0% 0 0 / 0.6);
  --shadow-field: inset 0 1px 2px oklch(0% 0 0 / 0.35);
}

/* ---------- base ---------- */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 13px/1.5 var(--sans); color: var(--ink); background: var(--canvas); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
::selection { background: var(--mark); }
.mono { font-family: var(--mono); }
.muted { color: var(--ink-3); }

.kbd {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 5px;
  font: 500 10.5px/1 var(--mono); color: var(--ink-3);
  background: var(--inset);
  box-shadow: var(--shadow-hairline);
}
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 18px; padding: 0 6px;
  border-radius: 5px;
  font-size: 11px; font-weight: 500; color: var(--ink-2);
  background: var(--hover);
  box-shadow: var(--shadow-hairline);
  white-space: nowrap;
}
.tag--gold { color: var(--gold-ink); background: var(--mark); box-shadow: none; }
.tag--accent { color: var(--accent-ink); background: var(--accent-tint); box-shadow: none; }
.tag--warn { color: var(--warn); background: var(--warn-tint); box-shadow: none; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px;
  border-radius: 7px;
  color: var(--ink-3);
  transition: background-color 100ms, color 100ms;
}
.icon-btn:hover { background: var(--hover-2); color: var(--ink-2); }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn.is-on { color: var(--accent-ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 11px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  transition: background-color 120ms, box-shadow 120ms, opacity 120ms, transform 120ms var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn--primary { color: var(--canvas); background: var(--ink); }
.btn--primary:hover { opacity: 0.88; }
.btn--primary:disabled { opacity: 0.35; cursor: default; transform: none; }
.btn--plain { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-btn); }
.btn--plain:hover { background: var(--hover); }
.btn--ghost { color: var(--ink-2); }
.btn--ghost:hover { background: var(--hover-2); color: var(--ink); }

.animated-underline { position: relative; display: inline-block; }
.animated-underline::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: 0 50%; transition: transform 280ms var(--ease-link); }
a:hover .animated-underline::after, button:hover .animated-underline::after { transform: scaleX(1); }

/* ---------- layout ---------- */

.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); height: 100vh; height: 100dvh; overflow: hidden; }

/* sidebar */
.side { display: flex; flex-direction: column; gap: 2px; min-height: 0; padding: 12px 10px 10px; border-right: 1px solid var(--line); }
.side-top { display: flex; align-items: center; gap: 8px; padding: 2px 6px 12px; }
.brand { display: flex; align-items: center; gap: 9px; }
/* Live AINA's logo: dark lettering on light backgrounds, white lettering on dark ones. */
.logo { display: block; height: 30px; width: auto; margin: 2px 0 2px 4px; }
.logo--dark { display: none; }
:root[data-theme="dark"] .logo--light { display: none; }
:root[data-theme="dark"] .logo--dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo--light { display: none; }
  :root:not([data-theme="light"]) .logo--dark { display: block; }
}
.side-new, .side-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; height: 30px; padding: 0 8px;
  border-radius: 8px;
  font-size: 13px; color: var(--ink-2); text-align: left;
  transition: background-color 100ms, color 100ms;
}
.side-new { margin-bottom: 6px; color: var(--ink); background: var(--surface); box-shadow: var(--shadow-btn); }
.side-new:hover { background: var(--hover); }
.side-new .kbd { margin-left: auto; }
.side-item:hover { background: var(--hover-2); color: var(--ink); }
.side-item.is-active { background: var(--hover-2); color: var(--ink); font-weight: 500; }
.side-item svg, .side-new svg { width: 15px; height: 15px; color: var(--ink-3); }
.side-item.is-active svg { color: var(--ink); }
.side-count { margin-left: auto; font: 500 11px var(--mono); color: var(--ink-3); }
.side-label { margin: 16px 8px 4px; font-size: 11.5px; font-weight: 500; color: var(--ink-3); }
.threads { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.thread { display: flex; align-items: center; border-radius: 8px; transition: background-color 100ms; }
.thread:hover { background: var(--hover-2); }
.thread.is-active { background: var(--hover-2); }
.thread-open { flex: 1; min-width: 0; height: 30px; padding: 0 8px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; color: var(--ink-2); }
.thread.is-active .thread-open { color: var(--ink); }
.thread-when { margin-right: 6px; font: 11px var(--mono); color: var(--ink-3); }
.thread-remove { display: none; place-items: center; width: 22px; height: 22px; margin-right: 4px; border-radius: 6px; color: var(--ink-3); }
.thread-remove svg { width: 12px; height: 12px; }
.thread:hover .thread-when { display: none; }
.thread:hover .thread-remove { display: grid; }
.thread-remove:hover { color: var(--bad); background: var(--hover); }
.threads-empty { padding: 4px 8px; font-size: 12.5px; color: var(--ink-3); }
.account { display: flex; align-items: center; gap: 9px; margin: 6px 0 8px; padding: 6px 4px 6px 6px; border-radius: 9px; }
.account:hover { background: var(--hover); }
.account-initials {
  display: grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  font: 600 10.5px/1 var(--sans); letter-spacing: 0.02em;
  color: var(--teal); background: var(--gold);
}
.account-who { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.account-name, .account-plan { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-name { font-size: 12.5px; font-weight: 500; color: var(--ink); }
.account-plan { font-size: 11.5px; color: var(--ink-3); }
.account-plan:empty { display: none; }
.side-foot { display: flex; align-items: center; gap: 6px; padding: 10px 4px 0 8px; border-top: 1px solid var(--line); }

/* sign-in screen */
.gate { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px 16px; background: var(--canvas); }
.gate-card {
  display: flex; flex-direction: column; gap: 12px;
  width: 100%; max-width: 360px; padding: 28px 28px 22px;
  border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-raised);
  animation: gate-in 420ms var(--ease) both;
}
@keyframes gate-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .gate-card { animation: none; } }
.gate-logo { align-self: flex-start; height: 34px; margin: 0 0 10px; }
.gate-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.gate-sub { margin-top: -8px; font-size: 13px; color: var(--ink-2); }
.gate-google { width: 100%; height: 36px; }
.gate-or { display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--ink-3); }
.gate-or::before, .gate-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field-label { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.field-input {
  height: 36px; padding: 0 10px;
  border: 0; border-radius: 8px; outline: 0;
  background: var(--inset); box-shadow: var(--shadow-hairline), var(--shadow-field);
  transition: box-shadow 120ms;
}
.field-input:focus { box-shadow: 0 0 0 1.5px var(--accent), var(--shadow-field); }
.gate-error { padding: 8px 10px; border-radius: 8px; font-size: 12.5px; color: var(--bad); background: color-mix(in oklch, var(--bad) 9%, transparent); }
.gate-submit { height: 36px; margin-top: 4px; }
.gate-foot { margin-top: 6px; font-size: 12px; color: var(--ink-3); text-align: center; }
.gate-foot a { color: var(--accent-ink); font-weight: 500; }
.status { display: inline-flex; align-items: center; gap: 7px; flex: 1; min-width: 0; font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: none; }
.status.is-ready i { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in oklch, var(--ok) 18%, transparent); }
.status.is-off i { background: var(--bad); }
.icon-btn .i-moon { display: none; }
:root[data-theme="dark"] .icon-btn .i-sun { display: none; }
:root[data-theme="dark"] .icon-btn .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn .i-sun { display: none; }
  :root:not([data-theme="light"]) .icon-btn .i-moon { display: block; }
}

/* main */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--canvas); }
.bar { display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 16px; flex: none; }
.bar-title { min-width: 0; font-size: 13px; font-weight: 500; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.only-narrow { display: none; }
.view { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.scroll { flex: 1; overflow-y: auto; overflow-x: hidden; }
.column { width: 100%; max-width: 728px; margin: 0 auto; padding: 8px 24px 40px; }
.column--wide { max-width: 1040px; }

/* ---------- empty state ---------- */

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: calc(100dvh - 120px); padding: 24px 0 64px; text-align: center; }
.ring-mark { width: 120px; height: 120px; margin-bottom: 18px; animation: fade-in 600ms ease-out both; }
.empty h1 { font-size: 21px; font-weight: 600; letter-spacing: -0.012em; color: var(--ink); animation: fade-up 400ms var(--ease) 80ms both; }
.empty > p { max-width: 430px; margin-top: 6px; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); animation: fade-up 400ms var(--ease) 140ms both; }
.empty-slot { width: 100%; max-width: 640px; margin-top: 22px; text-align: left; animation: fade-up 450ms var(--ease) 200ms both; }
.try { width: 100%; max-width: 640px; margin-top: 18px; text-align: left; }
.try-label { padding: 0 2px 2px; font-size: 12px; font-weight: 500; color: var(--ink-2); animation: fade-in 400ms ease-out 260ms both; }
.try-row {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; margin: 0 -8px;
  width: calc(100% + 16px);
  border-radius: 7px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px; color: var(--ink); text-align: left;
  transition: background-color 100ms;
  animation: fade-up 350ms var(--ease) both;
}
.try-row:last-child { border-bottom: 0; }
.try-row:hover { background: var(--hover-2); }
.try-row svg { width: 12px; height: 12px; color: var(--ink-3); stroke-width: 2; }
.try-row .tag { margin-left: auto; }
.empty-foot { max-width: none; margin-top: 26px; text-wrap: balance; font: 11.5px var(--mono); color: var(--ink-3); animation: fade-in 500ms ease-out 500ms both; }

/* ---------- messages ---------- */

.thread-list { display: flex; flex-direction: column; gap: 26px; padding-top: 12px; }
.msg-user {
  align-self: flex-end; max-width: 78%;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--hover-2);
  font-size: 14px; line-height: 1.5; color: var(--ink);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-user.is-new { animation: pop-in 220ms var(--ease) both; transform-origin: right bottom; }
.msg-aina { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

/* pixel loader — Beautiful UI "Drive" */
.px { display: grid; grid-template-columns: repeat(3, 4px); gap: 1.5px; flex: none; }
.px i { width: 4px; height: 4px; border-radius: 1px; background: var(--ink); opacity: 0.15; animation: pixel-on 650ms ease-in-out infinite; }
.shimmer {
  background-image: linear-gradient(90deg, var(--ink-3) 35%, var(--ink) 50%, var(--ink-3) 65%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer-text 1.4s linear infinite;
}
.elapsed { font: 12px var(--mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* thinking trace — Beautiful UI "Thinking" */
.think { display: flex; flex-direction: column; }
.think-head {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  margin: 0 -6px; padding: 4px 6px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
  transition: background-color 100ms;
}
.think-head:hover { background: var(--hover-2); }
.think-head .chev { width: 14px; height: 14px; color: var(--ink-3); stroke-width: 2.2; transition: transform 300ms var(--ease); }
.think.is-open .think-head .chev { transform: rotate(180deg); }
.think-head .done-icon { width: 15px; height: 15px; color: var(--ink-3); }
.think-label-done { animation: fade-in 350ms ease-out both; }
.think-body { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 400ms var(--ease), opacity 400ms var(--ease); }
.think.is-open .think-body { grid-template-rows: 1fr; opacity: 1; }
.think-inner { overflow: hidden; }
.think-trace { position: relative; margin: 2px 0 0 5px; padding: 4px 0 4px 16px; display: flex; flex-direction: column; gap: 3px; }
.think-trace::before { content: ""; position: absolute; left: 3px; top: 0; bottom: 6px; width: 1px; background: var(--line); }
.row { display: flex; align-items: center; gap: 8px; min-height: 22px; font-size: 12.5px; color: var(--ink-2); animation: fade-up 300ms var(--ease) both; }
.row-icon { display: grid; place-items: center; width: 14px; height: 14px; flex: none; color: var(--ink-3); }
.row-icon svg { width: 13px; height: 13px; }
.row.is-active .row-icon::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--line-strong); border-top-color: var(--ink-2); animation: spin 700ms linear infinite; }
.row.is-active .row-icon svg { display: none; }
.row.is-active { color: var(--ink); }
.row-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-text b { font-weight: 500; font-family: var(--mono); font-size: 12px; color: var(--ink); }
.row-sub { margin-left: auto; padding-left: 8px; font: 11px var(--mono); color: var(--ink-3); white-space: nowrap; }

/* streamed text — Beautiful UI "Streaming Text" */
.md { font-size: 14.5px; line-height: 1.65; color: var(--ink); overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 10px; }
.md h1, .md h2, .md h3 { margin: 18px 0 6px; font-size: 14.5px; font-weight: 620; color: var(--ink); }
.md strong { font-weight: 620; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 20px; }
.md li { margin: 4px 0; }
.md li::marker { color: var(--ink-3); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.md blockquote { margin: 0 0 10px; padding: 2px 0 2px 12px; border-left: 2px solid var(--gold); font-family: var(--serif); color: var(--ink-2); }
.md code { font: 12.5px var(--mono); padding: 1px 4px; border-radius: 4px; background: var(--hover-2); }
.md pre { margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; background: var(--inset); box-shadow: var(--shadow-hairline); overflow-x: auto; }
.md pre code { padding: 0; background: none; }
.md a { color: var(--accent-ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.md table { width: 100%; margin: 0 0 12px; border-collapse: collapse; font-size: 13px; }
.md th, .md td { padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.md th { font-weight: 500; color: var(--ink-2); }
.w-in { display: inline-block; animation: word-in 320ms var(--ease) both; }
.caret { display: inline-block; width: 2px; height: 14px; margin-left: 2px; border-radius: 2px; background: var(--ink); vertical-align: -2px; animation: fade-in 150ms ease-out both, blink 1s steps(2) 150ms infinite; }

/* an inline source chip */
.nb { white-space: nowrap; }
.cite {
  display: inline-flex; align-items: center; gap: 5px;
  margin: 0 1px; padding: 0 7px 0 3px; height: 20px;
  border-radius: 999px;
  vertical-align: 1px;
  font: 500 11px/20px var(--sans); color: var(--ink-2);
  background: var(--surface);
  box-shadow: var(--shadow-btn);
  white-space: nowrap;
  transition: background-color 120ms, color 120ms;
}
.cite:hover { background: var(--hover); color: var(--ink); }
.av { display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; flex: none; font: 700 8px/1 var(--sans); color: #fff; background: var(--av-fsc); }
.av--pefc { background: var(--av-pefc); }
.av--int { background: var(--av-int); color: oklch(25% 0.04 85); }
.av--expert { background: var(--av-expert); }
.av--sq { border-radius: 4px; width: 16px; height: 16px; font-size: 8.5px; }

/* the actions row, sources and follow-ups that appear once the answer is done */
.actions { display: flex; align-items: center; gap: 2px; margin-top: -2px; animation: fade-in 400ms ease-out both; }
.actions .icon-btn { width: 26px; height: 26px; border-radius: 6px; }
.sources-btn { display: inline-flex; align-items: center; gap: 7px; margin-left: 6px; padding: 2px 6px 2px 4px; border-radius: 6px; font-size: 12px; color: var(--ink-2); transition: background-color 150ms; }
.sources-btn:hover { background: var(--hover-2); }
.stack { display: flex; }
.stack .av { box-shadow: 0 0 0 1.5px var(--canvas); }
.stack .av + .av { margin-left: -4px; }
.meta { margin-left: auto; font: 11px var(--mono); color: var(--ink-3); opacity: 0; transition: opacity 200ms; }
.msg-aina:hover .meta { opacity: 1; }
.reveal { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 300ms var(--ease), opacity 300ms var(--ease); }
.reveal.is-open { grid-template-rows: 1fr; opacity: 1; }
.reveal > div { overflow: hidden; }
.source-list { display: flex; flex-direction: column; margin-top: 2px; padding: 4px; border-radius: 10px; background: var(--inset); box-shadow: var(--shadow-hairline); }
.source-link { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; font-size: 12.5px; color: var(--ink-2); text-align: left; transition: background-color 150ms, color 150ms; }
.source-link:hover { background: var(--hover-2); color: var(--ink); }
.source-link .code { font: 500 12px var(--mono); color: var(--ink); }
.source-link .where { margin-left: auto; font: 11px var(--mono); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50%; }
.cards-label { margin: 10px 2px 6px; font-size: 12px; font-weight: 500; color: var(--ink-2); }

/* context cards — Beautiful UI "Context Cards" */
.ctx { display: block; width: 100%; padding: 10px 12px; margin-bottom: 6px; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-card); text-align: left; transition: box-shadow 150ms; animation: fade-up 300ms var(--ease) both; }
.ctx:hover { box-shadow: var(--shadow-raised); }
.ctx-top { display: flex; align-items: baseline; gap: 8px; }
.ctx-title { font-size: 12.5px; font-weight: 550; color: var(--ink); }
.ctx-size { margin-left: auto; font: 11px var(--mono); color: var(--ink-3); white-space: nowrap; }
.ctx-quote { margin-top: 5px; font: 13.5px/1.55 var(--serif); color: var(--ink-2); }
.ctx-file { display: flex; align-items: center; gap: 6px; margin-top: 8px; font: 11px var(--mono); color: var(--ink-3); }
.ctx-kind { padding: 1px 4px; border-radius: 4px; font: 600 9.5px var(--mono); color: var(--ink-2); background: var(--hover-2); }
.ctx--out { opacity: 0.6; }
.ctx--related { box-shadow: 0 0 0 1px var(--line), inset 3px 0 0 var(--gold); }
.ctx-related { margin-bottom: 6px; font: 600 10.5px var(--mono); letter-spacing: 0.02em; text-transform: uppercase; color: var(--gold-ink); }
.ctx--out .ctx-title { text-decoration: line-through; }

.followups { margin-top: 4px; animation: fade-in 400ms ease-out both; }
.followups-label { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.followup {
  display: flex; align-items: center; gap: 8px;
  width: calc(100% + 12px); margin: 0 -6px; padding: 6px;
  border-radius: 7px; border-bottom: 1px solid var(--line-soft);
  font-size: 13px; color: var(--ink); text-align: left;
  transition: background-color 100ms;
  animation: fade-up 350ms var(--ease) both;
}
.followup:last-child { border-bottom: 0; }
.followup:hover { background: var(--hover-2); }
.followup svg { width: 11px; height: 11px; color: var(--ink-3); stroke-width: 2; }

.note { display: flex; gap: 8px; padding: 8px 10px; border-radius: 8px; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); background: var(--warn-tint); }
.note svg { width: 14px; height: 14px; margin-top: 2px; color: var(--warn); }
.note b { color: var(--ink); font-weight: 550; }
.note--plain { background: var(--inset); box-shadow: var(--shadow-hairline); }
.note--plain svg { color: var(--ink-3); }
.note--bad { background: color-mix(in oklch, var(--bad) 10%, transparent); }
.note--bad svg { color: var(--bad); }

/* question card — Beautiful UI "Approval Card" */
.ask { max-width: 520px; padding: 12px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-raised); animation: pop-in 220ms var(--ease) both; transform-origin: top left; }
.ask-q { padding: 0 4px 8px; font-size: 13.5px; font-weight: 550; line-height: 1.45; color: var(--ink); }
.ask-opts { display: flex; flex-direction: column; gap: 1px; }
.ask-opt {
  display: flex; align-items: center; gap: 9px;
  padding: 6px; border-radius: 8px;
  font-size: 13px; color: var(--ink); text-align: left;
  transition: background-color 100ms;
  animation: fade-up 300ms var(--ease) both;
}
.ask-opt:hover { background: var(--hover-2); }
.ask-opt .kbd { margin-left: auto; }
.radio { width: 15px; height: 15px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1.5px var(--line-strong); transition: box-shadow 150ms var(--ease); }
.ask-opt.is-on .radio { box-shadow: inset 0 0 0 4.5px var(--ink); }
.ask-other { color: var(--ink-3); }
.ask-foot { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding: 8px 4px 0; border-top: 1px solid var(--line-soft); }
.ask-foot .muted { margin-right: auto; font-size: 12px; }
.ask.is-done { box-shadow: var(--shadow-card); animation: none; }
.ask.is-done .ask-opt { cursor: default; animation: none; }
.ask.is-done .ask-opt:hover { background: none; }
.ask.is-done .ask-opt:not(.is-on) { opacity: 0.45; }
.ask.is-done .ask-foot, .ask.is-done .ask-other, .ask.is-done .kbd { display: none; }

/* ---------- the prompt bar ---------- */

.dock { padding: 0 24px 12px; flex: none; }
.dock .prompt { max-width: 680px; margin: 0 auto; }
.dock-note { max-width: 680px; margin: 7px auto 0; text-align: center; font-size: 11.5px; color: var(--ink-3); }
.view.is-empty .dock { display: none; }
.prompt {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 10px 8px 14px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  transition: box-shadow 150ms;
}
.prompt:focus-within { box-shadow: 0 0 0 1px var(--line-strong), 0 6px 20px -8px oklch(20% 0.02 205 / 0.18); }
.prompt textarea { display: block; width: 100%; min-height: 24px; max-height: 200px; padding: 4px 0; border: 0; outline: 0; resize: none; background: none; font-size: 14.5px; line-height: 1.5; color: var(--ink); }
.prompt textarea::placeholder { color: var(--ink-3); }
.prompt-row { display: flex; align-items: center; gap: 8px; }
.prompt-hint { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ink-3); }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 2px 0 7px; margin-left: -4px; border-radius: 7px; color: var(--ink-2); transition: background-color 100ms; }
.chip:hover { background: var(--hover-2); }
.chip svg { width: 14px; height: 14px; color: var(--ink-3); }
.chip select { height: 24px; border: 0; outline: 0; background: none; font-size: 12.5px; cursor: pointer; }
.send { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--canvas); background: var(--ink); transition: opacity 150ms, transform 120ms var(--ease); }
.send svg { width: 15px; height: 15px; stroke-width: 2.2; }
.send .i-stop { display: none; fill: currentColor; stroke: none; width: 12px; height: 12px; }
.send:hover { opacity: 0.85; }
.send:active { transform: scale(0.92); }
.send:disabled { opacity: 0.25; cursor: default; }
.send.is-busy { opacity: 1; }
.send.is-busy .i-up { display: none; }
.send.is-busy .i-stop { display: block; }

/* ---------- the source sheet ---------- */

.scrim { position: fixed; inset: 0; z-index: 30; background: oklch(15% 0.02 205 / 0.18); animation: fade-in 200ms ease-out both; }
.sheet {
  position: fixed; z-index: 40; top: 8px; right: 8px; bottom: 8px;
  width: min(480px, calc(100vw - 16px));
  display: flex; flex-direction: column;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-overlay);
  transform: translateX(calc(100% + 16px));
  visibility: hidden;
  transition: transform 380ms var(--ease), visibility 0s linear 380ms;
  overflow: hidden;
}
.sheet.is-open { transform: none; visibility: visible; transition: transform 380ms var(--ease), visibility 0s; }
.sheet-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 10px 12px 16px; border-bottom: 1px solid var(--line); }
.sheet-title { flex: 1; min-width: 0; }
.sheet-code { display: flex; align-items: center; gap: 8px; font: 600 13.5px/1.4 var(--mono); color: var(--ink); overflow-wrap: anywhere; }
.sheet-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px 18px 24px; }
.sheet-under { margin-bottom: 12px; font-size: 12px; color: var(--ink-3); }
.source-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 15px/1.7 var(--serif); color: var(--ink); }
.source-text mark { color: inherit; padding: 1px 0; background: linear-gradient(var(--mark), var(--mark)) no-repeat 0 100% / 0% 100%; animation: mark-in 600ms var(--ease) 300ms forwards; border-radius: 2px; }
.sheet-foot { display: flex; align-items: center; gap: 6px; padding: 10px 16px; border-top: 1px solid var(--line); font: 11px var(--mono); color: var(--ink-3); overflow-wrap: anywhere; }
.skeleton { display: grid; gap: 9px; }
.skeleton i { display: block; height: 11px; border-radius: 4px; background: linear-gradient(90deg, var(--hover-2) 35%, var(--hover) 50%, var(--hover-2) 65%); background-size: 200% 100%; animation: shimmer-text 1.4s linear infinite; }
.skeleton i:nth-child(2) { width: 88%; } .skeleton i:nth-child(3) { width: 94%; } .skeleton i:nth-child(4) { width: 60%; }

/* ---------- library ---------- */

.lib-head { padding: 28px 0 16px; }
.lib-head h1 { font-size: 21px; font-weight: 600; letter-spacing: -0.012em; }
.lib-head p { margin-top: 4px; max-width: 620px; font-size: 13.5px; color: var(--ink-2); }
.lib-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.search { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 260px; height: 34px; padding: 0 8px 0 10px; border-radius: 9px; background: var(--surface); box-shadow: var(--shadow-btn), var(--shadow-field); }
.search:focus-within { box-shadow: 0 0 0 1px var(--accent), var(--shadow-field); }
.search svg { width: 15px; height: 15px; color: var(--ink-3); }
.search input { flex: 1; min-width: 0; height: 32px; border: 0; outline: 0; background: none; font-size: 13px; }
.search input::placeholder { color: var(--ink-3); }
.filters { display: inline-flex; gap: 2px; padding: 2px; border-radius: 9px; background: var(--hover-2); }
.filter { height: 28px; padding: 0 10px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); transition: background-color 120ms, color 120ms, box-shadow 120ms; }
.filter:hover { color: var(--ink); }
.filter.is-on { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-btn); }
.filter small { margin-left: 4px; font: 500 11px var(--mono); color: var(--ink-3); }
.records { border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-card); overflow: hidden; animation: fade-up 300ms var(--ease) both; }
.records table { width: 100%; border-collapse: collapse; }
.records th { padding: 8px 12px; text-align: left; font-size: 12px; font-weight: 500; color: var(--ink-3); background: var(--inset); border-bottom: 1px solid var(--line); }
.records td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.records tr:last-child td { border-bottom: 0; }
.records tr.is-link { cursor: pointer; transition: background-color 100ms; }
.records tr.is-link:hover td { background: var(--hover); }
.records .group-row td { padding: 14px 12px 6px; font-size: 12px; font-weight: 550; color: var(--ink-2); background: var(--surface); border-bottom: 1px solid var(--line); }
.records .group-row td span { font-weight: 400; color: var(--ink-3); margin-left: 6px; }
.doc { display: flex; align-items: center; gap: 8px; }
.doc .code { font: 500 12px var(--mono); color: var(--ink); white-space: nowrap; }
.num { font: 12px var(--mono); color: var(--ink-3); text-align: right; white-space: nowrap; }
.snippet { color: var(--ink-2); }
.snippet b { font-weight: 550; color: var(--ink); background: var(--mark); border-radius: 2px; }
.back { margin-bottom: 12px; }
.doc-title { display: flex; align-items: center; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); }
.doc-title h2 { font-size: 14px; font-weight: 600; }

/* ---------- motion ---------- */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes pixel-on { 0%, 100% { opacity: 0.15; } 18%, 42% { opacity: 1; } 62% { opacity: 0.15; } }
@keyframes shimmer-text { from { background-position: 150% center; } to { background-position: -50% center; } }
@keyframes word-in { from { opacity: 0; filter: blur(4px); transform: translateY(2px); } to { opacity: 1; filter: none; transform: none; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes mark-in { to { background-size: 100% 100%; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: 0.01ms !important; }
  .source-text mark { background-size: 100% 100%; }
}

/* ---------- narrow screens ---------- */

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 35; inset: 0 auto 0 0; width: 272px; background: var(--canvas); transform: translateX(-102%); transition: transform 300ms var(--ease); box-shadow: var(--shadow-overlay); }
  .app.is-menu .side { transform: none; }
  .only-narrow { display: inline-grid; }
  .bar { padding: 0 8px; }
}
@media (max-width: 600px) {
  .column { padding: 4px 14px 32px; }
  .dock { padding: 0 10px 10px; }
  .prompt-hint { display: none; }
  .send { margin-left: auto; }
  .msg-user { max-width: 88%; }
  .records td:nth-child(3), .records th:nth-child(3) { display: none; }
  .sheet { top: auto; left: 6px; right: 6px; bottom: 6px; width: auto; height: 86dvh; transform: translateY(calc(100% + 16px)); }
  .meta { display: none; }
}
