/*
  Allay design system. Source of truth: plan/03-design-system.md. Used by the start page and by the sample page in muster/.
  Rules that shape this file:
  - No inline styles and no inline scripts (the server's Content-Security-Policy forbids them).
  - Only one element glows outward: the gel button. Everything else glows inward.
  - Three layers: ground, surface, raised. A raised surface never sits inside a raised surface.
  - Only position, rotation and opacity are animated. Nothing runs longer than 400ms. No endless loops.
  - Focus is always an outline, never a box-shadow, so no later shadow rule can erase it
    and it stays visible in high-contrast modes.
*/

:root {
  /* Ground and text */
  --bg: #06080f;
  --text: #f4f6fb;
  --text-2: #a9b3cc;
  --text-3: #8a94b0;

  /* Blue: active states, halo, edges */
  --blue: #0150f1;
  --blue-2: #3d7dff;
  --blue-soft: #8ab4ff;

  /* Gel button: bright fill, dark ink. Behind the label the fill is never darker than #5a93ff. */
  --gel-top: #8fbcff;
  --gel-bottom: #b7d4ff;
  --gel-core: #2f86ff;
  --gel-ink: #06204f;

  /* Yellow belongs to Premium and to the sun behind the mascot, nothing else. */
  --yellow: #fcc40b;
  --red: #ff6b6b;
  --green: #3ddc84;
  --violet: #a78bfa;
  --teal: #4fd1c5;
  --pink: #f38bc4;

  /* Layers */
  --surface: rgba(255, 255, 255, 0.035);
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --line-ctl: rgba(255, 255, 255, 0.38);
  --gloss: rgba(255, 255, 255, 0.08);
  --gloss-2: rgba(255, 255, 255, 0.22);

  /* Shape */
  --r-field: 12px;
  --r-row: 16px;
  --r-card: 20px;
  --r-pill: 999px;

  /* Spacing scale: 4 8 12 16 24 32 48 64 96 */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-switch: cubic-bezier(0.3, 1.45, 0.5, 1);
  --t-fast: 120ms;
  --t-mid: 200ms;
  --t-slow: 320ms;

  --font:
    "Figtree", ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Nunito", "Segoe UI",
    system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-alt:
    "Geist", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
  color-scheme: dark;
}

body {
  position: relative;
  isolation: isolate;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
}

/* Soft light from the top left, a blue haze on the right. Pure CSS, no image. */
body::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(58rem 34rem at 8% -8%, rgba(99, 112, 255, 0.22), transparent 62%),
    radial-gradient(46rem 40rem at 100% 22rem, rgba(1, 80, 241, 0.16), transparent 66%);
  pointer-events: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
p {
  margin: 0;
}

/* ---------- Focus: one ring everywhere ---------- */

