/*!
 * ENIGMA 2026 — "1944 intelligence bunker meets 2026 secure computer".
 * No external fonts, no frameworks. System monospace + typewriter stacks.
 */

/* ======================================================================
   1. Tokens
   ====================================================================== */
:root {
  --ink: #0b0c0a;          /* almost black */
  --charcoal: #141613;
  --panel: #191b17;
  --panel-2: #1f221c;
  --line: #34382d;
  --olive: #3d4a2c;
  --olive-2: #56663d;
  --olive-glow: #8fa56a;
  --brass: #b8955a;
  --brass-2: #d8b877;
  --brass-dim: #7d6538;
  --cream: #ece3cc;
  --cream-dim: #b9b19c;
  --paper: #efe6cf;
  --paper-ink: #1d1a14;
  --amber: #f2b544;
  --amber-dim: #b9852c;
  --red: #d0503f;
  --red-deep: #8c2a1f;
  --green: #7ccf52;

  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", "DejaVu Sans Mono", Menlo, monospace;
  --type: "Courier New", Courier, "Nimbus Mono PS", "Liberation Mono", monospace;
  --stencil: "Courier New", Courier, ui-monospace, monospace;

  --radius: 3px;
  --gutter: clamp(16px, 4vw, 32px);
  --focus: 0 0 0 2px var(--ink), 0 0 0 4px var(--amber);
  --t-fast: 120ms;
  --t-med: 260ms;
  color-scheme: dark;
}

/* ======================================================================
   2. Base
   ====================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  background: var(--ink);
  overflow-x: hidden;
  overflow-x: clip; /* no sideways scroll, without breaking position: sticky */
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--ink);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -10%, rgba(86, 102, 61, 0.22), transparent 60%),
    radial-gradient(ellipse 90% 60% at 50% 120%, rgba(184, 149, 90, 0.08), transparent 60%);
  color: var(--cream);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0.01em;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

img, svg, canvas { max-width: 100%; }
a { color: var(--brass-2); text-underline-offset: 3px; }
a:hover { color: var(--amber); }
p { margin: 0 0 0.9em; }
h1, h2, h3 { font-family: var(--stencil); font-weight: 700; letter-spacing: 0.12em; line-height: 1.2; margin: 0 0 0.6em; }
code, output, kbd { font-family: var(--mono); }
[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius); }

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--amber); color: var(--ink); padding: 8px 14px; font-weight: 700;
  text-decoration: none; transition: top var(--t-fast);
}
.skip-link:focus { top: 8px; }

.no-js .requires-js { display: none !important; }

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

/* ======================================================================
   3. Atmosphere — radar grid, noise, scanlines, coordinates
   ====================================================================== */
