/* Every Kilogram
   Day screens (goal, build, test, legacy) sit on drafting vellum.
   Night screens (window, flight, science) sit on a dark plotting table. */

:root {
  --vellum: #e6ece8;
  --vellum-2: #d8e1db;
  --vellum-line: #c3cfc8;
  --graphite: #23282e;
  --graphite-2: #545d66;
  --graphite-3: #7d8790;
  --redpen: #b4302c;
  --teal: #17807a;
  --gold: #d9a21b;
  --gold-ink: #7a5a0c;
  --slate: #101922;
  --slate-2: #172431;
  --slate-3: #22344a;
  --chalk: #e9eef2;
  --chalk-2: #a9b6c2;
  --chalk-3: #6f8090;
  --ok: #17807a;
  --warn: #b57d00;
  --bad: #b4302c;
  --night-ok: #3fc1b4;
  --night-warn: #f0b429;
  --night-bad: #f06a5f;

  --font: 'Archivo', 'Noto Kufi Arabic', 'Arial Narrow', 'Segoe UI', system-ui, sans-serif;
  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.5625rem;
  --step-3: 1.9375rem;
  --step-4: 2.4375rem;
  --step-6: 3.8125rem;
  --radius-s: 3px;
  --radius-m: 6px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.45;
  color: var(--graphite);
  background: var(--slate);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

[tabindex='-1']:focus {
  outline: none;
}

[hidden] {
  display: none !important;
}

body {
  overflow-x: hidden;
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.day {
  background-color: var(--vellum);
  background-image:
    linear-gradient(var(--vellum-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--vellum-line) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
  color: var(--graphite);
}

.night {
  background: var(--slate);
  color: var(--chalk);
}

/* ---------- Display type ---------- */
.display {
  font-stretch: 68%;
  font-weight: 850;
  letter-spacing: -0.01em;
  line-height: 0.95;
  margin: 0;
}

h1,
h2,
h3 {
  font-stretch: 75%;
  font-weight: 800;
  line-height: 1.05;
  margin: 0;
}

h2 {
  font-size: var(--step-3);
}

h3 {
  font-size: var(--step-1);
}

p {
  margin: 0;
  max-width: 68ch;
}

.muted {
  color: var(--graphite-2);
}

.night .muted {
  color: var(--chalk-2);
}

.small {
  font-size: var(--step--1);
}

.num {
  font-variant-numeric: tabular-nums;
}

/* ---------- Phase track ---------- */
.track {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--vellum-line);
  font-size: var(--step--1);
  overflow-x: auto;
}

.night .track {
  border-bottom-color: var(--slate-3);
}

.track .brand {
  font-stretch: 70%;
  font-weight: 850;
  font-size: var(--step-1);
  margin-right: 18px;
  white-space: nowrap;
}

.track ol {
  display: flex;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.track li {
  padding: 4px 10px;
  border-radius: 99px;
  white-space: nowrap;
  color: var(--graphite-3);
}

.night .track li {
  color: var(--chalk-3);
}

.track li.done {
  color: var(--graphite-2);
}

.night .track li.done {
  color: var(--chalk-2);
}

.track li.now {
  background: var(--graphite);
  color: var(--vellum);
  font-weight: 700;
}

.night .track li.now {
  background: var(--chalk);
  color: var(--slate);
}

.track .spacer {
  flex: 1;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-m);
  padding: 12px 20px;
  font-weight: 700;
  cursor: pointer;
  background: var(--graphite);
  color: var(--vellum);
  text-decoration: none;
}

.btn:hover {
  background: #000;
}

.btn.primary {
  background: var(--gold);
  color: #241a02;
}

.btn.primary:hover {
  background: #e8b42e;
}

.btn.ghost {
  background: transparent;
  color: inherit;
  box-shadow: inset 0 0 0 1.5px currentColor;
}

.btn.ghost:hover {
  background: rgba(127, 127, 127, 0.12);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.night .btn:not(.primary):not(.ghost) {
  background: var(--chalk);
  color: var(--slate);
}

.btn.small {
  padding: 7px 12px;
  font-size: var(--step--1);
}

/* Segmented choice */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.seg button {
  border: 1.5px solid var(--graphite-3);
  background: transparent;
  border-radius: var(--radius-s);
  padding: 5px 10px;
  font-size: var(--step--1);
  cursor: pointer;
}

.seg button[aria-pressed='true'] {
  background: var(--graphite);
  border-color: var(--graphite);
  color: var(--vellum);
  font-weight: 700;
}

.night .seg button {
  border-color: var(--chalk-3);
}

.night .seg button[aria-pressed='true'] {
  background: var(--chalk);
  border-color: var(--chalk);
  color: var(--slate);
}

input[type='range'] {
  width: 100%;
  accent-color: var(--graphite);
}

/* Tone marks: icon + word, never colour alone */
.tone {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  font-size: var(--step--1);
}

.tone::before {
  font-weight: 900;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  color: #fff;
}

.tone.ok {
  color: var(--ok);
}
.tone.ok::before {
  content: '✓';
  background: var(--ok);
}
.tone.warn {
  color: var(--warn);
}
.tone.warn::before {
  content: '!';
  background: var(--warn);
}
.tone.bad {
  color: var(--bad);
}
.tone.bad::before {
  content: '✕';
  background: var(--bad);
}
.night .tone.ok {
  color: var(--night-ok);
}
.night .tone.ok::before {
  background: var(--night-ok);
  color: var(--slate);
}
.night .tone.warn {
  color: var(--night-warn);
}
.night .tone.warn::before {
  background: var(--night-warn);
  color: var(--slate);
}
.night .tone.bad {
  color: var(--night-bad);
}
.night .tone.bad::before {
  background: var(--night-bad);
  color: var(--slate);
}

/* ---------- Title ---------- */
.title-screen {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(300px, 1.1fr);
  align-items: center;
  gap: 48px;
  padding: 48px clamp(16px, 6vw, 96px);
  min-height: 100vh;
}

.title-screen .patch-wrap {
  justify-self: center;
  width: min(440px, 80vw);
}

.title-screen .display {
  font-size: clamp(3.4rem, 9vw, 7.5rem);
}

.title-screen .lede {
  font-size: var(--step-1);
  color: var(--chalk-2);
  margin: 20px 0 32px;
  max-width: 34ch;
}

.title-screen .credit {
  margin-top: 40px;
  color: var(--chalk-3);
  font-size: var(--step--1);
}

.patch {
  width: 100%;
  height: auto;
  display: block;
}

.draw-in .patch {
  animation: stitch 1.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes stitch {
  from {
    clip-path: circle(0% at 50% 50%);
    transform: rotate(-12deg);
  }
  to {
    clip-path: circle(75% at 50% 50%);
    transform: rotate(0);
  }
}

.title-3d {
  position: relative;
  overflow: hidden;
}

.title-bg {
  position: absolute;
  inset: 0;
}

.title-copy {
  position: relative;
  z-index: 2;
  max-width: 560px;
  padding: clamp(32px, 9vh, 96px) clamp(16px, 6vw, 96px);
  display: grid;
  gap: 4px;
  background: linear-gradient(90deg, rgba(2, 4, 10, 0.85), rgba(2, 4, 10, 0));
  min-height: 100vh;
  align-content: center;
}

.title-copy .display {
  font-size: clamp(3.4rem, 9vw, 7.5rem);
}

.title-copy .lede {
  font-size: var(--step-1);
  color: var(--chalk-2);
  margin: 18px 0 26px;
  max-width: 34ch;
}

.title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.patch-mini {
  width: 96px;
  margin-bottom: 18px;
}

.title-copy .credit {
  margin-top: 34px;
  color: var(--chalk-3);
  font-size: var(--step--1);
}

/* ---------- Goal (headline) ---------- */
.goal {
  padding: 40px clamp(16px, 5vw, 72px) 64px;
}

.goal-intro {
  max-width: 62ch;
  margin-bottom: 36px;
}

.goal-intro h2 {
  font-size: var(--step-4);
  margin-bottom: 10px;
}

.sheets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 28px;
}

.sheet {
  position: relative;
  background: #f3f6f2;
  border: 1px solid var(--vellum-line);
  padding: 26px 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 1px 0 rgba(35, 40, 46, 0.08), 0 10px 24px -18px rgba(35, 40, 46, 0.5);
}

.sheet:nth-child(1) {
  transform: rotate(-0.6deg);
}
.sheet:nth-child(3) {
  transform: rotate(0.5deg);
}

.sheet::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  width: 84px;
  height: 20px;
  transform: translateX(-50%) rotate(-2deg);
  background: rgba(217, 162, 27, 0.35);
}

.sheet .planet {
  width: 64px;
  height: 64px;
}

.sheet .level {
  font-size: var(--step--1);
  font-weight: 700;
  color: var(--graphite-2);
}

.sheet h3 {
  font-size: var(--step-3);
  font-stretch: 68%;
  font-weight: 850;
}

.sheet .facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  font-size: var(--step--1);
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px dashed var(--vellum-line);
}

.sheet .facts dt {
  color: var(--graphite-2);
}

.sheet .facts dd {
  margin: 0;
  font-weight: 700;
}

/* ---------- Build ---------- */
.build {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr) minmax(280px, 330px);
  gap: 0;
  flex: 1;
  min-height: 0;
}