/* 2px white, 2px away from the element. Hidden native inputs pass it on to their row. */
:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.icon {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--lg {
  width: 24px;
  height: 24px;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

/* ---------- Type ---------- */

.t-title {
  font-size: clamp(2.25rem, 8vw, 4rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.t-section {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.t-card {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
}

.t-lead {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-2);
  text-wrap: pretty;
}

.t-body {
  font-size: 1rem;
  color: var(--text-2);
}

.t-small {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-3);
}

.t-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
}

/* Headline in two tones: the core words are bright, the rest fades to grey. */
.t-dim {
  color: var(--text-3);
}

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

/* ---------- Layers ---------- */

.surface {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  box-shadow: inset 0 1px 0 var(--gloss);
}

/*
  Raised does not rely on a shadow: black on near-black is invisible.
  It is lifted by light instead: a brighter top, a clear gloss edge and a soft glow from the top left.
*/
.raised {
  border: 1px solid var(--line-2);
  border-radius: var(--r-card);
  background:
    radial-gradient(60% 50% at 15% 0%, rgba(120, 150, 255, 0.1), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.055) 45%);
  box-shadow:
    inset 0 1px 0 var(--gloss-2),
    0 24px 48px -32px rgba(0, 0, 0, 0.9);
}

/* Hairline that glows blue in the middle and fades out at the edges. */
.hairline {
  height: 1px;
  border: 0;
  margin: 0;
  background: linear-gradient(
    90deg,
    transparent,
    var(--line-2) 18%,
    rgba(61, 125, 255, 0.75) 50%,
    var(--line-2) 82%,
    transparent
  );
}

/* ---------- Buttons ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  min-height: 3.5rem;
  padding: 0.8rem 1.6rem;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font: inherit;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    translate var(--t-fast) var(--ease),
    opacity var(--t-fast) var(--ease);
}

.btn:active {
  translate: 0 2px;
}

/*
  Gel button, the one outward glow per screen. A drop of glass:
  - a compact saturated core at the top centre, about half the button wide,
  - a white reflex welling up from the bottom centre,
  - a bright rim all the way round, so the ends read almost white,
  - a halo outside, roughly twice the button's height.
  The core fades out above the label line, so the fill behind the label stays bright
  and the dark ink keeps its contrast.
*/
.btn-gel {
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  background:
    radial-gradient(46% 50% at 50% 6%, var(--gel-core), rgba(47, 134, 255, 0) 100%),
    radial-gradient(38% 46% at 50% 100%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 100%),
    linear-gradient(180deg, var(--gel-top), var(--gel-bottom));
  box-shadow:
    inset 0 0 12px 2px rgba(255, 255, 255, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 0 1px rgba(1, 80, 241, 0.35),
    0 0 32px 0 rgba(1, 80, 241, 0.6),
    0 0 96px 8px rgba(1, 80, 241, 0.4);
  color: var(--gel-ink);
}

/* Hover brightens the halo by fading in a layer, never by animating shadows. */
.btn-gel::after {
  content: "";
  position: absolute;
  inset: -1.5px;
  border-radius: inherit;
  box-shadow: 0 0 120px 12px rgba(61, 125, 255, 0.5);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
  pointer-events: none;
}

.btn-gel[aria-busy="true"] {
  cursor: progress;
}

/* Fallback version: saturated blue with white ink, in case the bright gel reads too light. */
.btn-gel--solid {
  border: 1px solid rgba(190, 215, 255, 0.7);
  background:
    radial-gradient(90% 60% at 50% -18%, rgba(190, 220, 255, 0.55), rgba(190, 220, 255, 0) 62%),
    linear-gradient(180deg, #1c63fb, var(--blue));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 0 0 1px rgba(1, 80, 241, 0.45),
    0 0 32px 0 rgba(1, 80, 241, 0.6),
    0 0 96px 8px rgba(1, 80, 241, 0.4);
  color: #ffffff;
}

.btn-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  margin-left: -0.5rem;
  border-radius: 50%;
  background: rgba(6, 32, 79, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.btn-gel--solid .btn-icon {
  background: rgba(255, 255, 255, 0.24);
}

.spinner {
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0.8;
}

/* Quiet glass for secondary actions. No outward glow. */
.btn-glass {
  min-height: 3rem;
  padding: 0.6rem 1.2rem;
  border-color: var(--line-2);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03));
  box-shadow: inset 0 1px 0 var(--gloss-2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
}

.btn-glass--premium {
  border-color: rgba(252, 196, 11, 0.6);
  color: #ffe08a;
}

.link {
  color: var(--text);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--line-ctl);
  border-radius: 6px;
}

.link:visited {
  color: #cdd6ee;
}

/* ---------- Status pills ---------- */

/*
  Dark on the left, colour on the right, a rim in the same colour.
  Meaning never rests on colour alone: every pill carries an icon and a word.
*/
.pill {
  --c: var(--blue-soft);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.8rem 0.3rem 0.35rem;
  /* Plain values first, for browsers without color-mix. */
  border: 1px solid var(--line-2);
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
  border-radius: var(--r-pill);
  background: #10131d;
  background: linear-gradient(90deg, #10131d 0%, #10131d 30%, color-mix(in srgb, var(--c) 34%, #10131d) 100%);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--c) 22%, transparent);
  color: var(--text);
  color: color-mix(in srgb, var(--c) 45%, #ffffff);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  /* Never stretch to the width of a grid or flex parent. */
  justify-self: start;
  align-self: center;
  width: fit-content;
}

.pill-dot {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--c);
  color: #0a0d16;
}

.pill-dot .icon {
  width: 12px;
  height: 12px;
  stroke-width: 2.4;
}

.pill--active {
  --c: var(--green);
}

.pill--beta {
  --c: var(--violet);
}

.pill--planned {
  --c: var(--text-2);
}

.pill--premium {
  --c: var(--yellow);
}

.pill--soon {
  --c: var(--blue-soft);
}

/* ---------- Module tone: an identifying colour, never a status ---------- */

.tone-blue {
  --c: var(--blue-2);
}

.tone-teal {
  --c: var(--teal);
}

.tone-violet {
  --c: var(--violet);
}

.tone-pink {
  --c: var(--pink);
}

.tone-green {
  --c: var(--green);
}

/* An icon on its own small tinted square. Falls back to blue when no tone is set. */
.tile {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line-2);
  border: 1px solid color-mix(in srgb, var(--c, var(--blue-2)) 40%, transparent);
  border-radius: var(--r-field);
  background: var(--surface);
  background: color-mix(in srgb, var(--c, var(--blue-2)) 14%, transparent);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--c, var(--blue-2)) 30%, transparent);
  color: var(--text);
  color: color-mix(in srgb, var(--c, var(--blue-2)) 55%, #ffffff);
}

/* ---------- Switch row ---------- */

/* The whole row is the tap target: at least 48px high, 8px from the next one. */
.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 3rem;
  padding: 4px var(--s-4) 4px var(--s-3);
  border: 1px solid transparent;
  border-radius: var(--r-row);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.switch-row + .switch-row,
.switch-row + .switch-sub,
.switch-sub + .switch-row {
  margin-top: var(--s-2);
}

/* Switched on: the row fills from left to right. */
.switch-row:has(.switch-input:checked) {
  border-color: var(--line);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0%, rgba(61, 125, 255, 0.22) 100%);
}

