/* beam.html — one hand-written stylesheet for every surface.
   landing (/) · session chrome (/:code, /:code/present) · demo (/demo) · 404 */

/* ---------------------------------------------------------------- tokens
   Light values live on :root. The dark palette is declared once, right here,
   as --dk-* literals; the two dark selectors below only remap them. So no
   color is ever defined only inside a media query, and every literal has
   exactly one home.

   Two hues, two jobs. Amber is the brand: the beam, primary actions, copy
   confirmations, focus. Green means one thing only — a live connection. */
:root {
  color-scheme: light dark;

  --bg: #faf9f7;
  --surface: #ffffff;
  --ink: #161512;
  --muted: #73706a;    /* meaningful secondary text — AA on --bg */
  --faint: #8c887e;    /* decorative only: counters, placeholders, idle icons */
  --line: rgba(22, 21, 18, 0.09);
  --line-2: rgba(22, 21, 18, 0.17);
  --accent: #c77a02;          /* light source: beam, hairlines */
  --accent-solid: #a05f03;    /* filled primary action (AA on white) */
  --accent-soft: rgba(199, 122, 2, 0.13);
  --accent-line: rgba(199, 122, 2, 0.42);
  --on-accent: #fffdf8;
  --live: #15854c;            /* connected / following — 4.4:1 on --bg */
  --live-soft: rgba(21, 133, 76, 0.16);
  --danger: #a8412a;
  --glow: rgba(199, 122, 2, 0.055);
  --shadow: 0 1px 2px rgba(22, 21, 18, 0.05), 0 14px 34px -22px rgba(22, 21, 18, 0.4);
  --lift: 0 10px 24px -12px rgba(160, 95, 3, 0.75);

  --dk-bg: #151412;
  --dk-surface: #1c1b18;
  --dk-ink: #edebe6;
  --dk-muted: #99958c;
  --dk-faint: #75726a;
  --dk-line: rgba(237, 235, 230, 0.1);
  --dk-line-2: rgba(237, 235, 230, 0.2);
  --dk-accent: #f0a32b;
  --dk-accent-soft: rgba(240, 163, 43, 0.15);
  --dk-accent-line: rgba(240, 163, 43, 0.45);
  --dk-on-accent: #1b1408;
  --dk-live: #43c07d;         /* 8:1 on --dk-bg */
  --dk-live-soft: rgba(67, 192, 125, 0.2);
  --dk-danger: #e08163;
  --dk-glow: rgba(240, 163, 43, 0.07);
  --dk-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 16px 40px -24px rgba(0, 0, 0, 0.8);
  --dk-lift: 0 10px 26px -12px rgba(240, 163, 43, 0.42);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.22, 0.68, 0.32, 1);
  --t1: 160ms;
  --t2: 220ms;
  --bar: 52px;
  /* one gap scale for icon/label pairs: small glyphs sit 8px from their text,
     a 30px disc gets 10px. Nothing in between, so nothing looks accidental. */
  --gap-i: 8px;
  --gap-i-lg: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--dk-bg);
    --surface: var(--dk-surface);
    --ink: var(--dk-ink);
    --muted: var(--dk-muted);
    --faint: var(--dk-faint);
    --line: var(--dk-line);
    --line-2: var(--dk-line-2);
    --accent: var(--dk-accent);
    --accent-solid: var(--dk-accent);
    --accent-soft: var(--dk-accent-soft);
    --accent-line: var(--dk-accent-line);
    --on-accent: var(--dk-on-accent);
    --live: var(--dk-live);
    --live-soft: var(--dk-live-soft);
    --danger: var(--dk-danger);
    --glow: var(--dk-glow);
    --shadow: var(--dk-shadow);
    --lift: var(--dk-lift);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--dk-bg);
  --surface: var(--dk-surface);
  --ink: var(--dk-ink);
  --muted: var(--dk-muted);
  --faint: var(--dk-faint);
  --line: var(--dk-line);
  --line-2: var(--dk-line-2);
  --accent: var(--dk-accent);
  --accent-solid: var(--dk-accent);
  --accent-soft: var(--dk-accent-soft);
  --accent-line: var(--dk-accent-line);
  --on-accent: var(--dk-on-accent);
  --live: var(--dk-live);
  --live-soft: var(--dk-live-soft);
  --danger: var(--dk-danger);
  --glow: var(--dk-glow);
  --shadow: var(--dk-shadow);
  --lift: var(--dk-lift);
}