.parts {
  border-right: 1px solid var(--vellum-line);
  background: rgba(230, 236, 232, 0.92);
  overflow-y: auto;
  max-height: calc(100vh - 49px);
  padding: 18px 20px 40px;
}

.parts h3 {
  font-size: var(--step-0);
  font-stretch: 80%;
  margin: 22px 0 8px;
}

.parts h3:first-child {
  margin-top: 0;
}

.part-row {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.part-row .label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: var(--step--1);
  color: var(--graphite-2);
}

.part-row .label b {
  color: var(--graphite);
}

.inst {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 2px 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  padding: 8px;
  cursor: pointer;
}

.inst:hover {
  background: rgba(255, 255, 255, 0.5);
}

.inst[aria-pressed='true'] {
  background: #f7faf6;
  border-color: var(--graphite);
}

.inst .box {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--graphite);
  border-radius: 3px;
  margin-top: 2px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
}

.inst[aria-pressed='true'] .box {
  background: var(--graphite);
  color: var(--vellum);
}

.inst .name {
  font-weight: 700;
}

.inst .meta,
.inst .uses {
  grid-column: 2;
  font-size: var(--step--1);
  color: var(--graphite-2);
}

.inst .uses.hit {
  color: var(--teal);
  font-weight: 600;
}

.desk {
  padding: 18px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.gauges {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px 20px;
}

.gauge .g-label {
  font-size: var(--step--1);
  color: var(--graphite-2);
}

.gauge .g-value {
  font-weight: 800;
  font-stretch: 80%;
  font-size: var(--step-1);
  font-variant-numeric: tabular-nums;
}

.gauge .bar {
  position: relative;
  height: 8px;
  background: var(--vellum-2);
  border-radius: 4px;
  margin: 6px 0 4px;
  overflow: hidden;
}

.gauge .bar i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 4px;
  background: var(--graphite);
  transition: width 0.35s ease;
}

