:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --surface-3: #e7e5df;
  --border: #e3e1db;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7b7a74;
  --grid: #e8e6e0;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #e6f0fc;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --band: rgba(42, 120, 214, 0.10);
  --good: #0ca30c;
  --good-text: #006300;
  --good-soft: #e5f5e5;
  --critical: #d03b3b;
  --critical-text: #b42f2f;
  --critical-soft: #fbeaea;
  --warning: #fab219;
  --warning-text: #8a5a00;
  --warning-soft: #fff4dc;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2c2c29; --border: #2e2e2b;
    --text: #ffffff; --text-2: #c3c2b7; --muted: #8f8e86; --grid: #2b2b28;
    --accent: #3987e5; --accent-soft: #1b2b40; --series-1: #3987e5; --series-2: #d95926; --band: rgba(57,135,229,.16);
    --good-text: #4cc94c; --good-soft: #15291a; --critical-text: #f07a7a; --critical-soft: #331a1a;
    --warning-text: #f5c35a; --warning-soft: #2f2612; --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --surface-3: #2c2c29; --border: #2e2e2b;
  --text: #ffffff; --text-2: #c3c2b7; --muted: #8f8e86; --grid: #2b2b28;
  --accent: #3987e5; --accent-soft: #1b2b40; --series-1: #3987e5; --series-2: #d95926; --band: rgba(57,135,229,.16);
  --good-text: #4cc94c; --good-soft: #15291a; --critical-text: #f07a7a; --critical-soft: #331a1a;
  --warning-text: #f5c35a; --warning-soft: #2f2612; --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Hiragino Sans", "Yu Gothic UI", Meiryo, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK JP", "Noto Sans CJK KR", "Noto Sans Arabic", Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
