@font-face { font-family: "Geist"; font-weight: 400; font-style: normal; font-display: swap; src: url(../assets/fonts/geist-400.woff2) format("woff2"); }
@font-face { font-family: "Geist"; font-weight: 500; font-style: normal; font-display: swap; src: url(../assets/fonts/geist-500.woff2) format("woff2"); }
@font-face { font-family: "Geist"; font-weight: 600; font-style: normal; font-display: swap; src: url(../assets/fonts/geist-600.woff2) format("woff2"); }
@font-face { font-family: "Rajdhani"; font-weight: 500; font-style: normal; font-display: swap; src: url(../assets/fonts/rajdhani-500.woff2) format("woff2"); }
@font-face { font-family: "Rajdhani"; font-weight: 600; font-style: normal; font-display: swap; src: url(../assets/fonts/rajdhani-600.woff2) format("woff2"); }
@font-face { font-family: "Rajdhani"; font-weight: 700; font-style: normal; font-display: swap; src: url(../assets/fonts/rajdhani-700.woff2) format("woff2"); }

:root {
  --canvas: #04080E;
  --panel: #09121C;
  --panel-hi: #0D1926;
  --well: #0E1A27;
  --line: rgba(160, 190, 220, 0.09);
  --line-strong: rgba(160, 190, 220, 0.18);
  --ink: #F2F5F9;
  --muted: #899BAA;
  --dim: #74879A;
  --gold: #D4AF37;
  --gold-soft: rgba(212, 175, 55, 0.16);
  --on: #2FA4DE;              /* engaged / powered: the one color a theme changes */
  --on-soft: color-mix(in srgb, var(--on) 14%, transparent);
  --on-line: color-mix(in srgb, var(--on) 55%, transparent);
  --on-edge: color-mix(in srgb, var(--on) 35%, transparent);
  --canvas-glow: #0A1522;
  --hull-hue: 168deg;          /* rotates the sepia-toned hull render into the theme's hue */
  --crest: none;
  --alert: #E2554B;
  --alert-soft: rgba(226, 85, 75, 0.16);
  --r-panel: 14px;
  --r-ctl: 9px;
  --gap: 8px;                  /* gutter between tiles */
  --display: "Rajdhani", "Geist", sans-serif;
  --num: var(--display);       /* readouts: a style can give numbers their own face */
  --body: "Geist", system-ui, sans-serif;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t-state: 500ms;            /* every stream-driven transition: ones that start together end in one frame */
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.035) inset, 0 8px 20px -12px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% -10%, var(--canvas-glow) 0%, var(--canvas) 60%) fixed, var(--canvas);
  color: var(--ink);
  font: 400 15px/1.35 var(--body);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
::selection { background: var(--gold); color: var(--canvas); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; text-align: inherit; }

.ico { width: 1.15em; height: 1.15em; flex: none; fill: currentColor; vertical-align: -0.18em; }

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  gap: 12px;
}

/* ---------- top bar ---------- */
.bar { display: flex; align-items: center; gap: 12px; min-height: 46px; }
.bar > img { width: 36px; height: 36px; }
.who { display: grid; min-width: 0; flex: 1; }
.ship-name { font: 700 26px/1 var(--display); letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ship-maker { color: var(--muted); font-size: 12.5px; margin-top: 3px; white-space: nowrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 10px 14px;
  border-radius: 999px; background: var(--panel-hi); border: 1px solid var(--line-strong);
  font: 700 13px/1 var(--display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
  white-space: nowrap;
}
.chip .ico { width: 17px; height: 17px; }
button.chip { cursor: pointer; transition: transform 120ms var(--ease), color 200ms, border-color 200ms; }
button.chip:active { transform: scale(0.96); }
button.chip:disabled { opacity: 0.4; cursor: default; }
#role[data-role="pilot"], #role[data-role="gunner"], #role[data-role="crew"] { color: var(--ink); border-color: var(--on-line); }
#role[data-role="pilot"] .ico, #role[data-role="gunner"] .ico, #role[data-role="crew"] .ico { color: var(--on); }
#link[data-link="live"] { color: var(--ink); }
#link[data-link="live"] .ico { color: var(--on); }
#ack { color: var(--canvas); background: var(--gold); border-color: var(--gold); }
#ack[data-n="0"] { display: none; }

/* ---------- deck: every widget is a tile ---------- */
.deck { min-height: 0; display: flex; flex-direction: column; gap: var(--gap); }
.deck > .w {
  position: relative; min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--panel-hi), var(--panel) 46%);
  border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow);
}
/* A tile's content lives in .wi. On the grid it is a fixed, size-contained box: a grid item can never be a
   relayout boundary, so without it every digit the stream changes would re-lay-out the whole panel. */
.wi { display: contents; }
.deck > .w > .wi {
  flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 11px 12px;
  container-type: inline-size;
}
/* Tablet-sized screens: a grid that always fills the screen, 24 x 24 held sideways and 16 x 40 held
   upright (cells come out about the same size both ways). js/app.js picks it and sets <html data-deck>. */
[data-deck="land"] { --cols: 24; --rows: 24; }
[data-deck="port"] { --cols: 16; --rows: 40; }
[data-deck="land"] .deck, [data-deck="port"] .deck {
  display: grid; gap: 0; margin: calc(var(--gap) / -2);
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
}
[data-deck="land"] .deck > .w, [data-deck="port"] .deck > .w { margin: calc(var(--gap) / 2); }
[data-deck="land"] .deck > .w > .wi, [data-deck="port"] .deck > .w > .wi { position: absolute; inset: 0; container-type: size; contain: strict; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none; }
.label { font: 600 12px/1 var(--display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.label .ico { width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; }
.unit { color: var(--muted); font-size: 0.6em; letter-spacing: 0.06em; margin-left: 3px; font-weight: 600; }
/* Only transform and opacity animate on the panel: the compositor runs those without the main thread, so a
   stream update never keeps the tablet repainting. State colors switch at once. */
[data-key] { cursor: pointer; transition: transform 120ms var(--ease); }
[data-key]:active { transform: scale(0.97); }

/* ---------- body / vitals ---------- */
.body {
  position: relative; flex: 1; min-height: 0; display: grid; place-items: center; border-radius: var(--r-ctl);
  background: radial-gradient(60% 55% at 50% 45%, color-mix(in srgb, var(--on) 10%, transparent), transparent 70%);
}
.body .fig {
  --tint: var(--on);
  width: 100%; height: 100%;
  background: var(--tint);
  -webkit-mask: var(--fig) center / contain no-repeat; mask: var(--fig) center / contain no-repeat;
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--tint) 45%, transparent));
  animation: pulse var(--beat, 1s) ease-in-out infinite;
}
.body .fig[data-level="low"] { --tint: var(--gold); }
.body .fig[data-level="crit"] { --tint: var(--alert); }
.body .fig[data-level="none"] { --tint: var(--dim); animation: none; }
@keyframes pulse { 0%, 100% { opacity: 0.9; } 12% { opacity: 1; transform: scale(1.012); } 30% { opacity: 0.93; transform: none; } }
.body .fallback { color: var(--dim); }
.body .fallback .ico { width: 140px; height: 140px; }
.body:not(.no-fig) .fallback, .body.no-fig .fig { display: none; }
.hp { position: absolute; left: 2px; top: 2px; display: grid; gap: 4px; }
.hp b { font: 700 40px/0.9 var(--num); }
.hp b[data-level="low"] { color: var(--gold); }
.hp b[data-level="crit"] { color: var(--alert); }
.bpm { position: absolute; right: 2px; top: 2px; display: grid; gap: 4px; justify-items: end; }
.bpm b { font: 700 24px/1 var(--num); display: inline-flex; align-items: center; gap: 6px; }
.bpm .ico { color: var(--alert); animation: pulse var(--beat, 1s) ease-in-out infinite; }