:root[data-theme="light"] { color-scheme: light; }

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button { background: none; border: 0; padding: 0; cursor: pointer; }

h1, h2, p, ol, ul { margin: 0; }

code { font-family: var(--mono); }

/* Every svg here is a standalone icon inside a flex or grid box. Blocking
   them takes them off the text baseline (no descender gap, no half-pixel
   drift) and `flex: none` stops a long label from squeezing the glyph. */
svg { display: block; flex: none; }

::selection { background: var(--accent-soft); color: var(--ink); }

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

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------- shared atoms */
.wordmark {
  font: 600 15px/1 var(--mono);
  letter-spacing: -0.005em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  border-radius: 4px; /* so the focus ring is a rounded rect, not a box */
}
.wordmark span { color: var(--muted); font-weight: 500; }
a.wordmark { transition: color var(--t1) var(--ease); }
a.wordmark:hover span { color: var(--ink); }

.mark { display: block; }

/* Text links, two shapes. The rule is drawn by the font rather than by a
   border, so a focus ring can round the corners without bending it. */
.ulink {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--line-2);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
  border-radius: 4px;
  transition: text-decoration-color var(--t1) var(--ease), color var(--t1) var(--ease);
}
.ulink:hover { text-decoration-color: var(--accent); }

/* …and the same link with a trailing glyph. The words are underlined, not
   the row, so nothing is ever struck through the arrow. */
.tlink {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-i);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  border-radius: 5px;
}
.tlink span {
  text-decoration: underline;
  text-decoration-color: var(--line-2);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
  transition: text-decoration-color var(--t1) var(--ease);
}
.tlink svg { color: var(--faint); transition: transform var(--t1) var(--ease), color var(--t1) var(--ease); }
.tlink:hover span { text-decoration-color: var(--accent); }
.tlink:hover svg { color: var(--accent-solid); transform: translateX(2px); }

/* the signature: a hairline with one slow traveling glint */
.beam {
  position: relative;
  height: 1px;
  background: var(--line);
  overflow: hidden;
}
.beam::before,
.beam::after {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  animation: travel 7.5s linear infinite;
}
.beam::before {
  width: 30%;
  height: 1px;
  margin-top: -0.5px;
  background: linear-gradient(90deg, transparent, var(--accent) 62%, transparent);
}
.beam::after {
  width: 24%;
  height: 7px;
  margin-top: -3.5px;
  background: radial-gradient(50% 50% at 50% 50%, var(--accent-soft), transparent 72%);
}
.beam.is-dim::before,
.beam.is-dim::after { animation: none; opacity: 0; }

/* one live dot, three surfaces: the session bar, the demo status, the share
   eyebrow. Green is only ever this. */
.dot-live {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 4px var(--live-soft);
}

@keyframes travel {
  0%   { transform: translate3d(-110%, 0, 0); opacity: 0; }
  12%  { opacity: 1; }
  86%  { opacity: 1; }
  100% { transform: translate3d(430%, 0, 0); opacity: 0; }
}
@keyframes rise {
  from { opacity: 0; transform: translate3d(0, 7px, 0); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.28; } }
@keyframes sweep {
  0%   { transform: translate3d(-100%, 0, 0); }
  100% { transform: translate3d(340%, 0, 0); }
}

/* dark · light switch ---------------------------------------------------
   Two states, no hidden third: the knob sits over the glyph that is in
   force, and inverts against it. `aria-checked` is the single source of
   truth for the position — theme.js sets it from the *effective* theme. */