.gauge.warn .bar i {
  background: var(--warn);
}

.gauge.bad .bar i {
  background: var(--bad);
}

.gauge .g-note {
  font-size: var(--step--1);
  color: var(--graphite-2);
}

.viewport {
  position: relative;
  height: clamp(300px, 46vh, 520px);
  border: 1px solid var(--vellum-line);
  border-radius: var(--radius-m);
  overflow: hidden;
  background: #dfe6e2;
  touch-action: none;
}

.viewport canvas {
  cursor: grab;
}

.vp-label {
  position: absolute;
  left: 14px;
  top: 12px;
  z-index: 2;
  pointer-events: none;
  font-size: var(--step--1);
  color: var(--graphite-2);
}

.vp-label b {
  display: block;
  font-size: var(--step-3);
  font-stretch: 70%;
  font-weight: 850;
  color: var(--graphite);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.ripple-box {
  background: #f3f6f2;
  border: 1px solid var(--vellum-line);
  border-radius: var(--radius-m);
  padding: 14px 16px 12px;
}

.ripple-box header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}

.ripple-box header h3 {
  font-size: var(--step-0);
}

.ripple-svg {
  width: 100%;
  height: auto;
  display: block;
}

.ripple-svg .edge {
  stroke: var(--vellum-line);
  stroke-width: 1.5;
  fill: none;
}

.ripple-svg .edge.lit {
  stroke: var(--redpen);
  stroke-width: 2;
  stroke-dasharray: 6 4;
  animation: flow 0.9s linear infinite;
}

@keyframes flow {
  to {
    stroke-dashoffset: -20;
  }
}

.ripple-svg .node rect {
  fill: #fff;
  stroke: var(--graphite-3);
  stroke-width: 1;
  transition: stroke 0.2s;
}

.ripple-svg .node.lit rect {
  stroke: var(--redpen);
  stroke-width: 2;
}

.ripple-svg .node .n-label {
  font-size: 11px;
  fill: var(--graphite-2);
}

.ripple-svg .node .n-value {
  font-size: 14px;
  font-weight: 800;
  fill: var(--graphite);
  font-variant-numeric: tabular-nums;
}

.ripple-svg .node .n-delta {
  font-size: 11px;
  font-weight: 800;
  fill: var(--redpen);
}

.ripple-line {
  min-height: 2.9em;
  font-size: var(--step--1);
  color: var(--graphite-2);
  border-top: 1px dashed var(--vellum-line);
  padding-top: 8px;
  margin-top: 6px;
}

.ripple-line b {
  color: var(--redpen);
}

.board {
  border-left: 1px solid var(--vellum-line);
  background: rgba(230, 236, 232, 0.92);
  padding: 18px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  max-height: calc(100vh - 49px);
}

.voice {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 4px 10px;
}

.voice .face {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 850;
  font-stretch: 70%;
  font-size: 18px;
  background: var(--graphite);
  color: var(--vellum);
}

.voice .who {
  font-size: var(--step--1);
  color: var(--graphite-2);
}

.voice .who b {
  color: var(--graphite);
}

.voice .says {
  grid-column: 2;
  font-size: var(--step--1);
  line-height: 1.4;
}

.voice.bad .says {
  color: var(--redpen);
  text-decoration: underline wavy rgba(180, 48, 44, 0.5);
  text-underline-offset: 3px;
}

.mission-id {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: center;
  padding-top: 14px;
  border-top: 1px dashed var(--vellum-line);
}

.mission-id input {
  width: 100%;
  border: 1.5px solid var(--graphite-3);
  background: #fff;
  border-radius: var(--radius-s);
  padding: 6px 8px;
}