.atmosphere { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.atmo-grid {
  position: absolute; inset: -2px;
  background-image:
    linear-gradient(rgba(143, 165, 106, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(143, 165, 106, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(143, 165, 106, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(143, 165, 106, 0.025) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 30%, transparent 85%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 30%, transparent 85%);
}
.atmo-radar {
  position: absolute; width: 900px; height: 900px; right: -300px; top: -260px; border-radius: 50%;
  background:
    repeating-radial-gradient(circle, transparent 0 89px, rgba(143, 165, 106, 0.07) 89px 90px),
    conic-gradient(from 0deg, rgba(143, 165, 106, 0.10), transparent 12%, transparent);
  opacity: 0.55;
}
.spy .atmo-radar { animation: sweep 14s linear infinite; }
@keyframes sweep { to { transform: rotate(360deg); } }
.atmo-noise {
  position: absolute; inset: 0; opacity: 0.07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.atmo-scan {
  position: absolute; inset: 0; opacity: 0;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px);
  transition: opacity var(--t-med);
}
.spy .atmo-scan { opacity: 0.35; }
.coord {
  position: absolute; font-size: 10px; letter-spacing: 0.2em; color: rgba(185, 177, 156, 0.18);
  white-space: nowrap;
}
.coord-a { left: 18px; bottom: 90px; writing-mode: vertical-rl; transform: rotate(180deg); }
.coord-b { right: 18px; top: 45%; writing-mode: vertical-rl; }
.coord-c { left: 50%; bottom: 14px; transform: translateX(-50%); }

/* Everything else above the atmosphere */
.topbar, .page, .footer, noscript, .crypto-offline { position: relative; z-index: 1; }

/* ======================================================================
   4. Top bar
   ====================================================================== */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px 24px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(to bottom, rgba(20, 22, 19, 0.96), rgba(11, 12, 10, 0.92));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--cream); min-width: 0; }
.brand-rotor { width: 34px; height: 34px; flex: none; }
.br-outer { fill: #242720; stroke: var(--brass); stroke-width: 1.5; }
.br-inner { fill: none; stroke: var(--brass-dim); stroke-width: 1; stroke-dasharray: 2 2; }
.br-hub { fill: var(--brass); }
.br-teeth { stroke: var(--brass); stroke-width: 1.5; stroke-linecap: round; }
.spy .brand-rotor { animation: spin 30s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-text strong { font-family: var(--stencil); font-size: 20px; letter-spacing: 0.38em; color: var(--brass-2); }
.brand-text small { font-size: 9px; letter-spacing: 0.22em; color: var(--cream-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.status-grid { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; font-size: 11px; letter-spacing: 0.12em; justify-self: center; }
.status-grid > div { display: flex; gap: 6px; align-items: center; }
.status-grid dt { color: var(--cream-dim); }
.status-grid dt::after { content: ":"; }
.status-grid dd { margin: 0; color: var(--cream); display: flex; align-items: center; gap: 6px; }

.lamp {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 6px var(--green), 0 0 12px rgba(124, 207, 82, 0.5);
  animation: blink 2.4s ease-in-out infinite;
}
.lamp.offline { background: var(--red); box-shadow: 0 0 6px var(--red); }
@keyframes blink { 0%, 70%, 100% { opacity: 1; } 80% { opacity: 0.25; } }

.signal { display: inline-flex; align-items: flex-end; gap: 2px; height: 11px; }
.signal i { width: 3px; background: var(--olive-glow); display: block; }
.signal i:nth-child(1) { height: 3px; } .signal i:nth-child(2) { height: 5px; } .signal i:nth-child(3) { height: 7px; }
.signal i:nth-child(4) { height: 9px; } .signal i:nth-child(5) { height: 11px; opacity: 0.35; }

.clock { display: flex; flex-direction: column; align-items: flex-end; font-size: 11px; letter-spacing: 0.14em; color: var(--amber); font-variant-numeric: tabular-nums; }
.clock #clock-time { font-size: 13px; }

.toggles { display: flex; gap: 6px; }
.toggle {
  font: inherit; font-size: 10px; letter-spacing: 0.14em; color: var(--cream-dim);
  background: transparent; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 7px 9px; min-height: 34px; cursor: pointer; white-space: nowrap;
}
.toggle b { color: var(--cream-dim); font-weight: 700; }
.toggle[aria-pressed="true"] { border-color: var(--olive-2); color: var(--cream); }
.toggle[aria-pressed="true"] b { color: var(--green); }
.toggle:hover { border-color: var(--brass-dim); }

/* ======================================================================
   5. Layout
   ====================================================================== */
.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px var(--gutter) 40px;
  outline: none;
}
.page-doc .page { max-width: 820px; }

/* ======================================================================
   6. Hero
   ====================================================================== */
.hero { text-align: center; padding: 24px 0 36px; }
.classification-bar {
  display: inline-block; font-size: 11px; letter-spacing: 0.3em; color: var(--red);
  border: 1px solid rgba(208, 80, 63, 0.5); padding: 4px 12px; margin-bottom: 22px;
}
.hero-title {
  font-size: clamp(54px, 15vw, 118px);
  letter-spacing: 0.24em;
  margin: 0 0 6px;
  padding-left: 0.24em; /* optically centre letter-spacing */
  color: var(--brass-2);
  background: linear-gradient(180deg, #fbe9bd 0%, #e2c283 40%, #b8914f 75%, #8f6d38 100%);
  filter: drop-shadow(0 2px 0 #4a3b20) drop-shadow(0 14px 24px rgba(0, 0, 0, 0.65));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  line-height: 1;
}
.hero-sub { font-size: clamp(11px, 3vw, 15px); letter-spacing: 0.34em; color: var(--cream); margin-bottom: 8px; }
.hero-tagline { font-family: var(--type); font-style: italic; color: var(--amber); font-size: clamp(15px, 3.8vw, 19px); margin-bottom: 26px; }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-bottom: 34px; }

.steps {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
  background: var(--line); border: 1px solid var(--line); text-align: left;
}
.steps li { background: rgba(20, 22, 19, 0.92); padding: 16px 14px; display: flex; flex-direction: column; gap: 4px; }
.step-no { font-size: 26px; color: var(--olive-glow); font-family: var(--stencil); line-height: 1; }
.steps strong { letter-spacing: 0.2em; color: var(--brass-2); font-size: 13px; }
.steps li span:last-child { font-size: 12.5px; color: var(--cream-dim); line-height: 1.45; }

/* ======================================================================
   7. Buttons
   ====================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-decoration: none; text-align: center;
  color: var(--cream); background: linear-gradient(180deg, #262a21, #1b1e18);
  border: 1px solid #4a4f3f; border-radius: var(--radius);
  padding: 11px 16px; min-height: 48px; cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 0 #070806;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), color var(--t-fast);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:hover { border-color: var(--brass); color: var(--brass-2); }
.btn:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 1px 0 #070806; }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn-primary {
  color: var(--ink); background: linear-gradient(180deg, #e0c07e, #b8955a 60%, #9c7b43);
  border-color: #6f5a31; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn-primary:hover { color: var(--ink); background: linear-gradient(180deg, #edcf8f, #c6a263 60%, #a88549); border-color: var(--amber); }
.btn-danger { color: #f4c8bf; border-color: var(--red-deep); background: linear-gradient(180deg, #34201c, #231512); }
.btn-danger:hover { color: #fff; border-color: var(--red); }
.btn-lg { font-size: 14px; padding: 14px 22px; min-height: 54px; }
.btn-sm { min-height: 40px; padding: 6px 12px; font-size: 11px; }
.btn-block { display: flex; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 16px 0 10px; }

/* ======================================================================
   8. Terminal panels
   ====================================================================== */
.terminal {
  position: relative;
  background: linear-gradient(180deg, rgba(31, 34, 28, 0.97), rgba(22, 24, 20, 0.97));
  border: 1px solid #3e4335;
  border-radius: 6px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 0 0 4px rgba(0, 0, 0, 0.35);
  margin: 0 0 28px;
  scroll-margin-top: 90px;
}
.terminal-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid #3e4335;
  background: linear-gradient(180deg, #2b3024, #20241b);
  border-radius: 6px 6px 0 0;
  font-size: 11px; letter-spacing: 0.2em; color: var(--cream-dim);
}
.terminal-bar h1, .terminal-bar h2 { margin: 0; font-size: 13px; letter-spacing: 0.22em; color: var(--brass-2); flex: 1; }
.terminal-bar > span:first-child:not(.screw) { flex: 1; }
.bar-code { color: var(--olive-glow); white-space: nowrap; }
.screw {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 35%, #d8c08a, #7d6538 70%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
  position: relative;
}
.screw::after { content: ""; position: absolute; left: 1px; right: 1px; top: 4px; height: 2px; background: rgba(0, 0, 0, 0.45); transform: rotate(35deg); }
.terminal-body { padding: 20px clamp(14px, 3.5vw, 26px) 24px; }

/* Mode tabs */
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; overflow: hidden; }
.mode-tabs button {
  font: inherit; font-size: 12px; font-weight: 700; letter-spacing: 0.14em;
  padding: 12px 8px; min-height: 46px; border: 0; cursor: pointer;
  background: transparent; color: var(--cream-dim);
}
.mode-tabs button + button { border-left: 1px solid var(--line); }
.mode-tabs button[aria-selected="true"] { background: var(--olive); color: var(--cream); box-shadow: inset 0 -3px 0 var(--brass); }
.mode-tabs button:hover { color: var(--cream); }

/* ======================================================================
   9. The machine: rotors + lampboard (decorative only)
   ====================================================================== */
.machine {
  border: 1px solid #2d3127; border-radius: 4px; margin-bottom: 20px; padding: 14px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.15)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.012) 0 2px, transparent 2px 5px),
    #171914;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.6);
}
.rotor-bank { display: flex; align-items: flex-end; justify-content: center; gap: clamp(8px, 3vw, 22px); flex-wrap: wrap; }
.reflector {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 46px; height: 74px; border: 1px solid var(--brass-dim); border-radius: 3px;
  background: linear-gradient(180deg, #2a2d24, #1c1e18); font-size: 10px; letter-spacing: 0.15em; color: var(--cream-dim);
}
.reflector b { font-size: 20px; color: var(--brass-2); }
.rotor { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rotor-label { font-size: 11px; letter-spacing: 0.2em; color: var(--brass); }
.rotor-body { display: flex; align-items: stretch; height: 74px; }
.rotor-knurl {
  width: 12px; border-radius: 2px;
  background: repeating-linear-gradient(180deg, #8c7442 0 2px, #4a3c20 2px 4px);
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.7);
}
.rotor-window {
  width: 46px; overflow: hidden; position: relative;
  background: linear-gradient(180deg, #0c0d0b, #2a2a24 30%, #efe6cf 42%, #efe6cf 58%, #2a2a24 70%, #0c0d0b);
  border-top: 1px solid #4b4b40; border-bottom: 1px solid #4b4b40;
}
.rotor-window::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.75), transparent 35%, transparent 65%, rgba(0, 0, 0, 0.75));
}
.rotor-strip { display: flex; flex-direction: column; transform: translateY(0); }
.rotor-strip span {
  height: 24.67px; display: flex; align-items: center; justify-content: center;
  font-family: var(--type); font-weight: 700; font-size: 18px; color: #6f6857;
}
.rotor-strip span:nth-child(2) { color: var(--paper-ink); font-size: 22px; }
.rotor-strip.stepping { transition: transform 110ms cubic-bezier(.3, .7, .4, 1); transform: translateY(-24.67px); }
.machine-readout { display: flex; flex-direction: column; font-size: 10px; letter-spacing: 0.16em; color: var(--cream-dim); min-width: 132px; }
.machine-readout b { color: var(--amber); font-size: 11px; margin-top: 4px; word-break: break-all; font-weight: 400; }

.lampboard { margin-top: 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.lamp-row { display: flex; gap: 6px; }
.lamp-key {
  width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #5b5a4d; background: radial-gradient(circle at 40% 35%, #2c2e27, #16170f);
  border: 1px solid #34362c; transition: color 300ms, background 300ms, box-shadow 300ms;
}
.lamp-key.lit {
  color: #2a1a00; background: radial-gradient(circle at 40% 35%, #ffe1a0, var(--amber) 60%, #a86d12);
  box-shadow: 0 0 12px rgba(242, 181, 68, 0.8); transition: none;
}
body:not(.spy) .spy-only { display: none; }

/* ======================================================================
   10. Forms
   ====================================================================== */
.tx-form, .rx-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.page-create:not(.mode-agent) .field-grid { grid-template-columns: 1fr; }
.page-create:not(.mode-agent) .agent-only { display: none; }
label, legend, .label { font-size: 11.5px; letter-spacing: 0.18em; color: var(--brass); font-weight: 700; }
legend { padding: 0; margin-bottom: 8px; }
.opt { color: var(--cream-dim); font-weight: 400; letter-spacing: 0.08em; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.counter { font-size: 11px; color: var(--cream-dim); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--red); }

input[type="text"], input[type="password"], select, textarea, .out-input {
  width: 100%; font: inherit; font-size: 16px; /* 16px prevents iOS zoom */
  color: var(--amber); background: #0d0e0b;
  border: 1px solid #3a3e32; border-radius: var(--radius);
  padding: 12px 12px; min-height: 48px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
  caret-color: var(--amber);
  transition: border-color var(--t-fast);
}
textarea {
  min-height: 150px; resize: vertical; line-height: 1.5;
  font-family: var(--type); font-size: 17px; color: var(--amber);
  background:
    repeating-linear-gradient(to bottom, transparent 0 24.5px, rgba(242, 181, 68, 0.05) 24.5px 25.5px),
    #0d0e0b;
}
input::placeholder, textarea::placeholder { color: #6b6553; opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--amber); outline: none; box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--amber); }
select {
  appearance: none; -webkit-appearance: none; cursor: pointer; color: var(--cream);
  background-image: linear-gradient(45deg, transparent 50%, var(--brass) 50%), linear-gradient(135deg, var(--brass) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px;
}
.hint { font-size: 12px; color: var(--cream-dim); margin: 0; line-height: 1.5; }

.destroy-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.radio-tile { position: relative; display: block; cursor: pointer; }
.radio-tile input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.radio-tile span {
  display: flex; align-items: center; justify-content: center; text-align: center; min-height: 48px;
  padding: 8px 6px; font-size: 12px; letter-spacing: 0.06em; font-weight: 400; color: var(--cream-dim);
  border: 1px solid var(--line); border-radius: var(--radius); background: #121410;
  transition: all var(--t-fast);
}
.radio-tile input:checked + span { color: var(--ink); background: var(--brass); border-color: var(--brass-2); font-weight: 700; }
.radio-tile input:focus-visible + span { box-shadow: var(--focus); }
.radio-tile:hover span { border-color: var(--brass-dim); color: var(--cream); }
.radio-tile input:checked:hover + span { color: var(--ink); }

.options-row { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 44px; letter-spacing: 0.14em; }
.check input {
  appearance: none; -webkit-appearance: none; width: 22px; height: 22px; margin: 0; flex: none; cursor: pointer;
  border: 1px solid var(--brass-dim); border-radius: 2px; background: #0d0e0b; display: grid; place-content: center;
}
.check input::before { content: ""; width: 12px; height: 12px; background: var(--amber); transform: scale(0); transition: transform var(--t-fast); clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); }
.check input:checked::before { transform: scale(1); }
.check input:focus-visible { box-shadow: var(--focus); }
.check span { font-size: 12px; color: var(--cream); }

.pass-block { display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px dashed var(--brass-dim); border-radius: var(--radius); background: rgba(0, 0, 0, 0.2); }
.pass-wrap { display: flex; gap: 8px; }
.pass-wrap input { flex: 1; min-width: 0; }
.meter { height: 6px; background: #0d0e0b; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--red); transition: width var(--t-med), background var(--t-med); }
.meter span[data-score="1"] { background: #d07a3f; }
.meter span[data-score="2"] { background: var(--amber); }
.meter span[data-score="3"] { background: var(--olive-glow); }
.meter span[data-score="4"] { background: var(--green); }
.meter-label { font-size: 11px; letter-spacing: 0.18em; margin: 0; color: var(--cream-dim); }

.form-error {
  margin: 0; padding: 10px 12px; border-left: 3px solid var(--red); background: rgba(140, 42, 31, 0.18);
  color: #f1b4a8; font-size: 13px; letter-spacing: 0.06em;
}

/* ======================================================================
   11. Teletype log
   ====================================================================== */
.teletype {
  margin: 18px 0 0; padding: 14px 16px; min-height: 60px;
  background: #080907; border: 1px solid #2a2d24; border-radius: var(--radius);
  font-size: 13px; line-height: 1.7; color: var(--amber); letter-spacing: 0.08em;
  box-shadow: inset 0 0 30px rgba(242, 181, 68, 0.04);
  text-shadow: 0 0 6px rgba(242, 181, 68, 0.35);
  white-space: pre-wrap; word-break: break-word; overflow: hidden;
}
.teletype .ln { display: block; }
.teletype .ok { color: var(--green); text-shadow: 0 0 6px rgba(124, 207, 82, 0.35); }
.teletype .err { color: var(--red); text-shadow: none; }
.teletype .bar { color: var(--brass-2); }
.teletype .cursor::after { content: "▌"; animation: caret 0.9s steps(1) infinite; margin-left: 2px; }
@keyframes caret { 50% { opacity: 0; } }

/* ======================================================================
   12. Result
   ====================================================================== */
.result { margin-top: 20px; padding-top: 18px; border-top: 1px dashed var(--line); outline: none; }
.result-head { overflow: hidden; padding: 4px 2px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.stamp-title { font-size: clamp(16px, 4.2vw, 22px); color: var(--green); margin: 0; }
.out-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.out-id {
  display: block; font-size: clamp(15px, 4.4vw, 22px); letter-spacing: 0.1em; color: var(--amber);
  background: #0d0e0b; border: 1px solid #3a3e32; border-radius: var(--radius); padding: 10px 12px;
  word-break: break-all; font-variant-numeric: tabular-nums; user-select: all;
}
.out-input { font-size: 14px; color: var(--cream); text-overflow: ellipsis; }
.key-note { font-size: 13px; color: var(--olive-glow); border-left: 3px solid var(--olive-2); padding: 4px 0 4px 12px; }
.warn-note { font-size: 13px; color: #f1c27d; border-left: 3px solid var(--amber); padding: 4px 0 4px 12px; }
.meta-note { font-size: 12px; color: var(--cream-dim); letter-spacing: 0.08em; }
.copy-status { min-height: 1.5em; color: var(--green); font-size: 13px; letter-spacing: 0.16em; margin: 6px 0 12px; }

/* ======================================================================
   13. Stamps
   ====================================================================== */
.stamp {
  display: inline-block; font-family: var(--stencil); font-weight: 700; letter-spacing: 0.16em;
  border: 3px double currentColor; padding: 4px 10px; border-radius: 4px; text-transform: uppercase;
  transform: rotate(-8deg); opacity: 0.85; font-size: 14px; pointer-events: none; user-select: none;
  mix-blend-mode: normal;
}
.stamp-sealed { color: var(--green); }
.stamp-declassified { color: #a2301f; }
.stamp-destroyed { color: #b3261a; }
.spy .stamp:not(.stamp-static) { animation: stamp-in 380ms cubic-bezier(.2, 1.6, .5, 1) both; }
@keyframes stamp-in { from { transform: rotate(-8deg) scale(2.4); opacity: 0; } to { transform: rotate(-8deg) scale(1); opacity: 0.85; } }

/* ======================================================================
   14. Receiving terminal
   ====================================================================== */
.input-id { font-size: 18px; letter-spacing: 0.12em; text-transform: uppercase; }
.input-key { font-size: 15px; }
.located { border: 1px solid var(--olive-2); background: rgba(61, 74, 44, 0.25); padding: 12px 14px; border-radius: var(--radius); }
.located-title { color: var(--green); letter-spacing: 0.22em; font-weight: 700; margin: 0 0 4px; }
.located-id { margin: 0; font-size: 13px; letter-spacing: 0.1em; color: var(--cream-dim); word-break: break-all; }
.located-id b { color: var(--amber); }
.located-meta { margin: 4px 0 0; font-size: 12px; color: var(--cream-dim); letter-spacing: 0.08em; }
.awaiting { color: var(--amber); letter-spacing: 0.24em; margin: 0; font-weight: 700; }
.spy .awaiting { animation: blink 1.6s ease-in-out infinite; }
.burn-warning { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--red-deep); background: rgba(140, 42, 31, 0.15); padding: 12px 14px; border-radius: var(--radius); font-size: 13px; }
.burn-warning strong { color: var(--red); letter-spacing: 0.2em; }

.error-screen { outline: none; }
.error-panel .terminal-body { padding-top: 26px; }
.err-title { color: var(--red); font-size: clamp(20px, 5.5vw, 30px); letter-spacing: 0.14em; margin-bottom: 8px; }
.err-sub { color: #f1b4a8; letter-spacing: 0.12em; }
.causes { margin: 0 0 14px; padding-left: 0; list-style: none; color: var(--cream-dim); }
.causes li::before { content: "— "; color: var(--brass-dim); }
.err-code { color: var(--amber); letter-spacing: 0.2em; font-size: 13px; }

/* Classified document */
.classified { outline: none; margin-top: 4px; }
/* Programmatic focus targets (moved to for screen readers) need no ring */
.classified:focus, .result:focus, .error-screen:focus, .destroyed-panel:focus, .page:focus { box-shadow: none; }
.doc-paper {
  position: relative; overflow: hidden;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255, 255, 255, 0.35), transparent 50%),
    radial-gradient(ellipse at 90% 100%, rgba(120, 90, 40, 0.18), transparent 55%),
    linear-gradient(180deg, #f1e8d1, #e4d8ba);
  color: var(--paper-ink); font-family: var(--type); font-size: 16px; line-height: 1.6;
  padding: clamp(18px, 5vw, 40px) clamp(16px, 5vw, 44px) clamp(22px, 5vw, 36px);
  border-radius: 2px;
  box-shadow: 0 1px 0 #fff inset, 0 20px 40px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px #b9a882;
}
.doc-paper::before { /* paper fibres */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.35; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.6' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .38 0 0 0 0 .25 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E");
}
.doc-paper > * { position: relative; }
.doc-rule { height: 0; border-top: 2px solid #2b261c; border-bottom: 1px solid #2b261c; padding-top: 2px; margin: 10px 0; }
.doc-class { text-align: center; font-weight: 700; font-size: clamp(20px, 5.5vw, 28px); letter-spacing: 0.3em; color: #8e2415; margin: 6px 0 0; }
.doc-eyes { text-align: center; letter-spacing: 0.3em; font-size: 12px; margin: 0 0 6px; }
.doc-meta { margin: 14px 0 12px; display: grid; gap: 2px; }
.doc-meta div { display: flex; gap: 10px; flex-wrap: wrap; }
.doc-meta dt { font-weight: 700; letter-spacing: 0.12em; min-width: 7.5em; }
.doc-meta dd { margin: 0; word-break: break-word; }
.doc-label { font-weight: 700; letter-spacing: 0.12em; margin: 14px 0 6px; }
.doc-body {
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  font-size: 17px; line-height: 1.65; min-height: 2em; margin-bottom: 12px;
}
.doc-body.typing::after { content: "▌"; animation: caret 0.8s steps(1) infinite; }
.doc-footer { text-align: center; font-weight: 700; letter-spacing: 0.3em; font-size: 12px; margin: 6px 0 0; }
.doc-paper { padding-top: clamp(62px, 12vw, 78px); }
/* Stamps sit in the top margin of the paper so they never cover the message */
.doc-paper .stamp { position: absolute; right: 12px; top: 14px; font-size: clamp(13px, 3.8vw, 22px); opacity: 0.72; }
.doc-paper .stamp-destroyed { right: auto; left: 12px; transform: rotate(-6deg); }
.spy .doc-paper .stamp-destroyed { animation: stamp-in-2 420ms 600ms cubic-bezier(.2, 1.6, .5, 1) both; }
@keyframes stamp-in-2 { from { transform: rotate(-6deg) scale(2.4); opacity: 0; } to { transform: rotate(-6deg) scale(1); opacity: 0.8; } }
.doc-status { margin: 12px 0 0; font-size: 13px; letter-spacing: 0.1em; color: var(--cream-dim); }
.doc-status.burned { color: #f1b4a8; }

.destroyed-panel { text-align: center; padding: 24px 0 6px; outline: none; }
.destroyed-panel .stamp { font-size: 30px; margin-bottom: 18px; }
.destroyed-panel h2 { color: var(--red); }

/* ======================================================================
   15. QR dialog
   ====================================================================== */
.qr-dialog {
  border: 1px solid var(--brass-dim); border-radius: 6px; padding: 0; background: var(--panel); color: var(--cream);
  max-width: min(92vw, 420px); width: 100%;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.9);
}
.qr-dialog::backdrop { background: rgba(5, 6, 4, 0.82); backdrop-filter: blur(3px); }
.qr-inner { padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.qr-inner h2 { font-size: 14px; color: var(--brass-2); margin: 0; }
#qr-canvas { background: var(--paper); border-radius: 2px; image-rendering: pixelated; max-width: 100%; height: auto !important; }
.qr-inner .hint { text-align: center; }

/* ======================================================================
   16. Document pages (security / privacy)
   ====================================================================== */
.dossier { background: linear-gradient(180deg, rgba(31, 34, 28, 0.97), rgba(22, 24, 20, 0.97)); border: 1px solid #3e4335; border-radius: 6px; padding: clamp(18px, 5vw, 40px); }
.dossier h1 { color: var(--brass-2); font-size: clamp(22px, 6vw, 34px); }
.dossier h2 { color: var(--amber); font-size: 15px; margin-top: 1.8em; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.dossier p, .dossier li { color: var(--cream); font-size: 14.5px; }
.dossier ul, .dossier ol { padding-left: 1.3em; }
.dossier li { margin-bottom: 0.45em; }
.dossier code { color: var(--amber); background: #0d0e0b; padding: 1px 5px; border-radius: 2px; font-size: 0.92em; word-break: break-word; }
.dossier pre { background: #080907; border: 1px solid #2a2d24; padding: 14px; overflow-x: auto; font-size: 12.5px; color: var(--amber); line-height: 1.55; max-width: 100%; }
.dossier .lead { color: var(--cream-dim); font-size: 15px; }
.dossier .doc-tag { display: inline-block; color: var(--red); border: 1px solid rgba(208, 80, 63, 0.5); font-size: 11px; letter-spacing: 0.26em; padding: 3px 10px; margin-bottom: 14px; }
.dossier table { width: 100%; border-collapse: collapse; font-size: 13.5px; display: block; overflow-x: auto; }
.dossier th, .dossier td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.dossier th { color: var(--brass); letter-spacing: 0.1em; font-size: 12px; }
.limit-box { border-left: 3px solid var(--red); background: rgba(140, 42, 31, 0.12); padding: 10px 14px; margin: 14px 0; }

/* ======================================================================
   17. Footer, no-js, offline
   ====================================================================== */
.footer { text-align: center; padding: 10px var(--gutter) calc(34px + env(safe-area-inset-bottom)); color: var(--cream-dim); font-size: 12px; letter-spacing: 0.14em; }
.footer-rule { height: 1px; max-width: 880px; margin: 0 auto 22px; background: linear-gradient(90deg, transparent, var(--brass-dim), transparent); }
.footer-brand { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.footer-brand strong { color: var(--brass-2); letter-spacing: 0.34em; font-size: 14px; }
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-bottom: 12px; }
.footer-nav a { color: var(--cream); text-decoration: none; padding: 10px 4px; display: inline-block; }
.footer-nav a:hover { color: var(--amber); }
.footer-motto { font-family: var(--type); font-style: italic; letter-spacing: 0.04em; color: var(--brass); }
.footer-meta { font-size: 10px; opacity: 0.75; }

.noscript-panel, .crypto-offline {
  max-width: 880px; margin: 24px auto 0; padding: 18px 20px; border: 1px solid var(--red-deep);
  background: rgba(140, 42, 31, 0.15); border-radius: 4px; width: calc(100% - 2 * var(--gutter));
}
.noscript-panel h2, .crypto-offline h2 { color: var(--red); font-size: 18px; }

.error-only { padding: 2rem; }

/* ======================================================================
   18. Responsive
   ====================================================================== */
@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr auto; }
  .status-grid { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
  .clock { grid-column: 2; grid-row: 1; }
  .toggles { grid-column: 1 / -1; grid-row: 3; }
  .steps { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  body { font-size: 14px; }
  .topbar { gap: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); padding-bottom: 8px; position: relative; }
  .hide-sm { display: none !important; }
  .status-grid { font-size: 10px; gap: 2px 12px; }
  .toggles { width: 100%; }
  .toggles .toggle { flex: 1; min-height: 44px; }
  .brand-text strong { font-size: 17px; }
  .field-grid { grid-template-columns: 1fr; }
  .destroy-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .btn-grid { grid-template-columns: 1fr; }
  .hero-actions .btn { width: 100%; }
  .hero { padding-top: 10px; }
  .machine { padding: 10px; }
  .machine-readout { min-width: 0; width: 100%; align-items: center; text-align: center; margin-top: 4px; }
  .lamp-key { width: 22px; height: 22px; font-size: 10px; }
  .lamp-row { gap: 4px; }
  .terminal-bar .bar-code { display: none; }
  .coord { display: none; }
  .page { padding-top: 18px; }
}
@media (max-width: 380px) {
  .steps { grid-template-columns: 1fr; }
  .lamp-key { width: 20px; height: 20px; }
  .lamp-row { gap: 3px; }
  .rotor-window { width: 40px; }
  .doc-paper .stamp { font-size: 11px; letter-spacing: 0.1em; padding: 3px 7px; }
  .reflector { width: 40px; }
  .brand-text small { font-size: 8px; letter-spacing: 0.14em; }
  .clock { font-size: 10px; }
  .clock #clock-time { font-size: 11px; }
}

/* ======================================================================
   19. Reduced motion & minimal mode
   ====================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .atmo-radar, .brand-rotor { animation: none !important; }
  .lamp { animation: none; }
}
body:not(.spy) .atmo-radar { opacity: 0.25; }
body:not(.spy) .stamp { animation: none; }

@media print {
  .atmosphere, .topbar, .footer, .btn, .btn-grid, .toggles { display: none !important; }
  body { background: #fff; color: #000; }
}