.tsw {
  position: relative;
  flex: none;
  display: block;
  width: 56px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  transition: border-color var(--t1) var(--ease), background-color var(--t1) var(--ease);
}
.tsw:hover { border-color: var(--muted); }
.tsw-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform var(--t2) var(--ease);
}
.tsw-g {
  position: absolute;
  top: 50%;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  color: var(--faint);
  transition: color var(--t1) var(--ease);
}
.tsw-sun { left: 4px; }
.tsw-moon { right: 4px; }
.tsw[aria-checked="true"] .tsw-knob { transform: translate3d(26px, 0, 0); }
.tsw[aria-checked="false"] .tsw-sun,
.tsw[aria-checked="true"] .tsw-moon { color: var(--bg); }
/* Until theme.js wires up (one tick after parse) the markup still says
   "false". On a dark system that would flash the wrong side, so CSS holds
   the same position the script is about to set. Once anything is stored,
   [data-theme] exists and this stops matching. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .tsw .tsw-knob { transform: translate3d(26px, 0, 0); }
  :root:not([data-theme]) .tsw .tsw-sun { color: var(--faint); }
  :root:not([data-theme]) .tsw .tsw-moon { color: var(--bg); }
}
/* landing + 404 park it in the page corner; the demo bar keeps it inline */
.tsw-corner {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 5;
  background: var(--bg);
}

/* buttons ---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap-i);
  border-radius: 11px;
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.008em;
  text-decoration: none;
  transition: transform var(--t1) var(--ease), box-shadow var(--t1) var(--ease),
    background-color var(--t1) var(--ease), border-color var(--t1) var(--ease), color var(--t1) var(--ease);
}
.btn-primary {
  background: var(--accent-solid);
  color: var(--on-accent);
  box-shadow: 0 1px 1px rgba(22, 21, 18, 0.12);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--lift); }
.btn-primary:active { transform: translateY(0); }
.btn-quiet {
  border: 1px solid var(--line-2);
  color: var(--muted);
  font-weight: 600;
  padding: 11px 17px;
}
.btn-quiet:hover { color: var(--ink); border-color: var(--muted); background: var(--surface); }
.btn-big {
  min-height: 56px;
  padding: 14px 20px;
  border-radius: 13px;
  font-size: 17.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

/* -------------------------------------------------------- landing / 404 */
.wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  max-width: 720px;
  margin: 0 auto;
  padding: 30px 24px 44px;
}
.wrap::before {
  content: "";
  position: fixed;
  inset: -18vh -10vw auto -10vw;
  height: 78vh;
  background: radial-gradient(46% 58% at 50% 12%, var(--glow), transparent 72%);
  pointer-events: none;
  z-index: -1;
}
.stack {
  margin-block: auto;
  display: flex;
  flex-direction: column;
  gap: clamp(26px, 4.8vh, 40px);
  width: 100%;
}

/* hero ------------------------------------------------------------------- */
.stack > .wordmark { align-self: flex-start; }
.hero { display: flex; flex-direction: column; gap: 16px; }
.tagline {
  font-size: clamp(31px, 6vw, 45px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.032em;
  text-wrap: balance;
  margin-top: 2px;
}
.tagline code { font-size: 0.85em; font-weight: 700; letter-spacing: -0.035em; }
.hero .beam { margin-top: 4px; }

/* "see a demo" — the doorway, sitting under the hero line */
.demo-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: var(--gap-i-lg);
  padding: 5px 14px 5px 5px;
  margin-left: -5px;
  border-radius: 999px;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
  transition: background-color var(--t1) var(--ease), color var(--t1) var(--ease);
}
.demo-link .play {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-solid);
  transition: background-color var(--t1) var(--ease), color var(--t1) var(--ease),
    transform var(--t1) var(--ease);
}
/* the triangle's optical centre sits right of its bounding box, so the disc
   nudges it back by a hair */
.demo-link .play svg { margin-left: 1px; }
.demo-link .arrow { color: var(--faint); transition: transform var(--t1) var(--ease), color var(--t1) var(--ease); }
.demo-link:hover { background: var(--accent-soft); }
.demo-link:hover .play { background: var(--accent-solid); color: var(--on-accent); transform: scale(1.06); }
.demo-link:hover .arrow { color: var(--accent-solid); transform: translateX(3px); }

/* panels + the upload → share handoff ------------------------------------ */
.panel { display: flex; flex-direction: column; gap: 18px; }
[hidden] { display: none !important; }
.panel.is-out {
  opacity: 0;
  transform: translate3d(0, -6px, 0);
  transition: opacity var(--t1) var(--ease), transform var(--t1) var(--ease);
  pointer-events: none;
}

