/* The look: tokens, reset, the shell (three bars, the sheet, the footer) and every shared component.
   docs/BLUEPRINT.md section 4.9. FROZEN after the foundation step: builders use these classes and do not redefine
   them. Board and token page rules live in css/terminal.css; each other builder has its own stylesheet.

   Black is the face, and this file is black and nothing else: the light theme is a second set of the colour tokens in
   css/light.css, behind one switch (docs/LANES.md chapter 10).
   Orange (--brand) is for what is ours or hot: the logo, primary buttons, the quick-buy pill, the active tab, focus
   rings, the live dot, links, the heat meter. Green and red are ONLY buy / sell and profit / loss, and every profit
   or loss number also carries a sign or an arrow. Numbers use .num.
   No inline style attribute anywhere (the Content-Security-Policy forbids it): a dynamic size goes through a CSS
   variable set from JS, h('i', { css: { '--w': '42%' } }). No font file and no outside host: system fonts only. */

:root {                                   /* black: the only theme in v1 */
  color-scheme: dark;
  --bg: #070707; --bg-2: #0e0e0f; --bg-3: #151517; --hover: #1a1a1d; --chip: #1b1b1e;
  --line: #1f1f22; --line-2: #2c2c31;
  --text: #f2efe9; --muted: #9a958c; --dim: #7a756c;
  --brand: #ff6a00; --brand-hi: #ffa200; --brand-deep: #c24a00; --brand-text: #ff6a00;
  --brand-soft: rgba(255, 106, 0, 0.14); --on-brand: #0b0705;
  --up: #2fd08a; --down: #ff3d71; --up-soft: rgba(47, 208, 138, 0.14); --down-soft: rgba(255, 61, 113, 0.14);
  --warn: #f5c542; --warn-soft: rgba(245, 197, 66, 0.14);
  --heat-0: #3a1108;                      /* the empty track of the meter */
  --heat-1: #ff2a00; --heat-2: #ff6a00; --heat-3: #ffa200; --heat-4: #ffd23f;   /* ember, orange, flame, flame yellow: the mark's four stops */
  --heat-hot: #fff4d6;                    /* the white-hot core of level 4 */
  --glow: 0 0 0 1px rgba(255, 162, 0, 0.35), 0 10px 30px -8px rgba(255, 106, 0, 0.6);
  --font-ui: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", "JetBrains Mono", Consolas, "Roboto Mono", monospace;
  --radius: 10px; --top-h: 44px; --bar2-h: 36px; --bar3-h: 32px; --tab-h: 60px;
}

/* More tokens of the shell.
   --tab-h is "how tall the bottom bar is right now": the phone tab bar (60 px) under 900 px, the slim status bar
   (--bar3-h) from 900 px up. Anything that must clear the bottom bar adds var(--tab-h): it is right at every width
   (the board reads it from JS to size its lanes).
   --mock-h is the height of the sample-data banner (set from JS while it shows, else 0). */
:root {
  --mock-h: 0px;
  --scrim: rgba(0, 0, 0, 0.72);
  --shadow-pop: 0 18px 50px -14px rgba(0, 0, 0, 0.95);
  --ring: 0 0 0 3px var(--brand-soft);
  /* the generated coin badge (ui.js coinBadge): eight grounds, each a light and a deep tone. Pictures, not signals. */
  --cb-0: #ff7a2e; --cb-0d: #a33a00;
  --cb-1: #f5b83d; --cb-1d: #8a5a0a;
  --cb-2: #e0559b; --cb-2d: #7d2452;
  --cb-3: #9a7bff; --cb-3d: #43299c;
  --cb-4: #4fb6e8; --cb-4d: #17557a;
  --cb-5: #d9d2c5; --cb-5d: #6a645a;
  --cb-6: #ff5a4a; --cb-6d: #8a1f14;
  --cb-7: #c9a26b; --cb-7d: #5e4522;
}
/* The colours a rule used to spell out, as tokens (the light theme: css/light.css holds the second set of every
   colour token on this page; this file stays black). Each token below IS the literal its rule carried, value for
   value, so black is what it was. --<colour>-aNN = that colour at NN percent: a signal colour as a border, a wash or
   a flash; --shade-* = black as a shadow; --glint-* = white as a highlight; --bg-a70, --bg-2-a78, --bg-2-a94 = the
   ground seen through. The -fill tokens are what near-black text sits on (the buy and sell buttons, the sample
   banner, a hovered primary button): in black they are the signal colours themselves. --cb-ink is the letter on a
   coin badge. */