p { margin: 0; }
.muted { color: var(--text-2); font-size: 13.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* header */
.bar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.bar-in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.2; }
.brand b { display: block; font-size: 15px; line-height: 1.2; }
.logo-bg { fill: var(--accent); }
.logo-line { stroke: #fff; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.tabs { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.tabs a { color: var(--text-2); text-decoration: none; padding: 7px 10px; border-radius: 999px; font-size: 14px; white-space: nowrap; }
.tabs a:hover { background: var(--surface-2); color: var(--text); }
.tabs a.active { background: var(--text); color: var(--bg); }
.bar-tools { display: flex; align-items: center; gap: 8px; }
.select { font: inherit; font-size: 13.5px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 5px 10px; }
.icon-btn { font: inherit; font-size: 16px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.chip .dot, .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; display: inline-block; }
.dot.good { background: var(--good); } .dot.bad { background: var(--critical); } .dot.warn { background: var(--warning); }
.ticker { max-width: 1180px; margin: 0 auto; padding: 0 16px 8px; display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.ticker b { color: var(--text); font-weight: 600; }

/* layout */
main { padding-top: 20px; padding-bottom: 20px; }
.banners:empty { display: none; }
.banners { padding-top: 12px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; margin-bottom: 16px; }
.cols > .card { margin-bottom: 0; }
.card > .muted { margin: 4px 0 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sub-h { font-size: 14px; margin: 18px 0 8px; color: var(--text-2); font-weight: 600; }
.scroll { overflow-x: auto; max-width: 100%; }
.feed { max-height: 460px; overflow: auto; }

/* hero + steps */
.hero { padding: 18px 0 8px; }
.hero h1 { font-size: clamp(24px, 4vw, 36px); line-height: 1.15; max-width: 820px; }
.lead { color: var(--text-2); font-size: 16.5px; max-width: 760px; margin-top: 10px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 20px 0 8px; }
.facts > div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.facts b { display: block; font-size: 18px; }
.facts span { color: var(--text-2); font-size: 13px; }
.steps { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 14px; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.step.done { border-color: color-mix(in srgb, var(--good) 45%, var(--border)); }
.step.locked { opacity: .6; }
.step-head { display: flex; gap: 14px; align-items: flex-start; }
.step-head > div { flex: 1; }
.step-head .num { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; }
.step.done .num { background: var(--good-soft); color: var(--good-text); }
.step-body { margin-top: 14px; padding-inline-start: 46px; }
.status { font-size: 12.5px; white-space: nowrap; }
.status.ok { color: var(--good-text); }

/* forms */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.input, textarea.input { font: inherit; font-size: 14.5px; width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.input:focus, .select:focus, .btn:focus-visible, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea.input { min-height: 74px; resize: vertical; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .field { flex: 1; min-width: 140px; }
.row:has(> .field) { align-items: flex-start; }
.modal-in .mono, .kvlist .mono { word-break: break-all; }
.hint { font-size: 12.5px; color: var(--muted); }
.hint.bad { color: var(--critical-text); }
.btn { white-space: nowrap; font: inherit; font-size: 14.5px; font-weight: 600; border-radius: 10px; padding: 10px 16px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--critical-text); }
.btn.ghost { background: transparent; }
.btn.small { font-size: 13px; padding: 6px 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.wide { width: 100%; }
.btn.big { font-size: 16.5px; padding: 14px 26px; border-radius: 12px; }
.cta-hint { margin: 8px 0 14px; }
.row.alt { gap: 8px 12px; margin-top: 4px; }
.cli-note { margin-top: 12px; }
.cli-note summary { cursor: pointer; }
.cli-note p { margin-top: 6px; max-width: 720px; }
.modal-in-flow { display: grid; gap: 12px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.seg button { font: inherit; text-align: start; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface-2); color: var(--text); padding: 12px 14px; cursor: pointer; }
.seg button b { display: block; font-size: 15.5px; }
.seg button span { font-size: 12.5px; color: var(--text-2); }
.seg button.on.buy { border-color: var(--good); background: var(--good-soft); }
.seg button.on.sell { border-color: var(--critical); background: var(--critical-soft); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; margin: 12px 0; }
.check input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--accent); }

/* summaries */
.summary { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; margin: 4px 0 14px; display: grid; gap: 6px; font-size: 13.5px; }
.summary .kv { display: flex; justify-content: space-between; gap: 10px; }
.summary .kv span:first-child { color: var(--text-2); }
.pnl-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 6px; }
.pnl-grid div { background: var(--surface); border-radius: 8px; padding: 6px 8px; font-size: 12.5px; text-align: center; }
.pnl-grid .pos { color: var(--good-text); } .pnl-grid .neg { color: var(--critical-text); }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13.5px; word-break: break-all; background: var(--warning-soft); border: 1px dashed var(--warning); padding: 12px; border-radius: 10px; direction: ltr; }
.callout { border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin: 10px 0; }
.callout.warn { background: var(--warning-soft); color: var(--warning-text); }
.callout.bad { background: var(--critical-soft); color: var(--critical-text); }
.callout.good { background: var(--good-soft); color: var(--good-text); }
.callout.info { background: var(--accent-soft); color: var(--text); }
.kvlist { display: grid; gap: 8px; font-size: 14px; }
.kvlist > div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.kvlist > div > span:first-child { color: var(--text-2); }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: start; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-weight: 500; color: var(--text-2); font-size: 12.5px; white-space: nowrap; }
td.r, th.r { text-align: end; }
tbody tr:hover { background: var(--surface-2); }
.empty { color: var(--muted); padding: 14px 0; text-align: center; }
.did { cursor: copy; border-bottom: 1px dotted var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; padding: 2px 8px; border-radius: 999px; }
.badge.ok { color: var(--good-text); background: var(--good-soft); }
.badge.bad { color: var(--critical-text); background: var(--critical-soft); }
.badge.warn { color: var(--warning-text); background: var(--warning-soft); }
.badge.neutral { color: var(--text-2); background: var(--surface-2); }
.buy-t { color: var(--good-text); font-weight: 600; } .sell-t { color: var(--critical-text); font-weight: 600; }
.pill { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); margin: 1px 4px 1px 0; white-space: nowrap; }