/* drop zone -------------------------------------------------------------- */
.drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 196px;
  padding: 32px 26px;
  overflow: hidden;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 18px;
  box-shadow: var(--shadow);
  transition: border-color var(--t1) var(--ease), background-color var(--t1) var(--ease),
    box-shadow var(--t1) var(--ease), transform var(--t1) var(--ease);
}
.drop:hover { border-color: var(--muted); }
.drop.is-over { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.006); }
.drop .mark { color: var(--accent); margin-bottom: 3px; transition: transform var(--t2) var(--ease); }
.drop.is-over .mark { transform: translate3d(2px, -2px, 0) scale(1.08); }
.drop-title {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.drop-title code { font-size: 0.92em; font-weight: 650; }
.drop-sub { font-size: 15.5px; color: var(--muted); letter-spacing: -0.006em; }
.drop-busy, .drop-over { display: none; }
.drop-over { color: var(--ink); font-size: 21px; font-weight: 650; letter-spacing: -0.02em; }
.drop.is-over .drop-title,
.drop.is-over .drop-sub { display: none; }
.drop.is-over .drop-over { display: block; }

/* uploading: the beam runs along the bottom edge of the zone */
.drop-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  opacity: 0;
  transition: opacity var(--t1) var(--ease);
}
.drop-bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
body[data-state="busy"] .drop { pointer-events: none; border-color: var(--line); }
body[data-state="busy"] .drop .mark { opacity: 0.55; }
body[data-state="busy"] .drop-title,
body[data-state="busy"] .drop-sub { display: none; }
body[data-state="busy"] .drop-busy {
  display: block;
  font-size: 21px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: -0.02em;
}
body[data-state="busy"] .drop-bar { opacity: 1; }
body[data-state="busy"] .drop-bar::after { animation: sweep 1.15s var(--ease) infinite; }

/* inline message --------------------------------------------------------- */
.msg {
  font-size: 15px;
  line-height: 1.45;
  color: var(--danger);
  min-height: 0;
  margin-top: -4px;
}
.msg:empty { display: none; }

/* the retention promise: quiet, but on the page where the file goes up */
.privacy {
  display: flex;
  align-items: center;
  gap: var(--gap-i);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--muted);
  letter-spacing: -0.006em;
  margin-top: -6px;
}
/* top-aligned on purpose: at narrow widths the line wraps, and the glyph
   belongs to the first line of it */
.privacy svg { color: var(--faint); align-self: flex-start; margin-top: 4px; }

/* have a code? ----------------------------------------------------------- */
.join {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 2px;
}
.join-label { font-size: 15.5px; font-weight: 500; color: var(--muted); letter-spacing: -0.006em; }
.join-field {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1.5px solid var(--line-2);
  transition: border-color var(--t1) var(--ease);
}
.join-field:focus-within { border-color: var(--ink); }
/* a click already gets the darkened rule; a keyboard deserves the ring too,
   and it belongs to the whole field rather than to the bare input */