:root {
  --brand-a0: rgba(255, 106, 0, 0); --brand-a06: rgba(255, 106, 0, 0.06); --brand-a35: rgba(255, 106, 0, 0.35); --brand-a45: rgba(255, 106, 0, 0.45);
  --brand-a50: rgba(255, 106, 0, 0.5); --brand-a55: rgba(255, 106, 0, 0.55); --brand-a90: rgba(255, 106, 0, 0.9); --brand-hi-a55: rgba(255, 162, 0, 0.55);
  --up-a0: rgba(47, 208, 138, 0); --up-a26: rgba(47, 208, 138, 0.26); --up-a45: rgba(47, 208, 138, 0.45); --up-a55: rgba(47, 208, 138, 0.55);
  --down-a0: rgba(255, 61, 113, 0); --down-a12: rgba(255, 61, 113, 0.12); --down-a26: rgba(255, 61, 113, 0.26); --down-a30: rgba(255, 61, 113, 0.3); --down-a35: rgba(255, 61, 113, 0.35); --down-a45: rgba(255, 61, 113, 0.45);
  --warn-a30: rgba(245, 197, 66, 0.3); --warn-a45: rgba(245, 197, 66, 0.45);
  --shade-a25: rgba(0, 0, 0, 0.25); --shade-a45: rgba(0, 0, 0, 0.45); --shade-a55: rgba(0, 0, 0, 0.55); --shade-a60: rgba(0, 0, 0, 0.6); --shade-a80: rgba(0, 0, 0, 0.8); --shade-a90: rgba(0, 0, 0, 0.9); --shade-a95: rgba(0, 0, 0, 0.95);
  --glint-a10: rgba(255, 255, 255, 0.1); --glint-a12: rgba(255, 255, 255, 0.12); --glint-a14: rgba(255, 255, 255, 0.14); --glint-a22: rgba(255, 255, 255, 0.22);
  --bg-a70: rgba(7, 7, 7, 0.7); --bg-2-a78: rgba(14, 14, 15, 0.78); --bg-2-a94: rgba(14, 14, 15, 0.94);
  --up-fill: var(--up); --down-fill: var(--down); --warn-fill: var(--warn); --brand-hi-fill: var(--brand-hi);
  --cb-ink: var(--text);
}
@media (min-width: 900px) {
  :root { --tab-h: var(--bar3-h); }
}