.board .go {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

/* ---------- Test ---------- */
.test {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(260px, 320px);
  flex: 1;
}

.test-list {
  padding: 18px 20px 40px;
  border-right: 1px solid var(--vellum-line);
  background: rgba(230, 236, 232, 0.92);
  display: grid;
  align-content: start;
  gap: 10px;
}

.test-item {
  background: #f7faf6;
  border: 1px solid var(--vellum-line);
  border-radius: var(--radius-m);
  padding: 12px;
  display: grid;
  gap: 6px;
}

.test-item header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.test-item .covers {
  font-size: var(--step--1);
  color: var(--graphite-2);
}

.fog {
  padding: 18px 24px 40px;
}

.fog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.tile {
  position: relative;
  min-height: 116px;
  border: 1px solid var(--graphite-3);
  border-radius: var(--radius-m);
  background: #fbfcfa;
  padding: 10px 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tile .t-name {
  font-weight: 800;
  font-stretch: 80%;
  position: relative;
  z-index: 2;
}

.tile .t-odds {
  font-size: var(--step--1);
  color: var(--graphite-2);
  position: relative;
  z-index: 2;
  font-variant-numeric: tabular-nums;
}

.tile .mist {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 50% at 30% 40%, rgba(159, 175, 168, 0.9), transparent 70%),
    radial-gradient(50% 60% at 75% 70%, rgba(159, 175, 168, 0.85), transparent 70%),
    rgba(196, 207, 201, 0.6);
  transition: opacity 0.6s ease;
  z-index: 1;
}

.tile.found {
  border-color: var(--redpen);
  border-width: 2px;
}

.tile .finding {
  position: relative;
  z-index: 2;
  font-size: var(--step--1);
  color: var(--redpen);
  font-weight: 600;
}

.tile .acts {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
}

.tile.fixed .finding {
  color: var(--teal);
  text-decoration: line-through;
}

.test-side {
  padding: 18px 20px;
  border-left: 1px solid var(--vellum-line);
  background: rgba(230, 236, 232, 0.92);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ledger {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  font-size: var(--step--1);
}

.ledger dt {
  color: var(--graphite-2);
}

.ledger dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.log {
  font-size: var(--step--1);
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  padding: 0;
  margin: 0;
  list-style: none;
}

.log li {
  border-left: 2px solid var(--graphite-3);
  padding-left: 8px;
}

.log li.bad {
  border-left-color: var(--redpen);
}

.night .log li {
  border-left-color: var(--chalk-3);
}

.night .log li.bad {
  border-left-color: var(--night-bad);
}

.night .log li.ok {
  border-left-color: var(--night-ok);
}

/* ---------- Window ---------- */
.window {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  flex: 1;
}

.chart-area {
  padding: 18px 20px 24px;
  min-width: 0;
  position: relative;
}

.chart-area canvas {
  width: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.side {
  border-left: 1px solid var(--slate-3);
  padding: 18px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--slate-2);
}

.night .ledger dt {
  color: var(--chalk-2);
}

.legend {
  display: grid;
  gap: 8px;
  font-size: var(--step--1);
}

.legend .ramp {
  height: 10px;
  border-radius: 2px;
}

.legend .ramp-labels {
  display: flex;
  justify-content: space-between;
  color: var(--chalk-2);
}

.legend .key {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend .swatch {
  width: 22px;
  height: 14px;
  border-radius: 2px;
  flex: none;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--chalk);
  color: var(--slate);
  border-radius: var(--radius-s);
  padding: 8px 10px;
  font-size: var(--step--1);
  line-height: 1.35;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  min-width: 190px;
  z-index: 5;
  font-variant-numeric: tabular-nums;
}

.tooltip b {
  font-weight: 800;
}

/* ---------- Flight ---------- */
.flight {
  position: relative;
  flex: 1;
  min-height: 0;
}

.flight canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hud {
  position: absolute;
  top: 16px;
  left: 20px;
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 16px;
  font-size: var(--step--1);
  background: rgba(16, 25, 34, 0.75);
  padding: 10px 14px;
  border-radius: var(--radius-m);
  font-variant-numeric: tabular-nums;
}

.hud dt {
  color: var(--chalk-2);
}

.hud dd {
  margin: 0;
  font-weight: 700;
}

.hud-controls {
  position: absolute;
  top: 16px;
  right: 20px;
  display: flex;
  gap: 8px;
}

.event-card {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 32px));
  background: var(--chalk);
  color: var(--slate);
  border-radius: var(--radius-m);
  padding: 18px 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  display: grid;
  gap: 10px;
}

.event-card h3 {
  font-size: var(--step-2);
}

.event-card .choices {
  display: grid;
  gap: 8px;
}

.event-card .choice {
  text-align: left;
  border: 1.5px solid var(--slate);
  background: transparent;
  border-radius: var(--radius-m);
  padding: 10px 12px;
  cursor: pointer;
  display: grid;
  gap: 2px;
}

.event-card .choice:hover {
  background: rgba(16, 25, 34, 0.06);
}

.event-card .choice small {
  color: #4d5b68;
}

.event-card .outcome {
  font-weight: 600;
}

.event-card .tone.ok {
  color: var(--ok);
}
.event-card .tone.ok::before {
  background: var(--ok);
  color: #fff;
}
.event-card .tone.warn {
  color: var(--warn);
}
.event-card .tone.warn::before {
  background: var(--warn);
  color: #fff;
}
.event-card .tone.bad {
  color: var(--bad);
}
.event-card .tone.bad::before {
  background: var(--bad);
  color: #fff;
}

.suspense {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(10, 16, 22, 0.86);
  text-align: center;
  padding: 24px;
}

.suspense .inner {
  max-width: 560px;
  display: grid;
  gap: 14px;
  justify-items: center;
}