/* The lit edge: a short straight bar with a little distance to the rim. It fades in, nothing else moves. */
.switch-row::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 25%;
  width: 3px;
  height: 50%;
  border-radius: 2px;
  background: var(--blue-soft);
  opacity: 0;
  transition: opacity var(--t-mid) var(--ease);
  pointer-events: none;
}

.switch-row:has(.switch-input:checked)::after {
  opacity: 1;
}

.switch-row:has(.switch-input:focus-visible) {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.switch-row:has(.switch-input:disabled) {
  cursor: not-allowed;
}

.switch-text {
  flex: 1;
  min-width: 0;
  display: grid;
  justify-items: start;
}

.switch-name {
  font-weight: 700;
  line-height: 1.25;
}

.switch-desc {
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--text-2);
}

/* The real checkbox covers the row, invisible. Its outline is drawn on the row instead. */
.switch-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: inherit;
}

.switch-state {
  flex: none;
  min-width: 1.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: right;
  color: var(--text-2);
}

.switch-state .is-on,
.switch-input:checked ~ .switch-state .is-off {
  display: none;
}

.switch-input:checked ~ .switch-state .is-on {
  display: inline;
  color: #cfe0ff;
}

.switch-track {
  flex: none;
  position: relative;
  width: 44px;
  height: 26px;
  border: 1px solid var(--line-ctl);
  border-radius: var(--r-pill);
  background: #10131d;
}

/* The blue fill fades in as its own layer, so only opacity is animated. A light rim keeps it apart from the filled row. */
.switch-track::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(180deg, var(--blue-2), var(--blue));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 0 0 1px rgba(255, 255, 255, 0.45);
  opacity: 0;
  transition: opacity var(--t-mid) var(--ease);
}

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  transition: translate var(--t-mid) var(--ease-switch);
}

.switch-input:checked ~ .switch-track::before {
  opacity: 1;
}

.switch-input:checked ~ .switch-track .switch-knob {
  translate: 18px 0;
}

.switch-input:active ~ .switch-track .switch-knob {
  scale: 0.92;
}