/* ---------- reset and base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { scrollbar-color: var(--line-2) transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 500 15px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { color: var(--brand-hi); text-decoration: underline; text-underline-offset: 3px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { font-family: var(--font-ui); color: var(--text); font-weight: 700; line-height: 1.15; margin: 0 0 0.4em; letter-spacing: -0.02em; }
h1 { font-size: clamp(26px, 6vw, 40px); }
h2 { font-size: clamp(19px, 4.4vw, 24px); }
h3 { font-size: 17px; }
p { margin: 0 0 0.8em; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--brand); color: var(--on-brand); }
[hidden] { display: none !important; }
[data-tip] { cursor: help; }
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px; border: 1px solid var(--line-2); color: var(--muted); font: 600 11px/1 var(--font-mono); }

/* ---------- small helpers ---------- */
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.up { color: var(--up); }
.down { color: var(--down); }
.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: -999px; top: 8px; z-index: 100; background: var(--brand); color: var(--on-brand); padding: 8px 12px; border-radius: 8px; font-weight: 700; }
.skip:focus { left: 16px; }
/* "Skip to content" moves the keyboard to the page itself (js/app.js wireSkipLink): the place is taken, no ring is drawn round the whole page */
#app:focus { outline: none; }
.ico { width: 20px; height: 20px; flex: none; }
.ico-xs { width: 13px; height: 13px; flex: none; }
.soon { display: inline-flex; align-items: center; height: 18px; padding: 0 7px; border-radius: 999px; border: 1px dashed var(--line-2); color: var(--muted); font: 700 10px/1 var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; }
.view-in { animation: fadein 0.18s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes mark-breathe { from { opacity: 0.45; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 var(--brand-a55); } 100% { box-shadow: 0 0 0 8px var(--brand-a0); } }
@keyframes blink { 50% { opacity: 0.2; } }

/* an address: short form; .addr-copy copies it, .addr-link opens the explorer (ui.js addr) */
.addr { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text); white-space: nowrap; }
.addr-copy { padding: 0; border: 0; background: none; color: inherit; font: inherit; border-bottom: 1px dashed var(--line-2); }
.addr-copy:hover { color: var(--brand-hi); border-bottom-color: var(--brand); }
.addr-link { display: inline-flex; color: var(--muted); }
.addr-link:hover { color: var(--brand-hi); }
.txlink { display: inline-flex; align-items: center; gap: 3px; font: 600 12px/1 var(--font-ui); white-space: nowrap; }
.creator-link { overflow-wrap: anywhere; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: var(--mock-h); z-index: 30;
  display: flex; align-items: center; gap: 10px;
  height: var(--top-h); padding: 0 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.logo, .logo:hover { display: flex; align-items: center; gap: 8px; flex: none; margin-right: 6px; color: var(--text); text-decoration: none; }
.logo-mark { width: 22px; height: 22px; flex: none; }
/* the drawn wordmark is stroked in currentColor, which is black inside an <img>: shown light, as on the lockup */
.logo-word { height: 14px; width: auto; flex: none; filter: invert(0.95); }
/* the ink lockup: the light theme shows it in place of the two above (css/light.css). Black is the face: hidden here. */
.logo-ink { display: none; }
.nav { display: none; align-items: center; gap: 0; min-width: 0; }
.nav a { padding: 6px 10px; border-radius: 6px; font: 600 13.5px/1 var(--font-ui); color: var(--muted); text-decoration: none; white-space: nowrap; }
.nav a:hover { background: var(--chip); color: var(--text); text-decoration: none; }
.nav a.on { color: var(--brand-text); }
.top-search { display: flex; align-items: center; gap: 4px; height: 30px; margin-left: auto; padding: 0 6px 0 2px; flex: 0 1 260px; min-width: 0; border: 1px solid var(--line-2); border-radius: 999px; background: var(--bg-2); }
.top-search:focus-within { border-color: var(--brand); box-shadow: var(--ring); }
.top-search .top-search-open { width: 26px; height: 26px; flex: none; border: 0; color: var(--muted); }
.top-search .top-search-open .ico { width: 15px; height: 15px; }
.top-search input { flex: 1 1 auto; min-width: 0; width: 100%; padding: 0; border: 0; outline: none; background: none; color: var(--text); font: 500 12.5px/1 var(--font-ui); }
.top-search input::placeholder { color: var(--dim); }
.top-search input::-webkit-search-cancel-button { display: none; }
.top-right { display: flex; align-items: center; gap: 8px; flex: none; min-width: 0; }
#slot-wallet { display: inline-flex; align-items: center; min-width: 0; }
/* ---- the lanes' slots (js/lanes.js): an empty slot box takes no room, so a module may draw into it minutes later.
   The two places that only hold boxes hand them to the row they sit in (an empty one would cost that row a gap):
   #slot-prefs in the top bar and its twin .bar3-prefs, the first rows of the "More" sheet. ---- */
[data-slot]:empty { display: none; }
#slot-prefs, .bar3-prefs { display: contents; }
/* .only-narrow: drawn under 560 px only (the width contract); #slot-prefs is its wide twin */
@media (min-width: 560px) { .only-narrow { display: none; } }
@media (max-width: 559px) { #slot-prefs { display: none; } }

/* ---------- second bar: trade controls on the left, the live pill and the SOL price on the right ---------- */
.bar2 {
  position: sticky; top: calc(var(--mock-h) + var(--top-h)); z-index: 29;
  display: flex; align-items: center; gap: 10px;
  height: var(--bar2-h); padding: 0 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
#slot-trade { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.bar2-right { display: inline-flex; align-items: center; gap: 12px; margin-left: auto; flex: none; }
#sol-px { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* the status pill: a dot and a word. The dot is orange while live; it never claims more than the connection says. */
.st-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--muted); font: 700 11.5px/1.4 var(--font-ui); white-space: nowrap; }
.st-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.st-sub { color: var(--muted); font-weight: 500; }
.st-live { border-color: var(--brand-a45); color: var(--text); }
.st-live .st-dot { background: var(--brand); animation: livepulse 1.6s ease-out infinite; }
.st-poll { color: var(--text); }
.st-poll .st-dot { background: var(--brand-deep); }
.st-wait .st-dot { background: var(--dim); animation: blink 1s steps(2) infinite; }
.st-off { border-color: var(--line-2); color: var(--muted); }
.st-off .st-dot { background: var(--dim); }
.st-sample { border-style: dashed; border-color: var(--warn); color: var(--warn); }
.st-sample .st-dot { background: var(--warn); }

/* ---------- the sheet (main) and the footer ---------- */
.sheet { position: relative; max-width: 1140px; margin: 0 auto; padding: 18px 16px 24px; min-height: 60vh; outline: none; }
/* (the disclaimer is small print, not faint print: --muted is 6.8 to 1 on the ground, --dim was 4.4 to 1) */
.foot { max-width: 1140px; margin: 0 auto; padding: 18px 16px calc(var(--tab-h) + 28px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.foot p { margin: 0 0 6px; }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.foot-links a { color: var(--text); }
.foot-links a:hover { color: var(--brand-hi); }

/* ---------- bottom bar: a slim status bar on a wide screen, the tab bar on a phone ---------- */
.bar3 {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px)); padding: 0 12px env(safe-area-inset-bottom, 0px);
  background: var(--bg); border-top: 1px solid var(--line);
  font: 600 12px/1 var(--font-ui);
}
.bar3-links { display: flex; align-items: center; gap: 2px; min-width: 0; }
.bar3-links a, .bar3-more { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border: 0; border-radius: 6px; background: none; color: var(--muted); font: inherit; text-decoration: none; white-space: nowrap; }
.bar3-links a:hover, .bar3-more:hover { background: var(--chip); color: var(--text); text-decoration: none; }
.bar3-links a.on, .bar3-more.on { color: var(--brand-text); }
.bar3-links .ico { width: 14px; height: 14px; }
.bar3-morewrap { position: relative; display: inline-flex; }
.bar3-menu { position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 31; display: grid; gap: 2px; min-width: 170px; padding: 6px; border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--bg-3); box-shadow: var(--shadow-pop); }
.bar3-menu a { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 10px; border-radius: 7px; color: var(--text); font: 600 13px/1 var(--font-ui); text-decoration: none; }
.bar3-menu a:hover, .bar3-menu a.on { background: var(--chip); color: var(--brand-hi); text-decoration: none; }
.bar3-menu .ico { width: 16px; height: 16px; color: var(--muted); }
.bar3-right { display: inline-flex; align-items: center; gap: 12px; margin-left: auto; flex: none; }
.bar3-lat { color: var(--muted); font-size: 11.5px; }
.bar3-x { display: inline-flex; color: var(--muted); }
.bar3-x:hover { color: var(--text); }
.bar3-x .ico { width: 14px; height: 14px; }
.bar3-new { cursor: pointer; }

