﻿:root {
  color-scheme: light;
  --paper: #ffffff;
  --shade: #f6f6f6;
  --chip: #f1f1f1;
  --ink: #111111;
  --muted: #5f5f5f;
  --line: #dcdcdc;
  --control: #767676;
  --rule: var(--line);
  --rule-strong: #111111;
  --focus: #111111;
  --surface: var(--shade);
  --sans: system-ui, -apple-system, "Segoe UI", Arial, Helvetica, sans-serif;
  --numbers: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0d0d0d;
    --shade: #161616;
    --chip: #1c1c1c;
    --ink: #f2f2f2;
    --muted: #a3a3a3;
    --line: #2c2c2c;
    --control: #8a8a8a;
    --rule-strong: #f2f2f2;
    --focus: #f2f2f2;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0d0d0d;
  --shade: #161616;
  --chip: #1c1c1c;
  --ink: #f2f2f2;
  --muted: #a3a3a3;
  --line: #2c2c2c;
  --control: #8a8a8a;
  --rule-strong: #f2f2f2;
  --focus: #f2f2f2;
}
:root[data-theme="light"] {
  color-scheme: light;
  --paper: #ffffff;
  --shade: #f6f6f6;
  --chip: #f1f1f1;
  --ink: #111111;
  --muted: #5f5f5f;
  --line: #dcdcdc;
  --control: #767676;
  --rule-strong: #111111;
  --focus: #111111;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: 0;
}
::selection { background: var(--ink); color: var(--paper); }
h1, h2, h3, p, dl, dd, dt { margin: 0; }
h1 { font-size: clamp(28px, 4vw, 36px); line-height: 1.1; letter-spacing: -0.03em; font-weight: 600; }
h2 { font-size: 20px; line-height: 1.3; letter-spacing: -0.02em; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
a { color: inherit; text-underline-offset: 4px; }
button, input { font: inherit; color: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { background: none; border: 0; cursor: pointer; min-height: 44px; }
button:disabled { cursor: wait; opacity: 0.55; }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
button:hover, a:hover { color: var(--muted); }
input { caret-color: var(--ink); }
p, li { max-width: 72ch; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -64px; z-index: 20; padding: 10px 16px; min-height: 44px;
  display: inline-flex; align-items: center; background: var(--paper);
  border: 1px solid var(--ink); text-decoration: none;
}
.skip:focus { top: 12px; }

/* Shell */
.site-header {
  max-width: 1180px; margin: 0 auto; padding: 0 40px; height: 64px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  border-bottom: 1px solid var(--ink);
}
.brand { display: flex; align-items: center; gap: 12px; min-height: 44px; text-decoration: none; font-size: 19px; font-weight: 600; letter-spacing: -0.03em; }
.brand img { display: block; }
.primary { display: flex; align-items: center; gap: 28px; font-size: 14px; }
.primary a { text-decoration: none; padding: 12px 0; min-height: 44px; display: inline-flex; align-items: center; }
.primary a[aria-current="page"] { text-decoration: underline; text-underline-offset: 6px; }
.tabbar { display: none; }
#app { max-width: 1180px; margin: 0 auto; padding: 40px 40px 64px; }
#app:focus { outline: none; }
.site-footer {
  max-width: 1180px; margin: 0 auto; padding: 32px 40px 48px;
  border-top: 1px solid var(--rule); font-size: 12px; color: var(--muted);
}
.footer-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px 32px; }
.credit { font-size: 12px; line-height: 1.8; color: var(--muted); }
.credit a { text-decoration: underline; }
#app > .credit { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.secondary { display: flex; flex-wrap: wrap; gap: 20px; font-size: 12px; }
.secondary a { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.fine { margin-top: 18px; font-size: 12px; max-width: 80ch; }

/* Screen furniture */
.screen-head { margin-bottom: 24px; }
.eyebrow { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.lede { color: var(--muted); margin-top: 10px; font-size: 15px; }
.status-line { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 24px; font-size: 12px; color: var(--muted); margin: 18px 0 14px; }
.status-line p { max-width: none; }
.status-line p:first-child { flex: 1 1 620px; }
.status-line p:last-child { flex: 0 1 auto; }
.status-line strong { color: var(--ink); font-weight: 600; }
.text-link { font-size: 12px; text-decoration: underline; min-height: 44px; display: inline-flex; align-items: center; }
.asset-page { max-width: 960px; margin: 0 auto; }
.asset-page h2 { margin: 28px 0 12px; }
.search-page { max-width: 720px; margin: 0 auto; }
.settings-page { max-width: 760px; margin: 0 auto; }
.notice { border: 1px solid var(--ink); background: var(--shade); padding: 10px 12px; font-size: 12px; margin-bottom: 18px; }
.notice[hidden] { display: none; }
.notice button { min-height: 0; text-decoration: underline; padding: 0; font-size: 13px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 12px 0; border-bottom: 1px solid var(--rule-strong); }
.periods { display: flex; flex-wrap: wrap; gap: 6px; }
.periods button {
  min-width: 44px; padding: 0 12px; border: 1px solid var(--control);
  font-family: var(--numbers); font-size: 14px;
}
.periods button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); }
.toolbar .spacer { flex: 1; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border: 1px solid var(--ink);
  text-decoration: none; font-size: 14px; background: var(--paper);
}
.button.secondary-button { border-color: var(--control); }
.loading { color: var(--muted); font-size: 12px; }
.skeleton { display: grid; gap: 0; margin-top: 12px; border-top: 1px solid var(--line); }
.skeleton-row { display: flex; align-items: center; gap: 16px; min-height: 60px; border-bottom: 1px solid var(--line); }
.skeleton-row span { display: block; height: 10px; background: var(--chip); }
.skeleton-row span:nth-child(1) { width: 28px; }
.skeleton-row span:nth-child(2) { width: 34%; }
.skeleton-row span:nth-child(3) { width: 22%; margin-left: auto; }

/* Ledger table */
.ledger { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ledger caption { text-align: left; font-size: 12px; color: var(--muted); padding: 12px 0 6px; }
.ledger th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 10px 8px 10px 0; border-bottom: 1px solid var(--rule); white-space: nowrap;
}
.ledger th button { min-width: 44px; min-height: 44px; padding: 0; font-size: 12px; font-weight: 600; color: inherit; }
.ledger th[aria-sort="ascending"] button::after { content: " ↑"; }
.ledger th[aria-sort="descending"] button::after { content: " ↓"; }
.ledger th.numeric, .ledger td.numeric { text-align: right; }
.ledger td { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.market-row { min-height: 60px; }
.market-row:hover { background: var(--surface); }
.rank { width: 44px; font-family: var(--numbers); font-size: 13px; color: var(--muted); }
.asset-cell { min-width: 200px; }
.asset-link { display: inline-flex; align-items: baseline; gap: 10px; text-decoration: none; min-width: 44px; min-height: 44px; align-items: center; }
.asset-link .identity { display: inline-flex; align-items: baseline; gap: 10px; min-width: 0; }
.asset-link .symbol { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.asset-link .coin-name { font-size: 13px; color: var(--muted); }
.rank-inline { display: none; font-family: var(--numbers); font-size: 12px; color: var(--muted); }
.price { font-family: var(--numbers); font-size: 17px; letter-spacing: -0.02em; white-space: nowrap; }
.price.range { white-space: normal; }
.change { font-family: var(--numbers); font-size: 14px; font-weight: 600; white-space: nowrap; }
.cap { font-family: var(--numbers); font-size: 14px; white-space: nowrap; }
.sub { display: block; font-size: 12px; line-height: 1.4; color: var(--muted); font-family: var(--sans); font-weight: 400; margin-top: 2px; }
.cap-inline { display: none; }
.change-inline { display: none; }
.price.range .range-high { display: inline; }
.price.range .range-sep { display: inline; }
.tag {
  display: inline-block; font-size: 12px; line-height: 1.35; color: var(--ink);
  border: 1px solid var(--ink); padding: 2px 6px; margin-top: 3px;
}
.save-col { width: 52px; }
.save {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); border: 1px solid transparent;
}
.save[aria-pressed="true"] { color: var(--ink); border-color: var(--control); }
.save svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.save[aria-pressed="true"] svg { fill: currentColor; }
.empty { padding: 28px 0; color: var(--muted); font-size: 15px; }
.empty-actions { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 12px; }
.table-note { margin-top: 14px; font-size: 12px; color: var(--muted); }
.sort-note { font-size: 12px; color: var(--muted); margin-top: 10px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.sort-note button { text-decoration: underline; font-size: 12px; min-height: 44px; padding: 0; }

/* Search */
.search-box { display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--rule-strong); padding: 8px 0; margin: 18px 0 8px; }
.search-box input { flex: 1; min-height: 44px; border: 0; background: none; font-size: 18px; }
.search-box input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search-box input:focus { outline: none; }
.search-box input:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.search-group { margin-top: 28px; }
.search-group h2 { font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.result { display: flex; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.result .asset-cell { flex: 1; }
.result .result-price { font-family: var(--numbers); font-size: 15px; white-space: nowrap; }
.result .sub { margin-top: 0; }
.result .button { min-width: 88px; }
.search-save { min-width: 88px; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 12px; }

/* Asset details */
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-size: 14px; text-decoration: none; color: var(--muted); }
.asset-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 20px; margin: 8px 0 24px; }
.asset-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; }
.asset-title h1 { font-size: clamp(26px, 4vw, 34px); }
.asset-title .symbol { font-size: 18px; color: var(--muted); }
.big-price { font-family: var(--numbers); font-size: 40px; letter-spacing: -0.03em; margin: 18px 0 4px; }
.state-line { font-size: 13px; color: var(--muted); }
.state-sentence { max-width: 46ch; }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 28px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 18px 0; }
.detail-grid div { min-width: 0; }
.detail-grid dt { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.detail-grid dd { font-family: var(--numbers); font-size: 16px; }
.detail-grid .sub { margin-top: 2px; }
.quote { border-top: 1px solid var(--rule); padding: 18px 0; }
.quote-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: baseline; }
.quote-top a { font-size: 15px; font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }
.quote-price { font-family: var(--numbers); font-size: 18px; }
.quote-times { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.quote-metrics { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--muted); margin-top: 8px; font-family: var(--numbers); }
.quote-flag { display: inline-block; font-size: 12px; margin-top: 8px; border: 1px solid var(--ink); padding: 2px 6px; }
.asset-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 18px 0 28px; }
.detail-note { font-size: 12px; color: var(--muted); margin-top: 14px; }

