/* =========================================================================
   MediaShare — mobile-first stylesheet
   =========================================================================
   Plain CSS, self-hosted, no framework, no external font. A strict CSP means
   no inline styles anywhere, so every visual decision lives here.

   Written mobile-first: base rules target a 320px phone, and breakpoints add
   capability upward. A security tool should feel calm and precise rather than
   playful, so motion is short and crisp, and there is no decorative animation.
   ------------------------------------------------------------------------- */

:root {
  /* Surfaces */
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --panel-3: #262b36;
  --border: #2a2f3a;
  --border-strong: #3a4150;

  /* Text */
  --text: #e6e8ec;
  --muted: #9aa3b2;
  --faint: #6b7686;

  /* Accents */
  --accent: #5b8def;
  --accent-press: #4a76cc;
  --danger: #e05260;
  --warn: #d99a35;
  --ok: #46b17b;

  /* Type scale */
  --fs-xs: 11px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 21px;
  --fs-2xl: 26px;

  /* Spacing scale — everything is a multiple, so rhythm stays consistent */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --s10: 40px;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  /* Minimum comfortable touch target. Anything interactive meets this. */
  --tap: 44px;

  /* Strong custom curves. The CSS built-ins are too weak to feel deliberate.
     ease-in is deliberately absent: it delays the first movement, which is
     exactly when the user is looking. */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-3: 0 20px 60px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win.
 *
 * Browsers apply `[hidden] { display: none }` from the user-agent stylesheet,
 * and ANY author rule that sets `display` silently overrides it — author
 * styles beat UA styles regardless of specificity. That is not theoretical:
 * `.viewer-root { display: flex }` once overrode `hidden` and left a
 * full-screen overlay covering the app, swallowing every click. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;   /* stop iOS enlarging text on rotate */
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-md)/1.55 var(--sans);
  /* Respect the notch and the home indicator on phones. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-wrap: break-word;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

/* ---- Layout ------------------------------------------------------------ */

.container {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: var(--s4) var(--s4) var(--s10);
}
.narrow { max-width: 100%; }

h1 { font-size: var(--fs-xl); line-height: 1.25; margin: 0 0 var(--s1); letter-spacing: -0.01em; }
h2 { font-size: var(--fs-lg); line-height: 1.3; margin: var(--s5) 0 var(--s2); letter-spacing: -0.005em; }
h3 { font-size: var(--fs-md); line-height: 1.35; margin: var(--s4) 0 var(--s2); font-weight: 600; }
p  { margin: var(--s2) 0; }

.muted { color: var(--muted); font-size: var(--fs-sm); }
.mono, td.mono { font-family: var(--mono); font-size: var(--fs-xs); }
.grow { flex: 1; min-width: 0; }   /* min-width:0 lets flex children truncate */

.row {
  display: flex;
  gap: var(--s2);
  align-items: center;
  flex-wrap: wrap;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s4);
  margin-bottom: var(--s3);
}

/* ---- Boot stages ------------------------------------------------------- */

#stage-loading, #stage-error { padding: var(--s10) var(--s4); text-align: center; }

.spinner {
  width: 28px; height: 28px;
  margin: 0 auto var(--s4);
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#stage-error .error-box {
  max-width: 520px; margin: 0 auto; text-align: left;
  background: var(--panel);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: var(--s5);
}
#error-title { color: var(--danger); margin-top: 0; }
#error-detail { color: var(--muted); }

/* ---- Top bar ----------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border-bottom: 1px solid var(--border);
  /* Frosted bar keeps context visible while scrolling long timelines. */
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.topbar .brand {
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.topbar nav {
  display: flex;
  gap: var(--s2);
  align-items: center;
  flex: none;
}
/* On a phone the identity label is the first thing to sacrifice for space. */
.topbar nav #whoami { display: none; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s4);
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: 500 var(--fs-sm)/1 var(--sans);
  cursor: pointer;
  white-space: nowrap;
  /* Never `transition: all` — name the properties that actually change. */
  transition: transform 140ms var(--ease-out),
              background-color 140ms var(--ease-out),
              border-color 140ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;      /* removes the 300ms mobile tap delay */
  user-select: none;
}

/* Press feedback fires on pointer-down, before any handler runs — so every
   button confirms the tap instantly, even when the work behind it is slow. */
.btn:active:not(:disabled) {
  transform: scale(0.97);
  background: var(--panel-3);
}

