/* Retro ASCII/BBS terminal styling.
 *
 * Theme palettes are CSS custom properties switched by a `theme-*` class on the
 * root element (see src/theme.rs). Per-zone accent colours are applied inline
 * via `--accent` from each zone's `accent_hex`.
 */

:root {
  --bg: #0a0a0a;
  --bg-panel: #0f0f0f;
  --fg: #ffb000;       /* amber default */
  --fg-bright: #ffd47a;
  --fg-dim: #c48a2a;   /* readable dim: subtitles/handles/hints stay legible on #0a0a0a */
  --accent: #ffb000;
  --border: #6b4a00;
  --select-bg: #ffb000;
  --select-fg: #0a0a0a;
  --font: "Cascadia Mono", "JetBrains Mono", "Fira Code", "DejaVu Sans Mono",
    Menlo, Consolas, monospace;
}

/* ── Theme palettes ──────────────────────────────────────────────────────── */
.theme-amber {
  --fg: #ffb000; --fg-bright: #ffd47a; --fg-dim: #c48a2a;
  --accent: #ffb000; --border: #6b4a00; --select-bg: #ffb000;
}
.theme-green {
  --fg: #33ff66; --fg-bright: #b6ffc8; --fg-dim: #43b869;
  --accent: #33ff66; --border: #1f7a3a; --select-bg: #33ff66;
}
.theme-purple {
  --fg: #c792ea; --fg-bright: #e6ccff; --fg-dim: #a483c8;
  --accent: #c792ea; --border: #5a3f80; --select-bg: #c792ea;
}
.theme-sky {
  --fg: #56c2ff; --fg-bright: #b6e6ff; --fg-dim: #59a3cc;
  --accent: #56c2ff; --border: #2a6f99; --select-bg: #56c2ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  /* Phosphor burn in the shadows: the dark areas are never dead black — they
     carry a faint theme-tinted phosphor residue that lifts toward the centre. */
  background:
    radial-gradient(ellipse 120% 100% at 50% 50%,
      color-mix(in srgb, var(--accent) 5%, var(--bg)) 0%, var(--bg) 70%);
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
}

/* CRT scanlines + subtle flicker + vignette. */
.bbs-crt::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.15) 3px,
    rgba(0, 0, 0, 0.15) 4px
  );
}
.bbs-crt::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 49;
  /* Phosphor burn-in: a broad theme-tinted bloom that lights the screen from
     within and pools in the shadows, over a darkened-edge vignette. Kept well
     below text brightness so glyphs stay crisp. */
  background:
    radial-gradient(ellipse 95% 80% at 50% 48%,
      color-mix(in srgb, var(--accent) 14%, transparent) 0%,
      color-mix(in srgb, var(--accent) 6%, transparent) 40%,
      rgba(0,0,0,0) 72%),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 52%, rgba(0,0,0,0.62) 100%);
}

/* Fill the viewport so the terminal is a full-screen CRT rather than a block
   floating in a void; the footer then pins to the bottom edge. */
.bbs-crt { min-height: 100vh; }
@keyframes crt-flicker { 0%,100% { opacity: 1; } 50% { opacity: 0.97; } }

.bbs-root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Body copy carries only a hairline halo so glyphs stay crisp; the strong
     phosphor bloom is re-applied below to headings / chrome / accents where it
     reads as glow rather than smearing the text. */
  text-shadow: 0 0 1.5px color-mix(in srgb, var(--accent) 55%, transparent);
  animation: crt-flicker 6s infinite;
  padding: 0.5rem 1rem;
  max-width: 100ch;
  margin: 0 auto;
}

/* Strong phosphor glow, scoped to the bright/large/accent elements. */
.bbs-banner,
.bbs-panel .title,
.bbs-menu-item,
.bbs-fkeys .fk,
.bbs-row .accent,
.bbs-section-hero .label,
.bbs-statusbar .ok {
  text-shadow: 0 0 4px var(--accent);
}

