/* Base and reusable components. Layer 2 and 3 tokens only: no literal colour below this line. */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 var(--t-base)/var(--lh-ui) var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p, dl, dd, ol, ul, pre { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
code { font-family: var(--font-data); font-stretch: 87%; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; border-radius: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, .display {
  font-weight: var(--display-weight);
  font-stretch: var(--display-width);
  letter-spacing: var(--display-tracking);
  line-height: var(--lh-tight);
  text-wrap: balance;
}
h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-lead); font-weight: 600; }

.eyebrow {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--t-label); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--fg-2);
}
.eyebrow::before { content: ""; flex: none; width: 9px; height: 9px; background: var(--fg); border-radius: 1.5px; transform: skewX(var(--skew)); }
.body-sm { color: var(--fg-2); font-size: var(--t-small); line-height: var(--lh-text); }
.lead-sm { color: var(--fg-2); line-height: var(--lh-text); }
.hint { color: var(--muted); font-size: var(--t-small); line-height: 1.4; }
.hint-c { text-align: center; margin-top: var(--s-2); }
.foot-note { color: var(--muted); font-size: var(--t-small); line-height: 1.5; max-width: 70ch; }
.h-sub { margin: var(--s-6) 0 var(--s-3); font-size: var(--t-small); font-weight: 600; letter-spacing: .04em; }
.h-sub small { font-weight: 400; color: var(--muted); margin-left: var(--s-2); }

/* Data numerals */
.num, .tbl td.n, .sum dd, .kv dd code { font-variant-numeric: tabular-nums; }

/* Signs: dot = HL market data, square = DSX proof, X = simulated */
.sign { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-label); font-weight: 600; letter-spacing: .02em; color: var(--fg-2); white-space: nowrap; }
.sign-g { flex: none; color: var(--fg); }
.legend3 { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); }

/* Statuses: icon + word, never tone alone */
.status { display: inline-flex; align-items: center; gap: 5px; font-size: var(--t-small); font-weight: 600; white-space: nowrap; }
.status .ic { flex: none; }
.status-idle { color: var(--muted); }
.status-lock { color: var(--fg-2); }
.status-bad { background: var(--fg); color: var(--bg); padding: 2px 8px 2px 6px; border-radius: 3px; }
.status-warn { padding: 1px 7px 1px 5px; border: var(--line) solid var(--fg); border-radius: 3px; }
.spin { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tag { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 6px; border-radius: 2px; background: var(--fg); color: var(--bg); }

/* Buttons: parallelogram body, slab wipes in on hover. --skew comes from the brand. */
.btn {
  position: relative; isolation: isolate; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-5);
  font-size: var(--t-base); font-weight: 600; font-stretch: 110%; line-height: 1; white-space: nowrap; text-decoration: none;
  transition: color var(--dur) var(--ease);
}
.btn::before, .btn::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); transform: skewX(var(--skew)); z-index: -1; }
.btn-primary { color: var(--on-accent); }
.btn-primary::before { background: var(--accent); }
.btn-primary::after { background: var(--fg-2); transform: skewX(var(--skew)) scaleX(0); transform-origin: left; transition: transform var(--dur-slow) var(--ease); }
.btn-primary:hover:not([aria-disabled="true"])::after { transform: skewX(var(--skew)) scaleX(1); }
.btn-ghost { color: var(--fg); }
.btn-ghost::before { box-shadow: inset 0 0 0 var(--line) var(--fg); }
.btn-ghost:hover:not([aria-disabled="true"])::before { background: var(--wash); }
.btn-text { color: var(--fg); padding-inline: var(--s-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.btn-sm { min-height: var(--ctl); padding: 0 var(--s-4); font-size: var(--t-small); }
.btn-full { width: 100%; }
.btn[aria-disabled="true"] { cursor: not-allowed; }
.btn-primary[aria-disabled="true"]:not([aria-busy="true"]) { color: var(--fg-2); }
.btn-primary[aria-disabled="true"]:not([aria-busy="true"])::before { background: transparent; box-shadow: inset 0 0 0 var(--line) var(--rule-2); }
.btn-ghost[aria-disabled="true"] { color: var(--muted); }
.btn-ghost[aria-disabled="true"]::before { box-shadow: inset 0 0 0 var(--line) var(--rule-2); }
.iconbtn { display: inline-grid; place-items: center; flex: none; width: var(--ctl); height: var(--ctl); border-radius: var(--radius); color: var(--fg); }
.iconbtn:hover { background: var(--wash); }
.iconbtn-sm { width: 28px; height: 28px; }
.iconbtn-main { background: var(--accent); color: var(--on-accent); }
.iconbtn-main:hover { background: var(--fg-2); }
.link { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-small); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.link-inline { display: inline; font-weight: 400; }
[tabindex="0"][data-tip] { cursor: help; }

/* Segmented control */
.seg { display: inline-flex; border: var(--line) solid var(--fg); border-radius: var(--radius); overflow: hidden; }
.seg button { min-height: 32px; padding: 0 var(--s-3); border-left: var(--line) solid var(--fg); font-size: var(--t-small); font-weight: 600; white-space: nowrap; transition: background-color var(--dur-fast), color var(--dur-fast); }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.seg button:not([aria-pressed="true"]):hover { background: var(--wash); }
.seg button:focus-visible { outline-offset: -4px; }
.seg-full { display: flex; }
.seg-full button { flex: 1; }
.seg-sm button { min-height: 28px; padding: 0 var(--s-2); }

/* Fields */
.field { display: grid; gap: 6px; }
.field > label, .field-row label { font-size: var(--t-small); font-weight: 600; display: flex; justify-content: space-between; gap: var(--s-2); }
.field label small { font-weight: 400; color: var(--muted); font-size: inherit; }
.field-row { display: flex; align-items: baseline; justify-content: space-between; }
.input, .select {
  width: 100%; min-height: 40px; padding: 0 var(--s-3);
  background: transparent; border: var(--line) solid var(--rule-2); border-radius: var(--radius);
  transition: border-color var(--dur-fast);
}
.input:hover, .select:hover { border-color: var(--fg); }
.input:focus-visible, .select:focus-visible { border-color: var(--fg); outline: 2px solid var(--fg); outline-offset: 1px; }
.input::placeholder { color: var(--muted); }
.input-num { font-family: var(--font-data); font-stretch: 87%; font-size: 13px; font-variant-numeric: tabular-nums; }
.select { appearance: none; padding-right: var(--s-7); background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-size: 5px 5px; background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-repeat: no-repeat; }
.select option { background: var(--bg); color: var(--fg); }
.select-bare { width: auto; min-height: 32px; border-color: transparent; padding-left: var(--s-2); font-weight: 600; }
.has-error .input { border-color: var(--fg); border-width: 2px; }
.fmsg { display: none; gap: 5px; align-items: flex-start; font-size: var(--t-small); font-weight: 600; line-height: 1.35; }
.has-error .fmsg { display: flex; }
.fmsg .ic { margin-top: 1px; flex: none; }
.stepper { display: flex; gap: var(--s-2); align-items: center; }
.stepper .input { text-align: center; }
.stepper .iconbtn { box-shadow: inset 0 0 0 var(--line) var(--rule-2); height: 40px; width: 40px; }

/* Range: the thumb is the brand parallelogram */
.range { width: 100%; height: 26px; margin: 0; appearance: none; -webkit-appearance: none; background: transparent; cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 2px; background: var(--fg); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 18px; margin-top: -8px; border: 2.5px solid var(--bg); border-radius: 4px; background: var(--fg); transform: skewX(var(--skew)); }
.range::-moz-range-track { height: 2px; background: var(--fg); }
.range::-moz-range-thumb { width: 15px; height: 13px; border: 2.5px solid var(--bg); border-radius: 4px; background: var(--fg); transform: skewX(var(--skew)); }
.range-ends { display: flex; justify-content: space-between; font-size: var(--t-label); color: var(--muted); }
.lev-v { font-weight: var(--display-weight); font-stretch: var(--display-width); font-size: var(--t-lead); font-variant-numeric: tabular-nums; }

.check { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--t-small); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--fg); margin: 0; }

