/* 3 API Chat: the landing's language (black, Geist, white pills, one blue accent, glass) as a dense app. */
:root {
  --bg: #000;
  --s0: #050505;
  --s1: #0a0a0a;
  --s2: #111;
  --s3: #171717;
  --line: rgba(255,255,255,.08);
  --line2: rgba(255,255,255,.12);
  --hi: inset 0 1px 0 rgba(255,255,255,.05);
  --t1: #fafafa;
  --t2: #a3a3a3;
  --t3: #8a8a8a;
  --t4: #767676;
  --t5: #525252;
  --body: #d4d4d4;
  --blue: #3b82f6;
  --blue2: #60a5fa;
  --teal2: #5eead4;
  --green: #22c55e;
  --amber2: #fcd34d;
  --red: #f87171;
  --ease: cubic-bezier(.2,.7,.2,1);
  --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --side: 288px;
  --col: 768px;
  --tap: 36px;
  color-scheme: dark;
}
@media (pointer: coarse), (max-width: 860px) { :root { --tap: 40px; } }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--t2); overflow: hidden;
  font: 400 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01" 1; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
img, svg { display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
input, textarea { font: inherit; color: inherit; }
h1, h2, h3 { color: var(--t1); margin: 0; font-weight: 600; letter-spacing: -0.03em; }
p { margin: 0; }
.mono { font-family: var(--mono); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
kbd {
  font: 500 11px/1 var(--mono); color: var(--t3); min-width: 18px; height: 18px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center; vertical-align: 1px;
  background: var(--s3); border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 5px;
}
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 8px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shared controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px; border-radius: 999px; font-weight: 500; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .25s var(--ease), border-color .25s var(--ease), opacity .2s;
}
.btn svg { width: 16px; height: 16px; transition: transform .25s var(--ease); }
.btn-white { background: #fafafa; color: #000; box-shadow: 0 0 0 1px rgba(255,255,255,.2), 0 8px 30px -12px rgba(255,255,255,.35); }
.btn-white:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(255,255,255,.3), 0 10px 40px -8px rgba(96,165,250,.55); }
.btn-white:hover svg { transform: translate(1px, -1px); }
.btn-dark { background: rgba(14,14,14,.8); color: var(--t1); border: 1px solid var(--line2); box-shadow: var(--hi); }
.btn-dark:hover { border-color: rgba(255,255,255,.22); background: rgba(28,28,28,.9); }
.btn-danger { background: rgba(248,113,113,.12); color: #fecaca; border: 1px solid rgba(248,113,113,.35); }
.btn-danger:hover { background: rgba(248,113,113,.2); }
.btn-sm { height: var(--tap); padding: 0 14px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn:focus-visible { outline-offset: 3px; border-radius: 999px; }
.btn[aria-busy="true"] { opacity: .6; pointer-events: none; }
.link { color: var(--blue2); border-radius: 4px; transition: color .2s; }
.link:hover { color: #93c5fd; }
.icon-btn {
  width: var(--tap); height: var(--tap); flex: none; display: inline-grid; place-items: center; border-radius: 10px; color: var(--t2);
  transition: background .2s, color .2s;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: rgba(255,255,255,.06); color: var(--t1); }
.brand { display: inline-flex; align-items: center; gap: 9px; min-height: 40px; color: var(--t1); font-weight: 600; letter-spacing: -0.02em; font-size: 15px; border-radius: 8px; }
.tag {
  font: 500 11px/1 var(--mono); font-style: normal; letter-spacing: .12em; text-transform: uppercase; color: var(--blue2);
  padding: 4px 7px; border-radius: 999px; border: 1px solid rgba(96,165,250,.28); background: rgba(59,130,246,.08);
}
.eyebrow { font: 500 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--t4); }
.glyph {
  width: 22px; height: 22px; border-radius: 7px; display: inline-grid; place-items: center; flex: none;
  font: 600 10px/1 var(--mono); letter-spacing: .02em; border: 1px solid var(--line2); box-shadow: var(--hi);
}
.glyph[data-fam="deepseek"] { color: #93c5fd; background: radial-gradient(circle at 30% 20%, rgba(59,130,246,.38), rgba(59,130,246,.06)); border-color: rgba(96,165,250,.32); }
.glyph[data-fam="glm"] { color: #99f6e4; background: radial-gradient(circle at 30% 20%, rgba(45,212,191,.32), rgba(45,212,191,.05)); border-color: rgba(94,234,212,.3); }

/* ---------- boot ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; }
.boot img { animation: breathe 1.6s var(--ease) infinite alternate; }
@keyframes breathe { from { opacity: .35; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* ---------- signed out ---------- */
.gate { position: fixed; inset: 0; overflow-y: auto; overflow-x: hidden; isolation: isolate; padding: max(28px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom)); display: grid; place-items: center; }
.gate-bg { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 45% at 50% 100%, rgba(59,130,246,.16), transparent 70%),
    radial-gradient(40% 30% at 50% 0%, rgba(255,255,255,.05), transparent 70%),
    radial-gradient(30% 25% at 12% 80%, rgba(59,130,246,.06), transparent 70%),
    radial-gradient(30% 25% at 88% 80%, rgba(45,212,191,.05), transparent 70%);
}
.gate-bg::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.09) 1px, transparent 1.2px); background-size: 28px 28px;
  mask-image: radial-gradient(70% 55% at 50% 85%, #000 0%, transparent 75%); -webkit-mask-image: radial-gradient(70% 55% at 50% 85%, #000 0%, transparent 75%);
  opacity: .5;
}
.gate-in { width: 100%; max-width: 860px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.gate-in > * { animation: up .8s var(--ease) both; }
.gate-in > :nth-child(2) { animation-delay: .06s; }
.gate-in > :nth-child(3), .gate-in > :nth-child(4) { animation-delay: .12s; }
.gate-in > :nth-child(5) { animation-delay: .18s; }
@keyframes up { from { opacity: 0; transform: translateY(12px); filter: blur(6px); } to { opacity: 1; transform: none; filter: blur(0); } }
.gate-h { margin-top: 28px; font-size: clamp(36px, 6vw, 64px); line-height: 1; letter-spacing: -0.05em; font-weight: 650; text-wrap: balance; }
.gate-h span { display: block; }
.gate-h .l2 {
  margin-top: .14em; font-size: .52em; letter-spacing: -0.035em; padding-bottom: .06em;
  background: linear-gradient(180deg, #e5e5e5 0%, #8a8a8a 70%, #6b6b6b 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.gate-notice {
  margin-top: 22px; max-width: 560px; padding: 10px 14px; border-radius: 12px; font-size: 14px; color: #fde68a;
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.28);
}
.ways {
  margin-top: 34px; width: 100%; display: grid; grid-template-columns: 1fr auto 1fr; text-align: left;
  background: linear-gradient(180deg, rgba(20,20,20,.72), rgba(8,8,8,.82)); border: 1px solid var(--line2); border-radius: 22px;
  box-shadow: var(--hi), 0 40px 90px -40px rgba(0,0,0,.9), 0 30px 90px -50px rgba(59,130,246,.45);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.way { padding: 28px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.way h2 { font-size: 20px; letter-spacing: -0.03em; }
.way-p { font-size: 14.5px; line-height: 1.55; color: var(--t2); }
.way .btn { margin-top: auto; align-self: flex-start; }
.way-foot { font-size: 13.5px; color: var(--t3); }
.ways-or { position: relative; width: 1px; background: var(--line); display: grid; place-items: center; }
.ways-or span { position: absolute; font: 500 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--t4); background: #0d0d0d; padding: 8px 4px; }
.form { display: grid; gap: 10px; }
.field { display: grid; gap: 6px; }
.field span { font: 500 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--t4); }
.field input {
  height: 44px; padding: 0 14px; border-radius: 12px; font-size: 16px; color: var(--t1);
  background: rgba(0,0,0,.55); border: 1px solid var(--line2); box-shadow: inset 0 1px 2px rgba(0,0,0,.6);
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: rgba(96,165,250,.55); box-shadow: 0 0 0 4px rgba(59,130,246,.14); }
.form-err { font-size: 13.5px; line-height: 1.5; color: #fecaca; padding: 9px 12px; border-radius: 10px; background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.28); }
.form .btn { margin-top: 4px; }
.gate-fine { margin-top: 22px; font: 400 12.5px/1.5 var(--mono); color: var(--t4); }

/* ---------- app shell ---------- */
.app {
  position: fixed; left: 0; right: 0; top: 0; height: var(--vvh, 100dvh);
  display: grid; grid-template-columns: var(--side) minmax(0, 1fr);
}
.side {
  min-height: 0; display: flex; flex-direction: column; gap: 6px;
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: linear-gradient(180deg, #080808, #040404); border-right: 1px solid var(--line);
}
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 6px 8px; }
.side-close { display: none; }
.new-btn {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: 12px; color: var(--t1); font-size: 14px; font-weight: 500;
  background: rgba(255,255,255,.035); border: 1px solid var(--line2); box-shadow: var(--hi); transition: background .2s, border-color .2s;
}
.new-btn svg { width: 16px; height: 16px; color: var(--t2); }
.new-btn:hover { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.2); }
.list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 6px -4px 0; padding: 0 4px 12px; scrollbar-width: thin; scrollbar-color: #262626 transparent; }
.grp { font: 500 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--t5); padding: 16px 10px 7px; }
.ci { position: relative; display: flex; align-items: center; border-radius: 10px; transition: background .15s; }
.ci a { flex: 1; min-width: 0; min-height: var(--tap); display: flex; align-items: center; padding: 0 10px; font-size: 13.5px; color: var(--t2); border-radius: 10px; }
.ci a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci:hover { background: rgba(255,255,255,.04); }
.ci:hover a { color: var(--t1); }
.ci.on { background: rgba(255,255,255,.07); box-shadow: var(--hi); }
.ci.on a { color: var(--t1); }
.ci.on::before { content: ""; position: absolute; left: -4px; top: 50%; width: 2px; height: 14px; margin-top: -7px; border-radius: 2px; background: var(--blue2); }
.ci .live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue2); margin-right: 8px; flex: none; animation: breathe 1s ease-in-out infinite alternate; }
.ci-more { width: var(--tap); height: var(--tap); flex: none; display: grid; place-items: center; border-radius: 9px; color: var(--t4); opacity: 0; transition: opacity .15s, background .15s, color .15s; }
.ci-more svg { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.ci-more:hover { color: var(--t1); background: rgba(255,255,255,.07); }
.ci:hover .ci-more, .ci.on .ci-more, .ci-more:focus-visible, .ci-more[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .ci-more { opacity: .7; } }
.list-empty { padding: 18px 10px; font-size: 13px; color: var(--t4); }

.acct { margin-top: 4px; padding: 12px; border-radius: 16px; background: linear-gradient(180deg, rgba(23,23,23,.8), rgba(12,12,12,.9)); border: 1px solid var(--line2); box-shadow: var(--hi); display: grid; gap: 10px; }
.acct-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -2px -4px -2px 0; }
.acct-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center; font: 600 12px/1 var(--mono); color: var(--t1); background: linear-gradient(145deg, #2a2a2e, #111); border: 1px solid var(--line2); box-shadow: var(--hi); }
.acct-t { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.acct-t b { color: var(--t1); font-weight: 550; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-t small { font: 400 11px/1.4 var(--mono); color: var(--t4); }
.bal { display: flex; align-items: baseline; justify-content: space-between; padding: 8px 10px; border-radius: 10px; background: rgba(0,0,0,.45); border: 1px solid var(--line); }
.bal-l { font: 500 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--t4); }
.bal-v { font: 500 17px/1 var(--mono); color: var(--t1); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; transition: color .6s; }
.bal-v.flash { color: var(--blue2); }
.bal-v.low { color: var(--amber2); }
.acct-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.acct-btns .btn { padding: 0 10px; }
.privacy { font-size: 11.5px; line-height: 1.5; color: var(--t4); }

/* main column */
.main { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; isolation: isolate; }
.main::before { content: ""; position: absolute; inset: 0 0 auto; height: 340px; z-index: -1; pointer-events: none; background: radial-gradient(50% 100% at 50% 0%, rgba(59,130,246,.07), transparent 70%); }
.top {
  height: 56px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px; padding-top: env(safe-area-inset-top);
  box-sizing: content-box; border-bottom: 1px solid transparent; transition: border-color .2s, background .2s;
}
.top.lined { border-bottom-color: var(--line); background: rgba(0,0,0,.6); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.menu-btn { display: none; }
.picker-btn {
  display: inline-flex; align-items: center; gap: 9px; height: 38px; padding: 0 10px 0 8px; border-radius: 12px; min-width: 0;
  color: var(--t1); font-weight: 550; font-size: 14.5px; letter-spacing: -0.01em; transition: background .2s, border-color .2s;
  border: 1px solid transparent;
}
.picker-btn:hover, .picker-btn[aria-expanded="true"] { background: rgba(255,255,255,.05); border-color: var(--line); }
.picker-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { width: 14px; height: 14px; color: var(--t3); transition: transform .25s var(--ease); flex: none; }
.picker-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.top-title { flex: 1; min-width: 0; text-align: center; font-size: 13px; color: var(--t4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 12px; }

.scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #262626 transparent; }
.thread { max-width: var(--col); margin: 0 auto; padding: 18px 20px 28px; display: flex; flex-direction: column; gap: 26px; }
.thread:empty { display: none; }

/* empty state */
.empty { min-height: 100%; max-width: var(--col); margin: 0 auto; padding: 32px 20px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty > * { animation: up .7s var(--ease) both; }
.empty > :nth-child(2) { animation-delay: .05s; }
.empty > :nth-child(3) { animation-delay: .1s; }
.empty-mark { position: relative; }
.empty-mark::after { content: ""; position: absolute; left: 50%; top: 70%; width: 120px; height: 46px; transform: translateX(-50%); background: radial-gradient(50% 50% at 50% 50%, rgba(59,130,246,.5), transparent 70%); filter: blur(14px); z-index: -1; }
.empty-h { margin-top: 22px; font-size: clamp(28px, 4vw, 40px); line-height: 1.08; letter-spacing: -0.045em; font-weight: 650; }
.empty-h span { display: block; }
.empty-h .l2 { color: var(--t3); }
.starters { margin-top: 30px; width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.starter {
  text-align: left; padding: 14px 16px; border-radius: 16px; min-height: 72px; display: flex; flex-direction: column; gap: 4px;
  background: linear-gradient(180deg, rgba(20,20,20,.7), rgba(10,10,10,.7)); border: 1px solid var(--line); box-shadow: var(--hi);
  transition: transform .25s var(--ease), border-color .25s, box-shadow .25s;
}
.starter b { font: 500 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--t4); transition: color .25s; }
.starter span { font-size: 14px; line-height: 1.45; color: var(--t1); }
.starter:hover { transform: translateY(-2px); border-color: rgba(96,165,250,.3); box-shadow: var(--hi), 0 14px 40px -18px rgba(59,130,246,.5); }
.starter:hover b { color: var(--blue2); }
.empty-model { margin-top: 22px; font-size: 12px; color: var(--t4); }
.empty-model b { color: var(--t2); font-weight: 500; }

/* messages */
.msg { min-width: 0; animation: up .45s var(--ease) both; }
.msg-user { align-self: flex-end; max-width: min(85%, 620px); }
.bubble {
  padding: 10px 15px; border-radius: 20px 20px 6px 20px; color: var(--t1); font-size: 15px; line-height: 1.55;
  background: linear-gradient(180deg, #1b1b1d, #141416); border: 1px solid var(--line2); box-shadow: var(--hi);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-user .meta { justify-content: flex-end; }
.msg-ai { display: flex; flex-direction: column; gap: 8px; }
.ai-head { display: flex; align-items: center; gap: 8px; font: 500 12px/1 var(--mono); color: var(--t3); }
.md { color: var(--body); font-size: 15.5px; line-height: 1.7; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md .md-code, .md .md-table, .md hr { margin: 0 0 14px; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 22px 0 10px; line-height: 1.3; letter-spacing: -0.02em; }
.md h1 { font-size: 22px; } .md h2 { font-size: 19px; } .md h3 { font-size: 17px; } .md h4, .md h5, .md h6 { font-size: 15.5px; }
.md strong { color: var(--t1); font-weight: 600; }
.md em { font-style: italic; }
.md del { color: var(--t3); }
.md a { color: var(--blue2); text-decoration: underline; text-decoration-color: rgba(96,165,250,.35); text-underline-offset: 3px; }
.md a:hover { text-decoration-color: var(--blue2); }
.md ul, .md ol { padding-left: 1.4em; }
.md li { margin: 4px 0; }
.md li > ul, .md li > ol { margin: 4px 0 0; }
.md li::marker { color: var(--t4); }
.md ol li::marker { font-family: var(--mono); font-size: .88em; }
.md blockquote { padding: 2px 0 2px 16px; border-left: 2px solid rgba(96,165,250,.4); color: var(--t2); }
.md hr { border: 0; height: 1px; background: var(--line2); margin: 22px 0; }
.md code { font: 400 .86em/1.5 var(--mono); color: var(--t1); background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 6px; padding: .08em .36em; }
.md-code { border-radius: 14px; overflow: hidden; background: #070707; border: 1px solid var(--line2); box-shadow: var(--hi); }
.md-code-head { display: flex; align-items: center; justify-content: space-between; height: 36px; padding: 0 6px 0 14px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.025); }
.md-code-lang { font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: lowercase; color: var(--t3); }
.md-copy { height: 28px; padding: 0 10px; border-radius: 8px; font: 500 12px/1 var(--mono); color: var(--t3); transition: background .2s, color .2s; }
.md-copy:hover { background: rgba(255,255,255,.06); color: var(--t1); }
.md-copy.ok { color: var(--green); }
.md-code pre { margin: 0; padding: 14px 16px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: #2a2a2a transparent; }
.md-code pre code { display: block; font: 400 13px/1.65 var(--mono); color: #e5e5e5; background: none; border: 0; padding: 0; white-space: pre; overflow-wrap: normal; }
.md-table { overflow-x: auto; border: 1px solid var(--line2); border-radius: 12px; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; }
.md th, .md td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.md th { color: var(--t1); font-weight: 550; background: rgba(255,255,255,.03); white-space: nowrap; }
.md tr:last-child td { border-bottom: 0; }
.md .al-c { text-align: center; } .md .al-r { text-align: right; }

/* streaming caret */
.msg-ai.streaming .md > :last-child::after, .msg-ai.streaming .md:empty::after {
  content: ""; display: inline-block; width: .55em; height: 1.05em; margin-left: 2px; vertical-align: -.17em; border-radius: 2px;
  background: var(--blue2); box-shadow: 0 0 12px rgba(96,165,250,.7); animation: caret 1s steps(1) infinite;
}
.msg-ai.streaming .md > .md-code:last-child::after, .msg-ai.streaming .md > .md-table:last-child::after, .msg-ai.streaming .md > ul:last-child::after, .msg-ai.streaming .md > ol:last-child::after { display: none; }
@keyframes caret { 50% { opacity: 0; } }
.waiting { display: inline-flex; gap: 5px; padding: 8px 0; }
.waiting i { width: 6px; height: 6px; border-radius: 50%; background: var(--t3); animation: dot 1.2s var(--ease) infinite; }
.waiting i:nth-child(2) { animation-delay: .15s; } .waiting i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

/* thinking */
.think { border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.02); }
.think summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 12px;
  font: 500 12px/1 var(--mono); letter-spacing: .04em; color: var(--t3); border-radius: 14px;
}
.think summary::-webkit-details-marker { display: none; }
.think summary:hover { color: var(--t1); }
.think summary .chev { margin-left: auto; transform: rotate(-90deg); }
.think[open] summary .chev { transform: none; }
.think-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--t5); flex: none; }
.think.live .think-dot { background: var(--blue2); box-shadow: 0 0 10px var(--blue); animation: breathe .9s ease-in-out infinite alternate; }
.think.live .think-l { background: linear-gradient(90deg, var(--t3) 0%, var(--t1) 50%, var(--t3) 100%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: sheen 1.6s linear infinite; }
@keyframes sheen { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.think-body { padding: 2px 14px 12px 27px; font-size: 13.5px; line-height: 1.65; color: var(--t3); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow-y: auto; }

/* meta row */
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 4px; min-height: 28px; font: 400 11.5px/1.3 var(--mono); color: var(--t4); }
.meta .m-i { padding: 0 6px 0 0; white-space: nowrap; }
.meta .m-i + .m-i::before { content: "·"; margin-right: 6px; color: var(--t5); }
.meta .m-cost { color: var(--t3); }
.meta .m-st { color: var(--amber2); }
.meta .act { display: inline-flex; gap: 2px; margin-left: auto; }
.msg-user .meta .act { margin-left: 0; }
.act button { height: 28px; padding: 0 9px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px; font: 500 11.5px/1 var(--mono); color: var(--t4); transition: background .2s, color .2s; }
.act button svg { width: 13px; height: 13px; }
.act button:hover { background: rgba(255,255,255,.06); color: var(--t1); }
.act button.ok { color: var(--green); }
.msg-user .act { opacity: 0; transition: opacity .2s; }
.msg-user:hover .act, .msg-user:focus-within .act { opacity: 1; }
@media (hover: none) { .msg-user .act { opacity: 1; } }
.note { font: 400 12px/1.5 var(--mono); color: var(--t4); padding: 8px 12px; border-radius: 10px; border: 1px dashed var(--line2); align-self: center; }

/* inline error card */
.err {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(30,18,18,.8), rgba(14,10,10,.85)); border: 1px solid rgba(248,113,113,.28); box-shadow: var(--hi);
}
.err.warn { background: linear-gradient(180deg, rgba(30,24,12,.8), rgba(14,12,8,.85)); border-color: rgba(245,158,11,.3); }
.err-t { flex: 1; min-width: 200px; display: grid; gap: 2px; }
.err-t b { color: var(--t1); font-weight: 600; font-size: 14.5px; }
.err-t span { font-size: 13.5px; color: var(--t2); }
.err .btn { height: var(--tap); }

/* ---------- composer ---------- */
.dock { position: relative; flex: none; padding: 0 20px max(12px, env(safe-area-inset-bottom)); }
.dock::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 28px; pointer-events: none; background: linear-gradient(transparent, #000); }
.composer {
  position: relative; max-width: var(--col); margin: 0 auto; padding: 8px 8px 8px 18px; border-radius: 22px;
  display: flex; align-items: flex-end; gap: 10px;
  background: linear-gradient(180deg, rgba(24,24,26,.92), rgba(14,14,15,.94)); border: 1px solid var(--line2);
  box-shadow: var(--hi), 0 24px 60px -24px rgba(0,0,0,.9); transition: border-color .25s var(--ease), box-shadow .25s var(--ease);
}
.composer:focus-within { border-color: rgba(96,165,250,.42); box-shadow: var(--hi), 0 0 0 4px rgba(59,130,246,.1), 0 24px 60px -24px rgba(59,130,246,.35); }
.composer textarea {
  display: block; flex: 1; min-width: 0; resize: none; border: 0; background: none; padding: 9px 0; margin: 0;
  font-size: 16px; line-height: 1.5; color: var(--t1); min-height: 42px; max-height: 40vh; overflow-y: auto; scrollbar-width: thin;
}
.composer textarea::placeholder { color: var(--t4); }
.comp-row { display: flex; align-items: center; flex: none; padding-bottom: 1px; }
.hint { position: absolute; right: 14px; bottom: calc(100% + 8px); font-size: 11.5px; color: var(--t3); padding: 3px 8px; border-radius: 8px; background: rgba(10,10,10,.92); border: 1px solid var(--line); }
.hint:empty { display: none; }
.hint.over { color: var(--red); }
.send {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: #fafafa; color: #000; box-shadow: 0 0 0 1px rgba(255,255,255,.2), 0 6px 22px -8px rgba(255,255,255,.4);
  transition: transform .2s var(--ease), background .2s, box-shadow .2s, opacity .2s;
}
.send svg { width: 16px; height: 16px; stroke-width: 2; }
.send .i-stop { display: none; fill: currentColor; stroke: none; }
.send:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(255,255,255,.3), 0 8px 28px -6px rgba(96,165,250,.6); }
.send:disabled { background: #262626; color: var(--t5); box-shadow: none; }
.send.stop .i-send { display: none; }
.send.stop .i-stop { display: block; }
.dock-fine { max-width: var(--col); margin: 8px auto 0; text-align: center; font-size: 11.5px; color: var(--t5); }
.jump {
  position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%); width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; color: var(--t1); background: rgba(23,23,23,.9); border: 1px solid var(--line2); box-shadow: var(--hi), 0 10px 30px -10px #000;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.jump svg { width: 16px; height: 16px; }

/* ---------- popovers ---------- */
.picker, .menu {
  position: fixed; z-index: 60; background: rgba(12,12,12,.96); border: 1px solid var(--line2); border-radius: 18px;
  box-shadow: var(--hi), 0 30px 80px -20px #000, 0 0 0 1px rgba(0,0,0,.5);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  animation: pop .22s var(--ease) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
.picker { width: 400px; max-height: min(560px, calc(var(--vvh, 100dvh) - 90px)); overflow-y: auto; padding: 8px; scrollbar-width: thin; scrollbar-color: #262626 transparent; }
.pk-h { display: flex; align-items: center; gap: 8px; padding: 12px 10px 8px; font: 500 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--t4); }
.pk-h i { width: 6px; height: 6px; border-radius: 50%; }
.pk-h[data-fam="glm"] i { background: var(--teal2); box-shadow: 0 0 8px rgba(94,234,212,.6); }
.pk-h[data-fam="deepseek"] i { background: var(--blue2); box-shadow: 0 0 8px rgba(96,165,250,.6); }
.pk-h small { font-size: 11px; margin-left: auto; letter-spacing: .06em; text-transform: none; color: var(--t5); }
.pk {
  width: 100%; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  min-height: 52px; padding: 7px 10px; border-radius: 12px; text-align: left; transition: background .15s;
}
.pk:hover, .pk:focus-visible { background: rgba(255,255,255,.06); outline-offset: -2px; }
.pk[aria-selected="true"] { background: rgba(59,130,246,.1); box-shadow: inset 0 0 0 1px rgba(96,165,250,.25); }
.pk-check { width: 16px; height: 16px; color: var(--blue2); opacity: 0; justify-self: center; }
.pk[aria-selected="true"] .pk-check { opacity: 1; }
.pk-n { display: flex; flex-direction: column; min-width: 0; }
.pk-n b { color: var(--t1); font-weight: 550; font-size: 14px; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-n small { font: 400 11px/1.4 var(--mono); color: var(--t4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-p { display: grid; gap: 1px; text-align: right; font: 400 11.5px/1.35 var(--mono); color: var(--t2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pk-p em { font-style: normal; color: var(--t5); }
.pk-sep { height: 1px; margin: 4px 10px; background: var(--line); }
.pk-foot { padding: 10px 10px 6px; font: 400 11px/1.5 var(--mono); color: var(--t5); border-top: 1px solid var(--line); margin-top: 6px; }
.menu { min-width: 190px; padding: 6px; display: grid; gap: 1px; }
.menu button, .menu a { display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 12px; border-radius: 10px; font-size: 13.5px; color: var(--t1); text-align: left; }
.menu svg { width: 15px; height: 15px; color: var(--t3); }
.menu button:hover, .menu a:hover, .menu button:focus-visible { background: rgba(255,255,255,.06); outline-offset: -2px; }
.menu .danger { color: #fca5a5; }
.menu .danger svg { color: #f87171; }
.menu hr { border: 0; height: 1px; background: var(--line); margin: 4px 6px; }

/* dialog */
.dlg { padding: 0; border: 0; background: transparent; color: inherit; max-width: calc(100vw - 32px); width: 420px; }
.dlg::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.dlg[open] { animation: pop .22s var(--ease) both; }
.dlg-in { padding: 22px; border-radius: 20px; background: linear-gradient(180deg, rgba(23,23,23,.98), rgba(10,10,10,.98)); border: 1px solid var(--line2); box-shadow: var(--hi), 0 40px 100px -20px #000; display: grid; gap: 12px; }
.dlg h2 { font-size: 18px; }
.dlg p { font-size: 14px; color: var(--t2); line-height: 1.55; }
.dlg input { height: 44px; padding: 0 14px; border-radius: 12px; font-size: 16px; color: var(--t1); background: #000; border: 1px solid var(--line2); }
.dlg input:focus { border-color: rgba(96,165,250,.55); box-shadow: 0 0 0 4px rgba(59,130,246,.14); }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.toast {
  position: fixed; z-index: 80; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; color: var(--t1); background: rgba(23,23,23,.95); border: 1px solid var(--line2);
  box-shadow: var(--hi), 0 14px 40px -10px #000; animation: pop .2s var(--ease) both; max-width: calc(100vw - 32px); text-align: center;
}

/* ---------- phone / narrow ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: min(86vw, 330px);
    transform: translateX(-102%); transition: transform .32s var(--ease); visibility: hidden;
    box-shadow: 30px 0 80px -20px rgba(0,0,0,.9); border-right-color: var(--line2);
  }
  .app.drawer .side { transform: none; visibility: visible; }
  .side-close { display: inline-grid; }
  .scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade .25s var(--ease) both; }
  @keyframes fade { from { opacity: 0; } }
  .menu-btn { display: inline-grid; }
  .top { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); gap: 4px; }
  .picker-btn { height: 40px; }
  .top-title { display: none; }
  .top .picker-btn { margin-right: auto; }
  .thread { padding: 12px 16px 24px; gap: 22px; }
  .dock { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .composer { padding: 7px 7px 7px 15px; border-radius: 24px; }
  .md-code-head { height: 44px; padding-right: 2px; }
  .md-copy { height: 40px; padding: 0 12px; }
  .jump { width: 40px; height: 40px; }
  .think summary { min-height: 40px; }
  .dock-fine .kb { display: none; }
  .dock-fine { margin-top: 6px; }
  .act button { height: 40px; min-width: 40px; justify-content: center; }
  .ci-more { opacity: .7; }
  .picker {
    left: 8px !important; right: 8px; top: auto !important; bottom: max(8px, env(safe-area-inset-bottom)); width: auto;
    max-height: min(72dvh, calc(var(--vvh, 100dvh) - 70px)); border-radius: 22px; animation-name: sheet;
  }
  @keyframes sheet { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
  .ways { grid-template-columns: 1fr; }
  .ways-or { width: auto; height: 1px; margin: 0 28px; }
  .ways-or span { padding: 4px 10px; }
  .md-code pre code { font-size: 12.5px; }
}
@media (max-width: 520px) {
  .starters { gap: 8px; margin-top: 24px; }
  .starter { min-height: 0; padding: 12px 13px; }
  .starter span { font-size: 13.5px; }
  .way { padding: 22px 20px; }
  .way .btn { align-self: stretch; }
  .md { font-size: 15px; }
  .empty { justify-content: flex-end; padding-bottom: 12px; }
  .empty-h { font-size: 28px; }
}
@media (hover: hover) and (pointer: fine) { .dock-fine .kb { display: inline; } }
@media (hover: none) { .dock-fine .kb { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .think.live .think-l { color: var(--t1); background: none; }
}
.md .dim { color: var(--t4); font-size: 14px; }

/* sign-in: the bot path, as steps */
.steps { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; counter-reset: st; }
.steps li { counter-increment: st; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px; border-radius: 12px; font-size: 14px; color: var(--t2); background: rgba(0,0,0,.45); border: 1px solid var(--line); }
.steps li::before { content: counter(st, decimal-leading-zero); font: 500 11px/1 var(--mono); color: var(--t4); width: 18px; flex: none; }
.steps b { color: var(--t1); font-weight: 550; }
.steps .chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 8px; color: var(--t1); font-weight: 500; font-size: 13px; background: rgba(59,130,246,.14); border: 1px solid rgba(96,165,250,.35); white-space: nowrap; }
.way .btn { margin-top: auto; }
.way .steps + .btn { margin-top: 14px; }