.join-field:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 5px; }
#joinCode {
  width: 9.4em;
  padding: 9px 0 10px;
  border: 0;
  background: none;
  border-radius: 0;
  font: 600 18px/1.35 var(--mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
#joinCode:focus { outline: none; }
#joinCode::placeholder { color: var(--faint); font-weight: 500; letter-spacing: 0.18em; }
.join-go {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: 2px;
  border-radius: 50%;
  color: var(--faint);
  transition: color var(--t1) var(--ease), background-color var(--t1) var(--ease),
    transform var(--t1) var(--ease);
}
.join.is-ready .join-go { color: var(--ink); }
.join-go:hover { background: var(--accent-soft); color: var(--accent-solid); transform: translateX(1px); }
.join-hint {
  font-size: 14px;
  color: var(--danger);
  opacity: 0;
  transition: opacity var(--t1) var(--ease);
}
.join.is-bad .join-hint { opacity: 1; }

/* ------------------------------------------------------------ share state
   Two steps, one control each. Step one is what the room needs; step two is
   what the presenter needs. Everything else is a footnote. */
.share { gap: 24px; }
.share > .reveal { animation: rise var(--t2) var(--ease) both; }
.share > .reveal:nth-child(2) { animation-delay: 45ms; }
.share > .reveal:nth-child(3) { animation-delay: 90ms; }
.share > .reveal:nth-child(4) { animation-delay: 135ms; }

/* the birth announcement, and directly under it the one fact that comes with
   it: how long this thing lives */
.share-head { display: flex; flex-direction: column; gap: 7px; }
/* the state's own headline: same type as the step markers, one step louder */
.share-eyebrow {
  display: flex;
  align-items: center;
  gap: var(--gap-i-lg);
  font: 600 12.5px/1 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}
/* all-caps has no descenders, so its optical centre sits above the line's:
   the dot goes with the capitals, not with the box */
.share-eyebrow .dot-live { margin-top: -1.5px; }

.step { display: flex; flex-direction: column; gap: 11px; }
/* the marker echoes the how-it-works list: mono numeral, faint, tabular */
.step-h {
  display: flex;
  align-items: center;
  gap: var(--gap-i-lg);
  font: 600 12.5px/1 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.step-n {
  flex: none;
  font-variant-numeric: tabular-nums;
  color: var(--faint);
  letter-spacing: 0.16em;
}

/* step 1 — the link, with its copy button inside the field */
.field {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 5px 5px 15px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 13px;
  transition: border-color var(--t1) var(--ease);
}
.field:hover,
.field:focus-within { border-color: var(--accent-line); }
.field-url {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  font: 600 clamp(14px, 2.4vw, 18px)/1.5 var(--mono);
  letter-spacing: -0.015em;
  color: var(--ink);
}
.field-copy {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--muted);
  transition: color var(--t1) var(--ease), background-color var(--t1) var(--ease);
}
/* the divider lives on the button, so it can never drift from it */
.field-copy::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 9px;
  bottom: 9px;
  width: 1px;
  background: var(--line);
}
.field-copy:hover { color: var(--accent-solid); background: var(--accent-soft); }
.field-copy:focus-visible { outline-offset: 2px; }
.field-copy .i-done { display: none; }
.field-copy.copied { color: var(--accent-solid); }
.field-copy.copied .i-copy { display: none; }
.field-copy.copied .i-done { display: block; }

/* the quiet second line of each step */
.step-alt {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px 8px;
  font-size: 15px;
  color: var(--muted);
  letter-spacing: -0.006em;
}

/* the code, said out loud rather than pasted */
.code {
  position: relative;
  font: 600 17px/1.5 var(--mono);
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  padding: 2px 7px;
  margin-left: -1px;
  border-radius: 7px;
  transition: color var(--t1) var(--ease), background-color var(--t1) var(--ease);
}
.code:hover { background: var(--accent-soft); color: var(--accent-solid); }

/* step 2 — the private link, one line: lock · url · copy · whose it is */
.plink {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--gap-i);
  min-width: 0;
  max-width: 100%;
  padding: 6px 9px;
  margin-left: -9px;
  border-radius: 9px;
  color: var(--muted);
  transition: color var(--t1) var(--ease), background-color var(--t1) var(--ease);
}
.plink-url {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  font: 500 13.5px/1.5 var(--mono);
  color: var(--ink);
}
.plink .i-lock,
.plink .i-copy { color: var(--faint); transition: color var(--t1) var(--ease); }
.plink:hover { background: var(--surface); }
.plink:hover .i-copy { color: var(--accent-solid); }
.plink.copied .i-copy { color: var(--accent-solid); }
.plink-note { font-size: 13.5px; color: var(--muted); letter-spacing: -0.006em; }

/* the little floating "copied" tag, shared by the field, the code, the chip */
.cpx { position: relative; }
.cpx::after {
  content: "copied";
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  transform: translate3d(-50%, -3px, 0);
  padding: 5px 9px;
  border-radius: 7px;
  background: var(--accent-solid);
  color: var(--on-accent);
  font: 600 12px/1 var(--sans);
  letter-spacing: 0.005em;
  text-transform: none;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t1) var(--ease), transform var(--t1) var(--ease);
}
/* attr() has no reliable fallback form for `content`, so the plain rule above
   stays and elements that carry their own wording override it here. */
.cpx[data-copied]::after { content: attr(data-copied); }
.cpx.copied::after { opacity: 1; transform: translate3d(-50%, 0, 0); }
/* anchored variants: a tag centred under a control at the edge of a narrow
   screen would hang off it */
