:root {
  --bg: #07080a;
  --ink: #f3efe6;
  --ink-soft: rgba(243, 239, 230, 0.62);
  --ink-faint: rgba(243, 239, 230, 0.34);
  --gold: #cbab63;
  --line: rgba(243, 239, 230, 0.12);
  --line-strong: rgba(243, 239, 230, 0.30);
  --mono: 'DM Mono', ui-monospace, monospace;
  --serif: 'Fraunces', Georgia, serif;
  color-scheme: dark;
}

/* The UA's [hidden] loses to any author `display`; this keeps hidden meaning hidden. */
[hidden] { display: none !important; }

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 300;
  line-height: 1.5;
}

.skip-link {
  position: absolute; left: 16px; top: -3rem;
  padding: 0.5rem 0.8rem; background: var(--ink); color: var(--bg);
  font-size: 0.8rem; text-decoration: none; z-index: 10;
}
.skip-link:focus { top: 16px; }

kbd {
  font-family: var(--mono); font-size: 0.72em;
  padding: 0.05em 0.4em; border: 1px solid var(--line-strong); border-radius: 3px;
}

/* ── Page chrome ─────────────────────────────────────────────────────────── */
.masthead {
  display: flex; align-items: baseline; gap: 1rem;
  max-width: 1120px; margin: 0 auto; padding: 1.4rem 16px 0;
}
.wordmark {
  color: var(--ink); text-decoration: none;
  font-family: var(--serif); font-size: 1.1rem; letter-spacing: 0.18em;
}
.wordmark:hover, .wordmark:focus-visible { color: var(--gold); }
.masthead__kicker {
  font-size: 0.62rem; letter-spacing: 0.28em; text-transform: uppercase; color: var(--ink-faint);
}

.layout {
  display: grid; gap: 2rem 2.5rem;
  max-width: 1120px; margin: 0 auto; padding: 2.4rem 16px 4rem;
  grid-template-columns: minmax(0, 1fr);
}

.intro h1 {
  margin: 0 0 0.8rem;
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(1.9rem, 4.5vw, 3rem); line-height: 1.08; letter-spacing: -0.01em;
}
.intro p { margin: 0; max-width: 52ch; color: var(--ink-soft); font-size: 0.85rem; }

@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr) 17rem; align-items: start; padding-bottom: 2rem; }
  .intro {
    grid-column: 1 / -1;
    display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2.5rem; align-items: end;
  }
  .intro h1 { margin: 0; }
  .intro p { max-width: 46ch; }
  /* Width follows the viewport height too, so the whole tool fits without scrolling;
     capping height instead would fight aspect-ratio and squash the screen. */
  .screen { width: min(100%, calc((100vh - 17rem) * 16 / 9)); }
}

/* ── The screen: preview and full-screen surface in one ───────────────────── */
.preview { min-width: 0; }

.screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  container-type: size;
  overflow: hidden;
  background: #000;
  color: #fff;
  border: 1px solid var(--line);
  cursor: zoom-in;
  font-family: 'Segoe UI Variable Display', 'Segoe UI Variable', 'Segoe UI Light', 'Segoe UI', system-ui, sans-serif;
  font-weight: 300;
  text-align: center;
  -webkit-font-smoothing: antialiased;
}
.screen:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.screen:fullscreen {
  width: 100%; height: 100%; aspect-ratio: auto; border: 0; cursor: default;
}
/* Kept as its own rule: an engine that does not know a selector drops the whole list. */
.screen:-webkit-full-screen {
  width: 100%; height: 100%; aspect-ratio: auto; border: 0; cursor: default;
}
.screen::backdrop { background: #000; }
.screen.is-live.is-idle { cursor: none; }

/* Sizes are in container-height units so the miniature and the real thing match. */
.screen__center {
  position: absolute; left: 0; right: 0; top: 40%;
  transform: translateY(-40%);
  display: flex; flex-direction: column; align-items: center;
  font-size: max(8px, 2.1cqh); line-height: 1.45;
}
.screen__line { margin: 0; white-space: nowrap; }
.screen__foot {
  position: absolute; left: 0; right: 0; bottom: 9%; margin: 0;
  font-size: max(8px, 2.1cqh); white-space: nowrap;
}

/* Windows-style orbiting dots: each dot is a full-size ring that rotates about the
   centre with its own easing, so the dots bunch up, spread out and vanish together. */
.spinner {
  position: relative;
  width: 4.4cqh; height: 4.4cqh; min-width: 16px; min-height: 16px;
  margin-bottom: 2.4cqh;
}
.spinner i {
  position: absolute; inset: 0;
  opacity: 0;
  animation: orbit 5.4s infinite;
}
.spinner i::after {
  content: ''; position: absolute; top: 0; left: 50%;
  width: 13%; height: 13%; margin-left: -6.5%;
  border-radius: 50%; background: currentColor;
}
.spinner i:nth-child(2) { animation-delay: 0.24s; }
.spinner i:nth-child(3) { animation-delay: 0.48s; }
.spinner i:nth-child(4) { animation-delay: 0.72s; }
.spinner i:nth-child(5) { animation-delay: 0.96s; }

@keyframes orbit {
  0%   { transform: rotate(225deg); opacity: 1; animation-timing-function: ease-out; }
  7%   { transform: rotate(345deg); animation-timing-function: linear; }
  30%  { transform: rotate(455deg); animation-timing-function: ease-in-out; }
  39%  { transform: rotate(690deg); animation-timing-function: linear; }
  70%  { transform: rotate(815deg); opacity: 1; animation-timing-function: ease-out; }
  75%  { transform: rotate(945deg); animation-timing-function: ease-out; }
  76%  { transform: rotate(945deg); opacity: 0; }
  100% { transform: rotate(945deg); opacity: 0; }
}

/* ── Controls ────────────────────────────────────────────────────────────── */
.controls {
  display: grid; gap: 1.1rem;
  padding: 1.3rem; border: 1px solid var(--line);
  background: rgba(243, 239, 230, 0.02);
}

.field { display: grid; gap: 0.45rem; margin: 0; padding: 0; border: 0; min-width: 0; }
.field__label {
  padding: 0;
  font-size: 0.6rem; letter-spacing: 0.26em; text-transform: uppercase; color: var(--ink-faint);
}
.field__row { display: flex; align-items: baseline; gap: 0.6rem; }
.field__unit { font-size: 0.8rem; color: var(--ink-soft); }

.field input[type='number'] {
  width: 6.5rem; padding: 0.5rem 0.6rem;
  background: transparent; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 0;
  font: inherit; font-size: 1rem;
}
.field input[type='number']:focus-visible { outline: none; border-color: var(--gold); }

.field--choice { grid-template-columns: repeat(2, max-content); column-gap: 1.2rem; }
.field--choice .field__label { grid-column: 1 / -1; margin-bottom: 0.45rem; }
.field--choice label { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.85rem; cursor: pointer; }
.field--choice input { accent-color: var(--gold); margin: 0; }

.actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 1rem;
  background: transparent; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 0;
  font: inherit; font-size: 0.8rem; letter-spacing: 0.08em;
  cursor: pointer;
  transition: border-color 0.25s ease, color 0.25s ease, background 0.25s ease;
}
.btn:hover, .btn:focus-visible { border-color: var(--gold); color: var(--gold); outline: none; }
.btn--primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn--primary:hover, .btn--primary:focus-visible { background: var(--gold); border-color: var(--gold); color: var(--bg); }
.btn--primary kbd { border-color: rgba(7, 8, 10, 0.35); }

.status { margin: 0; min-height: 1.2em; font-size: 0.75rem; color: var(--ink-soft); }

/* ── Companion window on another monitor (?skarm=1): the screen and nothing else ── */
html[data-mode='screen'],
html[data-mode='screen'] body { height: 100%; overflow: hidden; background: #000; }
html[data-mode='screen'] .skip-link,
html[data-mode='screen'] .masthead,
html[data-mode='screen'] .intro,
html[data-mode='screen'] .controls { display: none; }
html[data-mode='screen'] .layout { display: block; max-width: none; margin: 0; padding: 0; }
html[data-mode='screen'] .screen {
  position: fixed; inset: 0; width: 100%; height: 100%;
  aspect-ratio: auto; border: 0; cursor: default;
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}