.suspense .display {
  font-size: clamp(2.4rem, 6vw, 4rem);
}

.signal-bar {
  width: min(420px, 80vw);
  height: 4px;
  background: var(--slate-3);
  border-radius: 2px;
  overflow: hidden;
}

.signal-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--gold);
}

/* ---------- 3D game screens ---------- */
.game {
  position: relative;
  flex: 1;
  min-height: 70vh;
  overflow: hidden;
  background: #000;
  outline: none;
}

.game > canvas {
  position: absolute;
  inset: 0;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 6px;
  margin: 0 2px;
  border-radius: 4px;
  border: 1px solid var(--chalk-3);
  border-bottom-width: 3px;
  font: 700 0.8rem var(--font);
  text-align: center;
  color: var(--chalk);
  background: var(--slate-2);
}

.g-hud {
  position: absolute;
  z-index: 3;
  background: rgba(10, 16, 22, 0.72);
  border-radius: var(--radius-m);
  padding: 12px 14px;
  font-size: var(--step--1);
  color: var(--chalk);
  backdrop-filter: blur(4px);
}

.g-hud.left {
  left: 16px;
  top: 16px;
  width: 270px;
}

.g-hud dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  margin: 0 0 8px;
  font-variant-numeric: tabular-nums;
}

.g-hud dt {
  color: var(--chalk-2);
}

.g-hud dd {
  margin: 0;
  font-weight: 800;
  font-size: var(--step-0);
}

.g-hud dd small {
  font-weight: 400;
  color: var(--chalk-2);
  font-size: var(--step--1);
}

.g-hud label {
  display: block;
  margin-top: 8px;
  color: var(--chalk-2);
}

.g-hud label em {
  font-style: normal;
  color: var(--gold);
  font-weight: 700;
}

.meter {
  position: relative;
  height: 9px;
  background: var(--slate-3);
  border-radius: 5px;
  overflow: hidden;
  margin-top: 4px;
}

.meter i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--chalk-2);
  border-radius: 5px;
}

.meter s {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--night-warn);
}

.meter.hot i {
  background: var(--night-bad);
}

.meter.fuel i {
  background: #5598e7;
}

.meter.thr i {
  background: var(--gold);
}

.g-dial {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: 230px;
  text-align: center;
  background: rgba(10, 16, 22, 0.72);
  border-radius: var(--radius-m);
  padding: 8px 10px 10px;
  font-size: var(--step--1);
  font-weight: 700;
}

.g-dial .good {
  color: var(--night-ok);
}
.g-dial .meh {
  color: var(--night-warn);
}
.g-dial .off {
  color: var(--night-bad);
}

.g-msg {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 16%;
  transform: translate(-50%, -12px);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  font-stretch: 70%;
  font-weight: 850;
  font-size: clamp(1.3rem, 2.6vw, 2.2rem);
  color: var(--chalk);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.9);
  transition: opacity 0.25s, transform 0.25s;
  max-width: 80%;
}

.g-msg.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.g-msg.count {
  font-size: clamp(4rem, 12vw, 9rem);
  top: 30%;
}

.g-msg.big {
  font-size: clamp(3rem, 8vw, 6rem);
  color: var(--gold);
  top: 26%;
}

.g-msg.warn {
  color: var(--night-warn);
}

.g-msg.bad {
  color: var(--night-bad);
}

.g-help,
.g-end {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100% - 32px));
  background: rgba(16, 25, 34, 0.94);
  border: 1px solid var(--slate-3);
  border-radius: 10px;
  padding: 22px 24px;
  display: grid;
  gap: 10px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.g-help b {
  font-size: var(--step-2);
  font-stretch: 72%;
  font-weight: 850;
}

.g-help .btn {
  margin-top: 8px;
  justify-self: start;
}

.g-end .display {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
}

.g-end ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  font-size: var(--step--1);
}

.g-stars {
  color: var(--gold);
  font-size: 2.2rem;
  letter-spacing: 6px;
}

.g-end-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.g-mute {
  position: absolute;
  z-index: 4;
  right: 16px;
  top: 16px;
}

.g-touch {
  position: absolute;
  z-index: 4;
  right: 16px;
  bottom: 16px;
  display: none;
  gap: 8px;
}

.g-touch button {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2px solid var(--chalk-3);
  background: rgba(16, 25, 34, 0.75);
  color: var(--chalk);
  font-weight: 800;
  touch-action: none;
}

@media (hover: none) {
  .g-touch {
    display: flex;
  }
  .g-dial {
    bottom: 96px;
  }
}

.game > canvas.minimap {
  position: absolute;
  inset: auto;
  z-index: 3;
  right: 16px;
  top: 60px;
  width: 220px;
  height: 220px;
  border-radius: var(--radius-m);
}

