@font-face {
  font-family: "Hanken Grotesk";
  src: url("vendor/fonts/hanken-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("vendor/fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("vendor/fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

:root {
  --paper: #eef0eb;
  --surface: #fbfbf8;
  --surface-2: #e5e8e1;
  --ink: #15181b;
  --ink-2: #4b5258;
  --ink-3: #5f656b;
  --line: #d6dad2;
  --control: #80867e;        /* input borders, 3:1 on surface */
  --action: #2338b8;
  --action-hover: #1b2d99;
  --action-ink: #f6f7ff;
  --action-soft: #e1e5fa;
  --up: #17713f;
  --up-bg: #e1eee4;
  --down: #a8332a;
  --down-bg: #f6e3e0;
  --warn: #7f4f00;
  --warn-line: #b57a12;
  --warn-bg: #f7ecd3;
  --c0: #15181b; --c1: #3a4249; --c2: #5f676d; --c3: #838a8f; --c4: #a9afb2;
  --radius: 10px;
  --radius-sm: 6px;
  --sans: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --bar: 64px;
  --tabbar: 0px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--bar) + 12px); }
body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: var(--bar) 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--action-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; border-radius: 4px; }
[tabindex="-1"]:focus { outline: none; }
a { color: var(--action); text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: 0.875em; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.up { color: var(--up); }
.down { color: var(--down); }
.skip { position: absolute; left: 12px; top: -48px; z-index: 50; background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: var(--radius-sm); }
.skip:focus { top: 12px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: var(--bar); padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.wordmark {
  display: inline-flex; align-items: center; gap: 10px; justify-self: start;
  font-weight: 700; font-size: 19px; letter-spacing: -0.02em;
  color: var(--ink); text-decoration: none; min-height: 44px;
}
.mark { color: var(--ink); }
.tabs { display: flex; gap: 4px; }
.tabs a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
  transition: background-color 150ms ease, color 150ms ease;
}
.tabs a i { font-size: 18px; }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--surface); }
.topbar-end { justify-self: end; display: flex; align-items: center; gap: 12px; }
.sample-tag { display: none; font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); padding: 3px 8px; border-radius: 4px; }
.wallet {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  padding: 0 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface);
  transition: border-color 150ms ease, transform 160ms var(--ease-out);
}
.wallet:active { transform: scale(0.97); }
.wallet-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--up); }
.wallet .addr-short { display: none; }

@media (hover: hover) and (pointer: fine) {
  .tabs a:not([aria-current="page"]):hover { background: var(--surface-2); color: var(--ink); }
  .wallet:hover { border-color: var(--control); }
}

/* ---------- layout ---------- */
main { width: 100%; max-width: 1240px; margin: 0 auto; padding: 20px 24px 16px; outline: none; }
.view { animation: viewIn 200ms var(--ease-out); }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } }
.view[hidden] { display: none; }
h1 { font-size: clamp(28px, 3vw, 38px); line-height: 1.1; letter-spacing: -0.03em; font-weight: 700; max-width: none; text-wrap: balance; }
.h-screen { font-size: 28px; max-width: none; }
.lede { margin-top: 10px; color: var(--ink-2); font-size: 18px; max-width: 72ch; text-wrap: pretty; }
.trade-head .lede { max-width: 68ch; }
h2 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
h3 { font-size: 15px; font-weight: 650; }
.label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.fineprint { font-size: 14px; color: var(--ink-3); max-width: 64ch; }

/* ---------- buttons ---------- */
.primary, .secondary, .ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  border-radius: var(--radius-sm); padding: 10px 18px; font-weight: 600; border: 1px solid transparent;
  transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.primary { background: var(--action); color: var(--action-ink); }