/* market */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile .label { color: var(--text-2); font-size: 12.5px; }
.tile .value { font-size: 22px; font-weight: 650; margin-top: 2px; }
.tile .foot { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tile { margin-bottom: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.sw { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-inline-end: 6px; }
.sw.s1 { background: var(--series-1); } .sw.s2 { background: var(--series-2); }
.sw.band { height: 10px; background: var(--band); border: 1px solid var(--grid); }
.chart { position: relative; width: 100%; direction: ltr; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart text.lab-v { fill: var(--text); font-size: 12px; font-weight: 600; }
.tip { position: absolute; top: 8px; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.12); white-space: nowrap; z-index: 2; display: none; }
.tip.show { display: block; }
.tip .k { color: var(--text-2); }
.trust { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; font-size: 14px; }

/* learn */
.prose h2 { margin: 22px 0 8px; } .prose h2:first-child { margin-top: 0; }
.prose p, .prose li { color: var(--text-2); max-width: 820px; }
.prose p { margin: 8px 0; }
.prose ul { padding-inline-start: 20px; }
.prose details { border-bottom: 1px solid var(--border); padding: 10px 0; }
.prose summary { cursor: pointer; font-weight: 600; color: var(--text); }

/* modal + toast */
dialog { border: 1px solid var(--border); border-radius: 16px; padding: 0; background: var(--surface); color: var(--text); width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.45); }
.modal-in { padding: 20px; display: grid; gap: 12px; }
.modal-in h2 { font-size: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.toast { position: fixed; inset-inline: 0; bottom: 20px; margin: 0 auto; width: max-content; max-width: calc(100vw - 32px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; transform: none; }
.toast.bad { background: var(--critical); color: #fff; }

.foot { color: var(--muted); font-size: 12.5px; padding-top: 8px; padding-bottom: 32px; display: grid; gap: 6px; }

@media (max-width: 1240px) {
  .brand small { display: none; }
  .bar-in { gap: 10px; }
}
@media (max-width: 720px) {
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .bar-tools { margin-inline-start: auto; }
  .brand small { display: none; }
  .step-body { padding-inline-start: 0; }
  .cols { grid-template-columns: 1fr; }
  .wallet { display: none; }
  .seg { grid-template-columns: 1fr; }
  .pnl-grid { grid-template-columns: repeat(2, 1fr); }
  .step-head { flex-wrap: wrap; }
  .step-head .status { order: 3; flex-basis: 100%; padding-inline-start: 46px; text-align: start; }
  .ticker { gap: 4px 14px; font-size: 12.5px; }
  .hero h1 { font-size: 26px; }
}

/* leaderboard */
.fact-link { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; color: var(--text); text-decoration: none; }
.fact-link:hover { border-color: var(--accent); }
.fact-link b { display: block; font-size: 18px; } .fact-link span { color: var(--text-2); font-size: 13px; }
.lb-search { margin: 4px 0 8px; max-width: 520px; }
tr.you-row { background: var(--accent-soft); }
tr.prize-row td:first-child { font-weight: 700; }
.medal { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 12px; font-weight: 700; color: #1a1a19; }
.medal.m1 { background: #eda100; } .medal.m2 { background: #c3c2b7; } .medal.m3 { background: #d9955e; }
.group-list { display: grid; gap: 4px; margin-top: 6px; max-height: 220px; overflow: auto; }
details.group summary { cursor: pointer; color: var(--text); }

/* identity choice + terminal commands */
.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: 12px; }
.choice-card { font: inherit; text-align: start; border-radius: 14px; border: 1.5px solid var(--border); background: var(--surface-2); color: var(--text); padding: 16px 18px; cursor: pointer; display: grid; gap: 4px; }
.choice-card b { font-size: 16.5px; } .choice-card span { color: var(--text-2); font-size: 13.5px; }
.choice-card:hover, .choice-card.on { border-color: var(--accent); }
.choice-card.primary-card { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.choice-card.primary-card span { color: color-mix(in srgb, var(--accent-ink) 85%, transparent); }
.choice-card[disabled] { opacity: .5; cursor: not-allowed; }
.cmd { display: flex; gap: 8px; align-items: center; background: #0f1115; color: #e8eaed; border-radius: 10px; padding: 10px 10px 10px 14px; margin: 6px 0; direction: ltr; }
.cmd code { flex: 1; word-break: normal; overflow-wrap: anywhere; white-space: pre-wrap; color: #e8eaed; font-size: 12.5px; }
.cmd .btn { flex: none; }
.setup { margin: 8px 0; } .setup summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.setup-list { padding-inline-start: 20px; display: grid; gap: 8px; margin: 10px 0 4px; }
.warnlist ul { margin: 6px 0 0; padding-inline-start: 18px; display: grid; gap: 4px; }
.grow { flex: 1; word-break: break-all; }

.term-badge { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 0 5px; color: var(--text-2); }
.cmd .tok { white-space: nowrap; } .cmd .tok.long { white-space: normal; overflow-wrap: anywhere; }

/* order board */
.book-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 4px 0 16px; }
.book-summary > div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.book-summary .k { color: var(--text-2); font-size: 12.5px; } .book-summary .v { font-size: 18px; font-weight: 650; }
.book { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.book-h { font-size: 15px; margin: 0; } .buy-h { color: var(--good-text); } .sell-h { color: var(--critical-text); }
.book-side > .hint { margin: 2px 0 8px; }
.book table td, .book table th { padding: 7px 6px; }
.book .px { font-weight: 700; }
.book tr.mine-row { background: var(--accent-soft); }
.instant { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.btn.buy { background: var(--good); border-color: var(--good); color: #fff; }
.btn.sell { background: var(--critical); border-color: var(--critical); color: #fff; }
.share-link { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.share-link code { flex: 1; overflow-wrap: anywhere; font-size: 12.5px; }
@media (max-width: 720px) { .book { grid-template-columns: 1fr; } }
.book-summary .v.small-v { font-size: 15px; }

/* balance */
.chip-bal { color: var(--text); font-weight: 600; text-decoration: none; padding-inline-start: 8px; border-inline-start: 1px solid var(--border); }
button.chip { font: inherit; font-size: 12.5px; cursor: pointer; }
button.chip:hover { border-color: var(--text-2); }
button.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.am-did { font-size: 13px; word-break: break-all; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.am-sep { border: 0; border-top: 1px solid var(--border); margin: 14px 0 4px; }
.bal-grant { font-weight: 600; }
.bal-tiles { margin-top: 12px; }
.bal-tiles .tile { background: var(--surface-2); border: none; box-shadow: none; }
.bal-tiles .bal-main .value { color: var(--accent, var(--text)); }
#t-statement tr.off td { opacity: .55; }
#acct-balance h3 { margin: 18px 0 2px; font-size: 15px; }
@media (max-width: 720px) { .chip-bal { display: none; } }
.chip-did .ds { display: none; }
@media (max-width: 1240px) {
  .wallet:has(.chip-bal) .chip-did .dl { display: none; }
  .wallet:has(.chip-bal) .chip-did .ds { display: inline; }
}
@media (max-width: 720px) {
  .bal-tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .bal-tiles .tile { padding: 10px 12px; min-height: 0; }
  .bal-tiles .bal-main { grid-column: 1 / -1; }
  .bal-tiles .tile .value { font-size: 18px; }
}
/* room for the balance in the header: the tagline goes, the language menu fits its choice */
.bar-in:has(.chip-bal) .brand small { display: none; }
#lang { field-sizing: content; }

/* contest over */
.ended-banner { background: var(--surface-2); border: 1px solid var(--accent); color: var(--text); padding: 14px 16px; }
.ended-banner b { font-size: 16px; }
.ended-banner p { margin: 4px 0 10px; color: var(--text-2); }