/* Meters */
.meter, .gauge { position: relative; height: 6px; background: var(--wash); border-radius: 1px; overflow: hidden; }
.meter i, .gauge i { position: absolute; inset: 0 auto 0 0; background: var(--fg); transition: width var(--dur-slow) var(--ease); }
.meter.is-hot { box-shadow: 0 0 0 1.5px var(--fg); }
.gauge { height: 10px; background: transparent; box-shadow: inset 0 0 0 var(--line) var(--fg); border-radius: 2px; }

/* Tables: fund-sheet rule, thick on top, thin below */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-small); }
.tbl th { text-align: left; font-size: var(--t-label); font-weight: 600; color: var(--muted); padding: var(--s-2) var(--s-3); white-space: nowrap; }
.tbl td { padding: 10px var(--s-3); border-top: var(--line-hair) solid var(--rule); white-space: nowrap; }
.tbl td.n, .tbl th.n { text-align: right; }
.tbl td.n { font-family: var(--font-data); font-stretch: 87%; font-size: 12px; }
.tbl td.n .btn { font-family: var(--font-ui); }
.tbl th:first-child, .tbl td:first-child { padding-left: 0; }
.tbl th:last-child, .tbl td:last-child { padding-right: var(--s-2); }
.tbl-fund { border-top: var(--line-head) solid var(--fg); border-bottom: var(--line) solid var(--fg); }
.tbl tr.is-bad td { background: var(--wash); font-weight: 600; }
.tbl tr.is-sel td { background: var(--wash); }
.tbl-fund tr.is-sel td:first-child, .tbl-fund tr.is-bad td:first-child { padding-left: var(--s-2); }
.dir { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }

/* key / value */
.kvs { display: grid; }
.kv { display: grid; grid-template-columns: minmax(110px, 40%) minmax(0, 1fr); gap: var(--s-3); padding: 9px 0; border-bottom: var(--line-hair) solid var(--rule); font-size: var(--t-small); }
.kv dt { color: var(--muted); }
.kv dd { min-width: 0; overflow-wrap: anywhere; }
.kv dd code { font-size: 12px; }
.kv-hash { grid-template-columns: 1fr; gap: 4px; }
.kv-hash dd { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--s-2); align-items: start; }
.kv-hash small { grid-column: 1 / -1; color: var(--muted); }
.hash-full { font-size: 11.5px; line-height: 1.5; overflow-wrap: anywhere; word-break: break-all; }

/* Banners and blocked reasons */
.blocked { display: flex; gap: var(--s-2); align-items: flex-start; padding: var(--s-2) var(--s-3); background: var(--fg); color: var(--bg); border-radius: var(--radius); font-size: var(--t-small); line-height: 1.4; }
.blocked .ic { flex: none; margin-top: 1px; }
.banner { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border: var(--line) solid var(--fg); border-radius: var(--radius); font-size: var(--t-small); }
.banner .ic { flex: none; }
.banner p { flex: 1; min-width: 0; }
.result { display: flex; gap: 6px; align-items: flex-start; margin-top: var(--s-2); font-size: var(--t-small); font-weight: 600; }
.result .ic { flex: none; margin-top: 1px; }

.empty { display: grid; justify-items: center; gap: var(--s-3); padding: var(--s-9) var(--s-5); text-align: center; }
.empty p { color: var(--fg-2); max-width: 46ch; line-height: var(--lh-text); }
.empty-left { justify-items: start; text-align: left; padding: 0; }
.empty-ic { color: var(--muted); }
.empty-act { display: flex; flex-wrap: wrap; gap: var(--s-3); justify-content: center; margin-top: var(--s-2); }
.empty-line { padding: var(--s-5) 0; color: var(--muted); font-size: var(--t-small); }

/* Fold */
.fold { border-top: var(--line-hair) solid var(--rule); border-bottom: var(--line-hair) solid var(--rule); }
.fold summary { padding: var(--s-3) 0; font-size: var(--t-small); font-weight: 600; cursor: pointer; }
.code { max-height: 320px; overflow: auto; padding: var(--s-3); background: var(--wash); border-radius: var(--radius); font: 400 11.5px/1.6 var(--font-data); font-stretch: 87%; white-space: pre-wrap; word-break: break-all; }

/* Drawer */
.drawer-wrap { position: fixed; inset: 0; z-index: 50; }
.drawer-scrim { position: absolute; inset: 0; width: 100%; background: var(--overlay); animation: fade var(--dur) var(--ease); cursor: default; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(var(--drawer-w), 100%); display: flex; flex-direction: column; background: var(--bg); border-left: var(--line-head) solid var(--fg); animation: slidein var(--dur) var(--ease); }
.drawer-wide { width: min(620px, 100%); }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); padding: var(--s-5) var(--s-5) var(--s-4); }
.drawer-head h2 { font-size: var(--t-h2); margin-top: var(--s-2); }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0 var(--s-5) var(--s-7); display: flex; flex-direction: column; gap: var(--s-3); }
.drawer-tools { display: flex; justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } }
@keyframes slidein { from { transform: translateX(32px); opacity: 0; } }

.insp { display: grid; gap: var(--s-2); padding-bottom: var(--s-5); margin-bottom: var(--s-2); border-bottom: var(--line) solid var(--fg); }
.insp:last-child { border-bottom: 0; }
.insp h3 .sign { font-size: var(--t-base); color: var(--fg); }
.proofpath { display: grid; gap: var(--s-2); padding: var(--s-2) 0 var(--s-2) var(--s-3); border-left: var(--line) solid var(--fg); }
.proofpath li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--s-2); align-items: start; }
.pp-l { grid-column: 1 / -1; font-size: var(--t-label); color: var(--muted); font-weight: 600; }

.real-list { display: grid; gap: var(--s-3); margin-top: var(--s-3); }
.real-row { display: grid; gap: 3px; }
.real-row .sign { font-size: var(--t-small); color: var(--fg); }
.real-row p { font-size: var(--t-small); color: var(--fg-2); line-height: 1.5; }

/* Toast and tooltip */
#toast-root { position: fixed; z-index: 60; right: var(--s-6); top: calc(var(--top-h) + var(--s-3)); display: grid; gap: var(--s-2); justify-items: end; pointer-events: none; }
.toast { display: flex; gap: var(--s-2); align-items: center; max-width: 380px; padding: 10px var(--s-3); background: var(--fg); color: var(--bg); border-radius: var(--radius); font-size: var(--t-small); font-weight: 600; animation: rise var(--dur) var(--ease); }
.toast .ic { flex: none; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
#tooltip { position: fixed; top: 0; left: 0; z-index: 70; max-width: 280px; padding: 7px 10px; background: var(--fg); color: var(--bg); border-radius: 4px; font-size: var(--t-small); line-height: 1.4; pointer-events: none; }
#tooltip b, #tooltip span { display: block; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
  .spin { animation-duration: 2.4s !important; }
}