.switch-input:disabled ~ .switch-track {
  opacity: 0.45;
}

.switch-lock {
  flex: none;
  color: var(--text-3);
}

/* A control that belongs to the row above it, for example the slider under Moderation. */
.switch-sub {
  padding-left: calc(2.5rem + var(--s-3) + var(--s-3));
}

/* ---------- Slider: a row of glass with a grip ---------- */

/*
  --v is the value from 0 to 1, set by the script.
  The fill always covers the label on the left and stops before the value on the right,
  so the grip never sits on top of text. The value maps onto the width in between.
  The invisible native input covers exactly that stretch and has a 28px thumb,
  so the centre of the native thumb is the centre of the drawn grip.
*/
.slider {
  --v: 0.5;
  --label-zone: 8rem;
  --value-zone: 6.25rem;
  --fill: calc(var(--label-zone) + (100% - var(--label-zone) - var(--value-zone)) * var(--v));
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: 3.5rem;
  padding: 0 var(--s-5);
  border: 1px solid var(--line-ctl);
  border-radius: var(--r-row);
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
  touch-action: pan-y;
}

/* Second glass layer: the fill, strong enough to read against the track. It runs a little past the grip. */
.slider::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--fill) + 12px);
  border-radius: var(--r-row);
  background: linear-gradient(90deg, rgba(61, 125, 255, 0.74), rgba(61, 125, 255, 0.8));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

/* The white grip line tells people they can drag. */
.slider::after {
  content: "";
  position: absolute;
  top: 50%;
  left: calc(var(--fill) - 2px);
  width: 4px;
  height: 28px;
  margin-top: -14px;
  border-radius: 2px;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(6, 8, 15, 0.25);
}

.slider:has(input:active)::after {
  height: 34px;
  margin-top: -17px;
}

.slider-label,
.slider-value {
  position: relative;
  z-index: 1;
  font-weight: 600;
  pointer-events: none;
}

.slider-value {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  top: 0;
  left: calc(var(--label-zone) - 14px);
  z-index: 2;
  width: calc(100% - var(--label-zone) - var(--value-zone) + 28px);
  height: 100%;
  margin: 0;
  background: none;
  opacity: 0;
  cursor: ew-resize;
}

.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 3.5rem;
}

.slider input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 3.5rem;
  border: 0;
}

.slider input[type="range"]:disabled {
  cursor: not-allowed;
}

.slider:has(input:focus-visible) {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.slider:has(input:disabled) {
  opacity: 0.5;
}

/* ---------- Switchboard and chat preview ---------- */

.board {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-3);
  padding: var(--s-3);
}

.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-1) var(--s-2) 0;
}

.board-title {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-width: 0;
}

.board-rows {
  padding: var(--s-2);
}

/*
  The mascot peeks over the top edge of the switchboard, in front of a rising sun,
  and shows a different prop for each module. Poses are stacked; only one is visible.
  They cross-fade and rise a few pixels: position and opacity only.
*/
.board--peek {
  margin-top: 7.5rem;
}

.board-peek {
  position: absolute;
  right: var(--s-6);
  bottom: calc(100% - 1px);
  width: 9.5rem;
  aspect-ratio: 529 / 420;
  overflow: hidden;
  pointer-events: none;
}

/* The sun: a flat disc that rises behind the mascot. It is clipped at the edge and does not glow outward. */
.board-peek::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 84%;
  aspect-ratio: 1;
  border-radius: 50%;
  translate: -50% 50%;
  background: radial-gradient(circle at 50% 30%, #ffe27a 0%, var(--yellow) 55%, #d99a00 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45);
}

.board-peek img {
  position: absolute;
  inset: auto 0 0 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  translate: 0 10px;
  transition:
    opacity var(--t-mid) var(--ease),
    translate var(--t-mid) var(--ease);
}

.board-peek img.is-active {
  opacity: 1;
  translate: 0 0;
}