/* ── Status bar ──────────────────────────────────────────────────────────── */
.bbs-statusbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
  color: var(--fg-dim);
  font-size: 0.85rem;
  flex-wrap: wrap;
}
.bbs-statusbar .ok { color: var(--accent); }
.bbs-statusbar .bad { color: #ff5555; }

/* ── Banner ──────────────────────────────────────────────────────────────── */
/* Plain text masthead (node name + tagline), not box-glyph art: nothing to
   misalign, clip, or mojibake. */
.bbs-banner {
  color: var(--fg-bright);
  margin: 0.5rem 0;
  line-height: 1.3;
}
.bbs-banner-node {
  font-size: 1.25rem; letter-spacing: 0.3em; text-transform: uppercase;
}
.bbs-banner-tag { color: var(--fg); opacity: 0.85; letter-spacing: 0.08em; }
/* Never below the 12 px mobile type floor: 0.85rem is 11.05 px on the 13 px
   mobile root, so clamp the hint up to 12 px (A11y). */
.bbs-banner .tagline { color: var(--fg-dim); font-size: max(12px, 0.85rem); }

/* ── Generic boxed panel ─────────────────────────────────────────────────── */
.bbs-panel { white-space: pre-wrap; margin: 0.5rem 0; }
/* Screen header line — the "you are here" signpost. Bright, weighted, and
   spaced so each section reads as a distinct place rather than more body text. */
.bbs-panel .title {
  color: var(--fg-bright);
  font-weight: bold;
  letter-spacing: 0.04em;
}

/* ── Main menu ───────────────────────────────────────────────────────────── */
.bbs-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 0 2rem; }
@media (max-width: 640px) { .bbs-menu { grid-template-columns: 1fr; } }
.bbs-menu-item {
  cursor: pointer;
  padding: 0 0.25rem;
  white-space: pre;
}
.bbs-menu-item .key { color: var(--accent); }
.bbs-menu-item.selected, .bbs-menu-item:hover {
  background: var(--select-bg);
  color: var(--select-fg);
  text-shadow: none;
}
.bbs-menu-item.selected .key { color: var(--select-fg); }

/* ── Lists (boards, files, nodes, users) ─────────────────────────────────── */
.bbs-list { margin: 0.25rem 0; }
.bbs-row { white-space: pre; padding: 0 0.25rem; cursor: pointer; }
.bbs-row.selected, .bbs-row:hover {
  background: var(--select-bg); color: var(--select-fg); text-shadow: none;
}
.bbs-row .accent { color: var(--accent); }
.bbs-row.selected .accent { color: var(--select-fg); }
.bbs-dim { color: var(--fg-dim); }

/* ── Command line + footer ───────────────────────────────────────────────── */
.bbs-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 0.25rem;
  color: var(--fg-dim);
  font-size: 0.8rem;
}
.bbs-fkeys { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.bbs-fkeys .fk { color: var(--accent); }
.bbs-cmdline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 0.25rem;
}
.bbs-cmdline { flex-wrap: wrap; }
.bbs-cmdline .prompt { color: var(--accent); }
.bbs-cmdline input {
  flex: 1 1 8ch;
  min-width: 0;                 /* allow the field to shrink instead of overflowing */
  min-height: 44px;             /* ≥44px touch target (DM composer reuses this) */
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg-bright);
  font: inherit;
  text-shadow: inherit;
}
/* Composer control labels never shatter across lines at 360 px, and carry a
   ≥44px tap box so the DM [ open ] / [ send ] actions clear the mobile target
   minimum (they reuse .bbs-cmdline .bbs-link). */
