@layer reset, tokens, base, chrome, parts, views, motion;

@import url('/css/chrome.css') layer(views);
@import url('/css/portraits.css') layer(views);
@import url('/css/inventory.css') layer(views);
@import url('/css/recap.css') layer(views);

@property --p { syntax: '<number>'; inherits: true; initial-value: 0; }

@font-face { font-family: 'Jersey'; src: url('/fonts/jersey.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Rubik'; src: url('/fonts/rubik.woff2') format('woff2'); font-weight: 300 900; font-display: swap; }

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body, h1, h2, h3, h4, p, figure, pre, dl, dd, ol, ul { margin: 0; }
  ol, ul { padding: 0; list-style: none; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { cursor: pointer; background: none; border: 0; padding: 0; }
  svg { display: block; }
  img, svg { max-width: 100%; }
  table { border-collapse: collapse; }
}

@layer tokens {
  :root {
    color-scheme: dark;
    --ink: #07060a;
    --void: #0c0b12;
    --stone-0: #15131c;
    --stone-1: #1c1926;
    --stone-2: #262231;
    --stone-3: #332e41;
    --stone-4: #463f58;
    --hi: #6a6084;
    --text: #f1ead9;
    --muted: #b3aac0;
    --faint: #7c7590;
    --gold: #f6c453;
    --gold-2: #c08a2c;
    --gold-3: #6e4a14;
    --up: #5ee586;
    --up-2: #1f7a3c;
    --down: #ff6b57;
    --down-2: #8c2418;
    --warn: #ffb547;
    --warn-2: #7a4c0e;
    --frozen: #8adcff;
    --frozen-2: #1d5a80;
    --arcane: #c38cff;
    --arcane-2: #5a2f99;
    --live: #ff3d2e;
    --line: #2e2939;
    --line-2: #463f58;

    --display: 'Jersey', 'Rubik', ui-monospace, monospace;
    --sans: 'Rubik', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

    --shadow-px: 2px 2px 0 var(--ink);
    --drop: 0 10px 30px -8px rgb(0 0 0 / 0.7);
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
    --fast: 120ms;
    --mid: 220ms;

    --gut: clamp(10px, 2.2vw, 24px);
    --bar-h: 64px;
  }
}

@layer base {
  html { background: var(--ink); scrollbar-color: var(--stone-4) var(--ink); }
  body {
    color: var(--text);
    font: 15px/1.45 var(--sans);
    font-feature-settings: 'tnum' 1;
    -webkit-font-smoothing: antialiased;
    min-height: 100dvh;
    overflow-x: hidden;
    background: radial-gradient(ellipse at 50% 0%, #1a1530 0%, var(--void) 55%, var(--ink) 100%) fixed;
  }
  ::selection { background: var(--arcane-2); color: #fff; }
  :focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
  a { color: var(--gold); text-decoration: none; }
  a:hover { color: #ffe39a; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
  h1, h2, h3, h4 { font-family: var(--sans); font-weight: 700; line-height: 1.15; text-wrap: balance; letter-spacing: 0.01em; }
  p { text-wrap: pretty; }
  code, .mono { font-family: var(--mono); font-size: 0.9em; }
  .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
  :root[data-hide] :is(.money, .spark, .chart-hide) { filter: blur(7px); user-select: none; }
  .muted { color: var(--muted); }
  .faint { color: var(--faint); }
  .up { color: var(--up); }
  .down { color: var(--down); }
  .warn { color: var(--warn); }
  .ice { color: var(--frozen); }
  .gold { color: var(--gold); }
  .px { font-family: var(--sans); }
  .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .wrap { overflow-wrap: anywhere; }
  .grow { flex: 1; }
  .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .stack { display: grid; gap: 10px; }
  [hidden] { display: none !important; }
}

@layer chrome {
  #world { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; z-index: 0; }
  :root.flat #world, :root.flat .plates { display: none; }
  .plates { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
  body.backdrop .plates { display: none; }

  .bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 30;
    display: flex; align-items: center; gap: 14px;
    height: var(--bar-h);
    padding: 0 var(--gut);
    background: linear-gradient(180deg, rgb(7 6 10 / 0.92) 0%, rgb(7 6 10 / 0.72) 70%, rgb(7 6 10 / 0) 100%);
  }
  .bar.scrolled { background: rgb(9 8 14 / 0.94); backdrop-filter: blur(8px); box-shadow: 0 2px 0 var(--ink); }
  .brand { display: flex; align-items: center; gap: 10px; flex: none; color: var(--text); }
  .brand:hover { text-decoration: none; color: var(--text); }
  .emblem { width: 40px; height: 40px; background: url('/img/emblem.svg') center / contain no-repeat; image-rendering: pixelated; filter: drop-shadow(0 0 10px rgb(246 196 83 / 0.35)); }
  .brand-word { font-family: var(--display); font-size: 30px; line-height: 1; letter-spacing: 0.04em; text-shadow: 3px 3px 0 var(--ink), 0 0 18px rgb(246 196 83 / 0.25); color: var(--gold); }
  .brand-word span { color: var(--text); }
  .tabs { display: flex; gap: 6px; margin-left: 10px; }
  .tab {
    display: flex; align-items: center; gap: 7px; padding: 7px 12px 6px;
    font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--muted);
    border: 2px solid transparent; position: relative;
    text-shadow: var(--shadow-px);
  }
  .tab:hover { color: var(--text); text-decoration: none; background: rgb(255 255 255 / 0.04); }
  .tab[aria-current='page'] {
    color: var(--gold);
    border-image: url('/img/frame-dark.svg') 4 / 8px / 0 stretch;
    background: rgb(20 17 28 / 0.85);
    background-clip: padding-box;
  }
  .tab[aria-current='page']::after {
    content: ''; position: absolute; left: 50%; bottom: -9px; width: 10px; height: 4px; translate: -50% 0;
    background: var(--gold); box-shadow: 0 0 10px var(--gold);
  }
  .tab .ico { width: 18px; height: 18px; }
  .tab .count { min-width: 20px; padding: 0 4px; font-size: 12px; line-height: 18px; text-align: center; background: var(--down); color: #fff; border: 2px solid var(--ink); }
  .tab .count.calm { background: var(--stone-4); }
  .alerts { display: flex; gap: 6px; flex: 1; justify-content: flex-end; min-width: 0; overflow: hidden; }
  .alert {
    display: flex; align-items: center; gap: 6px; padding: 4px 10px; white-space: nowrap;
    font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--text);
    border: 2px solid var(--ink); background: var(--stone-2);
    box-shadow: inset 2px 2px 0 rgb(255 255 255 / 0.12), inset -2px -2px 0 rgb(0 0 0 / 0.35);
    text-shadow: 1px 1px 0 var(--ink);
  }
  .alert:hover { text-decoration: none; filter: brightness(1.15); color: #fff; }
  .alert.bad { background: var(--down-2); animation: pulse-bad 1.6s ease-in-out infinite; }
  .alert.ice { background: var(--frozen-2); }
  .alert.warn { background: var(--warn-2); }
  .alert.ok { background: rgb(31 122 60 / 0.55); color: #d8ffe4; }
  .bar-end { display: flex; align-items: center; gap: 6px; flex: none; }
  .who { display: flex; align-items: center; gap: 6px; padding: 4px 8px; font-family: var(--sans); font-weight: 600; color: var(--text); }
  .who:hover { text-decoration: none; color: var(--gold); }
  .kbd { font-family: var(--sans); font-size: 11px; padding: 0 4px; border: 2px solid var(--stone-4); color: var(--muted); }

  .main { position: relative; z-index: 2; padding: calc(var(--bar-h) + 8px) var(--gut) 40px; display: grid; gap: 22px; }
  body.on-floor .main { padding: 0; gap: 0; }
  .main > *, .dash-grid > *, .output-grid > *, .two > *, .section { min-width: 0; }
  body.backdrop::before { content: ''; position: fixed; inset: 0; z-index: 1; pointer-events: none; background: radial-gradient(ellipse at 50% 30%, rgb(7 6 10 / 0.35), rgb(7 6 10 / 0.78) 75%); }
  .foot {
    position: relative; z-index: 2; display: flex; flex-wrap: wrap; gap: 6px 20px; justify-content: center;
    padding: 18px var(--gut) 28px; font-family: var(--sans); font-size: 12px; color: var(--faint);
    background: linear-gradient(180deg, transparent, rgb(7 6 10 / 0.9));
  }
  .foot .down { color: var(--down); }
}

@layer parts {
  .ico { width: 16px; height: 16px; flex: none; image-rendering: pixelated; shape-rendering: crispEdges; }
  .ico.lg { width: 24px; height: 24px; }
  .ico.xl { width: 32px; height: 32px; }

  .panel {
    position: relative;
    border: 8px solid transparent;
    border-image: url('/img/frame-stone.svg') 4 / 8px / 0 stretch;
    background: linear-gradient(180deg, rgb(32 28 44 / 0.94), rgb(20 18 28 / 0.96));
    background-clip: padding-box;
    box-shadow: var(--drop);
  }
  .panel.gold { border-image-source: url('/img/frame-gold.svg'); }
  .panel.red { border-image-source: url('/img/frame-red.svg'); }
  .panel.ice { border-image-source: url('/img/frame-ice.svg'); color: var(--text); }
  .panel.arcane { border-image-source: url('/img/frame-arcane.svg'); }
  .panel.dark { border-image-source: url('/img/frame-dark.svg'); }
  .panel.empty { padding: 22px; text-align: center; color: var(--muted); font-family: var(--sans); }
  .panel-head {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px 9px;
    border-bottom: 2px solid var(--ink); box-shadow: 0 2px 0 rgb(255 255 255 / 0.04);
    background: linear-gradient(180deg, rgb(255 255 255 / 0.05), transparent);
  }
  .panel-head h2, .panel-head h3 { font-size: 16px; color: var(--gold); text-shadow: var(--shadow-px); text-transform: uppercase; letter-spacing: 0.06em; }
  .panel-head .aside { margin-left: auto; display: flex; gap: 8px; align-items: center; }
  .panel-body { padding: 14px; }

  .title {
    display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
    font-family: var(--display); font-weight: 400; font-size: 34px; line-height: 1; letter-spacing: 0.03em;
    color: var(--gold); text-shadow: 3px 3px 0 var(--ink), 0 0 24px rgb(246 196 83 / 0.18); text-transform: uppercase;
  }
  .title .muted, .title small { font-family: var(--sans); font-size: 14px; text-transform: none; color: var(--muted); letter-spacing: 0; text-shadow: var(--shadow-px); }
  .section > .title { margin-bottom: 12px; }
  .ornament { height: 8px; margin: 2px 0 14px; background: linear-gradient(90deg, var(--gold-2) 0 6px, transparent 6px 10px, var(--gold-3) 10px) left / 100% 2px no-repeat; opacity: 0.8; }

  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: 36px; padding: 6px 14px 7px;
    font-family: var(--sans); font-weight: 600; font-size: 14px; color: var(--text); text-shadow: var(--shadow-px);
    background: linear-gradient(180deg, #514869, #3a3350);
    border: 2px solid var(--ink);
    box-shadow: inset 2px 2px 0 rgb(255 255 255 / 0.16), inset -2px -2px 0 rgb(0 0 0 / 0.35), 0 4px 0 var(--ink);
    translate: 0 0;
    transition: filter var(--fast), translate var(--fast), box-shadow var(--fast);
    white-space: nowrap;
  }
  .btn:hover { filter: brightness(1.18); color: #fff; text-decoration: none; }
  .btn:active { translate: 0 3px; box-shadow: inset 2px 2px 0 rgb(255 255 255 / 0.1), inset -2px -2px 0 rgb(0 0 0 / 0.35), 0 1px 0 var(--ink); }
  .btn:disabled { filter: grayscale(0.7) brightness(0.7); cursor: not-allowed; }
  .btn.sm { min-height: 30px; padding: 3px 10px 4px; font-size: 13px; }
  .btn.icon { padding: 3px; min-width: 32px; }
  .btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
  .btn.ghost:hover { background: rgb(255 255 255 / 0.07); }
  .btn.ghost:active { translate: 0 1px; }
  .btn.primary { background: linear-gradient(180deg, #f7cd63, #c58d2a); color: #2a1904; text-shadow: 1px 1px 0 rgb(255 240 190 / 0.6); }
  .btn.danger { background: linear-gradient(180deg, #d9473a, #8f2116); }
  .btn.ice { background: linear-gradient(180deg, #5bbbe8, #2a6f9c); }
  .btn.arm.armed { background: linear-gradient(180deg, #8adcff, #2e86bb); animation: shake 0.35s linear 2; }
  .btn.estop-arm { background: radial-gradient(circle at 40% 35%, #ff7a62, #b3170c 70%); border-radius: 0; min-width: 40px; min-height: 40px; box-shadow: inset 2px 2px 0 rgb(255 255 255 / 0.35), inset -2px -2px 0 rgb(0 0 0 / 0.4), 0 4px 0 var(--ink), 0 0 16px rgb(255 61 46 / 0.45); }
  .btn.estop-arm.armed { background: radial-gradient(circle at 40% 35%, #fff, #ff3d2e 60%); animation: shake 0.3s linear infinite; }
  .btn .arm-label:empty { display: none; }

  .chip {
    display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px 2px;
    font-family: var(--sans); font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap; color: var(--muted);
    background: rgb(0 0 0 / 0.35); border: 2px solid var(--stone-4);
  }
  .chip.up { color: var(--up); border-color: var(--up-2); }
  .chip.down, .chip.bad { color: var(--down); border-color: var(--down-2); }
  .chip.warn { color: var(--warn); border-color: var(--warn-2); }
  .chip.ice { color: var(--frozen); border-color: var(--frozen-2); }
  .chip.gold { color: var(--gold); border-color: var(--gold-3); }
  .chip .ico { width: 12px; height: 12px; }

  .tier { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px 2px; font-family: var(--sans); font-weight: 700; font-size: 12px; letter-spacing: 0.08em; border: 2px solid var(--ink); color: #fff; text-shadow: 1px 1px 0 var(--ink); }
  .tier.live { background: var(--live); box-shadow: 0 0 12px rgb(255 61 46 / 0.5); }
  .tier.live::before { content: ''; width: 6px; height: 6px; background: #fff; animation: blink 1.2s steps(2) infinite; }
  .tier.canary { background: var(--warn-2); color: var(--warn); }
  .tier.pretend { background: var(--stone-3); color: var(--muted); }

  .led { width: 10px; height: 10px; flex: none; background: var(--stone-4); border: 2px solid var(--ink); }
  .led.on { background: var(--up); box-shadow: 0 0 8px var(--up); }
  .led.on.beat { animation: beat 0.6s ease-out; }
  .led.ice { background: var(--frozen); box-shadow: 0 0 8px var(--frozen); }
  .led.bad { background: var(--down); box-shadow: 0 0 8px var(--down); animation: blink 1s steps(2) infinite; }
  .led.warn { background: var(--warn); }

  .seal { display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px 2px; font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--up); border: 2px solid var(--up-2); background: rgb(0 0 0 / 0.3); }
  .seal.bad { color: var(--down); border-color: var(--down-2); }
  .seal.unknown { color: var(--faint); border-color: var(--stone-4); }
  .seal .ico { width: 12px; height: 12px; }

  .note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border: 2px solid var(--ink); background: var(--stone-1); box-shadow: inset 4px 0 0 var(--stone-4); }
  .note.bad { background: linear-gradient(90deg, rgb(140 36 24 / 0.55), rgb(28 25 38 / 0.9)); box-shadow: inset 4px 0 0 var(--down); }
  .note.warn { background: linear-gradient(90deg, rgb(122 76 14 / 0.5), rgb(28 25 38 / 0.9)); box-shadow: inset 4px 0 0 var(--warn); }
  .note.ice { background: linear-gradient(90deg, rgb(29 90 128 / 0.55), rgb(28 25 38 / 0.9)); box-shadow: inset 4px 0 0 var(--frozen); }
  .note .ico { margin-top: 2px; }
  details.note { display: block; }
  details.note ul { margin: 8px 0 0 18px; font-size: 13px; color: var(--muted); }

  .quoted { quotes: '«\2009' '\2009»'; color: var(--warn); font-style: normal; }

  .lcd { display: inline-flex; align-items: center; justify-content: center; padding: 6px 8px; background: #0a0910; border: 2px solid var(--ink); box-shadow: inset 2px 2px 0 rgb(0 0 0 / 0.6), inset -2px -2px 0 rgb(255 255 255 / 0.05); }
  .dots .off { fill: #1b1924; }
  .dots .on { fill: var(--gold); filter: drop-shadow(0 0 2px var(--gold)); }
  .lcd.up .dots .on { fill: var(--up); filter: drop-shadow(0 0 2px var(--up)); }
  .lcd.down .dots .on { fill: var(--down); filter: drop-shadow(0 0 2px var(--down)); }
  .lcd.ice .dots .on { fill: var(--frozen); filter: drop-shadow(0 0 2px var(--frozen)); }
  .lcd.dim .dots .on { fill: #b7a27a; filter: none; }
  .lcd.blinking .face:first-child { animation: blink-face 0.3s steps(1) 1; }
  .lcd.blinking .face + .face { position: absolute; }

  .input {
    width: 100%; padding: 8px 10px; color: var(--text); font: 15px var(--sans);
    background: #0d0c13; border: 2px solid var(--ink); box-shadow: inset 2px 2px 0 rgb(0 0 0 / 0.6), 0 0 0 2px var(--stone-3);
  }
  .input:focus { outline: none; box-shadow: inset 2px 2px 0 rgb(0 0 0 / 0.6), 0 0 0 2px var(--gold-2); }
  textarea.input { resize: vertical; min-height: 90px; }

  .seg { display: inline-flex; border: 2px solid var(--ink); background: #0d0c13; }
  .seg button { padding: 4px 11px 5px; font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--muted); border-right: 2px solid var(--ink); }
  .seg button:last-child { border-right: 0; }
  .seg button:hover { color: var(--text); background: rgb(255 255 255 / 0.05); }
  .seg button[aria-pressed='true'] { color: #2a1904; background: linear-gradient(180deg, #f7cd63, #c58d2a); text-shadow: none; }

  .table-wrap { overflow-x: auto; border: 2px solid var(--ink); background: rgb(13 12 19 / 0.88); box-shadow: inset 0 0 0 2px var(--stone-2); }
  .table { width: 100%; font-size: 14px; }
  .table th { position: sticky; top: 0; text-align: left; padding: 8px 10px; font-family: var(--sans); font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold); background: var(--stone-2); border-bottom: 2px solid var(--ink); white-space: nowrap; text-shadow: 1px 1px 0 var(--ink); }
  .table td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
  .table tbody tr:nth-child(even) td { background: rgb(255 255 255 / 0.018); }
  .table tbody tr:hover td { background: rgb(246 196 83 / 0.06); }
  .table tbody tr.fresh td { animation: row-in 3.2s var(--ease-out); }
  .table .r { text-align: right; }
  .table .wide { min-width: 240px; }
  .rank { display: inline-grid; place-items: center; width: 26px; height: 26px; font-family: var(--display); font-size: 18px; color: var(--muted); background: var(--stone-2); border: 2px solid var(--ink); }
  .rank-1 { color: #2a1904; background: linear-gradient(180deg, #ffe08a, #c58d2a); box-shadow: 0 0 12px rgb(246 196 83 / 0.5); }
  .rank-2 { color: #1c1f26; background: linear-gradient(180deg, #e8edf5, #8c96a8); }
  .rank-3 { color: #2a1405; background: linear-gradient(180deg, #e6a26a, #8a4a1c); }
  .empty { padding: 18px; text-align: center; color: var(--faint); font-family: var(--sans); }
  .more { padding: 10px; text-align: center; }

  .fold summary { cursor: pointer; color: var(--muted); font-family: var(--sans); font-size: 13px; }
  .fold summary:hover { color: var(--text); }
  pre.block { margin-top: 8px; padding: 12px; max-height: 420px; overflow: auto; font: 12px/1.5 var(--mono); color: #d9d2c4; background: #0a0910; border: 2px solid var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }

  .menu-wrap { position: relative; display: inline-flex; }
  .menu { margin: 0; padding: 6px; min-width: 220px; border: 8px solid transparent; border-image: url('/img/frame-stone.svg') 4 / 8px / 0 stretch; background: #1c1926; background-clip: padding-box; color: var(--text); box-shadow: var(--drop); inset: auto; position: fixed; }
  .menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; text-align: left; font-family: var(--sans); font-weight: 600; font-size: 14px; }
  .menu-item:hover, .menu-item:focus-visible { background: rgb(246 196 83 / 0.12); color: var(--gold); }
  .menu-item.danger { color: var(--down); }
  .menu-sep { height: 2px; margin: 4px 0; background: var(--ink); }

  .toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 10px; width: min(420px, calc(100vw - 32px)); }
  .toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 8px solid transparent; border-image: url('/img/frame-stone.svg') 4 / 8px / 0 stretch; background: #1c1926; background-clip: padding-box; box-shadow: var(--drop); animation: toast-in var(--mid) var(--ease-pop); }
  .toast.good { border-image-source: url('/img/frame-gold.svg'); }
  .toast.good > .ico { color: var(--up); }
  .toast.bad { border-image-source: url('/img/frame-red.svg'); }
  .toast.bad > .ico { color: var(--down); }
  .toast strong { font-family: var(--sans); }
  .toast pre { margin-top: 6px; max-height: 160px; overflow: auto; font: 11px/1.4 var(--mono); white-space: pre-wrap; }

  dialog.sheet {
    width: min(560px, calc(100vw - 24px)); padding: 0; color: var(--text);
    border: 8px solid transparent; border-image: url('/img/frame-gold.svg') 4 / 8px / 0 stretch;
    background: linear-gradient(180deg, #24202f, #17141f); background-clip: padding-box; box-shadow: 0 30px 80px rgb(0 0 0 / 0.8);
  }
  dialog.sheet.wide { width: min(860px, calc(100vw - 24px)); }
  dialog.sheet[open] { animation: sheet-in var(--mid) var(--ease-pop); }
  dialog::backdrop { background: radial-gradient(ellipse at center, rgb(10 8 18 / 0.55), rgb(4 3 8 / 0.85)); backdrop-filter: blur(2px); }
  .sheet-head { padding: 14px 18px 10px; border-bottom: 2px solid var(--ink); }
  .sheet-head h2 { font-family: var(--display); font-weight: 400; font-size: 30px; color: var(--gold); text-shadow: 3px 3px 0 var(--ink); }
  .sheet-body { display: grid; gap: 12px; padding: 16px 18px; }
  .sheet-body .summary { padding: 12px; white-space: pre-wrap; font: 13px/1.55 var(--mono); background: #0a0910; border: 2px solid var(--ink); box-shadow: inset 4px 0 0 var(--gold-2); }
  .sheet-foot { display: flex; align-items: center; gap: 10px; padding: 12px 18px 16px; border-top: 2px solid var(--ink); }
  .field { display: grid; gap: 6px; font-family: var(--sans); font-size: 13px; color: var(--muted); }
  .danger-strip, .ice-strip { height: 10px; background: repeating-linear-gradient(-45deg, var(--down) 0 10px, var(--ink) 10px 20px); }
  .ice-strip { background: repeating-linear-gradient(-45deg, var(--frozen) 0 10px, var(--frozen-2) 10px 20px); }
  .hold {
    position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 8px 18px;
    font-family: var(--sans); font-weight: 700; color: #2a1904; border: 2px solid var(--ink);
    background: linear-gradient(180deg, #f7cd63, #c58d2a); box-shadow: inset 2px 2px 0 rgb(255 255 255 / 0.35), 0 4px 0 var(--ink);
    touch-action: none; user-select: none;
  }
  .hold.danger { background: linear-gradient(180deg, #d9473a, #8f2116); color: #fff; text-shadow: var(--shadow-px); }
  .hold::before { content: ''; position: absolute; inset: 0; transform-origin: left; scale: var(--p) 1; background: repeating-linear-gradient(90deg, rgb(255 255 255 / 0.55) 0 6px, rgb(255 255 255 / 0.35) 6px 8px); }
  .hold.snap::before { transition: scale var(--mid) var(--ease-out); }
  .hold.done { animation: flash 0.4s; }
  .hold > * { position: relative; }

  dialog.palette { width: min(620px, calc(100vw - 24px)); margin-top: 12vh; }
  .palette search { display: block; padding: 12px; }
  .pal-list { max-height: 50vh; overflow: auto; padding: 0 8px 10px; }
  .pal-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; text-align: left; font-family: var(--sans); font-weight: 600; }
  .pal-item[aria-selected='true'] { background: rgb(246 196 83 / 0.14); color: var(--gold); box-shadow: inset 4px 0 0 var(--gold); }
  .pal-item .kind { margin-left: auto; font-size: 12px; color: var(--faint); font-weight: 400; }

  .crumbs { display: flex; align-items: center; gap: 6px; font-family: var(--sans); font-size: 13px; color: var(--muted); }
  .crumbs a { color: var(--muted); }
  .crumbs a:hover { color: var(--gold); }
  .crumbs .ico { width: 12px; height: 12px; }

  .facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
  .fact { padding: 10px 12px; background: rgb(13 12 19 / 0.85); border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--stone-2); }
  .fact dt { font-family: var(--sans); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
  .fact dd { margin-top: 3px; font-size: 14px; overflow-wrap: anywhere; }

  .stat { display: grid; gap: 2px; padding: 12px 14px; background: rgb(13 12 19 / 0.82); border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--stone-2), inset 0 -24px 30px -24px rgb(246 196 83 / 0.08); }
  .stat dt { display: flex; align-items: center; gap: 6px; font-family: var(--sans); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
  .stat dd { font-family: var(--display); font-size: 34px; line-height: 1; letter-spacing: 0.02em; text-shadow: 2px 2px 0 var(--ink); }
  .stat dd .money { font-family: var(--display); }
  .stat small { font-family: var(--sans); font-size: 12px; color: var(--muted); }
  .stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
  .dash > .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  @media (max-width: 900px) { .dash > .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

  .bar-meter { position: relative; height: 14px; background: #0a0910; border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--stone-2); }
  .bar-meter > i { position: absolute; inset: 2px auto 2px 2px; width: calc((100% - 4px) * var(--v)); background: repeating-linear-gradient(90deg, var(--c, var(--up)) 0 8px, color-mix(in srgb, var(--c, var(--up)) 70%, #000) 8px 10px); box-shadow: 0 0 10px var(--c, var(--up)); }

  .money.up::before, .money.down::before { display: inline-block; }
}

@layer views {
  .camp { position: relative; height: 100svh; min-height: 560px; pointer-events: none; }
  .camp::after { content: ''; position: absolute; inset: auto 0 0; height: 140px; background: linear-gradient(180deg, rgb(7 6 10 / 0), rgb(7 6 10 / 0.88)); pointer-events: none; }
  .camp-hud { position: absolute; z-index: 1; inset: calc(var(--bar-h) + 8px) var(--gut) 16px; pointer-events: none; display: grid; grid-template-columns: minmax(300px, 370px) 1fr minmax(250px, 320px); grid-template-rows: 1fr auto; gap: 14px; }
  .camp-hud > * { pointer-events: auto; }
  .hud-status { grid-column: 1; grid-row: 2; align-self: end; }
  .hud-side { grid-column: 3; grid-row: 1 / 3; align-self: start; display: grid; gap: 12px; }
  .hud-bottom { grid-column: 2; grid-row: 2; align-self: end; display: flex; gap: 12px; align-items: flex-end; justify-content: space-between; pointer-events: none; }
  .hud-bottom > * { pointer-events: auto; }
  .hud-card .panel-body { padding: 8px 12px 10px; }
  .hud-rows { display: grid; gap: 2px; }
  .hud-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; border-bottom: 1px solid var(--line); }
  .hud-row:last-child { border-bottom: 0; }
  .hud-row a { color: var(--text); font-family: var(--sans); font-weight: 600; min-width: 0; }
  .hud-row a:hover { color: var(--gold); }
  #quests .hud-row, [data-key='quests'] .hud-row { grid-template-columns: auto 1fr; }
  .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hud-tip { display: flex; gap: 8px; align-items: center; padding: 6px 10px; font-size: 12px; color: var(--muted); background: rgb(7 6 10 / 0.6); border: 2px solid var(--ink); }
  .scroll-hint { display: flex; flex-direction: column; align-items: center; gap: 2px; font-family: var(--sans); font-size: 12px; color: var(--muted); text-shadow: var(--shadow-px); animation: bob 2s ease-in-out infinite; }
  .scroll-hint:hover { text-decoration: none; color: var(--gold); }

  .status-card { padding: 14px 16px; display: grid; gap: 10px; }
  .status-card h1 { font-family: var(--display); font-weight: 400; font-size: 32px; line-height: 1; color: var(--text); text-shadow: 3px 3px 0 var(--ink); overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
  .status-card .detail { margin-top: 6px; font-family: var(--sans); font-size: 13px; line-height: 1.4; color: var(--text); overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
  .status-card .mood { display: flex; gap: 12px; align-items: center; }
  .status-card .sub { font-family: var(--sans); font-size: 13px; color: var(--muted); }
  .status-card .ask { display: flex; gap: 8px; padding: 8px 10px; font-size: 13px; background: rgb(122 76 14 / 0.35); border: 2px solid var(--warn-2); }
  .gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .gauge { padding: 8px 10px; background: rgb(10 9 16 / 0.8); border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--stone-2); }
  .gauge dt { font-family: var(--sans); font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
  .gauge dd { font-family: var(--display); font-size: 28px; line-height: 1.05; text-shadow: 2px 2px 0 var(--ink); }
  .gauge small { font-family: var(--sans); font-size: 11px; color: var(--muted); }

  .plate {
    position: absolute; left: 0; top: 0; pointer-events: auto;
    display: grid; justify-items: center; gap: 3px;
    translate: -50% -100%;
    transition: opacity var(--mid);
    will-change: transform;
  }
  .plate-name {
    display: flex; align-items: center; gap: 7px; padding: 3px 9px 4px;
    font-family: var(--sans); font-weight: 700; font-size: 14px; color: var(--text); white-space: nowrap;
    background: rgb(8 7 12 / 0.78); border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px rgb(255 255 255 / 0.08);
    text-shadow: 1px 1px 0 var(--ink);
  }
  .plate:hover .plate-name, .plate.hot .plate-name { color: var(--gold); box-shadow: inset 0 0 0 2px var(--gold-2), 0 0 18px rgb(246 196 83 / 0.35); }
  .plate-name:hover { text-decoration: none; }
  .plate-line { display: flex; gap: 6px; align-items: center; font-family: var(--sans); font-size: 12px; font-weight: 600; padding: 2px 7px; background: rgb(8 7 12 / 0.7); border: 2px solid var(--ink); white-space: nowrap; }
  .plate-pin { width: 2px; height: 14px; background: linear-gradient(var(--gold), transparent); }
  .plate-act { padding: 1px 7px 2px; font-family: var(--sans); font-size: 12px; font-weight: 700; color: var(--gold); background: rgb(8 7 12 / 0.82); border: 2px solid var(--gold-2); white-space: nowrap; animation: act-in 0.5s var(--ease-pop); }
  .plate-act.down { color: var(--down); border-color: var(--down-2); }
  .plate-act.calm { color: var(--text); border-color: var(--stone-4); }
  .plate .tier { font-size: 10px; padding: 0 5px; }
  .plate.dim { opacity: 0.35; }
  .isle-label { position: absolute; left: 0; top: 0; translate: -50% 0; display: grid; justify-items: center; gap: 2px; pointer-events: none; opacity: 0.92; }
  .isle-name { font-family: var(--display); font-size: 28px; line-height: 1; letter-spacing: 0.06em; color: #fff1c9; text-shadow: 3px 3px 0 var(--ink), 0 0 16px rgb(0 0 0 / 0.7); white-space: nowrap; }
  .isle-venues { font: 700 10.5px/1 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); text-shadow: 1px 1px 0 var(--ink); }
  .mac-tag { position: absolute; left: 0; top: 0; translate: -50% -100%; display: grid; justify-items: center; gap: 3px; pointer-events: none; padding: 4px 8px; background: rgb(8 7 12 / 0.72); border: 1px solid rgb(255 255 255 / 0.12); white-space: nowrap; }
  .mac-tag strong { font: 700 12px/1 var(--sans); letter-spacing: 0.08em; color: var(--text); }
  .mac-tag span { font: 500 11px/1 var(--sans); color: var(--muted); }
  .mac-tag.down strong { color: var(--down); }
  .mac-tag.warn span { color: var(--gold); }
  .quay-board { position: absolute; left: 0; top: 0; translate: -50% -100%; margin-top: -12px; pointer-events: none; display: flex; align-items: baseline; gap: 7px; padding: 3px 9px; font: 700 12px/1.1 var(--sans); color: var(--text); background: rgb(8 7 12 / 0.84); border: 2px solid var(--edge); white-space: nowrap; animation: sheet-in 0.4s var(--ease-pop); --edge: var(--gold-2); }
  .quay-board::after { content: ''; position: absolute; left: 50%; top: 100%; width: 2px; height: 12px; background: var(--edge); }
  .quay-board .money { font-family: var(--display); font-size: 20px; color: var(--gold); text-shadow: 2px 2px 0 var(--ink); }
  .quay-board.down { --edge: var(--down-2); }
  .quay-board.down .money { color: var(--down); }
  :root[data-hide] .quay-board .money { display: none; }
  body:not(.on-floor) .plates > :not(.quay-board) { display: none; }
  .plates .tucked { visibility: hidden; }
  .float-gain { position: absolute; left: 0; top: 0; translate: -50% -100%; font-family: var(--display); font-size: 30px; color: var(--gold); text-shadow: 3px 3px 0 var(--ink), 0 0 16px rgb(246 196 83 / 0.6); animation: float-up 2.4s var(--ease-out) forwards; pointer-events: none; white-space: nowrap; }
  .float-gain.down { color: var(--down); text-shadow: 3px 3px 0 var(--ink); }
  .float-gain.sm { font-size: 20px; }
  .float-gain.xl { font-size: 44px; }
  .float-gain.xl:not(.down) { text-shadow: 3px 3px 0 var(--ink), 0 0 26px rgb(246 196 83 / 0.95); }
  .toast.go { cursor: pointer; }

  .codex { position: relative; z-index: 2; padding: 40px var(--gut) 20px; display: grid; gap: 26px; }
  .codex::before { content: ''; position: absolute; inset: 0 calc(50% - 50vw) 0; z-index: -1; background: linear-gradient(180deg, rgb(7 6 10 / 0.88) 0, rgb(9 8 14 / 0.97) 180px); pointer-events: none; }

  .two { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; }

  .racks { display: grid; grid-template-columns: repeat(auto-fit, minmax(520px, 1fr)); gap: 18px; }
  .rack-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 2px solid var(--ink); }
  .rack-head h2 { font-family: var(--display); font-weight: 400; font-size: 26px; color: var(--gold); text-shadow: 2px 2px 0 var(--ink); }
  .rack-head .aside { margin-left: auto; display: flex; gap: 8px; align-items: center; }
  .rack-units { display: grid; gap: 10px; padding: 12px; }
  .rack-empty { padding: 16px; color: var(--faint); font-family: var(--sans); }
  .idle-macs { display: flex; align-items: center; gap: 8px; font-family: var(--sans); font-size: 13px; }

  .unit { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; background: rgb(10 9 16 / 0.8); border: 2px solid var(--ink); box-shadow: inset 4px 0 0 hsl(var(--hue) 60% 55%), inset 0 0 0 2px var(--stone-2); }
  .unit[data-mood='frozen'] { box-shadow: inset 4px 0 0 var(--frozen), inset 0 0 0 2px var(--frozen-2); }
  .unit[data-mood='dead'], .unit[data-mood='error'] { box-shadow: inset 4px 0 0 var(--down), inset 0 0 0 2px var(--down-2); }
  .unit-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .unit-title a { font-family: var(--sans); font-weight: 700; font-size: 16px; color: var(--text); white-space: nowrap; }
  .unit-title a:hover { color: var(--gold); }
  .unit-title .kind { font-size: 12px; color: var(--faint); font-family: var(--sans); }
  .unit-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; font-size: 13px; color: var(--muted); }
  .beat { display: inline-flex; align-items: center; gap: 6px; }
  .unit-say { margin-top: 4px; font-size: 13px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52ch; }
  .unit-side { display: grid; justify-items: end; gap: 6px; max-width: 190px; }
  .unit-line .seal { white-space: nowrap; }
  .unit-out { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; font-size: 13px; }
  .unit-acts { display: flex; gap: 6px; }
  .lens-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }


  .portrait { position: relative; min-height: calc(62svh - var(--bar-h)); display: grid; grid-template-rows: auto 1fr; gap: 10px; pointer-events: none; }
  .portrait > * { pointer-events: auto; }
  .portrait .crumbs { justify-self: start; padding: 4px 10px; background: rgb(7 6 10 / 0.6); border: 2px solid var(--ink); }
  .portrait-hud { display: grid; grid-template-columns: minmax(320px, 420px) 1fr minmax(260px, 330px); gap: 16px; align-items: end; pointer-events: none; }
  .portrait-hud > * { pointer-events: auto; }
  .portrait-hud > .minimap { position: absolute; top: 0; right: 0; width: min(330px, 34vw); pointer-events: none; }
  .bay-head { padding: 14px 16px; display: grid; gap: 10px; }
  .bay-top { display: flex; gap: 14px; align-items: center; }
  .bay-title { display: grid; gap: 6px; min-width: 0; }
  .bay-title h1 { font-family: var(--display); font-weight: 400; font-size: 40px; line-height: 0.95; letter-spacing: 0.02em; color: var(--text); text-shadow: 3px 3px 0 var(--ink), 0 0 20px hsl(var(--hue) 70% 50% / 0.35); overflow-wrap: anywhere; }
  .say { font-size: 13px; color: var(--muted); }
  .bay-acts { display: flex; gap: 8px; flex-wrap: wrap; }
  .vitals { padding: 8px 0 0; display: grid; gap: 6px; }
  .vitals .fact { padding: 0 0 6px; background: none; border: 0; box-shadow: none; border-bottom: 1px solid var(--line); }
  .vitals .fact:last-child { border-bottom: 0; }
  .vitals .fact dd { font-size: 13px; }
  .below { position: relative; display: grid; gap: 26px; padding-top: 18px; }
  .below::before { content: ''; position: absolute; inset: -60px calc(50% - 50vw) -40px; z-index: -1; background: linear-gradient(180deg, rgb(7 6 10 / 0) 0, rgb(7 6 10 / 0.86) 90px, rgb(9 8 14 / 0.96) 260px); pointer-events: none; }
  .dash { display: grid; gap: 12px; }
  .dash-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; justify-content: space-between; }
  .dash-head .title { margin: 0; }
  .dash-controls { display: flex; gap: 10px; flex-wrap: wrap; }
  .stat.hero-stat { box-shadow: inset 0 0 0 2px var(--gold-3), inset 0 -30px 40px -30px rgb(246 196 83 / 0.25); }
  .stat .small-val { font-size: 22px; }
  .stat .small-val:not(.num) { overflow-wrap: anywhere; }
  .loss-guard { padding: 10px 14px; display: grid; gap: 8px; }
  .hero-band { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
  .hero-box { display: grid; align-content: start; gap: 6px; padding: 14px 16px 13px; min-width: 0; }
  .hero-label { display: flex; align-items: center; gap: 7px; font: 700 11px/1 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
  .hero-big { font-family: var(--display); font-size: 40px; line-height: 1; letter-spacing: 0.02em; text-shadow: 3px 3px 0 var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hero-big .money, .hero-big .num { font-family: var(--display); }
  .hero-big .treasure-big { font-size: inherit; }
  .hero-unit { font-family: var(--sans); font-size: 13px; color: var(--muted); text-shadow: none; letter-spacing: 0; }
  .hero-wait { font-size: 30px; }
  .hero-row { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 12.5px; color: var(--muted); }
  .hero-row b { font-weight: 600; color: var(--text); }
  .pace-row { display: flex; gap: 12px; }
  .book-row { display: grid; grid-template-columns: 74px 1fr auto auto; gap: 8px; align-items: center; width: 100%; }
  .book-row .bar-meter { height: 12px; }
  .pipeline { padding-bottom: 10px; }
  .pipe { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); padding: 4px 14px 10px; }
  .pipe-step { display: grid; gap: 5px; padding: 8px 12px; border-right: 2px solid var(--stone-3); min-width: 0; }
  .pipe-step:last-child { border-right: 0; }
  .pipe-label { font: 700 10.5px/1 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
  .pipe-num { font-family: var(--display); font-size: 30px; line-height: 1; text-shadow: 2px 2px 0 var(--ink); }
  .pipe-step .bar-meter { height: 11px; }
  .pipe-step small { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .why-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 2px 26px 4px; font-size: 12px; }
  @media (max-width: 1200px) { .hero-band { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
  @media (max-width: 640px) { .hero-band { grid-template-columns: 1fr; } }
  .dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .dash-grid .panel.wide { grid-column: 1 / -1; }
  .balance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
  .balance { display: grid; gap: 4px; }
  .engine { display: grid; gap: 22px; }
  .engine-group { display: grid; gap: 10px; }
  .engine-title { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--arcane); text-transform: uppercase; letter-spacing: 0.08em; text-shadow: var(--shadow-px); }
  .engine-stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .engine-stats .stat dd { font-size: 26px; }
  .engine-bars { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
  .bar-list { display: grid; gap: 6px; }
  .bar-row { display: grid; grid-template-columns: minmax(90px, 140px) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
  .bar-row .bar-meter { height: 12px; }
  @media (max-width: 1000px) {
    .portrait-hud { grid-template-columns: 1fr; }
    .portrait-hud > .minimap { position: static; width: min(330px, 100%); justify-self: end; }
    .dash-grid { grid-template-columns: 1fr; }
  }

  .chart { position: relative; }
  :root[data-hide] .chart canvas { filter: blur(8px); }
  body.world-hot { cursor: pointer; }
  .treasure { display: grid; gap: 2px; padding: 0 0 10px; margin-bottom: 8px; border-bottom: 2px solid var(--stone-3); }
  .treasure-big { font-family: var(--display); font-size: 40px; line-height: 1; color: var(--gold); text-shadow: 3px 3px 0 var(--ink), 0 0 18px rgb(246 196 83 / 0.3); }
  .hud-net { display: inline-flex; gap: 6px; justify-content: flex-end; }
  .hud-cap { font: 700 10px/1 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
  .no-usd { margin-left: 3px; font: 600 9px/1 var(--sans); color: var(--faint); letter-spacing: 0.04em; vertical-align: super; }
  :root.flat .camp { height: auto; min-height: 0; }
  :root.flat .camp::after { display: none; }
  :root.flat .camp-hud { position: static; padding: calc(var(--bar-h) + 8px) var(--gut) 0; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto; }
  :root.flat .hud-status { grid-row: 1; align-self: start; }
  :root.flat .hud-side { display: grid; grid-column: 2; grid-row: 1; }
  :root.flat .hud-bottom { display: none; }
  :root.flat .codex { padding-top: 22px; }
  :root.flat .codex::before { display: none; }
  .title .lens-row { font-family: var(--sans); font-size: 13px; text-transform: none; letter-spacing: 0; text-shadow: none; }
  :root.flat .scroll-hint { display: none; }
  .chart canvas { display: block; width: 100%; }
  .chart .chart-over { position: absolute; left: 0; top: 0; cursor: crosshair; }
  .chart-tip { position: absolute; z-index: 5; pointer-events: none; min-width: 150px; padding: 8px 11px; font-family: var(--sans); font-size: 12px; font-variant-numeric: tabular-nums; line-height: 1.55; background: rgb(14 11 22 / 0.95); border: 1px solid rgb(195 140 255 / 0.35); border-radius: 6px; box-shadow: 0 8px 22px rgb(0 0 0 / 0.55); white-space: nowrap; }
  .chart-tip b { display: block; margin-bottom: 2px; font-size: 12px; font-weight: 600; color: var(--gold); }
  .chart-tip i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; vertical-align: 0; }
  .chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-family: var(--sans); font-size: 12px; color: var(--muted); margin-top: 6px; }
  .chart-legend i { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 2px; vertical-align: 0; }
  .chart-legend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
  .chart-wrap { display: grid; gap: 4px; }
  .seg.sm button { padding: 2px 9px 3px; font-size: 12px; }
  .paged { display: grid; gap: 8px; }
  .scrollbox { max-height: 560px; overflow: auto; overscroll-behavior: contain; }
  .scrollbox thead th { position: sticky; top: 0; z-index: 1; background: #15121f; }
  .pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
  .pager .faint { margin: 0 6px; font-size: 12px; }
  .pager .btn[disabled] { opacity: 0.4; pointer-events: none; }
  .chain-dot { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
  .chain-dot::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--muted)); }
  .usd-sub { font-size: 11px; }
  .vol-row i { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; }
  .hero-big .arrow { font-size: 0.6em; vertical-align: 0.15em; }

  .output-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
  .output { padding: 12px 14px; display: grid; gap: 10px; }
  .output-head { display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; }
  .output-head h3 { flex: 1 0 100%; }
  .output-head h3 { font-size: 18px; color: var(--text); }
  .output-head .total { margin-left: auto; font-family: var(--display); font-size: 26px; }
  .wins { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .win { padding: 6px 8px; background: rgb(10 9 16 / 0.7); border: 2px solid var(--ink); }
  .win dt { font-family: var(--sans); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); }
  .win dd { font-family: var(--display); font-size: 22px; line-height: 1.1; }
  .win small { font-size: 11px; color: var(--faint); }

  .vault-line { display: grid; grid-template-columns: auto auto 1fr auto; gap: 10px; align-items: center; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }

  .timeline { padding: 6px 0; }
  .tl-row { display: grid; grid-template-columns: 74px auto 1fr; gap: 12px; align-items: center; padding: 7px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
  .tl-row:last-child { border-bottom: 0; }
  .stages { display: flex; gap: 3px; }
  .stage { padding: 0 4px; font-family: var(--sans); font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--faint); border: 2px solid var(--stone-3); }
  .stage.on { color: var(--up); border-color: var(--up-2); background: rgb(31 122 60 / 0.25); }
  .stage.bad { color: var(--down); border-color: var(--down-2); }
  .what { display: flex; gap: 10px; align-items: baseline; min-width: 0; }
  .what > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .corr { margin-left: auto; flex: none; }


  .hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: stretch; }
  .status-plate { display: flex; gap: 18px; align-items: center; padding: 16px 18px; border: 8px solid transparent; border-image: url('/img/frame-gold.svg') 4 / 8px / 0 stretch; background: linear-gradient(180deg, rgb(32 28 44 / 0.94), rgb(20 18 28 / 0.96)); background-clip: padding-box; box-shadow: var(--drop); }
  .status-plate h1 { font-family: var(--display); font-weight: 400; font-size: 34px; line-height: 1; color: var(--text); text-shadow: 3px 3px 0 var(--ink); }
  .status-plate p { margin-top: 6px; color: var(--muted); font-size: 14px; }
  .hero > .gauges { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
  .hero > .gauges .gauge { display: grid; align-content: center; gap: 6px; padding: 12px; background: rgb(13 12 19 / 0.88); }
  .hero .gauge dd .lcd { padding: 4px 6px; }
  .vaults { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
  .vault { padding: 12px 14px; display: grid; gap: 8px; }
  .vault[data-frozen] { border-image-source: url('/img/frame-ice.svg'); }
  .vault-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .vault-head a strong, .vault-head strong { font-family: var(--sans); font-size: 16px; color: var(--text); }
  .vault .vault-line { display: flex; gap: 8px; flex-wrap: wrap; border: 0; padding: 0; }
  .addr { font: 12px var(--mono); color: var(--muted); overflow-wrap: anywhere; padding: 6px 8px; background: #0a0910; border: 2px solid var(--ink); }
  .crew { display: grid; gap: 10px; }
  .crew-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; }
  .crew-row h3 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--faint); }
  .prompt { margin-top: 4px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ship { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
  .ship code { color: var(--gold); }
  .ship .s { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .line { display: grid; gap: 0; position: relative; }
  .line::before { content: ''; position: absolute; left: 15px; top: 10px; bottom: 10px; width: 4px; background: repeating-linear-gradient(180deg, var(--gold-2) 0 8px, transparent 8px 12px); }
  .station { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 8px 0; position: relative; }
  .station-dot { width: 34px; height: 34px; display: grid; place-items: center; background: var(--stone-2); border: 2px solid var(--ink); box-shadow: inset 0 0 0 2px var(--gold-3); color: var(--gold); }
  .station[data-kind='error'] .station-dot { color: var(--down); box-shadow: inset 0 0 0 2px var(--down-2); }
  .station-head { display: flex; gap: 10px; align-items: baseline; font-family: var(--sans); }
  .station-head strong { color: var(--gold); text-transform: uppercase; letter-spacing: 0.06em; }
  .note.good { background: linear-gradient(90deg, rgb(31 122 60 / 0.4), rgb(28 25 38 / 0.9)); box-shadow: inset 4px 0 0 var(--up); display: grid; }
  .lock-plate { display: grid; gap: 16px; justify-items: center; padding: 26px 22px; }
  .lock-plate h1 { font-family: var(--display); font-weight: 400; font-size: 40px; color: var(--gold); text-shadow: 3px 3px 0 var(--ink); }
  .heat { display: none; }
  @media (max-width: 900px) {
    .hero { grid-template-columns: 1fr; }
    .vaults { grid-template-columns: 1fr; }
  }

  .lock { min-height: 100svh; display: grid; place-items: center; padding: 20px; }
  .lock-card { width: min(460px, 100%); padding: 26px; display: grid; gap: 16px; justify-items: center; text-align: center; }
  .lock-card h1 { font-family: var(--display); font-weight: 400; font-size: 44px; color: var(--gold); text-shadow: 3px 3px 0 var(--ink); }

  @media (max-width: 1100px) {
    .camp-hud { grid-template-columns: minmax(280px, 340px) 1fr; }
    .hud-side { display: none; }
    .hud-bottom { grid-column: 2; }
  }
  @media (max-width: 760px) {
    :root { --bar-h: 56px; }
    .tabs .tab span:not(.count) { display: none; }
    .brand-word { display: none; }
    .camp { height: 78svh; min-height: 460px; }
    .camp-hud { grid-template-columns: 1fr; inset: calc(var(--bar-h) + 4px) 10px 10px; }
    .hud-bottom { display: none; }
    .bar { gap: 6px; }
    .tabs { margin-left: 0; gap: 2px; }
    .tab { padding: 6px 8px; }
    .bar-end .kbd, .bar-end .who .name { display: none; }
    .hud-status { max-width: 100%; }
    .status-card h1 { font-size: 24px; }
    .racks, .two { grid-template-columns: 1fr; }
    .unit { grid-template-columns: 1fr; }
    .unit > .persona { display: none; }
    .unit-side { justify-items: start; }
    .alerts .alert:nth-child(n + 2) { display: none; }
    .plate-line, .plate .tier { display: none; }
    .isle-name { font-size: 20px; }
    .portrait-hud > .bay-head { margin-top: 40svh; }
    .hero > .gauges { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .hero .gauge { min-width: 0; overflow: hidden; }
    .hero .gauge dd { font-size: 22px; }
    .tl-row { grid-template-columns: auto minmax(0, 1fr); row-gap: 4px; }
    .tl-row .what { grid-column: 1 / -1; }
  }
}

@layer motion {
  @keyframes pulse-bad { 50% { box-shadow: inset 2px 2px 0 rgb(255 255 255 / 0.12), 0 0 14px rgb(255 107 87 / 0.7); } }
  @keyframes blink { 50% { opacity: 0.2; } }
  @keyframes beat { 0% { scale: 1.6; box-shadow: 0 0 16px var(--up); } 100% { scale: 1; } }
  @keyframes shake { 25% { translate: -2px 0; } 75% { translate: 2px 0; } }
  @keyframes toast-in { from { translate: 0 20px; opacity: 0; } }
  @keyframes sheet-in { from { scale: 0.92; opacity: 0; } }
  @keyframes flash { 50% { filter: brightness(1.8); } }
  @keyframes bob { 50% { translate: 0 5px; } }
  @keyframes float-up { 0% { opacity: 0; translate: -50% -60%; scale: 0.6; } 12% { opacity: 1; scale: 1.15; } 25% { scale: 1; } 100% { opacity: 0; translate: -50% -260%; } }
  @keyframes blink-face { 0% { opacity: 0; } }
  @keyframes row-in { 0% { background: rgb(246 196 83 / 0.38); box-shadow: inset 0 0 0 1px rgb(246 196 83 / 0.5); } 100% { background: transparent; } }
  @keyframes act-in { 0% { opacity: 0; scale: 0.6; translate: 0 6px; } 60% { scale: 1.08; } }
  @keyframes float-fade { 0% { opacity: 0; } 15%, 70% { opacity: 1; } 100% { opacity: 0; } }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
    .float-gain { animation: float-fade 2.4s var(--ease-out) forwards !important; }
  }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 160ms; }
}