.primary.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.primary.danger-fill { background: var(--down); color: #fff8f6; }
.primary:active, .secondary:active, .ghost:active { transform: scale(0.97); }
.primary.bad { background: var(--down-bg); color: var(--down); border-color: var(--down); }
.primary:disabled, .primary[aria-disabled="true"] { background: var(--surface-2); color: var(--ink-3); border-color: transparent; cursor: not-allowed; }
.primary:disabled:active, .primary[aria-disabled="true"]:active { transform: none; }
.secondary { background: var(--surface); border-color: var(--control); color: var(--ink); }
.ghost { background: transparent; color: var(--ink-2); }
.link-btn { border: 0; background: none; padding: 4px 2px; color: var(--action); font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; min-height: 32px; }
.link-btn.danger { color: var(--down); }
@media (hover: hover) and (pointer: fine) {
  .primary:not(:disabled):not([aria-disabled="true"]):not(.warn):not(.bad):not(.danger-fill):hover { background: var(--action-hover); }
  .primary.warn:hover { background: #f2e2bd; }
  .primary.bad:hover { background: #f1d4cf; }
  .secondary:hover, .ghost:hover { background: var(--surface-2); }
}

/* ---------- trade ---------- */
.trade-head { margin-bottom: 16px; }
@media (max-width: 760px) { .trade-head .lede { max-width: 72ch; } }
.trade-grid { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 24px; align-items: stretch; }

.ticket {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 20px 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-content: start;
}
.group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.label-row { display: flex; justify-content: space-between; align-items: center; min-height: 24px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.segmented.three { grid-template-columns: repeat(3, 1fr); }
.segmented[hidden] { display: none; }
.segmented button {
  border: 0; background: transparent; min-height: 38px; padding: 6px 8px; border-radius: 4px; font-weight: 600; color: var(--ink-2); font-size: 15px;
  transition: background-color 150ms ease, color 150ms ease;
}
.segmented.three button { font-size: 14px; }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--control); }
@media (hover: hover) and (pointer: fine) { .segmented button[aria-checked="false"]:hover { color: var(--ink); } }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 36px;
  border: 1px solid var(--control); background: var(--surface); border-radius: 999px;
  padding: 4px 12px; font-weight: 600; font-size: 14px; color: var(--ink-2);
  transition: border-color 150ms ease, background-color 150ms ease, color 150ms ease, transform 160ms var(--ease-out);
}
.chip:active { transform: scale(0.97); }
.chip[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.chip .dot { display: none; width: 6px; height: 6px; border-radius: 50%; background: var(--warn-line); }
.chip.off .dot { display: inline-block; }
@media (hover: hover) and (pointer: fine) { .chip[aria-checked="false"]:hover { border-color: var(--control); color: var(--ink); } }

.amount-box {
  display: flex; align-items: center; border: 1px solid var(--control); border-radius: var(--radius-sm);
  background: var(--surface); padding: 0 14px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.amount-box:focus-within { border-color: var(--action); box-shadow: 0 0 0 3px var(--action-soft); }
.amount-box.invalid { border-color: var(--down); }
.amount-box.invalid:focus-within { box-shadow: 0 0 0 3px var(--down-bg); }
.amount-box input {
  flex: 1; min-width: 0; width: 100%; border: 0; outline: 0; background: transparent;
  font-size: 24px; font-weight: 600; padding: 8px 0; letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.unit { font-weight: 600; color: var(--ink-2); }
.msg { display: flex; gap: 6px; align-items: flex-start; font-size: 14px; color: var(--ink-3); min-height: 21px; }
.msg i { font-size: 17px; margin-top: 1px; }
.msg.error { color: var(--down); font-weight: 500; }
.msg.warn { color: var(--warn); font-weight: 500; }
.msg[hidden] { display: none; }
.receive { display: flex; justify-content: space-between; align-items: baseline; }
.receive span { color: var(--ink-2); font-size: 14px; font-weight: 600; }
.receive strong { font-size: 20px; letter-spacing: -0.01em; }

.pricecheck { border-radius: var(--radius-sm); background: var(--up-bg); color: var(--up); transition: background-color 200ms ease; }
.pricecheck summary {
  list-style: none; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px;
  font-weight: 600; font-size: 15px; cursor: pointer; border-radius: var(--radius-sm);
}
.pricecheck summary::-webkit-details-marker { display: none; }
.pricecheck summary i { font-size: 18px; }
.pricecheck .caret { margin-left: auto; transition: transform 180ms var(--ease-out); }
.pricecheck[open] .caret { transform: rotate(180deg); }
.pricecheck .rows { padding: 0 12px 12px; color: var(--ink); }
.pricecheck.warn { background: var(--warn-bg); color: var(--warn); }
.pricecheck select { border: 1px solid var(--control); border-radius: 4px; background: var(--surface); padding: 2px 6px; font-size: 14px; min-height: 30px; }

.rows { margin: 0; display: grid; gap: 4px; font-size: 14px; }
.rows > div { min-width: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.rows dt { color: var(--ink-2); }
.rows dd { margin: 0; font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.rows > div.sub { justify-content: flex-end; margin-top: -2px; }
.rows .sub dd { font-size: 13px; font-weight: 400; color: var(--ink-3); }
.rows.big { font-size: 15px; gap: 10px; }
.rows dd .line { display: block; }
.rows dd .note { font-size: 13px; font-weight: 400; color: var(--ink-3); }

.submit-wrap { display: grid; }
.ticket .primary { width: 100%; font-size: 17px; min-height: 48px; }

/* route map */
.route { align-self: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 24px 22px; display: flex; flex-direction: column; }
.route-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; margin-bottom: 20px; }
.tag { padding: 3px 8px; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; }
.route-map { list-style: none; margin: 0; padding: 0; }
.node { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; align-items: center; }
.node-icon {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--control); background: var(--surface); font-size: 19px; color: var(--ink);
}
.node-text { display: grid; min-width: 0; }
.node-title { font-weight: 600; }
.node-sub { color: var(--ink-3); font-size: 13px; overflow-wrap: anywhere; }
.node.muted .node-icon { border-style: dashed; color: var(--ink-3); }
.node.muted .node-title { color: var(--ink-2); }
.node.accent .node-icon { background: var(--action); border-color: var(--action); color: var(--action-ink); }
.node.bad .node-icon { background: var(--down-bg); border: 2px solid var(--down); color: var(--down); }
.node.bad .node-title { color: var(--down); }
.node.small { grid-template-columns: 40px minmax(0, 1fr); }
.node.small .node-icon { width: 30px; height: 30px; margin-left: 5px; font-size: 15px; }
.node.small .node-title { font-size: 14px; }
.node.small + .node.small { margin-top: 6px; }

.link { position: relative; display: flex; align-items: center; min-height: 24px; margin-left: 19.5px; padding-left: 33px; }
.link .line { position: absolute; left: 0; top: 0; bottom: 0; width: 1px; background: var(--control); }
.link-text { font-size: 13px; font-weight: 600; padding: 4px 0; color: var(--ink-2); }
.link-break { min-height: 44px; }
.link-break .line { background: none; }
.link-break .line::before, .link-break .line::after {
  content: ""; position: absolute; left: 0; width: 1px; height: calc(50% - 7px); background: var(--control);
}
.link-break .line::before { top: 0; }
.link-break .line::after { bottom: 0; }
.link-break .link-text { color: var(--up); }
.link-break::before, .link-break::after {
  content: ""; position: absolute; left: -4px; width: 9px; height: 2px; background: var(--up); border-radius: 1px;
}
.link-break::before { top: calc(50% - 6px); }
.link-break::after { top: calc(50% + 4px); }
.link-warn .line { background: var(--warn-line); width: 2px; left: -0.5px; }
.link-warn .link-text { color: var(--warn); }
.link-bad { min-height: 44px; }
.link-bad .line { background: var(--down); width: 3px; left: -1px; }
.link-bad .link-text { color: var(--down); }

.verdict { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 15px; }
.verdict .vnote { display: block; margin-top: 4px; color: var(--ink-2); font-size: 14px; }
.verdict i { font-size: 20px; flex: none; }
.verdict.good { background: var(--up-bg); color: #14532f; }
.verdict.warn { background: var(--warn-bg); color: var(--warn); }
.verdict.bad { background: var(--down-bg); color: #8a271f; }
.verdict.compact { display: none; margin-top: 0; font-size: 14px; padding: 10px 12px; }
.route-map { margin-bottom: 22px; }
.route .fineprint { padding-top: 14px; }

/* ---------- portfolio ---------- */
.pf-head { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 20px; }
.pf-total { display: grid; text-align: right; gap: 2px; flex: none; }
.pf-total strong { font-size: 44px; letter-spacing: -0.03em; line-height: 1.05; font-weight: 700; }
.pf-total .num:last-child { font-size: 15px; font-weight: 600; }

.alloc { margin-bottom: 20px; }
.alloc-bar { display: flex; gap: 2px; height: 12px; border-radius: 3px; overflow: hidden; }
.seg { flex-basis: 0; min-width: 4px; }
.c0 { background: var(--c0); } .c1 { background: var(--c1); } .c2 { background: var(--c2); } .c3 { background: var(--c3); } .c4 { background: var(--c4); } .c5 { background: #c3c8c4; } .c6 { background: #dadfd8; }
.alloc-legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 14px; }
.alloc-legend li { display: inline-flex; align-items: center; gap: 6px; }
.alloc-legend b { font-weight: 600; }
.alloc-legend .num { color: var(--ink-2); }
.sw { width: 10px; height: 10px; border-radius: 2px; }

.pf-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.positions { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 15px; }
.positions thead th { text-align: left; font-size: 13px; color: var(--ink-2); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.positions td, .positions tbody th { padding: 10px 16px; white-space: nowrap; text-align: left; font-weight: 400; }
.positions .r { text-align: right; }
.positions tbody.pos ~ tbody.pos tr > * { border-top: 1px solid var(--line); }
.row-toggle {
  display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 6px 0; min-height: 36px; text-align: left;
}
.row-toggle b { font-weight: 700; }
.row-toggle .tname { color: var(--ink-3); font-size: 13px; }
.row-toggle .tsub { display: none; color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.row-toggle .caret { color: var(--ink-3); transition: transform 180ms var(--ease-out); }
.row-toggle[aria-expanded="true"] .caret { transform: rotate(90deg); }
.pct { font-size: 13px; }
.subgroup tr td { background: var(--paper); font-size: 14px; color: var(--ink-2); padding-top: 7px; padding-bottom: 7px; }
.subgroup tr:first-child td { padding-top: 10px; }
.subgroup tr:last-child td { padding-bottom: 12px; }
.subgroup .mono { padding-left: 40px; }
.idx { display: inline-block; min-width: 34px; color: var(--ink-3); font-family: var(--sans); font-size: 13px; }
.ago { color: var(--ink-3); }
@media (hover: hover) and (pointer: fine) { .positions tbody.pos tr:hover { background: var(--paper); } }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 14px; }
.panel p { color: var(--ink-2); font-size: 15px; }
.panel-actions { display: grid; gap: 4px; justify-items: start; margin-top: 4px; }
.panel-actions .secondary { width: 100%; justify-content: flex-start; }

/* ---------- ask ---------- */
.ask-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; align-items: start; }
.chat {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; gap: 12px;
  height: calc(100dvh - var(--bar) - 41px - 44px); min-height: 480px;
}
.chat-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.quota { font-size: 14px; color: var(--ink-2); outline: none; }
.ctx-peek { display: none; align-items: center; flex-wrap: wrap; gap: 4px 6px; font-size: 13px; color: var(--ink-3); }
.ctx-peek i { font-size: 16px; }
.ctx-peek .link-btn { font-size: 13px; }
.thread { overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 4px 2px; outline-offset: 4px; }
.msg-b { max-width: 64ch; display: grid; gap: 6px; }
.msg-b.me { align-self: flex-end; background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: 14px 14px 4px 14px; }
.msg-b.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); padding: 12px 16px; border-radius: 14px 14px 14px 4px; }
.msg-b.ai .meta { font-size: 13px; color: var(--ink-3); }
.msg-b.typing p { color: var(--ink-3); }
.composer {
  display: flex; gap: 8px; align-items: flex-end;
  background: var(--surface); border: 1px solid var(--control); border-radius: var(--radius); padding: 6px 6px 6px 16px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.composer:focus-within { border-color: var(--action); box-shadow: 0 0 0 3px var(--action-soft); }
.composer textarea { flex: 1; min-width: 0; border: 0; outline: 0; resize: none; background: transparent; padding: 10px 0; font-size: 16px; line-height: 1.4; max-height: 160px; }
.composer textarea[readonly] { color: var(--ink-3); }
.primary.icon { padding: 0; width: 44px; height: 44px; flex: none; font-size: 19px; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; min-height: 40px; font-size: 14px; color: var(--ink-2);
  transition: border-color 150ms ease, color 150ms ease, transform 160ms var(--ease-out);
}
.suggest button:active { transform: scale(0.97); }
.suggest button[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.primary.icon[aria-disabled="true"] { background: var(--surface-2); color: var(--ink-3); }
@media (hover: hover) and (pointer: fine) { .suggest button:not([aria-disabled="true"]):hover { border-color: var(--control); color: var(--ink); } }

.context { align-self: stretch; align-content: start; display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.track { width: 38px; height: 22px; border-radius: 999px; background: var(--control); position: relative; transition: background-color 150ms ease; flex: none; }
.track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: transform 180ms var(--ease-out); }
.switch input:checked + .track { background: var(--action); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--action); outline-offset: 2px; }
.payload { list-style: none; margin: 0; padding: 0; display: grid; border-top: 1px solid var(--line); }
.payload li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.payload .k { font-weight: 600; }
.payload .v { color: var(--ink-2); text-align: right; }
.raw summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--action); min-height: 44px; display: flex; align-items: center; }
.raw .fineprint { margin-top: 4px; }
.raw pre { margin: 8px 0 0; background: var(--paper); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 12.5px; line-height: 1.55; overflow-x: auto; }

/* ---------- how ---------- */
.how-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 40px; align-items: start; }
.how-nav h1 { margin-bottom: 16px; }
.how-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.how-nav a {
  display: flex; align-items: center; min-height: 40px; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--ink-2); text-decoration: none; font-weight: 500;
  transition: background-color 150ms ease, color 150ms ease;
}
.how-nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); font-weight: 650; }
@media (hover: hover) and (pointer: fine) { .how-nav a:not([aria-current="page"]):hover { color: var(--ink); background: var(--surface-2); } }
.how-body { padding-top: 6px; outline: none; display: grid; gap: 16px; max-width: 760px; }
.how-body > h2 { font-size: 22px; letter-spacing: -0.02em; }
.how-body > p { color: var(--ink-2); }
.how-body > p, .how-body .steps { max-width: 68ch; }
.how-body .warnbox { max-width: none; }
.cols { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cols.n2 { grid-template-columns: 1fr 1fr; }
.cols.n3 { grid-template-columns: repeat(3, 1fr); }
.cols > div { background: var(--surface); padding: 16px 18px; }
.cols h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.cols h3 i { font-size: 18px; color: var(--ink-2); }
.cols ul { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 15px; }
.cols li + li { margin-top: 4px; }
.steps { margin: 0; padding-left: 22px; color: var(--ink-2); max-width: 68ch; }
.steps li + li { margin-top: 10px; }
.steps b { color: var(--ink); font-weight: 650; }
.warnbox { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn); font-size: 15px; max-width: 68ch; }
.warnbox i { font-size: 19px; flex: none; margin-top: 1px; }
.warnbox.bad { background: var(--down-bg); color: #8a271f; }
.steps.compact { font-size: 14px; padding-left: 20px; }
.steps.compact li + li { margin-top: 6px; }

/* ---------- status bar ---------- */
.statusbar {
  display: flex; gap: 20px; align-items: center; padding: 10px 24px;
  border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); background: var(--paper);
}
.statusbar span { display: inline-flex; align-items: center; gap: 6px; }
.statusbar > :first-child { margin-right: auto; }
.statusbar .proto-group { display: inline-flex; align-items: center; gap: 14px; }