/* ---------- the sample-data banner (only under ?mock=1) ---------- */
.mockbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 12px;
  padding: 6px 16px; text-align: center;
  background: var(--warn-fill); color: var(--on-brand); font: 700 12.5px/1.3 var(--font-ui);
}
.mockbar a, .mockbar a:hover { color: var(--on-brand); text-decoration: underline; }
.mock-short { display: none; }
body.is-mock { padding-top: var(--mock-h); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--bg-3); color: var(--text); font: 700 14px/1.2 var(--font-ui); text-decoration: none; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn:hover { border-color: var(--brand); color: var(--text); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn .ico { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-hi-fill); border-color: var(--brand-hi-fill); color: var(--on-brand); }
.btn-primary:active { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--text); }
.btn-buy { background: var(--up-fill); border-color: var(--up-fill); color: var(--on-brand); }
.btn-buy:hover { border-color: var(--text); color: var(--on-brand); }
.btn-sell { background: var(--down-fill); border-color: var(--down-fill); color: var(--on-brand); }
.btn-sell:hover { border-color: var(--text); color: var(--on-brand); }
.btn-danger { background: transparent; border-color: var(--down); color: var(--down); }
.btn-danger:hover { background: var(--down-soft); border-color: var(--down); color: var(--down); }
.btn-sm { min-height: 30px; padding: 4px 11px; border-radius: 8px; font-size: 12.5px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--chip); color: var(--text); }
.icon-btn .ico { width: 18px; height: 18px; }
.icon-btn.copy { width: 28px; height: 28px; }
.icon-btn.copy .ico { width: 15px; height: 15px; }