.cpx-left::after { left: 0; transform: translate3d(0, -3px, 0); }
.cpx-right::after { left: auto; right: 0; transform: translate3d(0, -3px, 0); }
.cpx-left.copied::after,
.cpx-right.copied::after { transform: none; }

.share-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.share-note { font-size: 13.5px; color: var(--muted); letter-spacing: -0.006em; }

/* how it works ----------------------------------------------------------- */
.how {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px 40px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}
.how h2 {
  font: 600 12.5px/1 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.how ol { list-style: none; padding: 0; counter-reset: step; }
/* Hanging indent, deliberately NOT a grid: in a grid container an inline
   child like <code> becomes its own grid item and lands in the number
   gutter. Negative text-indent keeps the marker on line one and every
   wrapped line aligned under the text, at any width. */
.how li {
  counter-increment: step;
  padding: 4px 0 4px 26px;
  text-indent: -26px;
  font-size: 16.5px;
  line-height: 1.5;
  color: var(--muted);
  letter-spacing: -0.008em;
}
.how li::before {
  content: counter(step);
  display: inline-block;
  width: 26px;
  text-indent: 0; /* the inline-block would otherwise inherit the -26px */
  font: 600 12px/1 var(--mono);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.how code { font-size: 0.93em; font-weight: 500; color: var(--ink); }
/* the room this was built for, said once, quietly, under both columns */
.how-note {
  grid-column: 1 / -1;
  font-size: 15px;
  line-height: 1.5;
  color: var(--faint);
  letter-spacing: -0.006em;
  text-wrap: balance; /* two even lines rather than a long one and a stub */
}

/* -------------------------------------------------------- empty state 404 */
.nf { display: flex; flex-direction: column; gap: 18px; align-items: flex-start; }
.nf .mark { color: var(--faint); opacity: 0.6; }
.nf h1 {
  font-size: clamp(28px, 5vw, 38px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.12;
}
.nf p {
  font-size: 16.5px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 46ch;
  letter-spacing: -0.006em;
}
.nf .beam { width: 100%; margin: 2px 0; }
.nf-back { font-size: 16px; }

/* ------------------------------------------------ session chrome (/:code) */
body[data-mode] { height: 100%; overflow: hidden; }

#bar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--bar);
  padding: 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  transition: box-shadow var(--t2) var(--ease);
}
#bar .wordmark { font-size: 14.5px; flex: none; }
.bar-gap { flex: 1 1 auto; }

#codeChip {
  position: relative;
  flex: none;
  font: 600 14px/1 var(--mono);
  letter-spacing: 0.2em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  padding: 8px 8px 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  transition: border-color var(--t1) var(--ease), background-color var(--t1) var(--ease);
}
#codeChip:hover { border-color: var(--accent-line); background: var(--surface); }

#note,
#viewers,
#status,
.presenting {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: -0.006em;
  white-space: nowrap;
}
#note { overflow: hidden; text-overflow: ellipsis; max-width: 34ch; }
#note:empty,
#viewers:empty { display: none; }
#viewers { font-variant-numeric: tabular-nums; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.presenting { font-weight: 500; }
.presenting::before {
  content: "";
  display: inline-block;
  width: 1px;
  height: 13px;
  margin-right: 14px;
  vertical-align: -2px;
  background: var(--line-2);
}

.stat { display: inline-flex; align-items: center; gap: var(--gap-i); min-width: 0; }
#status { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
#dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--faint);
  box-shadow: 0 0 0 0 transparent;
  transition: background-color var(--t2) var(--ease), box-shadow var(--t2) var(--ease);
}
/* The dot has one job: say what the follower is actually getting. These four
   rules carry equal specificity, so the order IS the precedence — least to
   most urgent, each one overriding the state above it.
   live means live, for the follower and the presenter alike */
body.is-connected #dot { background: var(--live); box-shadow: 0 0 0 4px var(--live-soft); }
/* paused is deliberately not following, so it cannot stay green. Amber, like
   the resume pill beside it: still connected, holding by choice. */
body.is-paused #dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
/* trouble with the socket outranks a hold: the reader needs to know the
   connection is the problem, not their own scrolling */