/*
  The chat preview is our own glass panel. It does not imitate the Discord app:
  no Discord colours, no Discord font, no logo, no server rail.
*/
.chat {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  /* Short on phones, so the preview and the switches fit on one screen together. */
  height: 12.5rem;
  border: 1px solid var(--line);
  border-radius: var(--r-row);
  background: rgba(6, 8, 15, 0.55);
  box-shadow: inset 0 1px 0 var(--gloss);
  overflow: hidden;
}

/* The cause: what just happened in the server. The messages below are the answer. */
.chat-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--line);
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 600;
}

.chat-body {
  position: relative;
  padding: var(--s-2) var(--s-4);
  overflow: hidden;
}

.chat-log {
  display: grid;
  gap: var(--s-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.chat-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--s-4);
  color: var(--text-2);
  font-size: 0.875rem;
  text-align: center;
}

.chat-empty[hidden],
.msg[hidden] {
  display: none;
}

.msg {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: var(--s-3);
  align-items: start;
}

.msg-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #ffe27a 0%, var(--yellow) 60%, #d99a00 100%);
  overflow: hidden;
}

/* The figure is a full body. Cover plus this position crops the square to the head. */
.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 16%;
}

/* Messages in a row come from the same sender: only the first shows the face and the name. */
.msg:not(.is-lead) .msg-avatar {
  visibility: hidden;
  height: 0;
}

.msg:not(.is-lead) .msg-name {
  display: none;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 1.25rem;
}

.msg-name {
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.25;
}

/* Which switch caused this message: the module's name in the module's own colour. */
.msg-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-2);
  color: color-mix(in srgb, var(--c, var(--blue-2)) 55%, #ffffff);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.25;
}

.msg-tag::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--c, var(--blue-2));
}

.msg-text {
  font-size: 0.9375rem;
  line-height: 1.4;
  color: #dbe2f3;
}

/* A new message fades in and moves up by 8px. */
@keyframes msg-in {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}

.msg.is-new {
  animation: msg-in var(--t-slow) var(--ease) both;
}

/* Mascot on its sun, small, at the corner of the switchboard. The sun does not glow outward. */
.sun-badge {
  position: relative;
  flex: none;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #ffe27a 0%, var(--yellow) 52%, #d99a00 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    0 0 0 1px rgba(255, 224, 138, 0.35);
  overflow: hidden;
}

.sun-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 16%;
  scale: 0.84;
}

/* ---------- Cards ---------- */

/* Module cards are content, not controls: no hover and no focus state. */
.card-module {
  position: relative;
  display: grid;
  gap: var(--s-3);
  align-content: start;
  padding: var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  background:
    radial-gradient(18rem 10rem at 100% 0%, color-mix(in srgb, var(--c, var(--blue-2)) 18%, transparent), transparent 70%),
    var(--surface);
  box-shadow: inset 0 1px 0 var(--gloss);
  overflow: hidden;
}

/* Short coloured edge on the left: the module's own colour, never a status. */
.card-module::before {
  content: "";
  position: absolute;
  left: 0;
  top: var(--s-5);
  width: 2px;
  height: 2.5rem;
  border-radius: 0 2px 2px 0;
  background: var(--c, var(--blue-2));
}

.card-module-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

/* Locked: the colour goes, the text stays readable, a lock and a pill say why. No dimming. */
.card-module--locked {
  --c: var(--text-3);
  background: var(--surface);
}

.card-module--locked .t-card,
.card-module--locked .t-body {
  color: var(--text-3);
}

.card-premium {
  position: relative;
  display: grid;
  gap: var(--s-4);
  align-content: start;
  padding: var(--s-5);
  border: 1px solid rgba(252, 196, 11, 0.42);
  border-radius: var(--r-card);
  background:
    linear-gradient(110deg, rgba(252, 196, 11, 0.14), rgba(252, 196, 11, 0.02) 55%), var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 240, 190, 0.22);
}

/* The one tilted label on the page. */
.tag-tilt {
  position: absolute;
  top: -0.7rem;
  right: var(--s-5);
  padding: 0.15rem 0.7rem;
  border-radius: 8px;
  background: var(--yellow);
  color: #2a1e00;
  font-size: 0.8125rem;
  font-weight: 800;
  rotate: 4deg;
}