.tiles { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: minmax(0, 1fr); gap: 10px 16px; align-items: center; }
.tile { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; row-gap: 8px; align-items: center; border-radius: var(--r-ctl); }
.tile .ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--on-soft); color: var(--on); }
.tile .ic .ico { width: 18px; height: 18px; }
.tile .v { font: 700 21px/1 var(--num); }
.tile .v small { font: 600 11px/1 var(--display); color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; display: block; margin-bottom: 4px; }
.tile .meter { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: rgba(255,255,255,0.06); overflow: hidden; }
.tile .meter i { display: block; height: 100%; transform-origin: left; transform: scaleX(0); background: var(--on); border-radius: 4px; transition: transform var(--t-state) var(--ease); }
.tile[data-level="low"] .ic { background: var(--gold-soft); color: var(--gold); }
.tile[data-level="low"] .meter i { background: var(--gold); }
.tile[data-level="crit"] .ic { background: var(--alert-soft); color: var(--alert); }
.tile[data-level="crit"] .meter i { background: var(--alert); }
.tile[data-level="crit"] .v { color: var(--alert); }
/* a wide, short tile lines the four up; follows the size rule in js/widgets/vitals.js */
@container (min-width: 470px) and (max-height: 104px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.deck > .w-wallet > .wi { padding-block: 6px; }
.wallet { flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-radius: var(--r-ctl); }
.wallet b { font: 700 22px/1 var(--num); white-space: nowrap; }
.wallet .label { white-space: nowrap; }

/* ---------- ship ---------- */
.deck > .w-plan > .wi, .deck > .w-env > .wi { padding: 0; }
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.crest-mark { position: absolute; width: 56%; aspect-ratio: 1; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--crest) center/contain no-repeat; opacity: 0.07; pointer-events: none; }
.scan { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(50% 45% at 50% 50%, color-mix(in srgb, var(--on) 8%, transparent), transparent 70%); }
/* fit box: the band between the top and bottom callouts, full width; every ship fits inside it whole */
.hull { position: absolute; inset: 92px 18px; display: flex; align-items: center; justify-content: center; }
.hull img {
  width: 100%; height: 100%; object-fit: contain;
  filter: grayscale(1) sepia(0.5) hue-rotate(var(--hull-hue)) saturate(1.6) brightness(0.78) contrast(1.2) drop-shadow(0 18px 30px rgba(0,0,0,0.55));
}
.hull img[hidden] { display: none; }
.hull[data-hit="true"] img { filter: grayscale(1) sepia(1) saturate(4) hue-rotate(-40deg) brightness(0.72) contrast(1.15); }
.hull[data-hit="true"][data-flash="true"] img { animation: hullhit 1s steps(2, jump-none) infinite; }
@keyframes hullhit { 50% { opacity: 0.55; } }
.hull .no-art { width: 100%; height: 100%; display: grid; grid-template-rows: 1fr auto; gap: 10px; justify-items: center; font: 600 15px/1.4 var(--display); letter-spacing: 0.12em; color: var(--dim); text-transform: uppercase; text-align: center; }
.hull .no-art[hidden] { display: none; }
.hull .no-art i { width: 100%; height: 100%; background: var(--muted); -webkit-mask: url(../assets/art/ship-mask.png) center / contain no-repeat; mask: url(../assets/art/ship-mask.png) center / contain no-repeat; opacity: 0.55; }