.g-challenge {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  background: rgba(10, 16, 22, 0.82);
  border: 1px solid var(--slate-3);
  border-radius: var(--radius-m);
  padding: 10px 14px;
  display: grid;
  gap: 6px;
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

.g-challenge > b {
  font-size: var(--step-1);
  font-stretch: 75%;
}

.ch-row {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 10px;
  align-items: center;
}

.ch-row .good {
  color: var(--night-ok);
}
.ch-row .meh {
  color: var(--night-warn);
}
.ch-row .off {
  color: var(--night-bad);
}

.g-challenge .hint {
  color: var(--gold);
  font-size: 1.25rem;
  line-height: 1;
}

.meter.dv i {
  background: var(--gold);
}

.meter.shield i {
  background: var(--night-ok);
}

.small-help {
  top: auto;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 8px 14px;
  width: auto;
  font-size: var(--step--1);
}

.event-card.dark {
  background: rgba(16, 25, 34, 0.95);
  color: var(--chalk);
  border: 1px solid var(--slate-3);
}

.event-card.dark .choice {
  border-color: var(--chalk-3);
}

.event-card.dark .choice small {
  color: var(--chalk-2);
}

.event-card.dark .choice:hover {
  background: rgba(233, 238, 242, 0.06);
}

.event-card.dark .tone.ok {
  color: var(--night-ok);
}
.event-card.dark .tone.ok::before {
  background: var(--night-ok);
  color: var(--slate);
}
.event-card.dark .tone.warn {
  color: var(--night-warn);
}
.event-card.dark .tone.warn::before {
  background: var(--night-warn);
  color: var(--slate);
}
.event-card.dark .tone.bad {
  color: var(--night-bad);
}
.event-card.dark .tone.bad::before {
  background: var(--night-bad);
  color: var(--slate);
}

.g-panel {
  position: absolute;
  z-index: 4;
  left: 16px;
  top: 16px;
  width: min(380px, calc(100% - 32px));
  background: rgba(10, 16, 22, 0.88);
  border: 1px solid var(--slate-3);
  border-radius: 10px;
  padding: 16px 18px;
  display: grid;
  gap: 10px;
}

.g-panel h2 {
  font-size: var(--step-2);
}

.slider {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  font-size: var(--step--1);
}

.slider b {
  font-variant-numeric: tabular-nums;
}

.slider input {
  grid-column: 1 / -1;
  accent-color: var(--gold);
}

.predict {
  display: grid;
  gap: 4px;
  font-size: var(--step--1);
  background: var(--slate-2);
  border-radius: var(--radius-m);
  padding: 10px 12px;
  font-variant-numeric: tabular-nums;
}

.g-hud.aero {
  width: 300px;
}

.g-hud .warn {
  color: var(--night-bad);
}

.g-hud .meh {
  color: var(--night-warn);
}

.aero-actions {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.ladder {
  position: absolute;
  z-index: 3;
  right: 70px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: min(60vh, 460px);
  border-radius: 4px;
  overflow: visible;
  background: var(--slate-3);
}

.ladder i {
  position: absolute;
  left: 0;
  right: 0;
  display: block;
}

.ladder b {
  position: absolute;
  left: 30px;
  transform: translateY(-50%);
  white-space: nowrap;
  font-size: var(--step--1);
  color: var(--chalk);
  font-variant-numeric: tabular-nums;
}

.ladder .lt,
.ladder .lb {
  position: absolute;
  right: 32px;
  font-size: 11px;
  color: var(--chalk-2);
  white-space: nowrap;
}

.ladder .lt {
  top: -4px;
}

.ladder .lb {
  bottom: -4px;
}

.sci-top {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  background: rgba(10, 16, 22, 0.8);
  border-radius: var(--radius-m);
  padding: 8px 14px 10px;
  display: grid;
  gap: 6px;
  font-size: var(--step--1);
  text-align: center;
}

.chip {
  justify-self: center;
  padding: 2px 10px;
  border-radius: 99px;
  background: var(--slate-3);
  font-weight: 700;
}

.chip.ok {
  background: var(--night-ok);
  color: var(--slate);
}

.chip.bad {
  background: var(--night-bad);
  color: var(--slate);
}

.sci-insts {
  width: 290px;
  display: grid;
  gap: 6px;
}

.sci-inst {
  display: grid;
  grid-template-columns: auto 10px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 4px 6px;
  border-radius: 4px;
}

.sci-inst i,
.objective .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.objective .dot {
  margin-right: 6px;
}

.sci-inst.on {
  background: rgba(233, 238, 242, 0.12);
}

.sci-inst.dead {
  opacity: 0.45;
  text-decoration: line-through;
}

.sci-inst.passive kbd {
  opacity: 0.6;
}

.sci-inst small {
  display: block;
  color: var(--chalk-2);
  font-size: 11px;
}

.sci-inst em {
  font-style: normal;
  color: var(--chalk-2);
  font-variant-numeric: tabular-nums;
}

.sci-goals {
  right: 16px;
  top: 16px;
  width: 300px;
  display: grid;
  gap: 10px;
}

.sci-bottom {
  left: 16px;
  bottom: 16px;
  width: 290px;
}

.sci-bottom.flash {
  box-shadow: 0 0 0 2px var(--night-bad);
}

.sci-keys {
  display: grid;
  gap: 6px;
  font-size: var(--step--1);
}

.sci-keys span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sci-keys i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.g-touch.sci-touch {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

.g-stars.small {
  font-size: 1.6rem;
}

/* ---------- Science ---------- */
.science {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr);
  gap: 0;
  flex: 1;
}

.sci-main {
  padding: 18px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.sci-side {
  padding: 18px 20px 32px;
  background: var(--slate-2);
  border-left: 1px solid var(--slate-3);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.forecast svg {
  width: 100%;
  height: auto;
  display: block;
}

.inst-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
}

.inst-table th {
  text-align: left;
  font-weight: 600;
  color: var(--chalk-2);
  padding: 6px 8px;
  border-bottom: 1px solid var(--slate-3);
}

.inst-table td {
  padding: 8px;
  border-bottom: 1px solid var(--slate-3);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.inst-table td.n {
  text-align: right;
}

.inst-table .dead {
  color: var(--night-bad);
}

.switch {
  border: 1.5px solid var(--chalk-3);
  background: transparent;
  border-radius: 99px;
  padding: 3px 10px;
  font-size: var(--step--1);
  cursor: pointer;
}

.switch[aria-pressed='true'] {
  background: var(--night-ok);
  border-color: var(--night-ok);
  color: var(--slate);
  font-weight: 700;
}

.objective {
  display: grid;
  gap: 4px;
}

.objective .o-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: var(--step--1);
}

.objective .o-head b {
  font-variant-numeric: tabular-nums;
}

.objective .key-flag {
  color: var(--gold);
  font-weight: 700;
}

.objective .obar {
  height: 10px;
  background: var(--slate-3);
  border-radius: 5px;
  overflow: hidden;
}

.objective .obar i {
  display: block;
  height: 100%;
  background: #5598e7;
  border-radius: 5px;
  transition: width 0.4s ease;
}

.objective.done .obar i {
  background: var(--night-ok);
}

.recorder .obar i {
  background: var(--chalk-2);
}

.sci-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- Legacy ---------- */
.legacy {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
  gap: 40px;
  padding: 36px clamp(16px, 5vw, 64px) 64px;
  align-items: start;
}

.legacy .patch-col {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 14px;
}

.legacy .verdict {
  font-size: var(--step--1);
  font-weight: 700;
}

.legacy .headline {
  font-size: clamp(2.4rem, 5.5vw, 4.4rem);
  margin: 6px 0 14px;
  max-width: 18ch;
}

.legacy section {
  margin-top: 30px;
}

.legacy section > h3 {
  font-size: var(--step-1);
  margin-bottom: 10px;
}

.legacy .stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.legacy .stat .v {
  font-size: var(--step-2);
  font-weight: 850;
  font-stretch: 75%;
  font-variant-numeric: tabular-nums;
}

.legacy .stat .l {
  font-size: var(--step--1);
  color: var(--graphite-2);
}

.legacy .objective .obar {
  background: var(--vellum-2);
}

.legacy .objective .obar i {
  background: var(--graphite);
}

.legacy .objective.done .obar i {
  background: var(--teal);
}

.legacy .objective .key-flag {
  color: var(--gold-ink);
}

.hindsight {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.hindsight li {
  background: #f7faf6;
  border-left: 3px solid var(--redpen);
  padding: 10px 14px;
  max-width: 72ch;
}

.hindsight li.good {
  border-left-color: var(--teal);
}

.autopsy {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
  max-width: 820px;
}

.autopsy th,
.autopsy td {
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid var(--vellum-line);
  vertical-align: top;
}

.autopsy th {
  color: var(--graphite-2);
  font-weight: 600;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .build,
  .test {
    grid-template-columns: 1fr;
  }
  .parts,
  .board,
  .test-list,
  .test-side {
    max-height: none;
    border: 0;
  }
  .window,
  .science {
    grid-template-columns: 1fr;
  }
  .side,
  .sci-side {
    border-left: 0;
    border-top: 1px solid var(--slate-3);
  }
}

@media (max-width: 760px) {
  .title-screen,
  .legacy {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .legacy .patch-col {
    position: static;
    max-width: 320px;
  }
  .track {
    padding: 8px 16px;
  }
  .desk,
  .fog,
  .sci-main,
  .chart-area {
    padding-left: 16px;
    padding-right: 16px;
  }
  .flight {
    min-height: 78vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- System: boot splash, crash and recovery, toasts, settings ---------- */
.ek-boot {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(120% 90% at 70% 110%, #2a1a10 0%, #0b1018 45%, #02040a 100%);
}

.ek-boot-in {
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 16px;
  text-align: center;
}

.ek-boot-name {
  font-stretch: 68%;
  font-weight: 850;
  font-size: clamp(2.4rem, 8vw, 4.5rem);
  line-height: 0.95;
  color: var(--chalk);
}

.ek-boot-bar {
  inline-size: min(220px, 60vw);
  block-size: 3px;
  background: var(--slate-3);
  border-radius: 2px;
  overflow: hidden;
}

.ek-boot-bar span {
  display: block;
  inline-size: 35%;
  block-size: 100%;
  background: var(--gold);
  animation: ek-boot 1.4s ease-in-out infinite;
}

@keyframes ek-boot {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(290%);
  }
}

[dir='rtl'] .ek-boot-bar span {
  animation-direction: reverse;
}

.ek-boot-msg {
  color: var(--chalk-2);
  font-size: var(--step--1);
  max-inline-size: 36ch;
}

/* A painted dusk sky where the 3D view would be (no WebGL). */
.ek-no3d {
  background:
    radial-gradient(60% 50% at 78% 105%, rgba(240, 180, 41, 0.28), transparent 70%),
    radial-gradient(1px 1px at 20% 30%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 62% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 84% 42%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 38% 62%, #cfd8e3 50%, transparent 51%),
    linear-gradient(180deg, #02040a 0%, #0d1824 70%, #1f2a33 100%);
}

.ek-sys {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px;
  background: radial-gradient(100% 70% at 50% 120%, #1d2a38 0%, var(--slate) 60%);
}

.ek-sys-card {
  max-inline-size: 560px;
  display: grid;
  gap: 14px;
  padding: clamp(20px, 4vw, 36px);
  border: 1px solid var(--slate-3);
  border-radius: var(--radius-m);
  background: rgba(16, 25, 34, 0.92);
}

.ek-sys-kicker {
  color: var(--night-warn);
  font-weight: 700;
  font-size: var(--step--1);
}

.ek-sys-card h1 {
  font-size: var(--step-4);
  color: var(--chalk);
}

.ek-sys-card p {
  color: var(--chalk-2);
}

.ek-sys-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-block-start: 6px;
}

.ek-sys-details {
  color: var(--chalk-3);
  font-size: var(--step--1);
}

.ek-sys-details summary {
  cursor: pointer;
  color: var(--chalk-2);
}

.ek-sys-details pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 8px 0 0;
  padding: 10px;
  background: #0a1118;
  border-radius: var(--radius-s);
}

.ek-toasts {
  position: fixed;
  /* Top corner, under screen headers: the bottom holds the main buttons. */
  inset-block-start: 76px;
  inset-inline-end: 16px;
  z-index: 1000;
  display: grid;
  gap: 8px;
  max-inline-size: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.ek-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border-radius: var(--radius-m);
  background: #0e1720;
  color: var(--chalk);
  border: 1px solid var(--slate-3);
  border-inline-start: 4px solid var(--chalk-3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  font-size: var(--step--1);
  animation: ek-toast-in 0.25s ease-out;
}

.ek-toast.warn {
  border-inline-start-color: var(--night-warn);
}

.ek-toast.ok {
  border-inline-start-color: var(--night-ok);
}

.ek-toast.bad {
  border-inline-start-color: var(--night-bad);
}

.ek-toast p {
  flex: 1;
}

.ek-toast-x {
  border: 0;
  background: transparent;
  color: var(--chalk-2);
  font-size: 1.2rem;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: var(--radius-s);
}

.ek-toast-x:hover {
  color: var(--chalk);
  background: rgba(255, 255, 255, 0.08);
}

@keyframes ek-toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

.ek-settings {
  inline-size: min(520px, calc(100vw - 32px));
  max-block-size: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--slate-3);
  border-radius: var(--radius-m);
  background: var(--slate);
  color: var(--chalk);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.ek-settings::backdrop {
  background: rgba(2, 4, 10, 0.6);
}

.ek-settings-in {
  display: grid;
  gap: 4px;
  padding: 20px clamp(16px, 4vw, 26px) 22px;
}

.ek-settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: 6px;
}

.ek-settings-head h2 {
  font-size: var(--step-3);
}

.ek-settings-x {
  border: 0;
  background: transparent;
  color: var(--chalk-2);
  font-size: 1.6rem;
  line-height: 1;
  padding: 4px 10px;
  border-radius: var(--radius-s);
  cursor: pointer;
}

.ek-settings-x:hover {
  color: var(--chalk);
  background: rgba(255, 255, 255, 0.08);
}

.ek-set-row {
  display: grid;
  gap: 8px;
  padding-block: 12px;
  border-block-start: 1px solid var(--slate-3);
}

.ek-set-row h3 {
  font-size: var(--step-0);
  font-stretch: 85%;
}

.ek-settings .seg button {
  padding: 8px 14px;
  font-size: var(--step-0);
  border-color: var(--chalk-3);
}

.ek-settings .seg button[aria-pressed='true'] {
  background: var(--chalk);
  border-color: var(--chalk);
  color: var(--slate);
}

.ek-set-note {
  color: var(--chalk-2);
  font-size: var(--step--1);
}

.ek-settings .tone.ok {
  color: var(--night-ok);
}

.ek-settings .tone.warn {
  color: var(--night-warn);
}

.ek-set-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ek-settings .btn.small:not(.ghost) {
  background: var(--chalk);
  color: var(--slate);
}

.ek-file {
  position: relative;
}

.ek-file input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  inline-size: 100%;
}

.ek-file:focus-within {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.ek-set-msg {
  color: var(--night-bad);
  font-size: var(--step--1);
}

.ek-set-msg:empty {
  display: none;
}

/* Settings → Reduce motion, whatever the system says. */
html.ek-reduce-motion *,
html.ek-reduce-motion *::before,
html.ek-reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* Low quality tier: skip the costliest page effects too. */
html.ek-tier-low .screen * {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .ek-boot-bar span {
    animation: none;
    inline-size: 100%;
    opacity: 0.6;
  }
}