/* ---------- Counter and progress ---------- */

.counter {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-2) var(--s-3);
  min-height: 2.75rem;
}

.counter-num {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* Numbers in two tones: the count is bright, the goal next to it is paler. */
.counter-num .lo {
  color: var(--text-3);
  font-weight: 700;
}

.progress {
  display: block;
  width: 100%;
  height: 10px;
  border: 1px solid var(--line-ctl);
  border-radius: var(--r-pill);
  background: #10131d;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
}

.progress::-webkit-progress-bar {
  background: #10131d;
}

.progress::-webkit-progress-value {
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--blue-2), var(--blue-soft));
}

.progress::-moz-progress-bar {
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--blue-2), var(--blue-soft));
}

.progress--premium::-webkit-progress-value {
  background: linear-gradient(90deg, #d99a00, var(--yellow));
}

.progress--premium::-moz-progress-bar {
  background: linear-gradient(90deg, #d99a00, var(--yellow));
}

/* ---------- Link field with copy button ---------- */

.linkfield {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  padding: var(--s-1);
  padding-left: var(--s-4);
  border: 1px solid var(--line-ctl);
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 0 var(--gloss);
}

/* width: 0 switches off the input's built-in minimum width, so the field can shrink on small phones. */
.linkfield input {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
}

/* The ring is drawn around the whole field, not around the text inside it. */
.linkfield input:focus-visible {
  outline: none;
}

.linkfield:has(input:focus-visible) {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.linkfield .btn-glass {
  min-height: 2.5rem;
  padding: 0.4rem 1rem;
  font-size: 0.9375rem;
}

/* The slot stays in the page so screen readers hear what appears inside it. */
.toast-slot {
  min-height: 2.25rem;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line-2);
  border: 1px solid color-mix(in srgb, var(--green) 50%, transparent);
  border-radius: var(--r-pill);
  background: #10131d;
  color: #c9f7dd;
  font-size: 0.875rem;
  font-weight: 600;
}

.toast[hidden] {
  display: none;
}

.toast.is-new {
  animation: msg-in var(--t-mid) var(--ease) both;
}

/* ---------- Steps ---------- */

.steps {
  display: grid;
  gap: var(--s-4);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.step {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  gap: var(--s-4);
  align-items: start;
  counter-increment: step;
}

.step::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 var(--gloss-2);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---------- Questions and answers ---------- */

.faq {
  border-bottom: 1px solid var(--line);
}

.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: 3.5rem;
  padding: var(--s-3) var(--s-1);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  border-radius: 8px;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary .icon {
  color: var(--text-2);
  transition: rotate var(--t-mid) var(--ease);
}

.faq[open] summary .icon {
  rotate: 45deg;
}

.faq-answer {
  max-width: 62ch;
  padding: 0 var(--s-1) var(--s-4);
  color: var(--text-2);
}

/* ---------- Notice card: errors and 404 ---------- */

.notice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-5);
}

.notice--error {
  border-color: rgba(255, 107, 107, 0.45);
}

.notice-icon {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: rgba(255, 107, 107, 0.18);
  color: #ffc2c2;
}

/* ---------- Sticky bar on phones ---------- */

.stickybar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  background: rgba(10, 13, 22, 0.82);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 var(--gloss-2);
}

/* The hidden attribute must win over display: flex, so the bar stays away until the script shows it. */
.stickybar[hidden] {
  display: none;
}

/* On the real page: pinned to the bottom, clear of the phone's home indicator. */
.stickybar--fixed {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 10;
  transition:
    translate var(--t-mid) var(--ease),
    opacity var(--t-mid) var(--ease);
}