/* the quick-buy pill: orange, near-black text. .is-off = the disabled look while trading cannot run right now
   (no wallet, locked, switched off, sample): it still takes a click, which opens the right dialog. */
.qpill { position: relative; z-index: 2; display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px 0 7px; border: 0; border-radius: 999px; background: var(--brand); color: var(--on-brand); font: 700 11.5px/1 var(--font-mono); white-space: nowrap; }
.qpill .ico { width: 11px; height: 11px; color: var(--on-brand); }
.qpill:hover { background: var(--brand-hi-fill); }
.qpill:active { transform: translateY(1px); }
.qpill:disabled { opacity: 0.5; cursor: progress; }
.qpill.is-off { background: var(--chip); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-2); }
.qpill.is-off .ico { color: var(--muted); }
.qpill.is-off:hover { background: var(--hover); color: var(--text); }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--bg-3); color: var(--muted); font: 600 11px/1.5 var(--font-ui); white-space: nowrap; }
.chip-ok { border-color: var(--up-a45); background: var(--up-soft); color: var(--up); }
.chip-warn { border-color: var(--warn-a45); background: var(--warn-soft); color: var(--warn); }
.chip-bad { border-color: var(--down-a45); background: var(--down-soft); color: var(--down); }
.chip-brand { border-color: var(--brand-a50); background: var(--brand-soft); color: var(--brand-hi); }
button.chip:hover { border-color: var(--brand); color: var(--text); }

/* ---------- cards and tables ---------- */
.card { position: relative; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; }
.card > h1:first-child, .card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2, .card-head h3 { margin: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { position: sticky; top: 0; z-index: 1; padding: 7px 10px; background: var(--bg-2); border-bottom: 1px solid var(--line-2); color: var(--muted); font: 600 11px/1.2 var(--font-ui); letter-spacing: 0.04em; text-transform: uppercase; text-align: left; white-space: nowrap; }
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: var(--hover); }
.tbl .num { text-align: right; }

/* ---------- inputs ---------- */
.input, .textarea { width: 100%; min-height: 38px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-3); color: var(--text); font-size: 14px; }
.textarea { min-height: 84px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--dim); }
.input:focus, .textarea:focus { border-color: var(--brand); outline: none; box-shadow: var(--ring); }
.field { display: grid; gap: 5px; margin: 0 0 14px; }
.field-l { font: 700 12px/1.2 var(--font-ui); color: var(--muted); }
.field-h { font-size: 12px; color: var(--muted); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; border-radius: 10px; background: var(--bg-3); border: 1px solid var(--line); max-width: 100%; }
.seg-btn { min-height: 30px; padding: 4px 11px; border-radius: 7px; border: 0; background: transparent; color: var(--muted); font: 700 12.5px/1 var(--font-ui); }
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--brand-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--brand-a55); }