/* Hover must be gated: touch devices fire it on tap, causing sticky states. */
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { border-color: var(--border-strong); background: var(--panel-3); }
  .btn-primary:hover:not(:disabled) { background: var(--accent-press); border-color: var(--accent-press); }
  .conv-item:hover { border-color: var(--border-strong); }
}

.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; opacity: 0.8; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-danger  { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn-close   { margin-left: auto; }

/* Full-width primary actions read better on a phone. */
.btn-block { width: 100%; }

/* ---- Form controls ----------------------------------------------------- */

input[type="text"], input[type="password"], input[type="file"], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s2) var(--s3);
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  /* 16px minimum, or iOS Safari zooms the viewport on focus. */
  font: var(--fs-md)/1.4 var(--sans);
  transition: border-color 140ms var(--ease-out), background-color 140ms var(--ease-out);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--panel-3);
}
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
input[type="file"] { padding: var(--s2); font-size: var(--fs-sm); }

label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--muted);
  margin: var(--s3) 0 var(--s1);
}

/* ---- Status messages --------------------------------------------------- */

.flash {
  padding: var(--s3);
  border-radius: var(--radius-sm);
  margin: var(--s3) 0;
  font-size: var(--fs-sm);
  border: 1px solid var(--border);
}
.flash-info  { background: #172033; border-color: var(--accent); }
.flash-error { background: #2a1a1e; border-color: var(--danger); }
.flash-ok    { background: #14241d; border-color: var(--ok); }
.flash-warn  { background: #262014; border-color: var(--warn); }

.warn-box {
  border: 1px solid var(--warn); background: #262014;
  border-radius: var(--radius-sm); padding: var(--s3);
  margin: var(--s3) 0; font-size: var(--fs-sm);
}
.danger-box {
  border: 1px solid var(--danger); background: #2a1a1e;
  border-radius: var(--radius-sm); padding: var(--s3);
  margin: var(--s3) 0; font-size: var(--fs-sm);
}

/* ---- Badges ------------------------------------------------------------ */

.badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 3px var(--s2);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
  flex: none;
}
.badge-unread    { background: var(--accent); color: #fff; border-color: var(--accent); }
.badge-oversight { border-color: var(--warn); color: var(--warn); }
.badge-all-users { border-color: var(--danger); color: var(--danger); }

/* ---- Conversation list ------------------------------------------------- */

.conv-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--s2); }
.conv-item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 64px;
  padding: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  cursor: pointer;
  transition: transform 140ms var(--ease-out),
              border-color 140ms var(--ease-out),
              background-color 140ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.conv-item:active { transform: scale(0.995); background: var(--panel-2); }

/* ---- Timeline ---------------------------------------------------------- */

.timeline { display: flex; flex-direction: column; gap: var(--s2); }
.item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s3);
  background: var(--panel);
}
.item.own { border-left: 3px solid var(--accent); }
.item-head {
  display: flex;
  gap: var(--s2);
  align-items: center;
  flex-wrap: wrap;
  font-size: var(--fs-sm);
}
.item-head .sender { font-weight: 600; }

/* Unopened media shows a placeholder and nothing else. There is no
   server-generated thumbnail anywhere in this system, by design. */