/* ---------- dialogs, toast ---------- */
.sheet {
  border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto;
  background: var(--surface); color: var(--ink); box-shadow: 0 24px 48px rgb(21 24 27 / 0.18);
}
.sheet[open] { animation: dlgIn 220ms var(--ease-out); }
.sheet-body { display: grid; gap: 16px; padding: 24px; }
@keyframes dlgIn { from { opacity: 0; transform: scale(0.96); } }
.sheet::backdrop { background: rgb(21 24 27 / 0.4); }
.sheet h2 { font-size: 21px; }
.sheet-body > p { color: var(--ink-2); }
.sheet-body > p.fineprint { color: var(--ink-3); }
#rvBody { display: grid; gap: 14px; }
#maxBtn { min-width: 44px; padding-right: 0; text-align: right; }
.check[hidden] { display: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-2); cursor: pointer; padding: 12px; border-radius: var(--radius-sm); background: var(--paper); }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--action); flex: none; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: -24px; background: var(--surface); margin: 0 -24px -24px; padding: 14px 24px 24px; border-top: 1px solid var(--line); z-index: 1; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--tabbar) + var(--safe-b)); z-index: 40;
  width: max-content; max-width: min(480px, calc(100vw - 32px));
  display: flex; gap: 8px; align-items: center;
  background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: var(--radius-sm); font-size: 14px;
  opacity: 0; transform: translate(-50%, 8px); pointer-events: none;
  transition: opacity 200ms ease, transform 240ms var(--ease-out);
}
.toast:empty { padding: 0; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .ask-grid { grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; }
}
@media (max-width: 980px) {
  .trade-grid, .pf-grid, .ask-grid { grid-template-columns: minmax(0, 1fr); }
  .how-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .how-nav ul { display: flex; overflow-x: auto; gap: 6px; scrollbar-width: none; margin: 0 -24px; padding: 0 24px 4px; scroll-padding: 0 24px; }
  .how-nav ul::-webkit-scrollbar { display: none; }
  .how-nav a { white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; min-height: 44px; }
  .how-nav a[aria-current="page"] { border-color: var(--ink); background: var(--surface); }
  .cols.n3 { grid-template-columns: 1fr; }
  .verdict.compact { display: flex; }
  .ctx-peek { display: flex; }
  .chat { grid-template-rows: auto minmax(0, 1fr) auto auto auto; height: calc(100dvh - var(--bar) - var(--tabbar) - var(--safe-b) - 40px); min-height: 420px; }
}
@media (max-width: 760px) {
  :root { --bar: 56px; --tabbar: 64px; }
  body { padding-bottom: calc(var(--tabbar) + var(--safe-b)); }
  .topbar { grid-template-columns: 1fr auto; padding: 0 16px; }
  .sample-tag { display: inline-block; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; height: calc(var(--tabbar) + var(--safe-b));
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 4px 4px var(--safe-b);
  }
  .tabs a { flex-direction: column; justify-content: center; gap: 2px; font-size: 12px; padding: 4px; color: var(--ink-3); min-height: 56px; }
  .tabs a i { font-size: 23px; }
  .tabs a[aria-current="page"] { background: none; color: var(--ink); font-weight: 650; }
  .wallet { padding: 0 12px; }
  .wallet .mono { font-size: 13px; }
  .wallet .addr-full { display: none; }
  .wallet .addr-short { display: inline; }
  .wordmark { font-size: 18px; }
  .pricecheck select { font-size: 16px; min-height: 44px; }
  main { padding: 18px 16px 24px; }
  .lede { font-size: 16px; }
  .how-nav ul { margin: 0 -16px; padding: 0 16px 4px; }
  .how-body > h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

  .chip { min-height: 44px; padding: 6px 14px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 0 20px 2px; }
  .chips::-webkit-scrollbar { display: none; }
  html { scroll-padding-bottom: calc(var(--tabbar) + 112px + var(--safe-b)); }
  .segmented button { min-height: 44px; }
  .segmented.three button { font-size: 13px; padding: 6px 4px; }
  .suggest button { min-height: 44px; }
  .link-btn { min-height: 44px; padding: 0 4px; }
  .submit-wrap {
    position: sticky; bottom: calc(var(--tabbar) + var(--safe-b)); z-index: 5;
    margin: 0 -20px -20px; padding: 12px 20px 14px;
    background: var(--surface); border-top: 1px solid var(--line);
    border-radius: 0 0 var(--radius) var(--radius);
  }

  .pf-head { flex-direction: column; align-items: start; gap: 12px; }
  .pf-total { text-align: left; }
  .pf-total strong { font-size: 36px; }
  .hide-m { display: none; }
  .positions td, .positions tbody th, .positions thead th { padding-left: 12px; padding-right: 12px; }
  .positions .pct { display: block; }
  .row-toggle { flex-wrap: wrap; column-gap: 6px; row-gap: 0; }
  .hide-s { display: none; }
  .row-toggle .tname { display: none; }
  .row-toggle .tsub { display: block; flex-basis: 100%; padding-left: 24px; }
  .subgroup .mono { padding-left: 12px; }
  .subgroup .ago { font-size: 12px; }

  .context { padding: 16px; }
  .cols.n2 { grid-template-columns: 1fr; }
  .statusbar { display: none; }

  .sheet {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 16px 16px 0 0; border-bottom: 0;
    max-height: 92dvh;
  }
  .sheet[open] { animation: sheetIn 280ms var(--ease-out); }
  @keyframes sheetIn { from { transform: translateY(100%); } }
  .sheet-body { padding: 22px 20px calc(16px + var(--safe-b)); }
  .dlg-actions { position: sticky; bottom: calc(-16px - var(--safe-b)); background: var(--surface); margin: 0 -20px calc(-16px - var(--safe-b)); padding: 12px 20px calc(16px + var(--safe-b)); border-top: 1px solid var(--line); }
  .dlg-actions { flex-direction: column-reverse; }
  .dlg-actions > * { flex: none; width: 100%; }
}