/* ---------- numbers in a grid ---------- */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 9px 11px; border-radius: 8px; background: var(--bg-3); border: 1px solid var(--line); }
.stat-k { display: flex; align-items: center; gap: 5px; color: var(--muted); font: 700 11px/1.2 var(--font-ui); letter-spacing: 0.04em; text-transform: uppercase; }
.stat-v { color: var(--text); font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.stat-h { color: var(--dim); font-size: 11.5px; }

/* ---------- page states ---------- */
.loading { display: flex; align-items: center; gap: 10px; padding: 26px 16px; color: var(--muted); font: 600 14px/1.4 var(--font-ui); }
.loading-mark { flex: none; animation: mark-breathe 0.9s ease-in-out infinite alternate; }
.empty { padding: 26px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty p { margin: 0 0 10px; }
.empty b { display: block; margin-bottom: 4px; color: var(--text); }
.empty-mark { margin: 0 auto 10px; opacity: 0.9; }
.errbox { padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--down-a45); background: var(--down-soft); color: var(--text); }
.errbox p { margin: 0 0 8px; }
.note { display: block; margin: 12px 0; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); border-left: 3px solid var(--brand); background: var(--bg-3); color: var(--text); font-size: 13.5px; }
.note b { display: block; margin-bottom: 2px; color: var(--brand-hi); font: 700 11px/1.3 var(--font-ui); letter-spacing: 0.06em; text-transform: uppercase; }

/* ---------- tooltips in plain words (ui.js tip / showTip) ---------- */
.tipq { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; padding: 0; border-radius: 50%; border: 1px solid var(--line-2); background: transparent; color: var(--muted); font: 700 10px/1 var(--font-ui); cursor: help; }
.tipq:hover, .tipq:focus-visible { border-color: var(--brand); color: var(--brand-hi); }
.tip-pop { position: fixed; z-index: 90; width: min(290px, calc(100vw - 24px)); padding: 12px 14px; border-radius: var(--radius); background: var(--bg-3); border: 1px solid var(--line-2); box-shadow: var(--shadow-pop); color: var(--muted); font: 500 13px/1.45 var(--font-ui); }
.tip-pop b { display: block; margin-bottom: 3px; color: var(--text); font: 700 14px/1.3 var(--font-ui); }
.tip-pop a { display: inline-block; margin-top: 6px; font-weight: 700; font-size: 12.5px; }