/* Settings */
.settings-block { border-top: 1px solid var(--rule); padding: 22px 0; }
.settings-block:first-of-type { border-top: 1px solid var(--rule-strong); }
.settings-block h2 { margin-bottom: 12px; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-row button { border: 1px solid var(--control); padding: 0 16px; font-size: 14px; }
.choice-row button[aria-pressed="true"] { border-color: var(--ink); }
.source-row { display: grid; grid-template-columns: minmax(120px, 1fr) auto; gap: 4px 18px; padding: 12px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
.source-row .source-caption { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.source-status { font-size: 12px; color: var(--muted); text-align: right; }
.kv { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 8px 18px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { font-family: var(--numbers); font-size: 13px; }

/* Static reference pages */
.prose-page { max-width: 760px; }
.prose-page h1 { margin-bottom: 12px; }
.prose-page h2 { margin: 32px 0 10px; }
.prose-page p, .prose-page li { font-size: 15px; line-height: 1.65; color: var(--ink); margin-bottom: 12px; }
.prose-page ul { padding-left: 20px; }
.prose-page .meta { font-size: 12px; color: var(--muted); margin-bottom: 24px; }
.prose-page a { text-decoration: underline; }
.prose-page .credit { margin: 28px 0; }
.prose-page .fine { color: var(--muted); font-size: 12px; }
.static-shell { max-width: 1180px; margin: 0 auto; padding: 40px; }
.static-footer { border-top: 1px solid var(--rule); margin-top: 40px; padding-top: 20px; font-size: 12px; color: var(--muted); }
.static-footer nav { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 12px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 30; max-width: min(560px, calc(100vw - 32px));
  background: var(--ink); color: var(--paper); padding: 10px 16px; font-size: 13px;
}
.toast[hidden] { display: none; }

@media (max-width: 1023px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .site-header { padding: 0 24px; }
  #app { padding: 32px 24px 48px; }
  .site-footer { padding: 28px 24px 40px; }
  .primary { gap: 18px; font-size: 13px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 10; background: var(--paper); border-top: 1px solid var(--ink);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a { min-height: 52px; display: flex; align-items: center; justify-content: center; font-size: 12px; text-decoration: none; }
  .tabbar a[aria-current="page"] { text-decoration: underline; text-underline-offset: 5px; }
  .ledger .cap { display: none; }
  .cap-inline { display: block; }
  .market-row { min-height: 64px; }
  .detail-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
  .site-header { padding: 0 20px; height: 60px; }
  .primary { display: none; }
  #app { padding: 24px 20px 40px; }
  .site-footer { padding: 24px 20px 32px; }
  .toolbar { gap: 10px 12px; }
  .toolbar .spacer { display: none; }
  .ledger th { font-size: 12px; padding: 8px 4px 8px 0; }
  .ledger td { padding: 12px 4px 12px 0; }
  .market-row { min-height: 72px; }
  .cap-inline { display: none; }
  .ledger .rank { display: none; }
  .asset-cell { min-width: 0; width: auto; }
  .asset-link { flex-wrap: wrap; align-items: flex-start; gap: 2px 6px; }
  .asset-link .identity { flex-direction: column; align-items: flex-start; gap: 1px; }
  .asset-link .coin-name { font-size: 13px; max-width: 100%; overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .price .tag { display: block; white-space: normal; }
  .rank-inline { display: inline; }
  .price { font-size: 17px; }
  .change { font-size: 14px; }
  .change .sub { display: none; }
  .rank { width: 24px; font-size: 12px; }
  .save-col { width: 44px; }
  .save { width: 44px; }
  .screen-head h1 { font-size: 28px; }
  h2 { font-size: 18px; }
  .big-price { margin-top: 12px; font-size: 32px; }
  .toast { bottom: calc(68px + env(safe-area-inset-bottom)); }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
}
@media (max-width: 360px) {
  #app { padding: 20px 16px 36px; }
  .site-header { padding: 0 16px; }
  .site-footer { padding: 20px 16px 28px; }
  .asset-link .coin-name { max-width: none; }
  .rank { width: 20px; }
  .price { font-size: 17px; }
  .ledger .change { display: none; }
  .change-inline { display: block; font-size: 14px; color: var(--ink); }
  .price.range { white-space: normal; }
  .price.range .range-high { display: block; }
  .price.range .range-sep { display: none; }
  .ledger th, .ledger td { padding-right: 3px; }
  .periods { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
}
@media (max-width: 1023px) {
  .static-shell { padding: 0 24px; }
  .static-shell .site-header { padding: 0; }
  .static-shell #app { max-width: 760px; padding: 32px 0; }
}
@media (max-width: 767px) {
  .static-shell { padding: 0 20px; }
  .static-shell .site-header { height: 60px; }
  .static-shell #app { padding: 24px 0; }
  .prose-page p, .prose-page li { font-size: 15px; }
}
@media (max-width: 360px) {
  .static-shell { padding: 0 16px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