.placeholder {
  display: flex; align-items: center; justify-content: center;
  height: 108px; margin-top: var(--s3);
  border-radius: var(--radius-sm);
  background:
    repeating-linear-gradient(45deg, #1b1f27, #1b1f27 10px, #1f242e 10px, #1f242e 20px);
  color: var(--muted); font-size: var(--fs-sm); text-align: center;
  padding: var(--s3);
}

.state-consumed { color: var(--muted); }
.state-revoked, .state-expired, .state-failed_before_display { color: var(--danger); }
.state-active { color: var(--ok); }

/* ---- Viewer ------------------------------------------------------------ */

.viewer-root {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(6, 8, 12, 0.98);
  display: flex; align-items: center; justify-content: center;
}
.viewer {
  position: relative;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
}
.viewer-stage {
  position: relative;
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  padding: var(--s3);
}

/* Canvas rendering is required: the browser then exposes no "Save image as"
   target. js/viewer.js documents fully what this does and does not prevent. */
.viewer-canvas {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.viewer-controls {
  display: flex; align-items: center; gap: var(--s3);
  flex-wrap: wrap;
  padding: var(--s3) var(--s4);
  /* Clear the home indicator on iPhones. */
  padding-bottom: calc(var(--s3) + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--border);
}
.playback { display: flex; align-items: center; gap: var(--s3); flex: 1; min-width: 200px; }
.scrub { flex: 1; min-width: 80px; height: var(--tap); accent-color: var(--accent); }
.time { font-family: var(--mono); font-size: var(--fs-xs); color: var(--muted); flex: none; }
.viewer-message { color: var(--muted); text-align: center; }

/* Dynamic watermark: a deterrence and accountability layer, explicitly NOT an
   encryption control. It does not prevent screen capture. */
.watermark {
  position: absolute; inset: 0; pointer-events: none;
  display: grid; grid-template-columns: repeat(2, 1fr);
  align-content: space-around; gap: var(--s8);
  transform: rotate(-24deg); opacity: 0.13;
  overflow: hidden;
}
.watermark-tile {
  font-family: var(--mono); font-size: 10px;
  text-align: center; white-space: nowrap; color: #fff;
}

/* ---- Modals — bottom sheet on phones, centred dialog on larger screens -- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, 0.66);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
  animation: backdrop-in 180ms var(--ease-out);
}
@keyframes backdrop-in { from { opacity: 0; } }

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: var(--s5) var(--s4);
  padding-bottom: calc(var(--s5) + env(safe-area-inset-bottom));
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-3);
  /* Slides its own height, so the value never needs tuning per modal. */
  animation: sheet-in 240ms var(--ease-out);
}
@keyframes sheet-in { from { transform: translateY(100%); } }

.modal h2 { margin-top: 0; }
.modal-actions {
  display: flex; gap: var(--s2);
  flex-direction: column-reverse;   /* primary action nearest the thumb */
  margin-top: var(--s5);
}
.modal-actions .btn { width: 100%; }

@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal { animation: none; }
}

.recipient-list { list-style: none; padding: 0; margin: var(--s2) 0; }
.recipient-list li {
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--s1);
  font-size: var(--fs-sm);
}

/* ---- Tables ------------------------------------------------------------ */
/* On a phone a wide table cannot be made readable by reflowing alone, so it
   scrolls horizontally inside its own container. The page itself must never
   scroll sideways. */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 calc(var(--s4) * -1); padding: 0 var(--s4); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); min-width: 520px; }
th, td { text-align: left; padding: var(--s2); border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
/* Skeleton rows are placeholders only; they never receive hover or press. */
.sk-row td { pointer-events: none; }

progress { width: 100%; height: 6px; border-radius: var(--radius-pill); overflow: hidden; }

/* ---- Loading states ---------------------------------------------------- */

.spinner-sm {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  flex: none;
}
.btn .spinner-sm { margin-right: var(--s1); }

.sk {
  display: block; height: 11px; border-radius: 5px;
  background: linear-gradient(90deg, #1d222b 25%, #262c37 50%, #1d222b 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.4s ease-in-out infinite;
}
.sk + .sk { margin-top: var(--s1); }
.sk-w40 { width: 40%; } .sk-w60 { width: 60%; } .sk-w80 { width: 80%; }
@keyframes sk-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.loading-line {
  display: flex; align-items: center; gap: var(--s2);
  color: var(--muted); font-size: var(--fs-sm); padding: var(--s3) 0;
}

[aria-busy="true"].busy-region {
  opacity: 0.5; pointer-events: none;
  transition: opacity 140ms var(--ease-out);
}

/* Viewer decryption overlay — reports a real fraction, because chunked video
   decryption is slow enough that a bare spinner reads as a hang. */
.viewer-loading {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: var(--s3);
  background: rgba(6, 8, 12, 0.92);
  text-align: center; padding: var(--s6);
}
.viewer-loading .spinner { margin: 0; }
.viewer-loading-label { color: var(--text); font-size: var(--fs-sm); }
.viewer-loading-sub { color: var(--muted); font-size: var(--fs-xs); font-family: var(--mono); }
.viewer-progress {
  width: min(300px, 72vw); height: 6px;
  border-radius: var(--radius-pill); overflow: hidden;
  background: var(--panel-2); border: 1px solid var(--border);
}
.viewer-progress > div {
  height: 100%; width: 0; background: var(--accent);
  transition: width 180ms var(--ease-out);
}

/* ---- Global network activity bar --------------------------------------- */

#net-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  z-index: 100; pointer-events: none;
  opacity: 0; transition: opacity 180ms var(--ease-out);
}
#net-progress[data-active="true"] { opacity: 1; }
#net-progress::after {
  content: ''; display: block; height: 100%; width: 35%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: net-slide 1.1s ease-in-out infinite;
}
@keyframes net-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(385%); }
}

/* ---- Camera capture ---------------------------------------------------- */