/* ---------- marks, verdicts, flags (ui.js hl / pnl / levelBadge / flagRow) ---------- */
.hl { padding: 0.05em 0.35em; border-radius: 6px; background: transparent; color: var(--text); }
.hl-gain, .hl-green { color: var(--up); background: var(--up-soft); }
.hl-loss, .hl-pink { color: var(--down); background: var(--down-soft); }
.hl-yellow { color: var(--warn); background: var(--warn-soft); }
.hl-flat { color: var(--muted); background: var(--bg-3); }
.lvl { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; border: 1px solid transparent; color: var(--text); font: 700 12.5px/1.4 var(--font-ui); white-space: nowrap; }
.lvl-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.lvl-red { background: var(--down-soft); border-color: var(--down); }
.lvl-red .lvl-dot { background: var(--down); }
.lvl-yellow { background: var(--warn-soft); border-color: var(--warn); }
.lvl-yellow .lvl-dot { background: var(--warn); }
.lvl-green { background: var(--up-soft); border-color: var(--up); }
.lvl-green .lvl-dot { background: var(--up); }
.lvl-unknown { background: var(--bg-2); border-color: var(--line-2); color: var(--muted); }
.lvl-unknown .lvl-dot { background: var(--dim); }
.lvl-big { font-size: 16px; padding: 6px 14px 6px 12px; }
.lvl-big .lvl-dot { width: 11px; height: 11px; }
.flags { list-style: none; margin: 0; padding: 0; }
.flag { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.flag:last-child { border-bottom: 0; }
.flag-mark { width: 9px; height: 9px; margin-top: 7px; border-radius: 50%; flex: none; }
.flag-red .flag-mark { background: var(--down); }
.flag-yellow .flag-mark { background: var(--warn); }
.flag-green .flag-mark { background: var(--up); }
.flag-info .flag-mark { background: var(--dim); }
.flag-title { color: var(--text); }
.flag-says { color: var(--muted); }

/* ---------- avatars and coin pictures (ui.js avatar / coinImg) ---------- */
.ava { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 50%; border: 1px solid var(--line-2); color: var(--text); font: 700 12px/1 var(--font-ui); }
.ava-sm { width: 26px; height: 26px; font-size: 10px; }
.ava-md { width: 36px; height: 36px; }
.ava-lg { width: 64px; height: 64px; font-size: 22px; border-width: 2px; }
.tone-yellow { background: var(--warn-soft); color: var(--warn); }
.tone-green { background: var(--chip); color: var(--text); }
.tone-pink { background: var(--bg-3); color: var(--muted); }
.tone-blue { background: var(--brand-soft); color: var(--brand-hi); }
.coin-img { flex: none; border-radius: 10px; object-fit: cover; background: var(--bg-3); border: 1px solid var(--line-2); }
.coin-sm { width: 28px; height: 28px; }
.coin-md { width: 40px; height: 40px; }
.coin-lg { width: 56px; height: 56px; border-radius: 14px; }
.coin-fb { display: inline-flex; align-items: center; justify-content: center; color: var(--text); font: 700 11px/1 var(--font-ui); }
/* the badge of a coin with no picture: two tones and an angle picked from its mint; the real picture is laid over it */
span.coin-img.coin-fb.cb { position: relative; overflow: hidden; border: 0; background: linear-gradient(var(--cb-ang, 135deg), var(--cb-a, var(--cb-0)), var(--cb-b, var(--cb-0d))); box-shadow: inset 0 0 0 1px var(--glint-a14); }
span.coin-img.coin-fb.cb::after { content: ""; position: absolute; inset: 9%; border-radius: inherit; border: 1px solid var(--glint-a22); box-shadow: inset 0 0 10px var(--glint-a10); pointer-events: none; }
.cb > .cb-t { position: relative; z-index: 1; color: var(--cb-ink); font: 800 1.5em/1 var(--font-ui); letter-spacing: 0.01em; text-shadow: 0 1px 2px var(--shade-a45); }
.cb > img.cb-pic { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; max-width: none; border: 0; border-radius: inherit; object-fit: cover; background: var(--bg-3); opacity: 0; }
.cb.has-pic > img.cb-pic { opacity: 1; }
span.coin-img.coin-fb.cb.has-pic::after { display: none; }
.cb-a0 { --cb-a: var(--cb-0); } .cb-a1 { --cb-a: var(--cb-1); } .cb-a2 { --cb-a: var(--cb-2); } .cb-a3 { --cb-a: var(--cb-3); }
.cb-a4 { --cb-a: var(--cb-4); } .cb-a5 { --cb-a: var(--cb-5); } .cb-a6 { --cb-a: var(--cb-6); } .cb-a7 { --cb-a: var(--cb-7); }
.cb-b0 { --cb-b: var(--cb-0d); } .cb-b1 { --cb-b: var(--cb-1d); } .cb-b2 { --cb-b: var(--cb-2d); } .cb-b3 { --cb-b: var(--cb-3d); }
.cb-b4 { --cb-b: var(--cb-4d); } .cb-b5 { --cb-b: var(--cb-5d); } .cb-b6 { --cb-b: var(--cb-6d); } .cb-b7 { --cb-b: var(--cb-7d); }
.cb-r0 { --cb-ang: 135deg; } .cb-r1 { --cb-ang: 200deg; } .cb-r2 { --cb-ang: 45deg; }

/* a progress bar (ui.js bar): the width comes in through --w */
.bar { position: relative; display: block; width: 100%; height: 8px; border-radius: 999px; background: var(--bg-3); border: 1px solid var(--line); overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; width: var(--w, 0%); border-radius: 999px; background: linear-gradient(90deg, var(--brand-deep), var(--brand-hi)); }
.bar.near .bar-fill { background: linear-gradient(90deg, var(--brand), var(--heat-4)); }

/* ---------- dialogs: a bottom sheet on a phone, a centred box from 640 px ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; padding: 0; background: var(--scrim); animation: fadein 0.15s ease-out; }
.modal { width: 100%; max-height: 88vh; overflow: auto; padding: 16px 16px calc(18px + env(safe-area-inset-bottom, 0px)); border-radius: 16px 16px 0 0; border: 1px solid var(--line-2); border-bottom: 0; background: var(--bg-2); box-shadow: var(--shadow-pop); }
.modal-red { border-top: 2px solid var(--down); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.modal-title { margin: 0; font-size: 19px; }
.modal-body { font-size: 14px; }
.modal-actions { display: flex; flex-wrap: wrap-reverse; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.modal-actions .btn { flex: 1 1 140px; }
/* the phone bottom sheet for anything that is not a dialog (a panel that slides over the page) */
.sheet-bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 55; max-height: 86vh; overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px)); border-radius: 16px 16px 0 0; border: 1px solid var(--line-2); border-bottom: 0; background: var(--bg-2); box-shadow: var(--shadow-pop); }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom, 0px)); z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; max-width: 520px; width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line-2); border-left: 3px solid var(--brand); background: var(--bg-3); color: var(--text); font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-pop); transition: opacity 0.25s, transform 0.25s; }
.toast-error { border-left-color: var(--down); }
.toast-gain, .toast-ok { border-left-color: var(--up); }
.toast-warn { border-left-color: var(--warn); }
.toast.out { opacity: 0; transform: translateY(8px); }
.toast.toast-act { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; }
.toast-t { flex: 1 1 auto; min-width: 0; }
.toast-btns { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toast-btn { min-height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--chip); color: var(--brand-hi); font: 700 12.5px/1 var(--font-ui); white-space: nowrap; }
.toast-btn:hover { border-color: var(--brand); color: var(--text); }

