/* self-hosted fonts — no Google Fonts request, works offline, keeps "zero data" honest */
@font-face{ font-family:'Inter'; font-style:normal; font-weight:400 800; font-display:swap; src:url('fonts/inter-latin.woff2') format('woff2'); unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face{ font-family:'Inter'; font-style:normal; font-weight:400 800; font-display:swap; src:url('fonts/inter-latin-ext.woff2') format('woff2'); unicode-range:U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face{ font-family:'JetBrains Mono'; font-style:normal; font-weight:400 600; font-display:swap; src:url('fonts/jetbrainsmono-latin.woff2') format('woff2'); unicode-range:U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face{ font-family:'JetBrains Mono'; font-style:normal; font-weight:400 600; font-display:swap; src:url('fonts/jetbrainsmono-latin-ext.woff2') format('woff2'); unicode-range:U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root{
  --bg:#f7f7f9; --surface:#ffffff; --surface-2:#f0f1f4; --surface-3:#e9eaef;
  --line:#e7e7ec; --line-2:#dcdde3;
  --ink:#15171e; --muted:#6b7280; --faint:#9aa0ad;
  --accent:#10a37f; --accent-press:#0c8c6c; --accent-ink:#ffffff; --glow:rgba(16,163,127,.22);
  --danger:#e5484d;
  --ui:'Inter',system-ui,-apple-system,sans-serif;
  --mono:'JetBrains Mono',ui-monospace,SFMono-Regular,Menlo,monospace;
  --maxw:740px;
}
*{ box-sizing:border-box; }
[hidden]{ display:none !important; }
html,body{ margin:0; padding:0; height:100%; }
body{ background:var(--bg); color:var(--ink); font-family:var(--ui); -webkit-font-smoothing:antialiased; overscroll-behavior:none; }
.logo,.brand{ font-weight:800; letter-spacing:-.025em; }
.g{ color:var(--accent); }
a{ color:var(--accent); text-decoration:none; }
::selection{ background:rgba(16,163,127,.2); }

/* ============ INTRO / LOADER ============ */
.intro{ position:fixed; inset:0; z-index:50; overflow-y:auto; background:var(--bg); scroll-behavior:smooth; }
.intro-hero{ min-height:100%; position:relative; display:flex; flex-direction:column; align-items:center; justify-content:center;
  padding:24px; text-align:center; background:radial-gradient(680px 380px at 50% 28%, rgba(16,163,127,.09), rgba(16,163,127,0) 70%); }
.intro-card{ width:min(460px,100%); display:flex; flex-direction:column; align-items:center; }
.intro .logo{ font-size:clamp(3.2rem,14vw,5rem); line-height:1; margin:0; }
.intro .tag{ font-size:1.08rem; line-height:1.55; color:#3a3f4b; margin:18px 0 30px; }
.intro .tag b{ color:var(--ink); }
.cta{ font-family:inherit; font-weight:700; font-size:1.06rem; color:var(--accent-ink); background:var(--accent); border:none;
  border-radius:13px; padding:15px 36px; cursor:pointer; box-shadow:0 12px 30px var(--glow); transition:transform .08s, background .15s; }
.cta:hover{ background:var(--accent-press); } .cta:active{ transform:translateY(2px); }
.cta:disabled{ opacity:.5; cursor:default; box-shadow:none; }
.loadwrap{ width:100%; max-width:340px; margin:26px 0 2px; }
.loadbar{ width:100%; height:8px; border-radius:999px; background:#e4e5ea; overflow:hidden; }
.loadbar > i{ display:block; height:100%; width:0; border-radius:999px; background:linear-gradient(90deg,#2bbf99,var(--accent)); transition:width .3s ease; }
.loadstatus{ font-family:var(--mono); font-size:.82rem; color:var(--muted); margin:13px 0 0; min-height:1.2em; letter-spacing:-.01em; }
.fine{ font-size:.82rem; line-height:1.6; color:var(--muted); margin:24px 0 0; max-width:380px; }
.fine b{ color:#4a4f5b; }
.nogpu{ margin:18px 0 0; font-size:.86rem; line-height:1.55; color:#8c2a2c; background:rgba(229,72,77,.07);
  border:1px solid rgba(229,72,77,.25); border-radius:12px; padding:12px 16px; max-width:410px; }
.intro-foot{ position:absolute; bottom:16px; left:0; right:0; text-align:center; font-size:.72rem; color:var(--faint); }
.intro-foot a{ color:var(--muted); }

/* ============ ABOUT / FAQ (below the fold of the intro) ============ */
.about{ max-width:640px; margin:0 auto; padding:56px 24px 72px; text-align:left; border-top:1px solid var(--line); }
.about h2{ font-size:1.4rem; letter-spacing:-.02em; color:var(--ink); margin:0 0 14px; }
.about h2 + p{ color:#3a3f4b; line-height:1.7; margin:0 0 44px; }
.about .qa h3{ font-size:1.02rem; color:var(--ink); margin:24px 0 7px; }
.about .qa p{ color:var(--muted); line-height:1.65; margin:0; font-size:.95rem; }
.about .qa b{ color:#4a4f5b; }
.about-foot{ margin:48px 0 0; font-size:.82rem; color:var(--faint); }

/* ============ APP SHELL ============ */
.app{ position:fixed; inset:0; display:grid; grid-template-rows:auto 1fr auto; height:100%; }
.topbar{ display:flex; align-items:center; gap:10px; padding:12px 16px; border-bottom:1px solid var(--line);
  background:rgba(247,247,249,.86); backdrop-filter:blur(10px); }
.topbar .brand{ font-size:1.22rem; }
.bar-actions{ margin-left:auto; display:flex; gap:8px; }
.ghost{ font-family:inherit; font-weight:600; font-size:.84rem; color:var(--muted); display:inline-flex; align-items:center; gap:6px;
  background:transparent; border:1px solid var(--line-2); border-radius:10px; padding:8px 13px; cursor:pointer; transition:.12s; }
.ghost:hover{ color:var(--ink); border-color:#c7c9d1; background:#fff; }
.ghost svg{ width:15px; height:15px; }

/* ============ MESSAGES ============ */
.messages{ overflow-y:auto; padding:24px 16px 10px; }
.thread{ width:100%; max-width:var(--maxw); margin:0 auto; display:flex; flex-direction:column; gap:18px; }
.row{ display:flex; flex-direction:column; animation:rise .24s ease both; }
@keyframes rise{ from{ opacity:0; transform:translateY(7px);} to{ opacity:1; transform:none;} }
.row.user{ align-items:flex-end; }
.msg-user{ max-width:84%; background:var(--accent); color:#fff; padding:11px 15px; border-radius:16px 16px 5px 16px;
  line-height:1.55; font-size:1rem; white-space:pre-wrap; word-wrap:break-word; }
.who{ display:none; }   /* assistant identity lives in the card itself */
.aimsg{ align-self:flex-start; max-width:100%; width:100%; background:var(--surface); border:1px solid var(--line);
  border-radius:16px 16px 16px 5px; padding:14px 17px; box-shadow:0 2px 8px rgba(20,20,40,.04); }
.md{ font-size:1.02rem; line-height:1.68; color:#23262e; word-wrap:break-word; }
.md p{ margin:0 0 11px; } .md p:last-child{ margin-bottom:0; }
.md ul,.md ol{ margin:7px 0 11px; padding-left:22px; } .md li{ margin:4px 0; }
.md h3,.md h4,.md h5{ margin:13px 0 7px; line-height:1.3; color:var(--ink); }
.md code{ font-family:var(--mono); font-size:.9em; background:rgba(16,163,127,.1); padding:1px 6px; border-radius:5px; color:#0c7a5e; }
.md a{ color:var(--accent); text-decoration:underline; text-underline-offset:2px; }
.md strong{ color:var(--ink); font-weight:700; }
.row.streaming .md::after{ content:''; display:inline-block; width:8px; height:1.05em; vertical-align:-2px; margin-left:2px;
  background:var(--accent); border-radius:1px; animation:caret 1s steps(1) infinite; }
@keyframes caret{ 50%{ opacity:0; } }
.think{ display:inline-flex; gap:6px; padding:3px 0; }
.think i{ width:8px; height:8px; border-radius:50%; background:#c2c6cf; animation:blink 1.2s infinite both; }
.think i:nth-child(2){ animation-delay:.2s; } .think i:nth-child(3){ animation-delay:.4s; }
@keyframes blink{ 0%,80%,100%{ opacity:.3; transform:translateY(0);} 40%{ opacity:1; transform:translateY(-3px);} }

/* code blocks (dark on the light page) */
.codeblock{ margin:11px 0; border:1px solid var(--line); border-radius:11px; overflow:hidden; background:#0f1116; }
.codeblock .cb-head{ display:flex; align-items:center; justify-content:space-between; padding:7px 12px; background:#171a21;
  border-bottom:1px solid rgba(255,255,255,.06); font-family:var(--mono); font-size:.72rem; color:#9aa0ab; }
.codeblock pre{ margin:0; padding:13px 14px; }
.codeblock code{ font-family:var(--mono); font-size:.84rem; line-height:1.6; color:#d6e4dc; background:none; padding:0;
  display:block; white-space:pre-wrap; overflow-wrap:anywhere; word-break:break-word; }   /* wrap long lines instead of scrolling out of the box */
.cb-btn{ font-family:var(--mono); font-size:.72rem; color:#9aa0ab; background:transparent; border:1px solid rgba(255,255,255,.16);
  border-radius:7px; padding:3px 9px; cursor:pointer; transition:.12s; }
.cb-btn:hover{ color:#fff; border-color:rgba(255,255,255,.35); }

/* search */
.searching{ display:inline-flex; align-items:center; gap:9px; font-family:var(--mono); font-size:.8rem; color:#0c7a5e;
  background:rgba(16,163,127,.08); border:1px solid rgba(16,163,127,.22); border-radius:10px; padding:8px 13px; }
.searching .sp{ width:13px; height:13px; border:2px solid rgba(16,163,127,.3); border-top-color:var(--accent); border-radius:50%; animation:spin .8s linear infinite; }
@keyframes spin{ to{ transform:rotate(360deg);} }

/* planning ("Thinking…") status */
.status{ display:inline-flex; align-items:center; gap:11px; color:var(--muted); font-size:.92rem; }
.status b{ font-weight:500; }

/* the harness's reasoning trace — shown open above the answer, collapsible */
.thought{ margin:0 0 12px; border:1px solid var(--line); border-radius:10px; background:var(--surface-2); overflow:hidden; }
.thought > summary{ list-style:none; cursor:pointer; display:flex; align-items:center; gap:8px; padding:8px 12px;
  font-family:var(--mono); font-size:.74rem; color:var(--muted); user-select:none; }
.thought > summary::-webkit-details-marker{ display:none; }
.thought > summary::after{ content:'▸'; margin-left:auto; transition:transform .15s ease; color:var(--faint); }
.thought[open] > summary::after{ transform:rotate(90deg); }
.thought .th-ic{ color:var(--accent); font-weight:700; letter-spacing:.5px; }
.thought .th-body{ padding:0 12px 11px; }
.thought .th-reason{ margin:0 0 7px; font-size:.9rem; line-height:1.55; color:#3a4150; }
.thought .th-act{ margin:0; display:inline-flex; align-items:center; gap:6px; font-family:var(--mono); font-size:.72rem;
  color:#0c7a5e; background:rgba(16,163,127,.08); border:1px solid rgba(16,163,127,.18); border-radius:7px; padding:3px 9px; }
.thought .th-act.th-warn{ color:#8a5a10; background:rgba(217,159,42,.1); border-color:rgba(217,159,42,.3); }   /* a lookup failed — flagged, not hidden */

/* multi-source citations */
.cites{ margin-top:11px; font-size:.8rem; color:var(--muted); border-left:2px solid var(--line-2); padding-left:11px; line-height:1.75; }
.cites .cites-l{ font-weight:600; color:#4a4f5b; }
.cites a{ color:var(--accent); }
.cites .cites-sep{ margin:0 8px; color:var(--faint); }

/* inline citation markers in the answer: [1] → superscript source link */
.md .cref{ font-size:.7em; line-height:0; vertical-align:super; }
.md .cref a{ color:var(--accent); text-decoration:none; font-weight:600; padding:0 1px; }
.md .cref a:hover{ text-decoration:underline; }

/* message actions: copy / retry */
.msg-actions{ display:flex; gap:4px; margin-top:9px; }
.act{ font-family:inherit; font-size:.76rem; font-weight:500; color:var(--muted); display:inline-flex; align-items:center; gap:5px;
  background:transparent; border:1px solid transparent; border-radius:8px; padding:4px 8px; cursor:pointer; transition:.12s; }
.act:hover{ color:var(--ink); background:var(--surface-2); }
.act:active{ transform:scale(.96); }
.act svg{ width:14px; height:14px; }
.act.ok{ color:var(--accent); }
.row.user .msg-actions{ margin-top:5px; justify-content:flex-end; opacity:0; transition:opacity .14s; }
.row.user:hover .msg-actions, .row.user:focus-within .msg-actions{ opacity:1; }
@media (hover:none){ .row.user .msg-actions{ opacity:1; } }   /* touch has no hover — keep copy visible */

/* empty state */
.empty{ max-width:var(--maxw); margin:8vh auto 0; text-align:center; padding:0 8px; }
.empty h2{ font-size:1.9rem; font-weight:800; letter-spacing:-.025em; margin:0 0 10px; }
.empty p{ color:var(--muted); margin:0 0 24px; line-height:1.55; }
.empty p b{ color:var(--ink); }
.examples{ display:flex; flex-wrap:wrap; gap:10px; justify-content:center; }
.examples button{ font-family:inherit; font-size:.9rem; font-weight:500; color:var(--ink); background:var(--surface);
  border:1px solid var(--line-2); border-radius:12px; padding:11px 16px; cursor:pointer; transition:.12s; }
.examples button:hover{ border-color:var(--accent); transform:translateY(-1px); box-shadow:0 6px 16px rgba(20,20,40,.06); }
.examples button b{ color:var(--accent); font-weight:600; }

/* ============ COMPOSER ============ */
.composer{ border-top:1px solid var(--line); background:rgba(247,247,249,.92); backdrop-filter:blur(10px);
  padding:12px 16px calc(12px + env(safe-area-inset-bottom)); }
.composer-inner{ width:100%; max-width:var(--maxw); margin:0 auto; display:flex; align-items:flex-end; gap:9px;
  background:var(--surface); border:1.5px solid var(--line-2); border-radius:18px; padding:8px; transition:border-color .14s, box-shadow .14s; }
.composer-inner:focus-within{ border-color:var(--accent); box-shadow:0 0 0 4px rgba(16,163,127,.1); }
#input{ padding-left:4px; }
#input{ flex:1; min-width:0; border:none; outline:none; resize:none; background:transparent; color:var(--ink);
  font-family:inherit; font-size:1rem; line-height:1.5; max-height:184px; padding:6px 0; }
#input::placeholder{ color:var(--faint); }
.send{ flex:none; width:40px; height:40px; border-radius:50%; border:none; background:var(--accent); color:#fff;
  display:flex; align-items:center; justify-content:center; cursor:pointer; transition:filter .12s, transform .08s, background .12s; }
.send:hover{ background:var(--accent-press); } .send:active{ transform:scale(.94); }
.send:disabled{ background:#c7cbd2; color:#fff; cursor:default; }
.send svg{ width:21px; height:21px; } .send .i-stop{ display:none; }
.app.generating .send{ background:var(--danger); } .app.generating .send .i-send{ display:none; } .app.generating .send .i-stop{ display:block; }
.disclaimer{ width:100%; max-width:var(--maxw); margin:10px auto 0; text-align:center; font-size:.71rem; color:var(--faint); line-height:1.45; }
.disclaimer a{ color:var(--faint); text-decoration:underline; }

/* toast */
.toast{ position:fixed; left:50%; bottom:96px; transform:translateX(-50%) translateY(10px); z-index:60;
  background:var(--ink); color:#fff; font-size:.86rem; font-weight:500; padding:11px 18px; border-radius:12px;
  box-shadow:0 12px 30px rgba(0,0,0,.25); opacity:0; pointer-events:none; transition:opacity .2s, transform .2s; }
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }

@media (max-width:640px){
  .messages{ padding:16px 12px 6px; }
  .md{ font-size:1rem; } .msg-user{ max-width:88%; }
  .empty{ margin-top:6vh; } .empty h2{ font-size:1.5rem; }
  .topbar{ padding:11px 13px; } .topbar .brand{ font-size:1.12rem; }
  .ghost{ padding:8px 11px; font-size:.8rem; }
}