body.is-reconnecting #dot {
  background: var(--muted);
  box-shadow: 0 0 0 0 transparent; /* drop whichever halo was showing */
  animation: pulse 1.4s var(--ease) infinite;
}
body.is-ended #dot {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--faint);
  animation: none;
}
body.is-ended #status { color: var(--ink); }

#resume {
  display: none;
  flex: none;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent-solid);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform var(--t1) var(--ease), box-shadow var(--t1) var(--ease);
}
#resume:hover { transform: translateY(-1px); box-shadow: var(--lift); }
body.is-paused #resume { display: inline-flex; animation: rise var(--t2) var(--ease) both; }
body.is-paused #bar { box-shadow: inset 0 -1px 0 var(--accent); }

#frame {
  position: fixed;
  inset: var(--bar) 0 0 0;
  /* replaced elements ignore `bottom`, so height is stated outright */
  width: 100%;
  height: calc(100% - var(--bar));
  height: calc(100dvh - var(--bar));
  border: 0;
  display: block;
  background: var(--bg);
  transition: opacity var(--t2) var(--ease), filter var(--t2) var(--ease);
}
body.is-ended #frame { opacity: 0.22; filter: saturate(0.35); pointer-events: none; }

.veil {
  position: fixed;
  inset: var(--bar) 0 0 0;
  z-index: 1;
  display: none;
  place-items: center;
  padding: 24px;
  text-align: center;
}
body.is-ended .veil { display: grid; animation: fade var(--t2) var(--ease) both; }
.veil-card { display: flex; flex-direction: column; align-items: center; gap: 11px; }
.veil .mark { color: var(--faint); opacity: 0.55; }
.veil h2 { font-size: 25px; font-weight: 700; letter-spacing: -0.025em; }
.veil p { font-size: 15px; color: var(--muted); }
.veil .tlink { font-size: 15px; margin-top: 4px; }

/* viewers never see the presenter-only bits */
body[data-mode="viewer"] #viewers,
body[data-mode="viewer"] .presenting { display: none; }

/* embedded in /demo (?embed=1): the session is scenery, so the bar sheds
   everything the surrounding page already says — starting with the code. */
body.is-embedded { --bar: 44px; }
body.is-embedded #codeChip { display: none; }
body.is-embedded #bar { gap: 10px; padding: 0 12px; }
body.is-embedded #bar .wordmark { font-size: 13px; }
body.is-embedded #note,
body.is-embedded #viewers,
body.is-embedded #status,
body.is-embedded .presenting { font-size: 13px; }
body.is-embedded .presenting::before { margin-right: 10px; }
body.is-embedded #resume { padding: 7px 12px; font-size: 13px; }

/* ------------------------------------------------------------ demo (/demo)
   Two real session pages, side by side, in their own chrome. The stages are
   the page: everything else is a caption. */
.demo-page { padding-top: var(--bar); }
.bar-tag {
  flex: none;
  font: 600 11.5px/1 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-solid);
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
}
.demo {
  max-width: 1680px;
  min-height: calc(100dvh - var(--bar));
  margin: 0 auto;
  padding: 20px 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.demo-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 24px;
}
.demo-lede {
  font-size: clamp(19px, 2.2vw, 24px);
  font-weight: 700;
  letter-spacing: -0.024em;
  line-height: 1.25;
  text-wrap: balance;
}
.demo-note {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 15px;
  color: var(--muted);
  letter-spacing: -0.006em;
}
.demo-note.is-warn { color: var(--danger); }
.demo-note.is-live::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 4px var(--live-soft);
}
.demo-retry { font-size: 15px; }

.demo-split {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* two rows the columns share: however the role lines wrap, both plates get
     the same height and both stages start and end on the same lines */
  grid-template-rows: auto 1fr;
  gap: 22px;
}
.demo-col {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 2;
  row-gap: 12px;
  min-width: 0;
  min-height: 0;
}

/* Role plates. Two windows of the same product look alike by design, so the
   label has to do the telling: a badge, the role at heading scale, and the one
   line that says what the side does — all of it directly above the stage it
   describes, rather than split above and below it. */
.demo-head {
  display: flex;
  /* the badge marks the role word, not the block: top-aligned it centres on
     the heading line instead of drifting down between the two lines */
  align-items: flex-start;
  gap: var(--gap-i-lg);
  min-width: 0;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}