/* ---------- wallet connection ---------- */
.wallet.cta { background: var(--surface); border-color: var(--action); color: var(--action); font-weight: 600; }
.wallet.cta i { font-size: 18px; }
.wallet .cta-short { display: none; }
.wallet-dot.off { background: var(--warn-line); }
@media (hover: hover) and (pointer: fine) { .wallet.cta:hover { background: var(--action-soft); } }
.cn-steps { list-style: none; margin: -6px 0 0; padding: 0; display: flex; gap: 16px; font-size: 13px; color: var(--ink-3); counter-reset: cn; }
.cn-steps li { counter-increment: cn; display: inline-flex; align-items: center; gap: 6px; }
.cn-steps li::before { content: counter(cn); display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--control); font-size: 12px; font-variant-numeric: tabular-nums; }
.cn-steps li.current { color: var(--ink); font-weight: 600; }
.cn-steps li.current::before { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.cn-steps li.done::before { background: var(--up-bg); border-color: var(--up); color: var(--up); }
.cn-body { display: grid; gap: 14px; }
.cn-body > p:not(.warnbox):not(.fineprint):not(.msg) { color: var(--ink-2); }
.wallet-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.wallet-opt {
  width: 100%; display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: center; text-align: left;
  min-height: 60px; padding: 10px 14px; border: 1px solid var(--control); border-radius: var(--radius-sm); background: var(--surface);
  transition: border-color 150ms ease, background-color 150ms ease, transform 160ms var(--ease-out);
}
.wallet-opt:active { transform: scale(0.99); }
.wallet-opt[aria-disabled="true"] { opacity: 0.6; cursor: progress; }
.wallet-opt > i { color: var(--ink-3); }
.wo-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); font-size: 18px; color: var(--ink-2); object-fit: contain; }
.wo-text { display: grid; min-width: 0; }
.wo-name { font-weight: 600; }
.wo-sub { font-size: 13px; color: var(--ink-3); }
@media (hover: hover) and (pointer: fine) { .wallet-opt:not([aria-disabled="true"]):hover { border-color: var(--ink-2); background: var(--paper); } }
.empty-state { display: grid; gap: 16px; justify-items: start; max-width: 60ch; padding: 24px; margin-top: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.empty-state p { color: var(--ink-2); }
.thread-empty { margin: auto 0; color: var(--ink-3); font-size: 15px; text-align: center; align-self: center; max-width: 40ch; }
#shareNote { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: -8px; }
#shareNote .link-btn { min-height: 32px; }
.switch:has(input:disabled) { cursor: not-allowed; color: var(--ink-3); }
.switch input:disabled + .track { background: var(--surface-2); }
@media (max-width: 760px) {
  .wallet.cta .cta-full { display: none; }
  .wallet.cta .cta-short { display: inline; }
  .cn-steps { gap: 12px; }
}


/* ---------- activity, funding ---------- */
.pf-grid > .table-wrap { grid-column: 1; }
.pf-grid > .panel { grid-column: 2; grid-row: 1 / span 2; }
.activity { grid-column: 1; display: grid; gap: 12px; }
.activity h2 { margin-top: 4px; }
.act-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.act { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 16px; width: 100%; text-align: left; background: none; border: 0; border-radius: 0; }
.act-item + .act-item { border-top: 1px solid var(--line); }
.act-item:first-child .act { border-radius: var(--radius) var(--radius) 0 0; }
.act-item:last-child .act { border-radius: 0 0 var(--radius) var(--radius); }
.act:focus-visible { outline-offset: -2px; }
@media (hover: hover) and (pointer: fine) { .act:hover { background: var(--surface-2); } }
.act-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); font-size: 17px; }
.act.cancelled .act-icon { background: transparent; border: 1px dashed var(--control); color: var(--ink-3); }
.act-text { display: grid; min-width: 0; }
.act-title { font-weight: 600; font-variant-numeric: tabular-nums; }
.act.cancelled .act-title { color: var(--ink-2); }
.act-sub { font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.act-meta { display: grid; justify-items: end; gap: 2px; text-align: right; }
.act-status { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; }
.act-status.confirmed { color: var(--up); }
.act-status.pending { color: var(--warn); }
.act-status.cancelled { color: var(--ink-3); }
.act-when { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.addr-box { display: grid; gap: 8px; padding: 12px; border-radius: var(--radius-sm); background: var(--paper); }
.addr-box code { font-size: 14px; overflow-wrap: anywhere; user-select: all; }
.addr-box .secondary { justify-self: start; }
@media (max-width: 980px) {
  .pf-grid > .panel { grid-column: 1; grid-row: auto; }
}
@media (max-width: 760px) {
  .act { grid-template-columns: 32px minmax(0, 1fr); padding: 12px; }
  .act-icon { width: 32px; height: 32px; }
  .act-meta { grid-column: 2; justify-items: start; text-align: left; grid-auto-flow: column; justify-content: start; gap: 10px; align-items: center; }
  #fundDlg .dlg-actions { flex-direction: column-reverse; }
}



/* ---------- round 9: trade detail, cash out, market ---------- */
#txStatus { margin-top: -6px; }
.tx-sub { font-size: 15px; font-weight: 650; margin: 4px 0 0; }
.tx-seen { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: 15px; }
.tx-seen li + li { margin-top: 4px; }
.tx-link { display: inline-flex; align-items: center; gap: 4px; color: var(--action); text-underline-offset: 3px; min-height: 32px; }
@media (max-width: 760px) { .tx-link { min-height: 44px; } }
.co-pick { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 8px; }
.co-pick legend { margin-bottom: 8px; }
.co-list { display: grid; gap: 8px; }
.co-opt { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 48px; padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.co-opt:has(input:checked) { border-color: var(--action); background: var(--action-soft); }
.co-opt input { width: 18px; height: 18px; margin: 0; accent-color: var(--action); }
.co-addr { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co-addr .mono { color: var(--ink-2); font-size: 14px; }
.co-amt { font-weight: 600; white-space: nowrap; }
.statusbar .link-btn.quiet { font-size: 13px; margin: -6px 0; min-height: 24px; padding: 0 2px; text-decoration: underline dotted; text-underline-offset: 3px; }

.statusbar a { color: var(--ink-3); text-decoration: none; min-height: 24px; display: inline-flex; align-items: center; }
.statusbar a:hover { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.legal-links { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; }
.legal-links a { color: var(--ink-2); text-underline-offset: 3px; min-height: 32px; display: inline-flex; align-items: center; }
@media (max-width: 760px) { .legal-links { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; } .legal-links a { min-height: 44px; } }
#txBody .rows dt, #coRows dt { flex: none; min-width: 7.5em; }
.in-pool { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 14px; color: var(--ink-2); }
.in-pool i { font-size: 17px; margin-top: 1px; color: var(--ink-3); }
.in-pool b { color: var(--ink); font-weight: 600; }

.statusbar { flex-wrap: wrap; row-gap: 6px; }
.statusbar > * { white-space: nowrap; }
@media (max-width: 1180px) { .statusbar .sb-chain { display: none; } .statusbar { gap: 14px; } }

/* ---------- round 6 polish ---------- */
.tok-quote { font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.tok-quote b { color: var(--ink); font-weight: 600; }
.tok-quote .tq-name { color: var(--ink-3); }
.addr-groups { display: flex; flex-wrap: wrap; gap: 2px 7px; font-size: 15px; letter-spacing: 0.01em; }
.addr-groups .key-part { font-weight: 500; color: var(--ink); }
.addr-groups span:not(.key-part) { color: var(--ink-2); }
.link-btn.quiet { color: var(--ink-3); font-weight: 500; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.link-btn.quiet:hover { color: var(--ink-2); text-decoration: underline; }
.dlg-actions .link-btn.quiet { margin-right: auto; }
.spin { display: inline-block; animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ghost-preview { width: 100%; display: grid; gap: 14px; margin-top: 28px; opacity: 0.75; }
.gp-legend { display: flex; gap: 18px; margin-bottom: 10px; }
.gp-legend span { width: 72px; height: 10px; border-radius: 3px; background: var(--surface-2); }
.ghost-preview .gp-row { height: 40px; border-radius: 0; background: none; border-bottom: 1px solid var(--line); position: relative; }
.ghost-preview .gp-row::before { content: ""; position: absolute; left: 0; top: 13px; width: 38%; height: 12px; border-radius: 3px; background: var(--surface-2); }
.ghost-preview .gp-row::after { content: ""; position: absolute; right: 0; top: 13px; width: 14%; height: 12px; border-radius: 3px; background: var(--surface-2); }
.gp-bar { height: 12px; border-radius: 3px; background: var(--surface-2); }
.gp-row { height: 14px; border-radius: 3px; background: var(--surface-2); width: 100%; }
.gp-row.short { width: 100%; }
.ghost-preview .gp-row.short::before { width: 24%; }
.empty-state { max-width: 640px; }
@media (max-width: 760px) {
  .tok-quote .tq-name { display: none; }
  .dlg-actions .link-btn.quiet { margin-right: 0; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } }

@media (prefers-reduced-motion: reduce) {
  .view, .sheet[open] { animation: fadeOnly 150ms ease; }
  @keyframes fadeOnly { from { opacity: 0; } }
  .toast { transition: opacity 150ms ease; transform: translate(-50%, 0); }
  *, *::before, *::after { transition-duration: 0ms !important; scroll-behavior: auto !important; }
  .toast { transition-duration: 150ms !important; }
}

/* Phone wallet option before a Project ID is set: a state, not an error.
   Muted but still focusable; overrides the busy look of .wallet-opt[aria-disabled]. */
.wallet-opt.off[aria-disabled="true"] { opacity: 1; cursor: default; background: var(--paper); border-color: var(--line); }
.wallet-opt.off:active { transform: none; }
.wallet-opt.off .wo-name { color: var(--ink-2); }
.wallet-opt.off .wo-icon { color: var(--ink-3); }

/* WalletConnect QR modal (AppKit, in shadow DOM). Rules on the host element win over its
   :host rules, and the --apkt-* tokens inherit into the shadow tree, so the modal can match
   our dialogs without touching AppKit's injected <style> (whose CSP hashes stay valid). */
w3m-modal {
  background-color: rgb(21 24 27 / 0.4); /* same scrim as .sheet::backdrop */
  --apkt-tokens-theme-backgroundPrimary: var(--surface);
  --apkt-fontFamily-regular: var(--sans);
  --apkt-fontFamily-mono: var(--sans); /* AppKit's default mono font is not loaded; it fell back to serif */
}
w3m-modal, w3m-modal.open { -webkit-backdrop-filter: none; backdrop-filter: none; }