/* ---------- widths ---------- */
@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .modal-wrap { align-items: center; padding: 16px; }
  .modal { max-width: 520px; border-radius: 16px; border-bottom: 1px solid var(--line-2); }
}
@media (min-width: 900px) {
  .nav { display: flex; }
  .sheet { padding: 26px 32px 40px; }
  .foot { padding-left: 32px; padding-right: 32px; }
  .toasts { left: auto; right: 20px; align-items: flex-end; }
}
/* under 900 px the top links are gone and the bottom bar is the tab bar: Trenches, Positions, Tracker, Rewards, More */
@media (max-width: 899px) {
  .bar3 { padding: 0 0 env(safe-area-inset-bottom, 0px); gap: 0; }
  .bar3-links { flex: 1 1 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; height: var(--tab-h); }
  .bar3-links a, .bar3-more { flex-direction: column; justify-content: center; gap: 4px; width: 100%; height: 100%; padding: 0 2px; border-radius: 0; font: 600 10.5px/1 var(--font-ui); }
  .bar3-links a:hover, .bar3-more:hover { background: none; }
  .bar3-links .ico { width: 20px; height: 20px; }
  .bar3-morewrap { display: block; width: 100%; height: 100%; }
  .bar3-menu { left: auto; right: 8px; }
  .bar3-right { position: absolute; right: 10px; bottom: calc(100% + 10px); margin: 0; }
  .bar3-lat, .bar3-x { display: none; }
}
/* the width contract under 560 px: the mark only, search as one icon button, the live pill as a dot */
@media (max-width: 559px) {
  .top { gap: 8px; padding: 0 10px 0 12px; }
  .logo { margin-right: 0; }
  .logo-word { display: none; }
  .top-search { flex: none; width: 32px; height: 32px; padding: 0; justify-content: center; border-color: transparent; background: none; }
  .top-search input, .top-search kbd { display: none; }
  .top-search .top-search-open { width: 32px; height: 32px; }
  .top-search .top-search-open .ico { width: 18px; height: 18px; }
  .top.search-open .top-search { position: absolute; inset: 6px 10px; z-index: 2; width: auto; height: auto; padding: 0 10px 0 2px; justify-content: flex-start; border-color: var(--brand); background: var(--bg-2); }
  .top.search-open .top-search input { display: block; font-size: 16px; }
  .top-right { margin-left: 0; }
  #slot-wallet { max-width: 132px; overflow: hidden; }
  .bar2 { padding: 0 10px; overflow: hidden; }
  #slot-trade { flex: 0 1 auto; overflow: hidden; }
  #live-pill { padding: 5px; border-color: transparent; background: none; }
  #live-pill .st-t { display: none; }
  .st-pill .st-sub { display: none; }
  .mock-long { display: none; }
  .mock-short { display: inline; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .top, .bar2, .bar3, .mockbar, .toasts { display: none; }
}
