/* shadows app. Tokens follow web-proto/app-dark.html. All text meets WCAG AA on --bg. */
:root {
  --bg: #0b0b0b;
  --panel: #111111;
  --raised: #181818;
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .14);
  --text: #f2efe9;
  --soft: rgba(242, 239, 233, .86);
  --muted: rgba(242, 239, 233, .70);
  --faint: rgba(242, 239, 233, .60);
  --hover: rgba(255, 255, 255, .05);
  --press: rgba(255, 255, 255, .08);
  --accent: #f3f2ef;
  --accent-ink: #0b0b0b;
  --danger: #ff9b8f;
  --ok: #9fd8a8;
  --sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --side: 280px;
  --top: 60px;
  --col: 760px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sprite { display: none; }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i-sm { width: 15px; height: 15px; }
.i-xs { width: 13px; height: 13px; }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: var(--side) 1fr; height: 100dvh; }

/* ── sidebar ── */
.side { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); padding: 12px; gap: 10px; }
.side-head { display: flex; align-items: center; justify-content: space-between; height: 36px; padding: 0 4px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand img { border-radius: 7px; }
.wm { font-weight: 600; letter-spacing: .01em; font-size: 16px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; color: var(--soft); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.new-chat { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 10px; color: var(--text); font-weight: 500; }
.new-chat:hover { background: var(--hover); }
.history { flex: 1; overflow-y: auto; min-height: 0; margin: 4px -4px 0; padding: 0 4px; }
.group-label { font-size: 12px; color: var(--faint); padding: 14px 10px 6px; letter-spacing: .02em; }
.chat-link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 9px; color: var(--soft); text-align: left; }
.chat-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-link:hover { background: var(--hover); color: var(--text); }
.chat-link[aria-current="page"] { background: var(--press); color: var(--text); }
.history-empty { color: var(--faint); font-size: 13px; padding: 12px 10px; }
.device-note { display: flex; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.device-note b { display: block; color: var(--text); font-weight: 500; margin-bottom: 2px; }
.device-note .btn { margin-top: 8px; }
.side-foot { display: flex; align-items: center; gap: 6px; }
.wallet { flex: 1; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; min-width: 0; text-align: left; }
.wallet:hover { background: var(--hover); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #5d5a55, #1d1c1a 70%); border: 1px solid var(--line-2); flex: none; }
.who { display: flex; flex-direction: column; min-width: 0; }
.addr { font-family: var(--mono); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.state { font-size: 12px; color: var(--faint); }
.scrim { display: none; }
.icon-btn.side-close, .icon-btn.menu-btn { display: none; }

/* ── main ── */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { display: flex; align-items: center; gap: 10px; height: var(--top); padding: 0 16px; border-bottom: 1px solid var(--line); flex: none; }
.model-pick { position: relative; min-width: 0; flex: 0 1 auto; }
.model { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border-radius: 9px; font-weight: 500; min-width: 0; max-width: 100%; overflow: hidden; }
.model > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model:hover, .model[aria-expanded="true"] { background: var(--hover); }
.menu { position: absolute; top: 42px; left: 0; z-index: 30; width: min(420px, calc(100vw - 32px)); max-height: min(70vh, 560px); overflow-y: auto; background: var(--raised); border: 1px solid var(--line-2); border-radius: 12px; padding: 6px; box-shadow: 0 18px 50px rgba(0, 0, 0, .55); }
.opt { display: grid; gap: 3px; width: 100%; padding: 10px 12px; border-radius: 10px; text-align: left; }
.opt:hover, .opt:focus-visible { background: var(--hover); }
.opt[aria-selected="true"] { background: var(--press); }
.opt[aria-disabled="true"] .name { color: var(--muted); }
.opt-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.opt .name { font-weight: 500; }
.opt .sub { font-size: 12.5px; color: var(--muted); }
.opt .check { margin-left: auto; color: var(--text); }
.badge { display: inline-flex; align-items: center; gap: 4px; height: 21px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.badge.enclave { background: rgba(159, 216, 168, .13); color: #a8e0b1; }
.badge.free { background: rgba(240, 203, 140, .14); color: #f2d09a; }
.badge.locked { background: var(--hover); color: var(--muted); }
.menu-search { position: sticky; top: -6px; z-index: 1; display: flex; align-items: center; gap: 8px; margin: -6px -6px 6px; padding: 10px 14px; background: var(--raised); border-bottom: 1px solid var(--line); color: var(--muted); }
.menu-search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 15px; color: var(--text); }
.menu-search input::placeholder { color: var(--faint); }
.menu-foot, .menu-empty { margin: 8px 10px 4px; text-align: left; }
.tag { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 12.5px; color: var(--soft); white-space: nowrap; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.balance { height: 34px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 13px; font-family: var(--mono); color: var(--soft); white-space: nowrap; }
.balance:hover { background: var(--hover); color: var(--text); }
.burn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px; color: var(--soft); font-size: 13px; }
.burn:hover { background: var(--hover); color: var(--danger); }

.scroll { flex: 1; overflow-y: auto; min-height: 0; }
.thread { max-width: var(--col); margin: 0 auto; padding: 28px 20px 40px; }
.turn { margin: 0 0 26px; }
.turn.user { display: flex; justify-content: flex-end; }
.bubble { max-width: 85%; background: var(--raised); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.ai-head img { border-radius: 5px; }
.answer { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.answer pre { white-space: pre; overflow-x: auto; background: #070707; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0; font-size: 13.5px; line-height: 1.5; }
.answer code { font-family: var(--mono); font-size: .9em; }
.answer :not(pre) > code { background: var(--hover); border-radius: 5px; padding: 1px 5px; }
.answer.error { color: var(--danger); }
.answer .cursor { display: inline-block; width: 8px; height: 1.05em; vertical-align: text-bottom; background: var(--soft); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
details.think { margin: 0 0 10px; color: var(--muted); font-size: 13.5px; }
details.think summary { cursor: pointer; }
details.think div { white-space: pre-wrap; border-left: 2px solid var(--line-2); padding-left: 12px; margin-top: 6px; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: var(--faint); font-family: var(--mono); }
.meta button { color: var(--faint); font-size: 12px; font-family: var(--sans); text-decoration: underline; text-underline-offset: 3px; }
.meta button:hover { color: var(--text); }

.welcome { max-width: 560px; margin: 0 auto; padding: 12vh 24px 24px; text-align: center; }
.welcome img { border-radius: 12px; }
.welcome h1 { font-size: 32px; line-height: 1.15; font-weight: 600; margin: 18px 0 6px; letter-spacing: -.01em; }
.lede { color: var(--soft); margin: 0 0 22px; font-size: 17px; }
.cta { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 26px; }
.points { list-style: none; padding: 0; margin: 0 auto; max-width: 460px; text-align: left; display: grid; gap: 10px; color: var(--muted); font-size: 14px; }
.points b { color: var(--text); font-weight: 500; }

.composer-wrap { flex: none; padding: 0 20px 14px; }
.composer { max-width: var(--col); margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; padding: 8px 8px 8px 16px; background: var(--raised); border: 1px solid var(--line-2); border-radius: 16px; }
.composer:focus-within { border-color: rgba(255, 255, 255, .26); }
.composer textarea { flex: 1; resize: none; border: 0; outline: 0; background: none; padding: 7px 0; max-height: 220px; line-height: 1.5; }
.composer textarea::placeholder { color: var(--faint); }
.send { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); flex: none; }
.send:disabled { opacity: .45; cursor: default; }
.send.stop { background: var(--press); color: var(--text); border: 1px solid var(--line-2); }
.fine { max-width: var(--col); margin: 8px auto 0; font-size: 12px; color: var(--faint); text-align: center; }
.fine a { color: var(--muted); }

/* ── buttons, forms ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2); font-weight: 500; color: var(--text); text-decoration: none; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #ffffff; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--soft); margin: 10px 0; }
label.check input { margin-top: 4px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.field { display: grid; gap: 6px; margin: 12px 0; font-size: 13px; color: var(--muted); }
.field select, .field input { height: 40px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg); padding: 0 12px; color: var(--text); font-size: 15px; }
.amounts { display: flex; flex-wrap: wrap; gap: 8px; }
.amounts button { height: 36px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 999px; font-family: var(--mono); font-size: 13px; }
.amounts button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ── dialog ── */
dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 48px); padding: 0; background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(0, 0, 0, .66); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 0 20px; }
.dlg-head h2 { font-size: 17px; font-weight: 600; margin: 0; }
.dlg-body { padding: 8px 20px 20px; overflow-y: auto; max-height: calc(100dvh - 120px); font-size: 14px; color: var(--soft); }
.dlg-body p { margin: 8px 0; }
.dlg-body h3 { font-size: 14px; font-weight: 600; color: var(--text); margin: 20px 0 6px; }
.box { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 12px 0; background: var(--bg); font-size: 13.5px; color: var(--soft); }
.box dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; }
.box dt { color: var(--muted); }
.box dd { margin: 0; }
.wallet-list { display: grid; gap: 4px; margin: 4px 0 12px; }
.dlg-body .group-label { padding: 12px 2px 4px; }
.wallet-opt { display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 12px 10px 10px; border-radius: 12px; text-align: left; font-weight: 500; font-size: 15px; color: var(--text); text-decoration: none; }
.wallet-opt:hover, .wallet-opt:focus-visible { background: var(--hover); }
.wallet-opt > span:not(.tile) { display: flex; flex-direction: column; min-width: 0; }
.wallet-opt small { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.wallet-opt .tile { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--raised); border: 1px solid var(--line); flex: none; color: var(--soft); }
.wallet-opt .tile img { width: 28px; height: 28px; border-radius: 7px; }
.wallet-opt .arrow { margin-left: auto; color: var(--faint); }
.wallet-opt:hover .arrow { color: var(--text); }
.wallet-none { text-align: left; margin: 6px 2px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .k { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.list { display: grid; gap: 0; }
.status-ok { color: var(--ok); }
.status-warn { color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.secret { word-break: break-all; font-family: var(--mono); font-size: 13px; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--bg); user-select: all; }
.steps { margin: 12px 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.steps li { display: flex; gap: 10px; color: var(--muted); }
.steps li.now { color: var(--text); }
.steps li.done { color: var(--ok); }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); max-width: min(520px, calc(100vw - 32px)); background: var(--raised); border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 16px; font-size: 14px; box-shadow: 0 18px 50px rgba(0, 0, 0, .5); z-index: 50; }

/* ── small screens ── */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(86vw, var(--side)); z-index: 40; transform: translateX(-102%); transition: transform .25s var(--ease); }
  .app.nav-open .side { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 35; }
  .icon-btn.side-close, .icon-btn.menu-btn { display: inline-grid; }
  .top { padding: 0 8px; gap: 6px; }
  .tag span, .burn .txt { display: none; }
  .tag { flex: none; }
  .top-right { flex: none; }
  .tag { padding: 0 8px; }
  .thread { padding: 20px 14px 30px; }
  .composer-wrap { padding: 0 10px 10px; }
  .welcome { padding-top: 8vh; }
  .welcome h1 { font-size: 27px; }
}

/* ── terms and privacy pages ── */
body.doc-page { overflow: auto; }
.doc { max-width: 720px; margin: 0 auto; padding: 32px 20px 80px; color: var(--soft); }
.doc h1 { color: var(--text); font-size: 30px; margin: 28px 0 4px; }
.doc h2 { color: var(--text); font-size: 17px; margin: 28px 0 6px; }
.doc-meta { color: var(--muted); font-size: 13px; }
.doc ul { padding-left: 20px; }
.doc li { margin: 6px 0; }
.doc b { color: var(--text); font-weight: 500; }

/* ── modes: chat, agent, API ── */
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg); }
.mode { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; border-radius: 8px; font-size: 13.5px; color: var(--muted); }
.mode .i { width: 16px; height: 16px; }
.mode:hover { color: var(--text); }
.mode[aria-selected="true"] { background: var(--press); color: var(--text); }
.page-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; padding-left: 4px; }

/* ── agent steps ── */
.tool-steps { display: grid; gap: 6px; margin: 2px 0 12px; }
.tool-step { font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.tool-step summary, .tool-step.live { display: flex; align-items: center; gap: 8px; padding: 7px 12px; cursor: pointer; list-style: none; }
.tool-step summary::-webkit-details-marker { display: none; }
.tool-step summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-step.failed { color: var(--danger); }
.tool-step pre { margin: 0; padding: 10px 12px; border-top: 1px solid var(--line); max-height: 220px; overflow: auto; white-space: pre-wrap; font-family: var(--mono); font-size: 12px; color: var(--soft); }
.tool-step.live { cursor: default; color: var(--soft); }
.spinner { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--text); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── API page ── */
.api-page { max-width: 900px; margin: 0 auto; padding: 28px 20px 60px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; color: var(--soft); }
.api-page > *, .tool-grid > *, .code { min-width: 0; }
.card p { overflow-wrap: anywhere; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; }
.card h1 { font-size: 22px; margin: 0 0 6px; color: var(--text); }
.card h2, .api-sub { font-size: 16px; margin: 0 0 6px; color: var(--text); }
.api-sub { margin: 8px 2px -6px; }
.card p { margin: 6px 0 12px; }
.card code, .tool-body code { font-family: var(--mono); font-size: .88em; background: var(--hover); border-radius: 5px; padding: 1px 5px; color: var(--text); }
.code { position: relative; }
.code pre { margin: 8px 0; padding: 14px 16px; background: #070707; border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.55; color: var(--text); }
.code pre code { background: none; padding: 0; }
.code .copy { position: absolute; top: 8px; right: 8px; height: 28px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--raised); font-size: 12px; color: var(--soft); }
.code .copy:hover { color: var(--text); }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 10px; }
.tool-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.tool-card[open] { grid-column: 1 / -1; }
.tool-card summary { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; list-style: none; }
.tool-card summary::-webkit-details-marker { display: none; }
.tool-card summary > span:last-child { display: flex; flex-direction: column; }
.tool-card summary b { color: var(--text); font-weight: 500; }
.tool-card summary small { color: var(--muted); font-size: 12.5px; }
.tool-card .tile { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--raised); border: 1px solid var(--line); color: var(--soft); }
.tool-body { padding: 0 16px 14px; font-size: 14px; }
.tool-body ol { margin: 4px 0; padding-left: 20px; }
.tool-body li { margin: 4px 0; }
.table-scroll { overflow-x: auto; }
.api-models { width: 100%; border-collapse: collapse; font-size: 14px; }
.api-models th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); }
.api-models th, .api-models td { padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.api-models .num { text-align: right; font-family: var(--mono); font-size: 13px; }
.id-copy { font-family: var(--mono); font-size: 13px; color: var(--text); background: var(--hover); border-radius: 6px; padding: 2px 7px; }
.id-copy:hover { background: var(--press); }
@media (max-width: 860px) { .card { padding: 18px 16px; } .api-page { padding: 18px 12px 40px; } }

@media (max-width: 480px) { .top-right .balance { display: none; } .menu { left: -36px; } }

/* ── end-to-end encryption ── */
.badge.e2ee { background: rgba(150, 190, 255, .14); color: #b9d0ff; }
.tag.sealed { border-color: rgba(150, 190, 255, .35); color: #c6d8ff; }
.sealed-note { display: inline-flex; align-items: center; gap: 5px; color: #b9d0ff; font-family: var(--sans); }