.bbs-cmdline .bbs-link {
  white-space: nowrap;
  display: inline-flex; align-items: center;
  min-height: 44px;
}
.bbs-blink { animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Motion-sensitivity: silence the full-screen CRT flicker and the cursor blink
   for users who ask for reduced motion (the phosphor-ghost + sentry already are). */
@media (prefers-reduced-motion: reduce) {
  .bbs-root { animation: none; }
  .bbs-blink { animation: none; }
}

/* Clickable text controls (governance Approve/Reject, [send], [reply], sign-in,
   theme-cycle, sentry door) carry role="button" — give them a pointer cursor so
   they read as interactive, not static text (verify-live: cursor was `auto`). */
a, .bbs-link { color: var(--accent); }
.bbs-link, [role="button"] { cursor: pointer; }
.bbs-link:hover { color: var(--fg-bright); }

/* ── ASCII image rendering ───────────────────────────────────────────────────
 * Images everywhere in the BBS are converted to ASCII server-side (preview /
 * pod workers) and injected as <pre class="ascii-img"> fragments whose cells
 * carry phosphor levels p0..p7. The levels map to a ramp from background to the
 * active theme's bright phosphor via color-mix on the EXISTING theme vars, so
 * they auto-recolour across all four themes with no per-theme duplication. */
.bbs-ascii-row { margin: 0.4rem 0; }
.bbs-banner-img { margin: 0.5rem 0 0; }
.ascii-img-wrap { overflow-x: auto; }

/* Content ASCII images (File Base, Message Base posts) read as contained
   "files" — a subtle phosphor-framed box with a small label. The masthead
   banner (.bbs-banner-img) is exempt so it stays edge-to-edge. */
.bbs-ascii-row:not(.bbs-banner-img) {
  width: max-content;
  max-width: 100%;
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  background: color-mix(in srgb, var(--accent) 3%, var(--bg));
}
.bbs-ascii-row:not(.bbs-banner-img)::before {
  content: "▞ IMG ▚";
  display: inline-block;
  margin-bottom: 0.3rem;
  padding: 0 0.4rem;
  background: var(--fg-dim);
  color: var(--bg);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-shadow: none;
}
.ascii-img {
  margin: 0;
  font-family: var(--font);
  font-size: 0.6rem;
  line-height: 1;
  letter-spacing: 0;
  white-space: pre;
  overflow-x: auto;
  text-shadow: 0 0 2px currentColor; /* per-cell phosphor glow */
}
.ascii-img-status {
  font-size: 0.8rem;
  line-height: 1.2;
  color: var(--fg-dim);
  text-shadow: 0 0 3px var(--accent);
}

/* Phosphor ramp: background → bright phosphor, eased so midtones aren't muddy. */
.ascii-img .p0 { color: color-mix(in srgb, var(--fg-bright)  6%, var(--bg)); }
.ascii-img .p1 { color: color-mix(in srgb, var(--fg-bright) 12%, var(--bg)); }
.ascii-img .p2 { color: color-mix(in srgb, var(--fg-bright) 20%, var(--bg)); }
.ascii-img .p3 { color: color-mix(in srgb, var(--fg-bright) 31%, var(--bg)); }
.ascii-img .p4 { color: color-mix(in srgb, var(--fg-bright) 45%, var(--bg)); }
.ascii-img .p5 { color: color-mix(in srgb, var(--fg-bright) 62%, var(--bg)); }
.ascii-img .p6 { color: color-mix(in srgb, var(--fg-bright) 80%, var(--bg)); }
.ascii-img .p7 { color: var(--fg-bright); }

/* ── Section heroes ──────────────────────────────────────────────────────────
 * Each configured zone's banner image rendered as ASCII at the top of the
 * Message Base, tinted to the zone accent. */
.bbs-section-hero { margin: 0.3rem 0 0.6rem; }
/* Each zone's banner gets a filled accent chip label — a strong, unmistakable
   signpost of which zone this board belongs to (tinted to the zone accent_hex). */
.bbs-section-hero .label {
  display: inline-block;
  background: color-mix(in srgb, var(--accent) 88%, var(--bg));
  color: var(--bg);
  padding: 0.1rem 0.55rem;
  margin-bottom: 0.2rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-shadow: none;
}

/* ── Redesign T1: landing, sign-in stack, zone cards, breadcrumb, bottom nav ──
 * Tap-first controls that split the difference between the retro skin and the
 * forum's proven patterns. Everything interactive here is a ≥44 px target with
 * a nowrap label so nothing shatters or clips at 360/390 px. */

/* Logged-out onboarding landing. */
.bbs-landing { display: flex; flex-direction: column; gap: 0.7rem; margin: 0.5rem 0; }
.bbs-landing-masthead {
  color: var(--fg-bright); margin: 0;
  font-size: 1.35rem; line-height: 1.2; letter-spacing: 0.3em;
  text-transform: uppercase; text-shadow: 0 0 6px var(--accent);
  overflow-wrap: anywhere;
}
.bbs-landing-tagline { color: var(--fg); letter-spacing: 0.08em; opacity: 0.85; }
.bbs-landing-props { display: flex; flex-wrap: wrap; gap: 0.4rem; }
/* Value-prop chips reuse the section-hero accent-chip look. */
.bbs-prop {
  display: inline-block;
  background: color-mix(in srgb, var(--accent) 88%, var(--bg));
  color: var(--bg); padding: 0.15rem 0.6rem;
  font-weight: bold; letter-spacing: 0.05em; text-shadow: none;
}
.bbs-landing-cta { display: flex; flex-direction: column; gap: 0.5rem; }
.bbs-landing-foot { font-size: 0.85rem; }

/* Full-width ≥44 px call-to-action buttons (landing + sign-in sheet). */
.bbs-cta {
  display: block; width: 100%; min-height: 44px; line-height: 42px;
  box-sizing: border-box; white-space: nowrap; text-align: center;
  border: 1px solid var(--border); padding: 0 0.75rem;
  text-decoration: none;
}
.bbs-cta:hover { background: color-mix(in srgb, var(--accent) 12%, var(--bg)); }

/* Sign-in sheet: a vertical stack, never a cramped single flex row. */
.bbs-signin { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.4rem 0; }
.bbs-signin .bbs-dim, .bbs-signin label { display: block; }
.bbs-signin .bbs-key {
  width: 100%; min-height: 44px; box-sizing: border-box;
  background: transparent; border: 1px solid var(--border);
  color: var(--fg-bright); font: inherit; text-shadow: inherit;
  padding: 0 0.6rem; outline: none;
}
.bbs-signin .bbs-key:focus { border-color: var(--accent); }
.bbs-signin-backup { white-space: pre-wrap; word-break: break-all; margin-top: 0.3rem; }

/* Zone cards + board rows + thread/member rows: a fixed, always-visible left
   accent chip and an ellipsised name — kills the 24-char pre-pad + clipped
   right-edge @handle. Button semantics + a ≥44 px target (was 39 px, and a bare
   `role=option` announced as static text — now `role=button`, focusable). */
.bbs-zone-card, .bbs-board-row, .bbs-thread-row, .bbs-member-row {
  display: flex; align-items: center; gap: 0.5rem; white-space: normal;
  min-height: 44px;
}
.bbs-zone-card:focus-visible, .bbs-board-row:focus-visible,
.bbs-thread-row:focus-visible, .bbs-member-row:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: -2px;
}
.bbs-chip { flex: 0 0 auto; }
.bbs-zone-name, .bbs-board-name, .bbs-member-name {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bbs-zone-count { flex: 0 0 auto; }
.bbs-zone-card.selected .bbs-zone-count, .bbs-zone-card:hover .bbs-zone-count { color: var(--select-fg); }
.bbs-member-id { flex: 0 0 auto; }

/* Identity block (member profile): the resolved did:nostr and WebID are 64-char
   unbreakable tokens. Inside a bare .bbs-panel (white-space:pre-wrap, no break
   rule) they push the whole document wider than the viewport (scrollWidth 677 vs
   360). Break them the same way .bbs-signin-backup does so the overflow-0
   invariant holds at 360/390 — pre-wrap still keeps the "\n"-aligned labels. */
.bbs-idblock { word-break: break-all; overflow-wrap: anywhere; }

/* Thread rows: a snippet that ellipsises + a fixed reply-count/last-activity
   meta column. */
.bbs-thread-snip {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bbs-thread-meta { flex: 0 0 auto; }
.bbs-thread-row.selected .bbs-thread-meta, .bbs-thread-row:hover .bbs-thread-meta { color: var(--select-fg); }

/* Thread view: the root post is subtly framed so it reads as the topic opener. */
.bbs-post-row.bbs-post-root {
  border-left: 2px solid var(--accent);
  padding-left: 0.4rem;
  background: color-mix(in srgb, var(--accent) 4%, var(--bg));
}

/* Composer image affordance: the file input is visually hidden (its own
   `[ ▸ image ]` control triggers it) but stays focusable/operable. */
.bbs-file-input {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0;
}
.bbs-ascii-pending { opacity: 0.85; }

/* Segmented a11y toggles (text size / motion) — inactive is dim, active is the
   bright accent so the current choice is unmistakable. */
.bbs-toggle { color: var(--fg-dim); cursor: pointer; white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center; }
.bbs-toggle.active { color: var(--accent); text-shadow: 0 0 4px var(--accent); }
.bbs-toggle:hover { color: var(--fg-bright); }

/* Key-backup sheet (F14): the "no reset" warning reads as a stop sign. */
.bbs-backup { border: 1px solid var(--border); padding: 0.4rem 0.6rem; margin: 0.4rem 0; }
.bbs-backup-warn {
  color: var(--fg-bright); white-space: pre-wrap;
  border-left: 2px solid #ff5555; padding-left: 0.5rem; margin-bottom: 0.4rem;
}

/* Breadcrumb / back control on board + thread views. */
.bbs-crumb { display: flex; align-items: center; flex-wrap: wrap; white-space: normal; }
.bbs-crumb .bbs-link { display: inline-flex; align-items: center; min-height: 44px; }

/* Persistent, skinned bottom navigation bar. */
.bbs-bottomnav {
  display: flex; align-items: stretch; justify-content: space-around;
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent) 4%, var(--bg));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bbs-navitem {
  flex: 1 1 0; min-height: 48px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.1rem;
  background: transparent; border: none; color: var(--fg-dim);
  font: inherit; text-shadow: inherit; cursor: pointer; padding: 0.3rem 0.2rem;
}
.bbs-navitem .ico { font-size: 1.1rem; line-height: 1; color: var(--accent); }
.bbs-navitem .lab { font-size: 0.7rem; letter-spacing: 0.03em; }
.bbs-navitem:hover:not(:disabled) { color: var(--fg-bright); }
.bbs-navitem.active { background: var(--select-bg); color: var(--select-fg); text-shadow: none; }
.bbs-navitem.active .ico { color: var(--select-fg); text-shadow: none; }
.bbs-navitem:disabled, .bbs-navitem[aria-disabled="true"] { opacity: 0.5; cursor: default; }

/* Status bar third state: connected-but-unauthenticated (deny-by-default reads). */
.bbs-statusbar .warn { color: var(--fg-bright); }

/* ── Accessibility prefs (F13) ─────────────────────────────────────────────────
 * Applied as classes on <html> (see app::apply_prefs) so the whole rem-based
 * layout scales and the CRT motion stops even when the OS pref isn't set. The
 * text-size class beats the base `html, body` rule on specificity. */
html.bbs-text-large { font-size: 18px; }
@media (max-width: 640px) { html.bbs-text-large { font-size: 15px; } }
html.bbs-reduced-motion .bbs-root,
html.bbs-reduced-motion .bbs-blink { animation: none; }
html.bbs-reduced-motion .phosphor-ghost { display: none; }
html.bbs-reduced-motion .sentry-critical.on,
html.bbs-reduced-motion .sentry-radar::before { animation: none; }

/* ── Phosphor persistence ─────────────────────────────────────────────────────
 * When the screen text changes, the previous frame lingers as a faint phosphor
 * afterglow and fades linearly to nothing — the slow decay of a real tube. The
 * ghost is a text-only clone of the prior body region injected by the small
 * script in index.html; here we only define how it looks + decays. */
.phosphor-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 48;
  overflow: hidden;
  white-space: pre;
  will-change: opacity;
  opacity: 0.05;                     /* faint */
  transition: opacity 3s linear;     /* slow, even decay to zero */
}
@media (prefers-reduced-motion: reduce) { .phosphor-ghost { display: none; } }