.capture-preview {
  width: 100%;
  max-height: 46vh;
  border-radius: var(--radius-sm);
  background: #000;
  margin: var(--s3) 0;
  object-fit: cover;
}
.modal-actions .btn-danger { animation: rec 1.4s ease-in-out infinite; }
@keyframes rec { 50% { opacity: 0.6; } }

/* =========================================================================
   Tablet — 640px and up
   ========================================================================= */
@media (min-width: 640px) {
  .container { padding: var(--s6) var(--s6) var(--s10); max-width: 760px; }
  .narrow { max-width: 480px; }

  h1 { font-size: var(--fs-2xl); }
  h2 { font-size: var(--fs-xl); }

  .topbar { padding: var(--s3) var(--s6); gap: var(--s4); }
  .topbar nav { gap: var(--s3); }
  .topbar nav #whoami { display: inline; font-size: var(--fs-sm); color: var(--muted); }

  .card { padding: var(--s5); }

  /* Dialogs stop being sheets and become centred modals. */
  .modal-backdrop { align-items: center; padding: var(--s5); }
  .modal {
    max-width: 480px;
    border-radius: var(--radius);
    padding: var(--s6);
    max-height: 84vh;
    animation: modal-in 200ms var(--ease-out);
  }
  /* Modals scale from centre: unlike a popover they are not anchored to any
     trigger. Starting at 0.96 rather than 0 — nothing appears from nothing. */
  @keyframes modal-in { from { transform: scale(0.96); opacity: 0; } }
  .modal-actions { flex-direction: row; justify-content: flex-end; }
  .modal-actions .btn { width: auto; }

  .btn-block { width: auto; }
  table { min-width: 0; }
  .table-wrap { margin: 0; padding: 0; }
}

/* =========================================================================
   Desktop — 1024px and up
   ========================================================================= */
@media (min-width: 1024px) {
  .container { max-width: 1040px; padding: var(--s8) var(--s6) var(--s10); }
  .watermark { grid-template-columns: repeat(3, 1fr); }
  .viewer-stage { padding: var(--s5); }
}

/* =========================================================================
   Reduced motion — fewer and gentler, not zero. Opacity and colour survive
   because they aid comprehension; movement is what causes discomfort.
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  .btn, .conv-item { transition-property: background-color, border-color; }
  .btn:active:not(:disabled), .conv-item:active { transform: none; }
  .spinner, .spinner-sm { animation-duration: 2.4s; }
  .sk { animation: none; background: #222834; }
  .viewer-progress > div { transition: none; }
  #net-progress::after { animation: none; width: 100%; opacity: 0.55; }
  .modal-actions .btn-danger { animation: none; }
}

/* =========================================================================
   Utilities
   =========================================================================
   These exist because the CSP is `style-src 'self'` with no 'unsafe-inline'.
   Inline `style="..."` attributes — and `setAttribute('style', …)` from JS —
   are therefore BLOCKED and silently never apply. Nineteen of them were in
   this codebase, doing nothing. Weakening the CSP to fix layout would trade a
   real XSS control for convenience, so the spacing lives here instead.
   ------------------------------------------------------------------------- */

.m0   { margin: 0 !important; }
.mt0  { margin-top: 0 !important; }
.mt2  { margin-top: var(--s2); }
.mt3  { margin-top: var(--s3); }
.ml2  { margin-left: var(--s2); }

.w-xs { max-width: 160px; }
.w-sm { max-width: 200px; }
.w-md { max-width: 280px; }

.break-all { word-break: break-all; overflow-wrap: anywhere; }

/* A row whose children stay on one line and align to centre — used for the
   checkbox-plus-label pattern where a wrapping label looks broken. */
.row-inline { display: flex; gap: var(--s2); align-items: center; }

/* Toolbar row inside a card header: title grows, controls sit at the end and
   wrap onto their own line on a phone rather than crushing the title. */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.toolbar > h2 { margin: 0; flex: 1 1 auto; min-width: 0; }

/* ---- Thread header ------------------------------------------------------
   Back, title and member list were one flex row; on a phone the comma-joined
   member list wrapped and pushed the title out of view. Stacking them keeps
   the title readable at 320px and lets members truncate to two lines. */
.thread-head {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  margin-bottom: var(--s4);
}
.thread-head h1 {
  font-size: var(--fs-lg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#thread-members {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* A square icon-sized back button reads better than a wide "← Back" pill. */
#back { padding: 0 var(--s3); min-width: var(--tap); font-size: var(--fs-lg); }

@media (min-width: 640px) {
  .thread-head h1 { font-size: var(--fs-xl); }
}