.stickybar--fixed.is-hidden {
  translate: 0 12px;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* A smaller gel button with a smaller halo. Focus is an outline, so it survives this rule. */
.stickybar .btn-gel {
  min-height: 2.75rem;
  padding: 0.5rem 1.1rem;
  font-size: 0.9375rem;
  box-shadow:
    inset 0 0 8px 1px rgba(255, 255, 255, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 0 1px rgba(1, 80, 241, 0.35),
    0 0 26px 0 rgba(1, 80, 241, 0.6);
}

/* ---------- Hover: only where a pointer can actually hover ---------- */

/* On touch screens a hover style would stick after a tap and look like a wrong state. */
@media (hover: hover) {
  .btn-gel:hover::after {
    opacity: 1;
  }

  .btn-glass:hover {
    border-color: rgba(140, 180, 255, 0.55);
    background: linear-gradient(180deg, rgba(120, 165, 255, 0.18), rgba(120, 165, 255, 0.05));
  }

  .btn-glass--premium:hover {
    border-color: var(--yellow);
    background: linear-gradient(180deg, rgba(252, 196, 11, 0.16), rgba(252, 196, 11, 0.04));
  }

  .link:hover {
    text-decoration-color: currentColor;
  }

  .switch-row:not(:has(.switch-input:checked)):not(:has(.switch-input:disabled)):hover {
    background: rgba(255, 255, 255, 0.04);
  }

  .slider:has(input:not(:disabled)):hover {
    border-color: rgba(255, 255, 255, 0.6);
  }
}

/* ---------- Narrow phones ---------- */

/*
  Below 420px there is no room for the word On or Off next to the switch.
  The state still shows without colour: the knob moves, the row fills and the lit edge appears.
*/
@media (max-width: 419px) {
  .switch-state {
    display: none;
  }

  .switch-row .tile {
    width: 2.25rem;
    height: 2.25rem;
  }

  .board--peek {
    margin-top: 5.5rem;
  }

  .board-peek {
    right: var(--s-4);
    width: 6.75rem;
  }

  /* Keep the head of the switchboard on one line next to the Preview pill. */
  .board-title .t-card {
    font-size: 1.125rem;
    white-space: nowrap;
  }

  .board-title .sun-badge {
    width: 2.5rem;
    height: 2.5rem;
  }

  .slider {
    --label-zone: 6.5rem;
    --value-zone: 5.5rem;
    padding-inline: var(--s-4);
  }

  .btn-gel {
    gap: var(--s-2);
    padding-inline: 1.25rem;
  }

  .btn-gel .btn-icon {
    width: 1.75rem;
    height: 1.75rem;
  }

  .linkfield input {
    font-size: 0.875rem;
  }

  /* Icon only; the word stays for screen readers. */
  .linkfield .btn-glass .btn-word {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .linkfield .btn-glass {
    padding-inline: 0.7rem;
  }
}

/* On phones the slider under a row uses the full width; the indent only exists on wide screens. */
@media (max-width: 899px) {
  .switch-sub {
    padding-left: 0;
  }

  .only-wide {
    display: none;
  }
}

/* ---------- Older browsers without :has() ---------- */

/* Without :has() the row cannot show the focus of the hidden input, so the track and the field do. */
@supports not selector(:has(*)) {
  .switch-input:focus-visible ~ .switch-track,
  .slider:focus-within,
  .linkfield:focus-within {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
  }

  .switch-input:checked ~ .switch-text .switch-name {
    color: #cfe0ff;
  }
}

/* ---------- Reduced motion: every state stays visible, nothing travels ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- High-contrast themes ---------- */

/*
  The browser removes shadows and gradients here. Outlines stay, so focus stays.
  Everything that was drawn only with a background gets a system colour.
*/
@media (forced-colors: active) {
  .switch-track,
  .slider,
  .btn,
  .pill,
  .linkfield,
  .progress {
    border: 1px solid CanvasText;
  }

  .switch-knob {
    background: CanvasText;
  }

  .switch-input:checked ~ .switch-track {
    background: Highlight;
  }

  .switch-input:checked ~ .switch-track .switch-knob {
    background: HighlightText;
  }

  .switch-row::after {
    background: Highlight;
  }

  .slider::before {
    background: Highlight;
  }

  .slider::after {
    background: CanvasText;
  }

  .progress::-webkit-progress-value {
    background: Highlight;
  }

  .progress::-moz-progress-bar {
    background: Highlight;
  }

  .card-module::before {
    background: CanvasText;
  }
}