/* ── Mobile / touch ──────────────────────────────────────────────────────────
 * First-class mobile: a single-column terminal that fills the dynamic viewport
 * (100dvh dodges the mobile browser-chrome gap), larger touch targets, and a
 * fitted banner. Touch navigation (slide to move the highlight, release to
 * select) is driven by the small script in index.html; `touch-action: none` on
 * the selectable lists hands those gestures to it instead of the browser. */
.bbs-root, .bbs-crt { min-height: 100vh; min-height: 100dvh; }
.bbs-menu, .bbs-list { touch-action: none; }

@media (max-width: 640px) {
  html, body { font-size: 13px; }
  .bbs-root { padding: 0.3rem 0.5rem; max-width: 100%; }

  /* Single full-screen list, zoomed: the masthead banner is dropped (the
     status bar already carries the node name) and the active list fills the
     viewport as large, finger-sized rows — a mobile-app-style menu rather than
     a compact block floating up top. */
  .bbs-banner { display: none; }
  /* The onboarding masthead is exempt from the banner drop — it is the
     newcomer's first signpost (F3). Slightly smaller on phones. */
  .bbs-landing-masthead { display: block; font-size: 1.1rem; }
  /* Status/footer/nav-labels rendered ~9–11 px; lift clear of the 12 px type
     floor on a 13 px root (0.95rem = 12.35 px). Colours are untouched, so the
     amber-palette AA contrast (10.8:1 status, 6.6:1 dim) is unchanged (A11y). */
  .bbs-statusbar { font-size: 0.95rem; }
  .bbs-footer { font-size: 0.95rem; }
  .bbs-navitem .lab { font-size: 0.95rem; }
  .bbs-landing-foot { font-size: 0.95rem; }

  .bbs-menu {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    gap: 0;
    margin: 0.3rem 0;
  }
  .bbs-menu-item {
    flex: 1 1 0;                       /* rows grow to fill the screen evenly */
    display: flex;
    align-items: center;
    font-size: 1.45rem;               /* zoomed */
    padding: 0 0.7rem;
    border-bottom: 1px solid var(--border);
  }
  .bbs-menu-item:first-child { border-top: 1px solid var(--border); }
  .bbs-menu-item .key { margin-right: 0.5rem; }

  /* Dynamic lists fill + scroll, with large rows. */
  .bbs-list {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    overflow-y: auto;
    margin: 0.3rem 0;
  }
  .bbs-row {
    display: flex;
    align-items: center;
    /* Large finger rows, never under the 44 px touch minimum (3rem is 39 px on
       the 13 px mobile root, below target — clamp up). */
    min-height: max(3rem, 44px);
    font-size: 1.15rem;
    padding: 0.6rem 0.7rem;
    border-bottom: 1px solid var(--border);
  }
  /* Top-anchor content: panels take their natural height (was `flex:1 1 auto`,
     which grew the header and bottom-anchored the body, wasting ~50% of the
     screen). The scrollable `.bbs-list` still fills; the footer/bottom-nav pin
     to the bottom via the footer's `margin-top:auto`. */
  .bbs-panel { flex: 0 0 auto; }

  /* No decorative banners anywhere on mobile — the zone "section hero" banners
     are dropped too (the masthead already is). Content images survive: posted
     pictures (.bbs-ascii-row) and link previews still render as ASCII. */
  .bbs-section-hero { display: none; }

  /* Posted/preview ASCII images stay, sized to the narrow column (kept legible;
     wide art scrolls horizontally in its own container rather than shrinking away). */
  .ascii-img { font-size: 0.5rem; }

  /* Keyboard hints are meaningless without a keyboard — swap them for a touch
     hint that names the bottom bar (the primary return path). Slide over rows to
     move the highlight, lift to select; the bar below jumps between sections. */
  .bbs-fkeys { display: none; }
  .bbs-footer::before {
    content: "use the bar below to move around \00B7 slide over rows, lift to open";
    display: block;
    margin-bottom: 0.15rem;
    color: var(--fg-dim);
    font-size: 0.95rem;              /* ≥12 px on the 13 px mobile root (A11y) */
  }
  .bbs-cmdline input, .bbs-signin .bbs-key { font-size: 16px; }  /* stop iOS focus-zoom */
}