.demo-badge {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: var(--surface);
  color: var(--faint);
  transition: background-color var(--t2) var(--ease), border-color var(--t2) var(--ease),
    color var(--t2) var(--ease);
}
.demo-role { min-width: 0; }
.demo-h {
  font-size: clamp(23px, 1.9vw, 27px);
  font-weight: 700;
  letter-spacing: -0.028em;
  line-height: 1.12;
  color: var(--ink);
}
.demo-sub {
  margin-top: 2px;
  font-size: 15px;
  line-height: 1.4;
  color: var(--muted);
  letter-spacing: -0.006em;
}
/* the presenter side is the one with a hand on it, so it takes the hue this
   site already uses for "you act here" */
.demo-col-p .demo-badge {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-solid);
}
.demo-col-p .demo-head { border-bottom-color: var(--accent-line); }
/* the follower earns green only once the beam is actually up: green is a live
   connection on this site and nothing else. Until then the plate stays neutral,
   which is also what it should look like if the demo never connects. */
.demo-col-f:has(.demo-stage.is-live) .demo-badge {
  border-color: transparent;
  background: var(--live-soft);
  color: var(--live);
}
.demo-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 520px;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.demo-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--bg); }
.stage-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  color: var(--faint);
  font-size: 14px;
  letter-spacing: -0.006em;
}
.stage-empty .mark { opacity: 0.5; animation: pulse 2.2s var(--ease) infinite; }
.demo-stage.is-live .stage-empty { display: none; }
/* the driving keys only make sense once there is something to drive, so
   demo.js reveals them. Reserved, not collapsed: the hint shares the sub-line,
   and appearing must not reflow the column under it. */
.demo-hint.is-hidden { visibility: hidden; }
/* an inline-block on the text baseline, so the keys sit where the letters do */
.demo-sub kbd {
  display: inline-block;
  min-width: 1.9em;
  text-align: center;
  font: 600 12.5px/1.45 var(--mono);
  color: var(--ink);
  padding: 0 5px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
}
.demo-foot {
  flex: none;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 15px;
  color: var(--muted);
  letter-spacing: -0.006em;
}

/* ---------------------------------------------------------------- narrow */
@media (max-width: 1000px) {
  .demo { padding: 18px 20px 16px; }
  .demo-split { gap: 18px; }
}
@media (max-width: 900px) {
  /* one column: the stages stop chasing the viewport and take a shape, and
     with nothing beside them the plates have no row left to share */
  .demo { min-height: 0; }
  .demo-split { grid-template-columns: 1fr; grid-template-rows: none; gap: 26px; }
  .demo-col { display: flex; flex-direction: column; grid-row: auto; gap: 12px; }
  .demo-stage { flex: none; aspect-ratio: 4 / 3; min-height: 320px; }
}
@media (max-width: 720px) {
  .wrap { padding: 24px 20px 34px; }
  .how { grid-template-columns: 1fr; gap: 22px; }
  .demo { padding: 16px 18px 22px; }
}
@media (max-width: 620px) {
  /* the link no longer fits on one line, and the half of it that would be cut
     is the half that matters, so let it wrap instead of truncating */
  .field { padding: 9px 6px 9px 13px; }
  .field-url { white-space: normal; overflow-wrap: anywhere; line-height: 1.45; }
  .plink { flex: 1 1 100%; }
}
@media (max-width: 560px) {
  #bar { gap: 10px; padding: 0 11px; }
  #bar .wordmark span,
  #note,
  .presenting { display: none; }
  #codeChip { letter-spacing: 0.14em; padding: 7px 7px 7px 9px; }
  #resume .wide { display: none; }
  .tsw-corner { top: 12px; right: 12px; }
  .bar-tag { display: none; }
  /* the role word is already at its clamp floor; the plate around it tightens */
  .demo-head { gap: var(--gap-i); padding-bottom: 9px; }
  .demo-badge { width: 30px; height: 30px; }
}

/* ------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .beam::before,
  .beam::after {
    animation: none !important;
    opacity: 0.85;
    transform: translate3d(120%, 0, 0);
  }
  .drop-bar::after { animation: none !important; width: 100%; opacity: 0.5; }
  .stage-empty .mark { animation: none !important; }
  .btn-primary:hover,
  #resume:hover { transform: none; }
}