.callout {
  position: absolute; min-width: 172px; padding: 10px 13px; border-radius: 12px;
  /* solid enough to read over the hull without a backdrop blur: four blurred callouts doubled the cost of
     every frame on the tablet */
  background: color-mix(in srgb, var(--panel-hi) 92%, transparent);
  border: 1px solid var(--line-strong); display: grid; grid-template-columns: auto 1fr; column-gap: 11px; row-gap: 4px; align-items: center;
}
.callout .ic { grid-row: span 3; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: rgba(255,255,255,0.04); color: var(--muted); transition: transform 400ms var(--ease); }
.callout .ic .ico { width: 21px; height: 21px; }
.callout .state { font: 700 21px/1 var(--display); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.callout .sub { font-size: 12px; color: var(--muted); }
.callout .sub:empty { display: none; }
.callout[data-on="true"] { border-color: var(--on-line); }
.callout[data-on="true"] .state { color: var(--ink); }
.callout[data-on="true"] .ic { background: var(--on-soft); color: var(--on); }
.callout[data-on="unknown"] { border-color: var(--line); background: color-mix(in srgb, var(--panel-hi) 50%, transparent); }
.callout[data-on="unknown"] .state { color: var(--dim); font-size: 14px; letter-spacing: 0.12em; }
.callout.tl { top: 12px; left: 12px; } .callout.tr { top: 12px; right: 12px; }
.callout.bl { bottom: 12px; left: 12px; } .callout.br { bottom: 12px; right: 12px; }
[data-c="gear"][data-on="false"] .ic { transform: rotate(-18deg); }
@container (max-width: 520px) {
  .hull { inset: 70px 10px; }
  .callout { min-width: 0; max-width: calc(50% - 16px); padding: 8px 10px; column-gap: 8px; }
  .callout .ic { width: 30px; height: 30px; border-radius: 9px; }
  .callout .ic .ico { width: 17px; height: 17px; }
  .callout .state { font-size: 17px; }
  .callout[data-on="unknown"] .state { font-size: 12px; }
  .callout .sub { display: none; }
}

.deck > .w-power > .wi, .deck > .w-annun > .wi, .deck > .w-master > .wi { padding: 8px; }
.power { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 5px; }
.pw {
  display: grid; justify-items: center; align-content: center; gap: 5px; min-width: 0; padding: 4px 2px; border-radius: var(--r-ctl);
  font: 700 11px/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim);
  background: rgba(255,255,255,0.025); border: 1px solid var(--line);
}
.pw span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw .ico { width: 17px; height: 17px; }
.pw[data-on="true"] { color: var(--ink); background: var(--on-soft); border-color: var(--on-edge); }
.pw[data-on="true"] .ico { color: var(--on); }
@container (max-width: 500px) { .power { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@container (max-width: 280px) { .power { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@container (max-height: 44px) { .pw span { display: none; } }
@container (max-width: 500px) and (max-height: 84px) { .pw span { display: none; } }
@container (max-width: 280px) and (max-height: 130px) { .pw span { display: none; } }

.annun { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 5px; }
.an {
  display: grid; place-items: center; min-height: 30px; font: 700 14.5px/1 var(--display); letter-spacing: 0.08em; border-radius: 8px;
  border: 1px solid var(--line); color: var(--dim); background: rgba(0,0,0,0.25); box-shadow: 0 1px 0 rgba(0,0,0,0.5) inset;
}
.an[data-s="NOMINAL"] { color: var(--muted); border-color: var(--line-strong); }
:root .an:is([data-s="MINOR_ON"], [data-s="MINOR_FLASHING"]) { background: var(--gold); border-color: var(--gold); color: var(--canvas); box-shadow: 0 6px 18px -6px rgba(212,175,55,0.6); }
:root .an:is([data-s="MAJOR_ON"], [data-s="MAJOR_FLASHING"]) { background: var(--alert); border-color: var(--alert); color: var(--canvas); box-shadow: 0 6px 18px -6px rgba(226,85,75,0.7); }
.an[data-s$="FLASHING"] { animation: blink 1s steps(2, jump-none) infinite; }
@keyframes blink { 50% { opacity: 0.32; } }
@container (max-width: 460px) { .annun { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

/* ---------- flight ---------- */
.w-speed > .wi { justify-content: space-between; }
.speedrow { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.big { font: 700 60px/0.86 var(--num); letter-spacing: -0.01em; font-size: clamp(40px, 40cqh, 120px); white-space: nowrap; }
.big .unit { font-size: 16px; }
.gchip { font: 700 15px/1 var(--num); padding: 7px 10px; border-radius: var(--r-ctl); background: var(--well); color: var(--muted); white-space: nowrap; }
.gchip b { color: var(--ink); }
.mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini div { display: grid; gap: 5px; }
.mini b { font: 700 18px/1 var(--num); white-space: nowrap; }
.ifcs { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: minmax(0, 1fr); gap: 6px; }
.mode {
  display: flex; align-items: center; gap: 7px; padding: 0 9px; min-height: 32px; border-radius: var(--r-ctl); min-width: 0;
  font: 700 13px/1 var(--display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim);
  background: rgba(255,255,255,0.02); border: 1px solid var(--line);
}
.mode .led { margin-left: auto; width: 26px; height: 15px; border-radius: 999px; background: rgba(255,255,255,0.08); position: relative; flex: none; }
.mode .led::after { content: ""; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%; background: var(--dim); transition: transform 260ms var(--ease); }
.mode[data-on="true"] { color: var(--ink); border-color: var(--on-edge); background: var(--on-soft); }
.mode[data-on="true"] .led { background: color-mix(in srgb, var(--on) 45%, transparent); }
.mode[data-on="true"] .led::after { transform: translateX(11px); background: var(--ink); }
.mode[data-on="na"] { opacity: 0.45; }
.mode .ico { width: 16px; height: 16px; }
@container (max-width: 250px) { .mode .led, .mode .ico, .master > .label { display: none; } .mode { justify-content: center; } }
@container (min-width: 460px) { .ifcs { grid-template-columns: repeat(3, 1fr); } }
@container (min-width: 800px) { .ifcs { grid-template-columns: repeat(6, 1fr); } }
.deck > .w-fuel > .wi { justify-content: space-evenly; }
.gauge { display: grid; grid-template-columns: 18px 64px minmax(0, 1fr) 42px; align-items: center; gap: 8px; }
.gauge .ico { color: var(--muted); }
.gauge .track { height: 8px; border-radius: 8px; background: var(--well); position: relative; overflow: hidden; }
.gauge .fill { position: absolute; inset: 0; border-radius: 8px; transform: scaleX(0); transform-origin: left; background: var(--on); transition: transform var(--t-state) var(--ease); }
.gauge[data-level="low"] .fill { background: var(--gold); }
.gauge[data-level="crit"] .fill { background: var(--alert); }
.gauge b { font: 700 16px/1 var(--num); text-align: right; }
.gauge[data-na] b, .gauge[data-na] .label { color: var(--dim); }
.wlist { flex: 1; min-height: 0; overflow: auto; display: grid; gap: 6px; align-content: start; }
.wpn { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: var(--r-ctl); background: var(--well); }
.wpn .ico { color: var(--dim); }
.wpn[data-on="true"] .ico { color: var(--on); }
.wpn span { font: 600 15px/1.1 var(--display); letter-spacing: 0.03em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.wpn em { font: 700 11px/1 var(--display); letter-spacing: 0.12em; font-style: normal; color: var(--dim); text-transform: uppercase; }
.wpn[data-on="true"] em { color: var(--on); }
.cms { display: flex; gap: 8px; flex: none; }
.cms:empty { display: none; }
.cms > div { flex: 1; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-ctl); background: var(--well); min-width: 0; }
.cms .ico { color: var(--muted); }
.cms b { font: 700 20px/1 var(--num); margin-left: auto; }
.empty { color: var(--dim); font: 600 13px/1.4 var(--display); letter-spacing: 0.08em; text-transform: uppercase; padding: 6px 0; }

.flist { flex: 1; overflow: auto; min-height: 0; display: grid; align-content: start; gap: 2px; }
.fi { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 9px; cursor: pointer; }
.fi:hover { background: rgba(255,255,255,0.03); }
.fi .ico { width: 16px; height: 16px; color: var(--muted); }
.fi span { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.fi span b { font-weight: 600; color: var(--ink); }
.fi time { font: 600 12px/1 var(--display); color: var(--dim); letter-spacing: 0.06em; }
.fi.new { animation: slidein var(--t-state) var(--ease); }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } }

/* change highlight: flash once, hold gold until tapped */
.changed { border-color: var(--gold) !important; box-shadow: 0 0 0 1px var(--gold), 0 8px 22px -10px rgba(212,175,55,0.7) !important; }
/* the flash is a gold layer that fades out (opacity only), laid over the element */
/* core.js flash() swaps data-flash between a and b: a new animation name replays the fade on the compositor,
   with no forced reflow (a script animation on a pseudo-element would run on the main thread) */
.changed:not(.callout) { position: relative; }
.changed[data-flash]::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: var(--gold-soft); box-shadow: 0 0 0 4px var(--gold); opacity: 0;
}
.changed[data-flash="a"]::after { animation: flash-a 900ms var(--ease); }
.changed[data-flash="b"]::after { animation: flash-b 900ms var(--ease); }
@keyframes flash-a { 0% { opacity: 1; } }
@keyframes flash-b { 0% { opacity: 1; } }
.changed .ic { animation: pop var(--t-state) var(--ease); }
@keyframes pop { 40% { transform: scale(1.18); } }
.ping { outline: 2px solid var(--on); outline-offset: 3px; }

/* rolling digits */
.roll { display: inline-flex; overflow: hidden; height: 1em; line-height: 1; vertical-align: baseline; }
.roll .d { display: inline-block; height: 1em; overflow: hidden; width: 0.54em; text-align: center; }
.roll .d.sep { width: auto; }
.roll .d > span { display: flex; flex-direction: column; transition: transform var(--t-state) var(--ease); }
.roll .d > span > span { height: 1em; line-height: 1; }

/* detail popover */
.pop {
  position: fixed; z-index: 20; width: 280px; padding: 14px; border-radius: 14px;
  background: color-mix(in srgb, var(--panel-hi) 96%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line-strong); box-shadow: 0 24px 60px -16px rgba(0,0,0,0.8);
  display: none; opacity: 0; transform: translateY(6px) scale(0.98); pointer-events: none;
  transition: opacity 180ms, transform 220ms var(--ease), display 220ms allow-discrete;
}
.pop.open { display: block; opacity: 1; transform: none; pointer-events: auto; }
@starting-style { .pop.open { opacity: 0; transform: translateY(6px) scale(0.98); } }
.pop h3 { margin: 0; font: 700 13px/1 var(--display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.pop .now { font: 700 30px/1 var(--display); margin: 8px 0 4px; text-transform: uppercase; letter-spacing: 0.03em; }
.pop .since { font-size: 12.5px; color: var(--muted); }
.pop ol { list-style: none; margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.pop li { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.pop li time { color: var(--dim); font: 600 12px/1.3 var(--display); letter-spacing: 0.06em; white-space: nowrap; }

/* on foot */
.envview { position: absolute; inset: 0; display: grid; place-content: center; gap: 26px; padding: 28px; }
.loco { font: 700 clamp(44px, 9cqw, 92px)/0.9 var(--display); text-transform: uppercase; letter-spacing: 0.02em; display: flex; align-items: center; gap: 18px; }
.loco .ico { width: 0.8em; height: 0.8em; color: var(--on); }
.env { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; min-width: min(460px, 100%); }
.env > div { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--well); border: 1px solid var(--line); min-width: 0; }
.env .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--on-soft); color: var(--on); flex: none; }
.env .ic .ico { width: 22px; height: 22px; }
.env b { display: block; font: 700 26px/1 var(--num); margin-top: 5px; }
.env .warn .ic { background: var(--gold-soft); color: var(--gold); }
.env .warn b { color: var(--gold); }
@container (max-width: 520px) {
  .envview { padding: 16px; gap: 18px; }
  .env > div { padding: 11px 12px; gap: 9px; }
  .env .ic { width: 34px; height: 34px; }
  .env b { font-size: 20px; }
}

/* no stream / no bridge */
.down { position: absolute; inset: 0; z-index: 30; display: none; place-items: center; padding: 16px; background: color-mix(in srgb, var(--canvas) 88%, transparent); backdrop-filter: blur(6px); }
[data-link="down"]:not([data-keys="on"]) .down, [data-link="offline"] .down { display: grid; }
[data-edit] .down { display: none; }
.down .card { display: none; max-width: 540px; padding: 28px 30px; border-radius: 18px; border: 1px solid var(--line-strong); background: var(--panel-hi); box-shadow: var(--shadow); }
[data-link="down"] .card[data-for="down"], [data-link="offline"] .card[data-for="offline"] { display: block; }
.down h1 { margin: 0 0 10px; font: 700 34px/1 var(--display); letter-spacing: 0.04em; text-transform: uppercase; display: flex; align-items: center; gap: 12px; }
.down h1 .ico { color: var(--muted); }
.down p { margin: 0 0 10px; color: var(--muted); line-height: 1.5; }
.down code { font: 500 13px/1 ui-monospace, Consolas, monospace; color: var(--ink); background: var(--well); padding: 3px 7px; border-radius: 6px; }

/* sheets: anchored under the top bar, not modals */
.chip.icon-only { padding: 10px 11px; cursor: pointer; }
.chip.icon-only[aria-expanded="true"], .chip.icon-only[aria-pressed="true"] { color: var(--ink); border-color: var(--on-line); }
.chip.icon-only:active { transform: scale(0.94); }

/* night mode (themes.json "night" sets the colors): pictures go dim red too, so nothing on the panel glows white.
   The hull stays duller than its red hit state, so a hit still reads at a glance. */
:root[data-night] #crestImg, :root[data-night] .th img { filter: grayscale(1) sepia(1) hue-rotate(-32deg) saturate(2.4) brightness(0.62); }
:root[data-night] .hull img { filter: grayscale(1) sepia(0.6) hue-rotate(var(--hull-hue)) saturate(1.3) brightness(0.5) contrast(1.15); }
:root[data-night] .hull[data-hit="true"] img { filter: grayscale(1) sepia(1) saturate(5) hue-rotate(-40deg) brightness(0.85) contrast(1.2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sheet {
  position: fixed; z-index: 25; top: 70px; right: max(14px, env(safe-area-inset-right)); width: 340px; max-height: calc(100dvh - 90px); overflow: auto;
  padding: 16px; border-radius: var(--r-panel); background: color-mix(in srgb, var(--panel-hi) 97%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line-strong);
  box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.8);
  display: none; opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity 180ms, transform 240ms var(--ease), display 240ms allow-discrete;
}
/* closed overlays are display: none, so they hold no composited layer (several blur what is under them);
   @starting-style and allow-discrete keep the same fade in and out */
.sheet.open { display: block; opacity: 1; transform: none; pointer-events: auto; }
@starting-style { .sheet.open { opacity: 0; transform: translateY(-6px); } }
.sheet h2 { margin: 0; font: 700 20px/1 var(--display); letter-spacing: 0.06em; text-transform: uppercase; }
.sheet p { margin: 6px 0 14px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.th-list { display: grid; gap: 6px; }
.th {
  display: grid; grid-template-columns: 40px 1fr auto 20px; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--r-ctl);
  border: 1px solid var(--line); background: var(--well); cursor: pointer; transition: border-color 200ms, background-color 200ms;
}
.th:active { transform: scale(0.98); }
.th img { width: 40px; height: 40px; }
.th-name { display: grid; gap: 4px; min-width: 0; }
.th-name b { font: 700 16px/1 var(--display); letter-spacing: 0.04em; text-transform: uppercase; }
.th-name small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th-sw { display: flex; border-radius: 6px; overflow: hidden; border: 1px solid var(--line-strong); }
.th-sw i { width: 14px; height: 22px; background: var(--a); }
.th-sw i:nth-child(2) { background: var(--b); }
.th-sw i:nth-child(3) { background: var(--c); }
.th-check { color: var(--on); opacity: 0; }
.th[aria-pressed="true"] { border-color: var(--on-line); background: var(--on-soft); }
.th[aria-pressed="true"] .th-check { opacity: 1; }

/* ---------- commands (5.0+) ---------- */
[data-controls="off"] [data-cmd] { cursor: default; }
/* waiting for the stream to confirm a press: a ring that breathes (opacity, so the compositor runs it) */
[data-pending]:not(.callout) { position: relative; }
[data-pending]::before {
  content: ""; position: absolute; inset: -4px; border: 2px solid var(--on); border-radius: calc(var(--r-ctl) + 4px);
  pointer-events: none; animation: pend 800ms ease-in-out infinite alternate;
}
@keyframes pend { to { opacity: 0; } }
.nochange { animation: nochange 1.4s var(--ease); }
@keyframes nochange { 0%, 60% { outline: 2px solid var(--gold); outline-offset: 2px; } 100% { outline: 2px solid transparent; outline-offset: 6px; } }
.sent { animation: sent 700ms var(--ease); }
@keyframes sent { 0% { background-color: var(--on-soft); border-color: var(--on); } }

.master { flex: 1; min-height: 0; display: flex; align-items: stretch; gap: 10px; }
.master > .label, .spool { align-self: center; }
.master > .label { padding-left: 4px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border-radius: var(--r-ctl); background: var(--well); flex: 1; }
.segb { display: grid; place-items: center; padding: 8px 0; border-radius: 7px; text-align: center; font: 700 15px/1 var(--display); letter-spacing: 0.12em; color: var(--dim); border: 1px solid transparent; cursor: pointer; }
.segb[data-on="true"] { color: var(--ink); background: var(--on-soft); border-color: var(--on-edge); }
.spool { font: 600 12px/1 var(--display); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); min-width: 64px; text-align: right; padding-right: 4px; }
.spool[data-state="spooling"] { color: var(--gold); }

/* button tiles spread their buttons over the tile; sheets keep fixed columns */
.cmds { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(64px, 100%), 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 6px; }
.sheet .cmds { grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); grid-auto-rows: auto; }
@container (min-width: 250px) { .cmds.fixed { grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); } }
.cmdb[data-danger-opener] { display: none; }
[data-danger="on"] .cmdb[data-danger-opener] { display: grid; }
.danger-note { margin: 0 0 12px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.danger-sheet { border-color: color-mix(in srgb, var(--alert) 45%, transparent); }
.cmdb {
  display: grid; justify-items: center; align-content: center; gap: 5px; min-height: 30px; min-width: 0; padding: 4px; border-radius: var(--r-ctl);
  background: var(--well); border: 1px solid var(--line); color: var(--ink); position: relative; overflow: hidden; cursor: pointer;
  font: 700 12px/1.1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; text-align: center;
  -webkit-touch-callout: none;
}
.sheet .cmdb { min-height: 54px; padding: 8px 4px; }
.cmdb .ico { width: 19px; height: 19px; color: var(--on); }
/* a short button keeps its label and drops the icon */
/* (buttons.js marks a button grid .short when its buttons get under 46 px tall) */
.short .cmdb .ico { display: none; }
.cmdb:active { transform: scale(0.96); }
.cmdb[data-na="true"] { opacity: 0.4; pointer-events: none; }
.cmdb.big { font-size: 13px; letter-spacing: 0.06em; border-color: var(--line-strong); }
.deck .cmdb.solo { flex: 1; font-size: 14px; letter-spacing: 0.08em; }
.deck .cmdb.solo .ico { width: 24px; height: 24px; }
.deck > .w:has(> .wi > .cmdb.solo) > .wi { padding: 6px; }
.cmdb.danger { border-color: color-mix(in srgb, var(--alert) 45%, transparent); }
.cmdb.danger .ico { color: var(--alert); }
.cmdb.danger .arm { position: absolute; inset: 0; background: var(--alert-soft); transform: scaleX(0); transform-origin: left; pointer-events: none; }
.cmdb.danger.arming .arm { transform: scaleX(1); transition: transform 1500ms linear; }
.cmdb.danger span, .cmdb.danger .ico { position: relative; }
/* a held holdable action: the fill runs to the 5 s cap, letting go sends how long it was held */
:is(.cmdb[data-holdable], .cmdb[data-live])::after { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--on) 24%, transparent); transform: scaleX(0); transform-origin: left; pointer-events: none; }
.cmdb.holding::after { transform: scaleX(1); transition: transform var(--hold-ms, 4780ms) linear; }
:is(.cmdb[data-holdable], .cmdb[data-live]) :is(span, .ico) { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) { .cmdb.holding::after { transition: none; } }

/* settings sheet sections */
.sheet-sec + .sheet-sec { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.ctl-state p { margin: 6px 0 12px; }
.ctl-state[data-state="paired"] #ctlText { color: var(--ink); }
.pair label { display: block; font: 600 12px/1 var(--display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.pair-row { display: flex; gap: 8px; }
.pair input {
  flex: 1; min-width: 0; height: 42px; padding: 0 12px; border-radius: var(--r-ctl); border: 1px solid var(--line-strong);
  background: var(--well); color: var(--ink); caret-color: var(--on); font: 700 20px/1 var(--display); letter-spacing: 0.3em;
}
.pair input:focus-visible { outline: 2px solid var(--on); outline-offset: 1px; }
.btn { height: 42px; padding: 0 18px; border-radius: var(--r-ctl); background: var(--on); color: var(--canvas); font: 700 14px/1 var(--display); letter-spacing: 0.12em; text-transform: uppercase; cursor: pointer; white-space: nowrap; }
.btn:active { transform: scale(0.97); }
.err { margin: 6px 0 0 !important; color: var(--alert) !important; font-size: 13px; min-height: 1em; }
.err:empty { display: none; }
.linkbtn { font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; margin-bottom: 6px; }
.switch { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border-radius: var(--r-ctl); background: var(--well); border: 1px solid var(--line); cursor: pointer; margin-top: 8px; }
.switch span { display: grid; gap: 4px; flex: 1; }
.switch b { font: 700 15px/1 var(--display); letter-spacing: 0.06em; text-transform: uppercase; }
.switch small { font-size: 12px; line-height: 1.4; color: var(--muted); }
.switch .led { width: 30px; height: 17px; border-radius: 999px; background: rgba(255,255,255,0.08); position: relative; flex: none; transition: background-color 220ms; }
.switch .led::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--dim); transition: transform 260ms var(--ease), background-color 220ms; }
.switch[aria-checked="true"] { border-color: color-mix(in srgb, var(--alert) 45%, transparent); }
.switch[aria-checked="true"] .led { background: color-mix(in srgb, var(--alert) 60%, transparent); }
.switch[aria-checked="true"] .led::after { transform: translateX(13px); background: var(--ink); }
.sheet.wide { width: 460px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }

/* layouts and the library */
.btn.ghost { background: var(--well); color: var(--ink); border: 1px solid var(--line-strong); }
.lib-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.lib-state p { margin: 12px 0 8px; }
.lay-list { display: grid; gap: 6px; margin-top: 10px; }
.lay-row { display: flex; align-items: center; gap: 6px; }
.lay-pick { flex: 1; display: grid; gap: 4px; padding: 10px 12px; border-radius: var(--r-ctl); background: var(--well); border: 1px solid var(--line); cursor: pointer; }
.lay-pick b { font: 700 15px/1 var(--display); letter-spacing: 0.04em; text-transform: uppercase; }
.lay-pick small { font-size: 12px; color: var(--muted); }
.lay-row[aria-current="true"] .lay-pick { border-color: var(--on-line); background: var(--on-soft); }
.ship-lays { margin-top: 18px; }
.ship-lays h3 { margin: 0 0 4px; font: 700 13px/1.2 var(--display); letter-spacing: 0.08em; text-transform: uppercase; }
.ship-lays > p { margin: 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.ship-row .lay-pick { cursor: default; }
.ship-row .btn { min-height: 44px; padding: 0 14px; }
.ship-row .btn[data-armed] { border-color: var(--alert); color: var(--alert); }
.field-label { display: block; margin: 12px 0 6px !important; font: 600 12px/1 var(--display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted) !important; }
.lib-search, .ed-name-input {
  width: 100%; margin-top: 10px; padding: 10px 12px; border-radius: var(--r-ctl); border: 1px solid var(--line-strong);
  background: var(--well); color: var(--ink); caret-color: var(--on); font: 400 15px/1.3 var(--body);
}
.field-label + .lib-search { margin-top: 0; }
.lib-search:focus-visible, .ed-name-input:focus-visible { outline: 2px solid var(--on); outline-offset: 1px; }
.lib-search::placeholder { color: var(--muted); }
textarea.lib-search { resize: vertical; }
#libTabs { margin-bottom: 0; }
.lib-list { display: grid; gap: 8px; margin-top: 12px; }
.lib-empty { color: var(--muted); font-size: 14px; }
.lib-card { display: grid; gap: 8px; padding: 12px; border-radius: var(--r-ctl); background: var(--well); border: 1px solid var(--line); }
.lib-card > div { display: grid; gap: 4px; }
.lib-card b { font: 700 16px/1 var(--display); letter-spacing: 0.04em; text-transform: uppercase; }
.lib-card small { font-size: 12px; color: var(--muted); }
.lib-card p { margin: 0 !important; font-size: 13px; line-height: 1.45; color: var(--muted); }
.lib-card .lib-widgets { font-size: 12px; }
.lib-card .btn { justify-self: start; }

/* ---------- layout editor: the panel itself, with handles ---------- */
.editbar, .tray { display: none; }
[data-edit] .bar { display: none; }
[data-edit] .editbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-height: 46px; }
.ed-scope { flex: none; grid-template-columns: repeat(2, auto); }
.ed-scope .segb { padding: 9px 12px; font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-where { flex: 1 1 100%; order: 9; margin: 0; font-size: 12.5px; color: var(--muted); }
.segb:disabled { opacity: 0.35; cursor: default; }
.ed-name-input { flex: 1 1 160px; min-width: 120px; max-width: 340px; margin: 0; height: 40px; padding-block: 0; font: 600 18px/1 var(--display); letter-spacing: 0.04em; }
.ed-modes { flex: none; grid-template-columns: repeat(4, auto); margin-right: auto; }
[data-deck="port"] .ed-modes { margin-right: 0; }
.ed-modes .segb { padding: 9px 14px; font-size: 13px; }
#edSave { height: 40px; }
[data-edit] .deck { background: radial-gradient(circle, var(--line-strong) 1px, transparent 1.6px) calc(var(--cw, 50px) / -2) calc(var(--ch, 30px) / -2) / var(--cw, 50px) var(--ch, 30px); }
.ed-ui {
  position: absolute; inset: 0; z-index: 6; border-radius: inherit; cursor: grab; touch-action: none;
  background: color-mix(in srgb, var(--canvas) 38%, transparent); outline: 1px dashed var(--line-strong); outline-offset: -1px;
}
.ed-tag {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 6px; max-width: calc(100% - 44px);
  padding: 3px 3px 3px 12px; border-radius: 999px; background: var(--panel-hi); border: 1px solid var(--line-strong); box-shadow: 0 6px 16px -8px rgba(0,0,0,0.8);
  font: 700 12.5px/1 var(--display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink); pointer-events: none;
}
.ed-tag > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-x { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; pointer-events: auto; color: var(--muted); background: var(--well); }
.ed-x .ico { width: 14px; height: 14px; }
.ed-x:active { color: var(--canvas); background: var(--alert); }
.ed-rz { position: absolute; width: 26px; height: 26px; }
.ed-rz::after { content: ""; position: absolute; width: 12px; height: 12px; border: 0 solid var(--gold); }
.ed-rz[data-dir="nw"] { top: 0; left: 0; cursor: nwse-resize; } .ed-rz[data-dir="nw"]::after { top: 4px; left: 4px; border-width: 3px 0 0 3px; border-top-left-radius: 8px; }
.ed-rz[data-dir="ne"] { top: 0; right: 0; cursor: nesw-resize; } .ed-rz[data-dir="ne"]::after { top: 4px; right: 4px; border-width: 3px 3px 0 0; border-top-right-radius: 8px; }
.ed-rz[data-dir="sw"] { bottom: 0; left: 0; cursor: nesw-resize; } .ed-rz[data-dir="sw"]::after { bottom: 4px; left: 4px; border-width: 0 0 3px 3px; border-bottom-left-radius: 8px; }
.ed-rz[data-dir="se"] { bottom: 0; right: 0; cursor: nwse-resize; } .ed-rz[data-dir="se"]::after { bottom: 4px; right: 4px; border-width: 0 3px 3px 0; border-bottom-right-radius: 8px; }
.deck > .w.ed-drag { z-index: 10; box-shadow: 0 0 0 1px var(--gold), 0 28px 50px -18px rgba(0, 0, 0, 0.9); }
.deck > .w.ed-drag.ed-bad { box-shadow: 0 0 0 2px var(--alert), 0 28px 50px -18px rgba(0, 0, 0, 0.9); }
.ed-drag .ed-ui { cursor: grabbing; background: color-mix(in srgb, var(--canvas) 12%, transparent); }
.ed-ghost {
  z-index: 8; margin: calc(var(--gap) / 2); border-radius: var(--r-panel); pointer-events: none; display: grid; place-items: end center; padding: 6px;
  border: 2px dashed var(--gold); background: var(--gold-soft);
}
.ed-ghost b { padding: 3px 8px; border-radius: 999px; background: var(--gold); color: var(--canvas); font: 700 12px/1 var(--display); letter-spacing: 0.1em; text-transform: uppercase; }
.ed-ghost.bad { border-color: var(--alert); background: var(--alert-soft); }
.ed-ghost.bad b { background: var(--alert); }
[data-edit] .tray {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; min-height: 58px; padding: 8px 14px; border-radius: var(--r-panel);
  background: var(--panel); border: 1px dashed var(--line-strong); transition: border-color 160ms, background-color 160ms;
}
.tray > .label { flex: none; }
.tray-head { flex: none; display: grid; gap: 6px; align-content: center; }
.tray-tabs, .tray-groups { flex: none; display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: var(--r-ctl); background: var(--well); }
.tray-tabs .segb, .tray-groups .segb { padding: 7px 11px; font-size: 12px; }
.tray-groups:empty { display: none; }
.tray-chip.act[data-na="true"] .ico { color: var(--dim); }
.tray-list { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tray-chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 11px; border-radius: var(--r-ctl); cursor: grab; touch-action: none;
  background: var(--panel-hi); border: 1px solid var(--line-strong); font: 700 13px/1 var(--display); letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap;
}
.tray-chip .ico { width: 17px; height: 17px; color: var(--on); }
.tray-chip.lifted { opacity: 0.35; }
.tray-float { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; border-color: var(--gold); box-shadow: 0 18px 36px -14px rgba(0, 0, 0, 0.9); }
.tray-empty { margin: 0; font-size: 13px; color: var(--muted); }
.tray-bin { display: none; color: var(--alert); }
.tray.drop { border-color: var(--alert); background: var(--alert-soft); }
.tray.drop .tray-bin { display: inline; }
.tray.drop .tray-list, .tray.drop .tray-head { display: none; }

.toast {
  position: fixed; z-index: 40; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); max-width: min(560px, calc(100vw - 32px));
  padding: 12px 16px; border-radius: 12px; background: var(--panel-hi); border: 1px solid var(--line-strong); box-shadow: 0 18px 40px -14px rgba(0,0,0,0.8);
  font-size: 14px; line-height: 1.4; color: var(--ink); transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  display: none; transition: opacity 180ms, transform 260ms var(--ease), display 260ms allow-discrete;
}
.toast.show { display: block; opacity: 1; transform: translate(-50%, 0); }
@starting-style { .toast.show { opacity: 0; transform: translate(-50%, 12px); } }
.toast[data-tone="warn"] { border-color: var(--gold); }
[data-edit] .toast { bottom: 90px; }

/* phones: the same tiles stacked in one scrolling column */
[data-deck="stack"] body { overflow: auto; }
[data-deck="stack"] .app { height: auto; min-height: 100dvh; grid-template-rows: auto auto auto; }
[data-deck="stack"] .deck > .w { grid-area: auto !important; flex: none; }
[data-deck="stack"] .stage { min-height: 440px; }
[data-deck="stack"] .body { min-height: 380px; }
[data-deck="stack"] .envview { position: static; }
[data-deck="stack"] .cmdb { min-height: 52px; }
[data-deck="stack"] .mode { min-height: 40px; }
[data-deck="stack"] .an { min-height: 40px; }
[data-deck="stack"] .pw { min-height: 52px; }
[data-deck="stack"] .master { min-height: 44px; }
[data-deck="stack"] .wallet { min-height: 40px; }
[data-deck="stack"] .flist { max-height: 260px; }
[data-deck="stack"] .big { font-size: 60px; }
@media (max-width: 900px) {
  .ship-maker { display: none; }
  .chip { min-height: 34px; padding: 8px 11px; font-size: 12px; }
  #linkText, #roleText { display: none; }
  .pop { left: 12px !important; right: 12px; width: auto; }
  .sheet, .sheet.wide { top: 64px; left: 12px; right: 12px; width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 1ms !important; }
}

/* ---------- narrow tiles: every widget reads at 4 cells wide (about 200 px on the tablet) ---------- */
@container (max-width: 260px) {
  .hull { inset: 64px 6px; }
  .callout { padding: 6px 7px; column-gap: 0; grid-template-columns: 1fr; max-width: calc(50% - 10px); border-radius: 10px; }
  .callout .ic { display: none; }
  .callout .label { font-size: 10px; letter-spacing: 0.08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .callout .state { font-size: 14px; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .callout[data-on="unknown"] .state { font-size: 11px; letter-spacing: 0.04em; }
  .callout.tl, .callout.bl { left: 6px; } .callout.tr, .callout.br { right: 6px; }
  .callout.tl, .callout.tr { top: 6px; } .callout.bl, .callout.br { bottom: 6px; }
  .tiles { gap: 8px 10px; }
  .tile { column-gap: 0; grid-template-columns: 1fr; }
  .tile .ic { display: none; }
  .tile .v { font-size: 19px; white-space: nowrap; }
  .wallet .label { font-size: 0; }
  .wallet .label .ico { margin-right: 0; width: 16px; height: 16px; }
  .wallet b { font-size: 19px; }
  .wpn em, .cms .label { display: none; }
  .head [data-r="gimbal"] { font-size: 0; }
  .head [data-r="gimbal"] .ico { margin-right: 0; width: 15px; height: 15px; }
  .cms > div { gap: 6px; padding: 7px 8px; }
  .wpn span { font-size: 14px; }
  .envview { padding: 12px; gap: 14px; }
  .loco { font-size: 34px; gap: 10px; }
  .env { min-width: 0; gap: 6px; }
  .env > div { padding: 8px 9px; gap: 0; }
  .env .ic { display: none; }
  .env .label { font-size: 10.5px; letter-spacing: 0.08em; }
  .env b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .an { font-size: 12px; letter-spacing: 0.02em; }
  .fi { gap: 7px; padding: 6px 4px; }
}

/* ---------- careers ---------- */
.careers { display: flex; gap: 3px; padding: 3px; border-radius: 999px; background: var(--panel-hi); border: 1px solid var(--line-strong); }
.career {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; height: 38px; padding: 0 12px; border-radius: 999px;
  border: 1px solid transparent; color: var(--muted); cursor: pointer; font: 700 13px/1 var(--display); letter-spacing: 0.1em; text-transform: uppercase;
}
.career .ico { width: 18px; height: 18px; }
.career span { display: none; }
.career:active { transform: scale(0.96); }
.career[aria-pressed="true"] { color: var(--ink); background: var(--on-soft); border-color: var(--on-edge); }
.career[aria-pressed="true"] .ico { color: var(--on); }
.career[aria-pressed="true"] span { display: inline; }

/* labels whose word drops away on a narrow tile */
.label s { text-decoration: none; }

/* engineering */
.sysb { flex: 1; min-height: 0; display: grid; grid-auto-rows: minmax(0, 1fr); gap: 4px; }
.sys {
  display: grid; grid-template-columns: 20px minmax(64px, 1fr) minmax(84px, auto) 150px 44px; align-items: center; gap: 12px; padding: 0 12px;
  border-radius: var(--r-ctl); background: var(--well); border: 1px solid var(--line); color: var(--dim); min-height: 0;
}
.sys .ico { width: 18px; height: 18px; }
.sys b { font: 700 16px/1 var(--display); letter-spacing: 0.04em; text-transform: uppercase; }
.sys em { font: 700 14px/1 var(--display); letter-spacing: 0.06em; font-style: normal; text-transform: uppercase; white-space: nowrap; }
.sys[data-on="true"] { color: var(--ink); border-color: var(--on-edge); background: var(--on-soft); }
.sys[data-on="true"] .ico, .sys[data-on="true"] em { color: var(--on); }
.sys[data-on="false"] { color: var(--muted); }
.sys[data-on=""] em { font-size: 12px; }
.sys .lt { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.sys .lt i, .sys .lt u { font: 700 12.5px/1 var(--display); letter-spacing: 0.08em; font-style: normal; text-decoration: none; }
.sys .lt i { min-width: 46px; padding: 5px 0; text-align: center; border-radius: 6px; border: 1px solid var(--line-strong); }
.sys .lt:empty { border: 0; }
.sys .lt[data-s^="MINOR"] i { background: var(--gold); border-color: var(--gold); color: var(--canvas); }
.sys .lt[data-s^="MAJOR"] i { background: var(--alert); border-color: var(--alert); color: var(--canvas); }
.sys time { font: 600 12.5px/1 var(--num); color: var(--dim); text-align: right; }
@container (max-width: 500px) { .sys { grid-template-columns: 18px minmax(0, 1fr) auto 50px; gap: 8px; padding: 0 9px; } .sys .lt u, .sys time { display: none; } }
@container (max-width: 270px) { .sys { grid-template-columns: minmax(0, 1fr) auto; } .sys > .ico, .sys .lt { display: none; } .sys b { font-size: 14px; } .sys em { font-size: 12px; } .sys[data-on=""] em { font-size: 0; } .sys[data-on=""] em::after { content: "n/r"; font-size: 12px; } }

.pips { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pipcol { display: grid; grid-template-rows: auto repeat(4, minmax(0, 1fr)); gap: 5px; min-height: 0; }
.pipcol > .label { display: flex; align-items: center; justify-content: center; padding: 2px 0 4px; }
.deck .pips .cmdb, .deck .pipreset { min-height: 0; font-size: 14px; }
.pips .cmdb .ico { width: 20px; height: 20px; }
.pipreset { flex: none; height: 42px; }
@container (max-width: 300px) { .pipcol > .label s { display: none; } .pipcol > .label .ico { margin: 0; width: 18px; height: 18px; } }

.hullb { flex: 1; min-height: 0; overflow: auto; display: grid; align-content: space-evenly; gap: 8px; }
.hrow, .faces > div { display: grid; grid-template-columns: 62px minmax(0, 1fr) minmax(44px, auto); align-items: center; gap: 10px; }
.hullb .track { height: 10px; border-radius: 8px; background: var(--well); overflow: hidden; }
.hullb .fill { height: 100%; border-radius: 8px; background: var(--on); transform-origin: left; }
.hullb b { font: 700 18px/1 var(--num); text-align: right; }
.faces { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 18px; }
.faces b { font-size: 14px; }

.airmain { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-radius: var(--r-ctl); padding: 0 4px; }
.airmain b { font: 700 34px/1 var(--num); font-size: clamp(24px, 22cqh, 64px); white-space: nowrap; }
.airmain span { font: 700 15px/1.1 var(--display); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); text-align: right; }
.airmain[data-level="low"] span, .w-air .head [data-level="low"] { color: var(--gold); }
.aircells { flex: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.aircells > div { display: grid; gap: 6px; padding: 9px 10px; border-radius: var(--r-ctl); background: var(--well); min-width: 0; }
.aircells .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aircells b { font: 700 18px/1 var(--num); white-space: nowrap; }
.aircells b[data-level="low"] { color: var(--gold); } .aircells b[data-level="crit"] { color: var(--alert); }
@container (max-width: 380px) { .aircells .label .ico { display: none; } .aircells .label { font-size: 11px; letter-spacing: 0.06em; } .aircells b { font-size: 16px; } .aircells > div { padding: 8px; } }
@container (max-width: 330px) { .airmain { flex-direction: column; align-items: flex-start; justify-content: center; gap: 6px; } .airmain span { text-align: left; font-size: 13px; } .aircells { grid-template-columns: 1fr; } .aircells > div { display: flex; justify-content: space-between; align-items: center; } }

/* combat */
.threats { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: minmax(0, 1fr); gap: 6px; }
.thr {
  display: grid; align-content: center; justify-items: center; gap: 4px; min-width: 0; min-height: 0; padding: 4px; border-radius: var(--r-ctl);
  background: var(--well); border: 1px solid var(--line); color: var(--dim); text-align: center;
}
.thr .ico { width: 22px; height: 22px; }
.thr b { font: 700 13.5px/1 var(--display); letter-spacing: 0.06em; text-transform: uppercase; }
.thr em { font: 600 12px/1 var(--num); font-style: normal; min-height: 1em; }
.thr[data-s^="MINOR"] { background: var(--gold); border-color: var(--gold); color: var(--canvas); }
.thr[data-s^="MAJOR"] { background: var(--alert); border-color: var(--alert); color: var(--canvas); }
.thr[data-s$="FLASHING"] { animation: blink 1s steps(2, jump-none) infinite; }
@container (max-height: 150px) and (max-width: 619px) { .thr .ico { display: none; } }

/* mining */
.laser { flex: 1.4; min-height: 0; display: grid; grid-template-columns: 1fr 1.5fr 1fr; gap: 8px; }
.mods { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 6px; }
.deck .laser .cmdb { font-size: 15px; }
.laser .cmdb .ico { width: 28px; height: 28px; }
.laser .fire { background: var(--on-soft); border-color: var(--on-line); }
.deck .laser .fire { font-size: 18px; }
@container (max-width: 560px) { .mods { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@container (max-width: 270px) { .mods { grid-template-columns: repeat(2, minmax(0, 1fr)); } .mods .ico { display: none; } .laser .cmdb .ico { width: 20px; height: 20px; } .deck .laser .cmdb, .deck .laser .fire { font-size: 12px; } }

.run { flex: 1; min-height: 0; display: grid; align-content: center; gap: 8px; }
.run b { font: 700 32px/1 var(--num); font-size: clamp(24px, 13cqw, 56px); white-space: nowrap; }
.run span { font-size: 14px; color: var(--muted); }
.runbtn { flex: none; height: 46px; }
.tlist { flex: 1; min-height: 0; overflow: auto; display: grid; align-content: start; gap: 5px; }
.job { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: var(--r-ctl); background: var(--well); border: 1px solid var(--line); cursor: pointer; }
.job span { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job b { font: 700 18px/1 var(--num); }
.job[data-done="true"] { background: var(--gold); border-color: var(--gold); }
.job[data-done="true"] :is(span, b) { color: var(--canvas); }
.tadd { flex: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.tgo { flex: none; display: grid; grid-template-columns: 1fr 2fr; gap: 5px; }
.deck .tadd .cmdb, .deck .tgo .cmdb { min-height: 40px; font-size: 13px; letter-spacing: 0.04em; }

/* medical */
.mon { flex: 1; min-height: 0; display: grid; grid-auto-rows: minmax(0, 1fr); gap: 6px; }
.lane { display: grid; grid-template-columns: minmax(0, 1fr) 128px; gap: 12px; align-items: stretch; min-height: 0; padding: 6px 12px 6px 6px; border-radius: var(--r-ctl); background: var(--well); }
.lane canvas { width: 100%; height: 100%; min-height: 0; display: block; }
.mv { display: grid; align-content: center; justify-items: end; gap: 5px; min-height: 0; }
.mv b { font: 700 38px/0.95 var(--num); white-space: nowrap; color: var(--on); }
.mv small { font: 600 12px/1 var(--num); color: var(--muted); min-height: 1em; }
.lane[data-level="low"] .mv b { color: var(--gold); } .lane[data-level="crit"] .mv b { color: var(--alert); }
@container (max-width: 400px) { .lane { grid-template-columns: minmax(0, 1fr) 84px; gap: 6px; } .mv b { font-size: 24px; } .mv small { display: none; } }
@container (max-height: 330px) { .mv b { font-size: 26px; } .mv small { display: none; } }
.triage { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(170px, 100%), 1fr)); grid-template-rows: 44px; grid-auto-rows: minmax(82px, 108px); align-content: start; gap: 6px; overflow: auto; }
.pt {
  position: relative; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr auto; align-items: center; gap: 2px 8px; padding: 5px 8px 6px 11px;
  border-radius: var(--r-ctl); background: var(--well); border: 1px solid var(--line-strong); min-width: 0;
}
.pt > span { grid-row: 1; grid-column: 1; font-size: 13px; }
.ptx { grid-row: 1; grid-column: 2; }
.pt b { grid-row: 2; grid-column: 1; font: 700 19px/1 var(--display); letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap; }
.pt time { grid-row: 2; grid-column: 2; font: 700 17px/1 var(--num); }
.pt em { grid-row: 3; grid-column: 1 / -1; font: 600 14px/1 var(--num); font-style: normal; }
.ptx { justify-self: end; min-width: 34px; height: 28px; margin: -3px -2px 0 0; display: grid; place-items: center; font: 700 12.5px/1 var(--display); border-radius: 6px; cursor: pointer; touch-action: manipulation; }
.ptx .ico { width: 15px; height: 15px; }
.ptset { grid-row: 3; grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.ptset button { height: 26px; border-radius: 6px; border: 1px solid currentColor; font: 700 13px/1 var(--display); letter-spacing: 0.04em; text-transform: uppercase; text-align: center; cursor: pointer; touch-action: manipulation; }
.ptset button[aria-pressed="true"] { background: var(--canvas); border-color: var(--canvas); color: var(--ink); }
.ptset button:active, .ptx:active, .pt.add:active { transform: scale(0.96); }
.pt[data-lv="down"] { background: var(--alert); border-color: var(--alert); color: var(--canvas); }
.pt[data-lv="hurt"] { background: var(--gold); border-color: var(--gold); color: var(--canvas); }
.pt[data-lv="ok"] { background: var(--on-soft); border-color: var(--on-line); }
/* the player's own card stays on top while the rest scroll */
.pt.me { position: sticky; top: 0; z-index: 1; grid-column: 1 / -1; grid-template: auto / 1fr auto auto auto; gap: 16px; padding: 0 12px; }
.pt.me > * { grid-row: 1; grid-column: auto; }
.pt.me[data-lv="ok"], .pt.me[data-lv=""] { background: var(--panel-hi); }
.pt.me[data-lv=""] { color: var(--dim); }
.pt.add > * { grid-row: 1; grid-column: auto; }
.pt.add { grid-template: none / auto auto; justify-content: center; border-style: dashed; color: var(--muted); cursor: pointer; text-align: left; }
.pt.add small { display: block; font-size: 12px; color: var(--dim); margin-top: 3px; }
.pt.add .ico { width: 22px; height: 22px; }
.pens { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); grid-auto-rows: minmax(max-content, 1fr); gap: 6px; overflow: auto; }
.pen { display: grid; align-content: center; gap: 4px; padding: 4px 12px; text-align: left; border-radius: var(--r-ctl); background: var(--well); border: 1px solid var(--line); cursor: pointer; touch-action: manipulation; }
.pen b { font: 700 17px/1 var(--display); }
.pen span { font-size: 13px; line-height: 1.15; color: var(--muted); }
.pen:active { transform: scale(0.97); }
.pen[aria-pressed="true"] { background: var(--on-soft); border-color: var(--on-line); }
.pen[data-need="true"] { background: var(--gold); border-color: var(--gold); }
.pen[data-need="true"] :is(b, span) { color: var(--canvas); }
.pennote { flex: none; margin: 0; font-size: 13px; line-height: 1.35; min-height: 2.7em; color: var(--muted); }
@container (max-width: 400px) { .pens { grid-template-columns: repeat(auto-fill, minmax(min(130px, 100%), 1fr)); } }
@container (max-height: 230px) { .pennote { min-height: 0; max-height: 2.7em; overflow: auto; } }

[data-deck="stack"] :is(.sys, .job) { min-height: 48px; }
[data-deck="stack"] .w-monitor .mon { min-height: 420px; }
[data-deck="stack"] .w-triage .triage { min-height: 100px; }
[data-deck="stack"] .w-pens .pens { min-height: 290px; }
[data-deck="stack"] .pen { padding: 9px 12px; }
[data-deck="stack"] .w-threat .threats { min-height: 170px; }
[data-deck="stack"] .pips { min-height: 240px; }
[data-deck="stack"] .laser, [data-deck="stack"] .mods { min-height: 110px; }
/* ---------- dials (js/dial.js): the face is a canvas, everything that moves is a rotated layer ---------- */
.dialbox { flex: 1; min-height: 0; position: relative; display: grid; place-items: center; container-type: size; }
.dial { position: relative; width: min(100cqw, 100cqh); aspect-ratio: 1; container-type: inline-size; }
.dial canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.dneedle, .dmark, .dpeak { position: absolute; inset: 0; transition: transform var(--t-state) var(--ease); }
.dneedle::before { content: ""; position: absolute; left: calc(50% - 1.1cqw); top: 9cqw; width: 2.2cqw; height: 47cqw; background: var(--ink); clip-path: polygon(50% 0, 100% 12%, 100% 100%, 0 100%, 0 12%); }
.dneedle::after { content: ""; position: absolute; left: calc(50% - 1.8cqw); top: 52cqw; width: 3.6cqw; height: 11cqw; border-radius: 1.8cqw; background: var(--muted); }
.dmark::before, .dpeak::before { content: ""; position: absolute; left: calc(50% - 2.6cqw); top: 1.5cqw; width: 5.2cqw; height: 5.2cqw; background: var(--gold); clip-path: polygon(0 0, 100% 0, 50% 100%); }
.dpeak::before { left: calc(50% - 0.6cqw); width: 1.2cqw; height: 9cqw; background: var(--muted); clip-path: none; }
.dcap { position: absolute; left: 44%; top: 44%; width: 12%; height: 12%; border-radius: 50%; background: var(--panel-hi); border: 1px solid var(--line-strong); }
/* a fixed box, so a changed digit lays out only itself */
.dread { position: absolute; inset: auto 0 5cqw; height: 26cqw; contain: strict; display: grid; align-content: end; justify-items: center; gap: 1cqw; }
.dread b { font: 700 clamp(17px, 16cqw, 64px)/0.9 var(--num); }
.dread small { font: 600 clamp(10px, 6cqw, 16px)/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.dial[data-level="low"] .dread b { color: var(--gold); }
.dial[data-level="crit"] .dread b { color: var(--alert); }
.dial[data-level="crit"] .dneedle::before { background: var(--alert); }
.dial[data-off="true"] .dneedle { opacity: 0.35; }
.dial[data-off="true"] .dread small { color: var(--muted); }
/* a real gauge without power drops a flag across its face */
.dflag { display: none; position: absolute; left: 50%; top: 27%; transform: translate(-50%, -50%) rotate(-8deg); padding: 1.6cqw 4cqw; background: var(--gold); color: var(--canvas); font: 700 clamp(10px, 8cqw, 20px)/1 var(--display); letter-spacing: 0.12em; }
.dial[data-off="true"] .dflag { display: block; }
.w:has(> .wi > .dialbox) .dsub { color: var(--muted); letter-spacing: 0.06em; }
.dcorner { position: absolute; display: none; gap: 5px; }
.dcorner b { font: 700 24px/1 var(--num); white-space: nowrap; }
.dcorner b[data-on="true"] { color: var(--on); }
.dcorner[data-c="hdg"] { left: 0; top: 0; } .dcorner[data-c="alt"] { right: 0; top: 0; text-align: right; }
.dcorner[data-c="vsi"] { left: 0; bottom: 0; } .dcorner[data-c="bst"] { right: 0; bottom: 0; text-align: right; }
@container (min-width: 400px) { .dcorner { display: grid; } }

/* combat dials: no bezel, a lance for a needle, the number in the middle */
[data-panel="combat"] .dneedle::before { top: 0; height: 9cqw; left: calc(50% - 4cqw); width: 8cqw; background: var(--on); clip-path: polygon(0 0, 100% 0, 50% 100%); }
[data-panel="combat"] .dneedle::after, [data-panel="combat"] .dcap { display: none; }
[data-panel="combat"] .dmark::before { top: 7cqw; left: calc(50% - 0.9cqw); width: 1.8cqw; height: 8cqw; clip-path: none; }
[data-panel="combat"] .dpeak::before { top: 7cqw; }
.deck:has(> .w-drums) .w-weapons .cms { display: none; }
[data-panel="combat"] .dial[data-level="crit"] .dneedle::before { background: var(--alert); }
[data-panel="combat"] .dread { inset: 0; height: auto; align-content: center; gap: 2.5cqw; }
[data-panel="combat"] .dread b { font-size: clamp(22px, 27cqw, 108px); }
[data-panel="combat"] .dread small { font-size: clamp(11px, 7cqw, 20px); }
[data-panel="combat"] .dflag { top: 34%; }
[data-panel="combat"] .dial[data-off="true"] .dread { align-content: end; padding-bottom: 24cqw; }

/* combat frame: instruments sit straight on the dark, only controls get a tile */
[data-panel="combat"][data-deck] .deck > .w:has(> .wi > .dialbox) { background: none; border-color: transparent; box-shadow: none; }
[data-panel="combat"] body { background: radial-gradient(60% 55% at 50% 42%, var(--canvas-glow), var(--canvas) 70%) fixed, var(--canvas); }
/* glareshield: four warning lamps across the top */
[data-panel="combat"] .w-threat .head { display: none; }
[data-panel="combat"] .deck > .w-threat > .wi { padding: 8px; }
[data-panel="combat"] .w-threat { --r-ctl: 4px; }
[data-panel="combat"] .thr { border: 2px solid var(--line-strong); box-shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.8) inset; }
@container (min-width: 620px) { .threats { grid-template-columns: repeat(4, 1fr); } .thr b { font-size: 19px; } .thr .ico { width: 30px; height: 30px; display: block; } }
@container (min-width: 900px) {
  .thr { grid-template-columns: auto 1fr; grid-template-rows: auto auto; justify-items: start; column-gap: 14px; padding: 6px 20px; text-align: left; }
  .thr .ico { grid-row: 1 / -1; width: 38px; height: 38px; align-self: center; display: block; }
  .thr b { font-size: 24px; letter-spacing: 0.05em; align-self: end; }
  .thr em { font-size: 15px; align-self: start; }
}

.drums { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.drum { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.drum .label { white-space: nowrap; }
.drum b { font: 700 30px/1 var(--num); letter-spacing: 0.06em; padding: 5px 8px; border-radius: 4px; background: var(--canvas); border: 1px solid var(--line-strong); box-shadow: 0 5px 7px -4px rgba(0, 0, 0, 0.9) inset, 0 -5px 7px -4px rgba(0, 0, 0, 0.9) inset; }
.drum[data-level="crit"] b { color: var(--alert); border-color: var(--alert); }
.drum[data-level="none"] b { color: var(--dim); }
@container (max-width: 300px) { .drum .label { font-size: 0; } .drum .label .ico { margin: 0; width: 20px; height: 20px; } }
@container (max-width: 230px) { .drums { grid-template-columns: 1fr; } .drum b { font-size: 22px; padding: 3px 6px; } }

/* engineering frame: plates held on with screws (paint only, so nothing repaints while the stream runs) */
[data-panel="engineering"][data-deck] .deck > .w {
  --screw: radial-gradient(circle, var(--dim) 0 1.6px, rgba(0, 0, 0, 0.7) 1.7px 3.2px, transparent 3.4px);
  background: var(--screw) 2px 2px / 12px 12px no-repeat, var(--screw) calc(100% - 2px) 2px / 12px 12px no-repeat, var(--screw) 2px calc(100% - 2px) / 12px 12px no-repeat, var(--screw) calc(100% - 2px) calc(100% - 2px) / 12px 12px no-repeat, linear-gradient(180deg, var(--panel-hi), var(--panel));
}
[data-panel="engineering"]:not([data-style]) { --r-panel: 5px; --r-ctl: 4px; }
[data-panel="engineering"] .deck > .w:has(> .wi > .dialbox) > .wi { gap: 4px; }
[data-panel="engineering"] .deck > .w-annun > .wi { padding-inline: 18px; }

/* power bus */
.bus { flex: 1; min-height: 0; position: relative; display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; padding-top: 14px; }
.busbar { position: absolute; left: 0; right: 0; top: 0; height: 8px; border-radius: 2px; background: var(--line-strong); }
.bus[data-live="true"] .busbar { background: var(--on); }
.brk { position: relative; display: grid; grid-template-rows: 22px 26px minmax(0, 1fr) auto auto 13px; justify-items: center; align-items: center; gap: 5px; min-width: 0; min-height: 0; color: var(--muted); }
.drop { width: 4px; height: calc(100% + 8px); margin-top: -8px; background: var(--line-strong); }
.brk[data-on="true"] .drop { background: var(--on); }
.lamp { width: 100%; max-width: 62px; height: 24px; display: grid; place-items: center; border-radius: 3px; border: 1px solid var(--line-strong); background: var(--canvas); color: var(--dim); font: 700 12.5px/1 var(--display); letter-spacing: 0.06em; }
.lamp:empty { visibility: hidden; }
.lamp[data-s="NOMINAL"] { color: var(--muted); }
.lamp[data-s^="MINOR"] { background: var(--gold); border-color: var(--gold); color: var(--canvas); }
.lamp[data-s^="MAJOR"] { background: var(--alert); border-color: var(--alert); color: var(--canvas); }
.lamp[data-s$="FLASHING"] { animation: blink 1s steps(2, jump-none) infinite; }
.lever { position: relative; width: min(46px, 80%); height: 100%; max-height: 130px; border-radius: 6px; background: var(--canvas); border: 1px solid var(--line-strong); box-shadow: 0 6px 10px -6px rgba(0, 0, 0, 0.9) inset; overflow: hidden; }
.lever i { position: absolute; left: 4px; right: 4px; top: 50%; height: calc(50% - 4px); border-radius: 4px; background: linear-gradient(180deg, var(--muted), var(--dim) 45%, var(--well)); transition: transform var(--t-state) var(--ease); }
.lever i::after { content: ""; position: absolute; left: 22%; right: 22%; top: calc(50% - 1px); height: 2px; background: var(--canvas); opacity: 0.6; }
.brk[data-on="true"] .lever i { transform: translateY(calc(-100% + 0px)); background: linear-gradient(180deg, var(--ink), var(--on) 60%, var(--on-edge)); }
.brk[data-on=""] .lever i { transform: translateY(-50%); opacity: 0.4; }
.jewel { width: min(52px, 84%); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: var(--canvas); border: 3px solid var(--panel-hi); outline: 1px solid var(--line-strong); color: var(--dim); }
.jewel .ico { width: 46%; height: 46%; }
.brk[data-on="true"] .jewel { background: var(--on-soft); color: var(--on); outline-color: var(--on-line); }
.brk b { font: 700 14px/1 var(--display); letter-spacing: 0.03em; text-transform: uppercase; }
.brk em { font: 700 13px/1 var(--display); font-style: normal; letter-spacing: 0.06em; text-transform: uppercase; }
.brk time { font: 600 11.5px/1 var(--num); color: var(--dim); }
.brk[data-on="true"] { color: var(--ink); }
.brk[data-on="true"] em { color: var(--on); }
.brk[data-on=""] { color: var(--dim); }
@container (max-width: 600px) { .brk b { font-size: 12px; letter-spacing: 0; } }
@container (max-width: 520px) { .bus { grid-template-columns: repeat(5, minmax(0, 1fr)); row-gap: 12px; } .brk { grid-template-rows: 10px 22px minmax(0, 1fr) auto auto; } .brk time { display: none; } }
@container (max-width: 270px) { .bus { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

[data-deck="stack"] .dialbox { min-height: 260px; }
[data-deck="stack"] .bus { min-height: 460px; }
[data-deck="stack"] .drums { min-height: 56px; }
@media (max-width: 560px) { .careers { order: 9; flex: 1 1 100%; justify-content: space-between; } .bar { flex-wrap: wrap; } }

/* bind check (Settings) */
.binds { display: grid; gap: 5px; }
.bind { border-radius: var(--r-ctl); background: var(--well); border: 1px solid var(--line); }
.bind summary { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 12px; cursor: pointer; list-style: none; }
.bind summary::-webkit-details-marker { display: none; }
.bind summary b { font: 700 15px/1 var(--display); text-transform: uppercase; letter-spacing: 0.06em; }
.bind summary span { margin-left: auto; font-size: 13.5px; color: var(--gold); }
.bind[data-ok="true"] summary { cursor: default; }
.bind[data-ok="true"] summary span { color: var(--muted); }
.bind ul { margin: 0; padding: 0 12px 12px; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 13.5px; color: var(--muted); }