/* ── Door game: UA 571-C sentry gun ───────────────────────────────────────────
 * A faithful Aliens (1986) UA 571-C remote-sentry control deck — but rendered
 * in OUR phosphor skin: it inherits the active theme's --accent/--fg/--bg via
 * the theme-* class copied onto the overlay, with our scanlines + glow. Pure
 * client-side, no auth. Logic in the script in index.html. */
.sentry {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  flex-direction: column;
  overflow: auto;
  padding: 1rem;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  text-shadow: 0 0 4px var(--accent);
}
.sentry.open { display: flex; }
.sentry::before {                                   /* scanlines */
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 2;
  background: repeating-linear-gradient(to bottom,
    rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px, rgba(0,0,0,0.26) 3px, rgba(0,0,0,0.26) 4px);
}
.sentry::after {                                    /* phosphor bloom + vignette */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background:
    radial-gradient(ellipse 95% 80% at 50% 45%, color-mix(in srgb, var(--accent) 12%, transparent) 0%, rgba(0,0,0,0) 70%),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.6) 100%);
}
.sentry-inner { position: relative; z-index: 3; max-width: 96ch; width: 100%; margin: 0 auto; }
.sentry-boot { white-space: pre-wrap; color: var(--fg-bright); min-height: 8rem; }
.sentry-close {
  position: fixed; top: 0.6rem; right: 1rem; z-index: 4; cursor: pointer;
  color: var(--fg-bright); border: 1px solid var(--border); padding: 0.1rem 0.5rem;
}
.sentry-close:hover { background: var(--accent); color: var(--bg); text-shadow: none; }
.sentry-title {
  text-align: center; color: var(--fg-bright); letter-spacing: 0.18em;
  border: 1px solid var(--border); padding: 0.5rem; margin-bottom: 0.6rem; white-space: pre;
}
.sentry-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 0.6rem; }
.sentry-cell { border: 1px solid var(--border); padding: 0.4rem 0.5rem; }
.sentry-cell .lab { color: var(--fg-dim); font-size: 0.78rem; letter-spacing: 0.08em; }
.sentry-opts { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.3rem; }
.sentry-opt { padding: 0.15rem 0.45rem; border: 1px solid var(--border); cursor: pointer; user-select: none; }
.sentry-opt.sel { background: var(--accent); color: var(--bg); text-shadow: none; }
.sentry-opt.danger.sel { background: #ff5555; color: #0a0a0a; }
.sentry-status { display: grid; grid-template-columns: 1.4fr 1fr 0.8fr auto; gap: 0.6rem; align-items: stretch; }
.sentry-box { border: 1px solid var(--border); padding: 0.4rem 0.5rem; display: flex; flex-direction: column; justify-content: center; }
.sentry-box .lab { color: var(--fg-dim); font-size: 0.78rem; }
.sentry-rounds { font-size: 2.4rem; line-height: 1; color: var(--fg-bright); }
.sentry-time { font-size: 1.6rem; color: var(--fg-bright); }
.sentry-critical { border: 2px solid #ff5555; color: #ff5555; text-align: center; padding: 0.4rem; opacity: 0.22; letter-spacing: 0.2em; }
.sentry-critical.on { opacity: 1; animation: sentry-flash 0.5s step-end infinite; }
@keyframes sentry-flash { 50% { opacity: 0.3; } }
.sentry-gaugewrap { display: flex; gap: 0.5rem; align-items: flex-end; }
.sentry-gauge { width: 1.4rem; height: 5rem; border: 1px solid var(--border); position: relative; }
.sentry-gauge .fill { position: absolute; left: 0; right: 0; bottom: 0; background: var(--accent); transition: height 0.4s linear; }
.sentry-gauge.hot .fill { background: #ff5555; }
.sentry-gauge .gl { position: absolute; top: -1rem; left: 0; color: var(--fg-dim); font-size: 0.7rem; }
.sentry-radar { width: 6rem; height: 6rem; border-radius: 50%; border: 1px solid var(--border); position: relative; overflow: hidden; align-self: center; }
.sentry-radar::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, color-mix(in srgb, var(--accent) 45%, transparent) 0deg, transparent 60deg);
  animation: sentry-sweep 2.6s linear infinite;
}
.sentry-radar.fast::before { animation-duration: 0.9s; }
.sentry-radar .ring { position: absolute; inset: 22%; border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); border-radius: 50%; }
.sentry-radar .ring.r2 { inset: 40%; }
@keyframes sentry-sweep { to { transform: rotate(360deg); } }
.sentry-actions { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; margin: 0.7rem 0; }
.sentry-btn { border: 1px solid var(--accent); color: var(--accent); padding: 0.45rem 0.9rem; cursor: pointer; letter-spacing: 0.06em; user-select: none; }
.sentry-btn:hover { background: var(--accent); color: var(--bg); text-shadow: none; }
.sentry-btn.armed { border-color: #ff5555; color: #ff5555; }
.sentry-log { border: 1px solid var(--border); padding: 0.4rem 0.5rem; margin-top: 0.4rem; min-height: 3.5rem; max-height: 8rem; overflow-y: auto; color: var(--fg-dim); font-size: 0.85rem; white-space: pre-wrap; }
.sentry-log .hi { color: var(--fg-bright); }
.sentry-hint { text-align: center; color: var(--fg-dim); font-size: 0.78rem; margin-top: 0.4rem; }
@media (max-width: 640px) {
  .sentry { padding: 0.5rem; }
  .sentry-modes { grid-template-columns: 1fr; }
  .sentry-status { grid-template-columns: 1fr; }
  .sentry-title { letter-spacing: 0.1em; font-size: 0.85rem; }
}
@media (prefers-reduced-motion: reduce) {
  .sentry-critical.on { animation: none; }
  .sentry-radar::before { animation: none; }
}

/* ── F8 Encrypted DMs ──────────────────────────────────────────────────────── */
/* Conversation (inbox) row — mirrors .bbs-thread-row: flex, ellipsised preview,
   ≥44px tap target, never overflows a 360px viewport. */
.bbs-dm-convo {
  display: flex; align-items: center; gap: 0.5rem;
  white-space: normal; min-height: 44px;
}
.bbs-dm-convo .bbs-chip { flex: 0 0 auto; }
.bbs-dm-name { flex: 0 0 auto; max-width: 40%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bbs-dm-preview {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bbs-dm-unread { flex: 0 0 auto; color: var(--accent); }

/* Thread bubbles — wrap long text, break unbreakable tokens (URLs/hex) so nothing
   pushes the page wide. Sent messages tint toward the bright phosphor + right-align. */
.bbs-dm-thread { margin: 0.25rem 0; }
.bbs-dm-msg {
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
  padding: 0.15rem 0.25rem; cursor: default;
}
.bbs-dm-msg.bbs-dm-sent { color: var(--fg-bright); text-align: right; }
.bbs-dm-msg.bbs-dm-sent .accent { color: var(--accent); }

/* F9 native passkey CTA — "waiting for your passkey" pending state. Dim + a
   gentle pulse while the WebAuthn ceremony / round-trips are in flight; the
   button keeps its ≥44 px .bbs-cta box. */
.bbs-cta.bbs-pending {
  opacity: 0.65;
  cursor: progress;
  animation: bbs-pending-pulse 1.1s ease-in-out infinite;
}
@keyframes bbs-pending-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .bbs-cta.bbs-pending { animation: none; }
}

/* ── F11 Global search palette ─────────────────────────────────────────────
 * A phosphor command palette (Cmd/Ctrl+K, /search, or the [⌕] footer twin).
 * Top-anchored, backdrop-dimmed; full-screen on mobile. Reuses the theme vars,
 * so it recolours with the active CRT theme. Sits above the status/bottom bars
 * (z 48/50) but below the sentry Easter egg (z 100). */
.bbs-search-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  display: flex; justify-content: center;
  padding: 8vh 0.75rem 1rem;
  overflow-y: auto;
}
.bbs-search-panel {
  width: 100%; max-width: 64ch; height: max-content;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 22%, transparent);
  display: flex; flex-direction: column;
}
.bbs-search-head {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.bbs-search-glyph { font-size: 1.1rem; }
.bbs-search-input {
  flex: 1 1 auto; min-width: 0;
  background: transparent; border: none; outline: none;
  color: var(--fg); font: inherit; font-size: 16px;  /* 16px: no iOS focus-zoom */
  min-height: 44px;
}
.bbs-search-input::placeholder { color: var(--fg-dim); }
.bbs-search-esc {
  white-space: nowrap; min-height: 44px;
  display: inline-flex; align-items: center;
  padding: 0 0.4rem; font-size: 0.85rem;
}
.bbs-search-body { padding: 0.25rem; overflow-y: auto; max-height: 60vh; }
.bbs-search-list { display: flex; flex-direction: column; }
.bbs-search-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0.4rem; min-height: 44px; cursor: pointer;
}
.bbs-search-row.selected, .bbs-search-row:hover {
  background: var(--select-bg); color: var(--select-fg);
}
.bbs-search-row.selected .accent, .bbs-search-row:hover .accent,
.bbs-search-row.selected .bbs-dim, .bbs-search-row:hover .bbs-dim { color: var(--select-fg); }
.bbs-search-text { display: flex; flex-direction: column; min-width: 0; }
.bbs-search-title {
  display: flex; align-items: baseline; gap: 0.4rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bbs-search-sub {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 0.8rem;
}
.bbs-search-score {
  color: var(--accent); font-size: 0.75rem;
  border: 1px solid var(--border); padding: 0 0.3rem;
}
.bbs-search-row.selected .bbs-search-score,
.bbs-search-row:hover .bbs-search-score { color: var(--select-fg); border-color: var(--select-fg); }
.bbs-search-empty { padding: 1.2rem 0.6rem; text-align: center; }
.bbs-search-note { padding: 0.4rem 0.6rem; border-top: 1px solid var(--border); font-size: 0.8rem; }
.bbs-search-foot {
  padding: 0.4rem 0.6rem; border-top: 1px solid var(--border);
  font-size: 0.75rem;
}
@media (max-width: 480px) {
  .bbs-search-overlay { padding: 0; }
  .bbs-search-panel { max-width: none; min-height: 100dvh; }
  .bbs-search-body { max-height: none; flex: 1 1 auto; }
}

/* ── F12 notifications badge ─────────────────────────────────────────────────
 * Small pill carrying the unread mentions/replies count, overlaid on a
 * bottom-nav item. The extra `.bbs-navitem { position: relative }` rule below is
 * appended AFTER the base rule so it wins by source order (same specificity) and
 * establishes the positioning context for the absolutely-placed badge. */
.bbs-navitem { position: relative; }
.bbs-navbadge {
  position: absolute;
  top: 3px;
  left: calc(50% + 0.4rem);
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.7rem; line-height: 1;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  text-shadow: none;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
@media (max-width: 640px) {
  /* Lift the badge type clear of the ~12 px mobile floor (A11y). */
  .bbs-navbadge { font-size: 0.8rem; height: 1.2rem; min-width: 1.2rem; }
}
