/*
 * BBR Originals stylesheet. Hand-written, no framework, no inline styles (the Content-Security-Policy
 * forbids them). Colours follow the brand brief: #00D2FF primary cyan, #0066FF deep blue,
 * #000511 deep background, #040D21 midnight, #FFFFFF text. Gradients are used sparingly.
 */

/* ---------- Fonts (self-hosted) ---------- */
@font-face {
  font-family: "Manrope";
  src: url("/static/fonts/manrope-variable.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("/static/fonts/source-serif-4-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("/static/fonts/source-serif-4-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("/static/fonts/source-serif-4-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("/static/fonts/source-serif-4-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --cyan: #00d2ff;
  --blue: #0066ff;
  --bg: #000511;
  --midnight: #040d21;
  --surface: #071231;
  --surface-2: #0b1a3d;
  --text: #ffffff;
  --text-soft: #c5d3e8;     /* about 12:1 on --bg */
  --text-muted: #9fb2cf;    /* about 8:1 on --bg */
  --line: rgba(160, 200, 255, 0.18);
  --danger: #ff8a8a;
  --warn-bg: #2a1a05;
  --warn-text: #ffd27a;
  --ok: #7ef0b5;
  --focus: #00d2ff;
  --radius: 10px;
  --max: 72rem;
  --measure: 40rem;
  --font-ui: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-story: "Source Serif 4", Georgia, "Times New Roman", serif;
  --story-size: 1.125rem;   /* 18px, default */
  --story-line: 1.72;
  --gradient-hero: radial-gradient(120% 80% at 0% 0%, rgba(0, 102, 255, 0.28), transparent 60%),
    linear-gradient(180deg, var(--midnight), var(--bg));
}

/* Text size steps set by the reader's controls (0 smaller, 1 default, 2 larger, 3 largest). */
html[data-story-size="0"] { --story-size: 1.0625rem; }
html[data-story-size="1"] { --story-size: 1.125rem; }
html[data-story-size="2"] { --story-size: 1.25rem; }
html[data-story-size="3"] { --story-size: 1.375rem; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; outline: none; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--cyan); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { color: #7fe9ff; }
h1, h2, h3, h4 { font-family: var(--font-ui); line-height: 1.2; margin: 0 0 0.6em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 4.2vw, 3rem); font-weight: 750; }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.85rem); font-weight: 700; }
h3 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.4em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
pre { overflow-x: auto; padding: 1rem; background: var(--surface); border-radius: var(--radius); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.small { font-size: 0.875rem; }
.container { width: min(100% - 2.5rem, var(--max)); margin-inline: auto; }
.narrow { max-width: var(--measure); }
.visually-hidden, .sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }
.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100; padding: 0.6rem 1rem;
  background: var(--cyan); color: #00121f; font-weight: 700; border-radius: var(--radius);
}
.skip-link:focus { top: 1rem; }
.section { padding: clamp(2.5rem, 6vw, 4.5rem) 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1.5rem; margin-bottom: 1.5rem; }
.section-title { margin: 0; }
.section-intro, .page-intro-text, .page-intro { color: var(--text-soft); max-width: 46rem; }
.section-link { font-weight: 700; white-space: nowrap; }
.eyebrow { display: block; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--cyan); margin-bottom: 0.6rem; }
.lede { font-size: clamp(1.1rem, 2vw, 1.3rem); color: var(--text-soft); max-width: 42rem; }
.meta, .byline, .pagination-status { color: var(--text-muted); font-size: 0.9rem; }
.meta-sep { margin: 0 0.4rem; opacity: 0.6; }

/* ---------- Header and navigation ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: rgba(0, 5, 17, 0.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4rem; }
.wordmark { display: inline-flex; align-items: baseline; gap: 0.3rem; text-decoration: none; color: var(--text); font-weight: 800; letter-spacing: 0.02em; font-size: 1.15rem; }
.wordmark-bbr { color: var(--cyan); }
.wordmark-originals { color: var(--text); font-weight: 600; }
.site-nav { display: flex; align-items: center; }
.nav-list { list-style: none; display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; margin: 0; padding: 0; }
.nav-list a { display: inline-block; padding: 0.45rem 0.7rem; border-radius: 999px; color: var(--text-soft); text-decoration: none; font-weight: 600; font-size: 0.95rem; }
.nav-list a:hover, .nav-list a[aria-current="page"] { color: var(--text); background: rgba(0, 210, 255, 0.1); }
.nav-list a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--cyan); border-radius: 6px 6px 0 0; }

/* Mobile navigation: wraps into a row under the wordmark, large touch targets. */
@media (max-width: 52rem) {
  .header-inner { flex-direction: column; align-items: flex-start; padding: 0.7rem 0; gap: 0.4rem; }
  .nav-list { gap: 0; }
  .nav-list a { padding: 0.5rem 0.6rem; font-size: 0.9rem; }
}

/* ---------- Hero and homepage ---------- */
.hero { background: var(--gradient-hero); padding: clamp(3rem, 9vw, 6.5rem) 0 clamp(2.5rem, 6vw, 4.5rem); border-bottom: 1px solid var(--line); }
.hero-inner { max-width: none; }
.hero-inner > * { max-width: 46rem; }
.hero-title { font-size: clamp(2.2rem, 6vw, 3.9rem); font-weight: 800; letter-spacing: -0.02em; margin-bottom: 0.5em; }
.hero-note { color: var(--text-muted); font-size: 0.92rem; margin-top: 1.2rem; }
.intro-points, .points, .checklist { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: 0.7rem; }
.intro-points li, .points li { padding-left: 1.3rem; position: relative; color: var(--text-soft); }
.intro-points li::before, .points li::before { content: ""; position: absolute; left: 0; top: 0.55em; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--cyan); }
.pill-list, .chips { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; padding: 0; margin: 0; }
.pill { display: inline-block; padding: 0.35rem 0.8rem; border: 1px solid var(--line); border-radius: 999px; color: var(--text-soft); font-size: 0.9rem; text-decoration: none; background: rgba(4, 13, 33, 0.6); }
a.pill:hover { border-color: var(--cyan); color: var(--text); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1rem; }
.stat { border-top: 1px solid var(--line); padding-top: 0.8rem; }
.stat-value { font-size: 1.5rem; font-weight: 750; }
.stat-label { color: var(--text-muted); font-size: 0.9rem; }
.philosophy { background: var(--midnight); border-top: 1px solid var(--line); }
.philosophy-inner { max-width: 46rem; }
.prose-page p, .prose, .prose-page li { color: var(--text-soft); }

/* Hero actions and CTAs */
.hero-actions, .cta-row, .actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.75rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; min-height: 2.75rem; padding: 0.6rem 1.15rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; transition: background-color 0.15s ease, border-color 0.15s ease; }
.btn:hover { border-color: var(--cyan); color: var(--text); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--cyan); border-color: var(--cyan); color: #00121f; }
.btn-primary:hover { background: #5fe4ff; border-color: #5fe4ff; color: #00121f; }
.btn-secondary { background: transparent; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn-danger { background: #3a0d12; border-color: #7a2430; color: #ffd1d6; }
.btn-danger-text { background: none; border: 0; color: var(--danger); padding: 0; min-height: 0; font-weight: 700; text-decoration: underline; }
.btn-small { min-height: 2.1rem; padding: 0.35rem 0.7rem; font-size: 0.9rem; }

/* ---------- Cards and grids ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: 1.25rem; list-style: none; padding: 0; margin: 0; }
.card, .story-card, .category-card, .panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem;
  display: flex; flex-direction: column; gap: 0.6rem; min-width: 0;
}
.story-card { padding: 0; overflow: hidden; }
.story-card .card-body { padding: 1.1rem 1.1rem 1.25rem; display: flex; flex-direction: column; gap: 0.6rem; }
.card-image { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-2); }
.card-title { font-size: 1.2rem; margin: 0; }
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { color: var(--cyan); text-decoration: underline; }
.card-synopsis { color: var(--text-soft); margin: 0; font-size: 0.97rem; }
.category-card-title { font-size: 1.15rem; margin: 0; }
.category-card-title a { color: var(--text); text-decoration: none; }
.category-card p { color: var(--text-soft); margin: 0; font-size: 0.95rem; }
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); gap: 1rem; }
.category-card a.card-link { color: var(--cyan); font-weight: 700; margin-top: auto; }
.featured .card { border-color: rgba(0, 210, 255, 0.35); }
.badge, .chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.8rem; font-weight: 700; border: 1px solid var(--line); color: var(--text-soft); background: rgba(4, 13, 33, 0.7); }
.chip-warning, .warning-chip { background: var(--warn-bg); border-color: #6b4a12; color: var(--warn-text); }
.badge-live { border-color: #1f7a54; color: var(--ok); }
.badge-scheduled { border-color: #1d5fb0; color: #8cc8ff; }
.badge-draft { border-color: #6b5b1f; color: #ffe08a; }
.badge-archived { border-color: #4a4f5e; color: #b9c0cf; }
.badge-demo { border-color: #6a3c8f; color: #e0c4ff; }
.badge-published { border-color: #1f7a54; color: var(--ok); }
.is-featured { border-color: var(--cyan); }
.warnings, .story-warnings { display: flex; flex-direction: column; gap: 0.5rem; }
.warnings-label { display: flex; align-items: center; gap: 0.4rem; margin: 0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 700; }
.warning-list, .warning-defs { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; }
.warning-defs dt { font-weight: 700; color: var(--text); }
.warning-defs dd { margin: 0 0 0.25rem; color: var(--text-soft); }
.empty-state { text-align: center; padding: 2.5rem 1.25rem; border: 1px dashed var(--line); border-radius: var(--radius); background: rgba(4, 13, 33, 0.5); }
.empty-title { font-size: 1.2rem; margin-bottom: 0.4rem; }
.empty-state p { color: var(--text-soft); max-width: 36rem; margin-inline: auto; }

/* ---------- Pagination and breadcrumbs ---------- */
.pagination { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; justify-content: space-between; margin-top: 2rem; }
.breadcrumbs { font-size: 0.9rem; color: var(--text-muted); padding: 1rem 0 0; }
.breadcrumbs ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.breadcrumbs li + li::before { content: "/"; margin-right: 0.3rem; opacity: 0.6; }
.breadcrumbs a { color: var(--text-soft); }

/* ---------- Newsletter ---------- */
.newsletter, .invite { background: linear-gradient(135deg, rgba(0, 102, 255, 0.16), rgba(0, 210, 255, 0.04)); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1.25rem, 3vw, 2rem); }
.newsletter-body { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }
@media (min-width: 52rem) { .newsletter-body { grid-template-columns: 1fr 1fr; align-items: start; } }
.newsletter-copy p { color: var(--text-soft); }
.newsletter-form, .inline-form { display: flex; flex-direction: column; gap: 0.75rem; }
.inline-form { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.inline-form-wide { flex: 1 1 22rem; }
.inline-form .field { flex: 1 1 14rem; }
.invite-title { font-size: 1.3rem; margin-bottom: 0.4rem; }
.invite p { color: var(--text-soft); }
.check-group { display: flex; gap: 0.6rem; align-items: flex-start; color: var(--text-soft); font-size: 0.95rem; }
.check-group input { margin-top: 0.3rem; width: 1.15rem; height: 1.15rem; accent-color: var(--cyan); flex: 0 0 auto; }
.check-scroll { max-height: 14rem; overflow: auto; padding: 0.4rem 0.6rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--midnight); display: grid; gap: 0.5rem; }
.hp-field { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.cf-turnstile { min-height: 65px; }

/* ---------- Forms ---------- */
.form-stack { display: flex; flex-direction: column; gap: 1rem; max-width: 42rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.field label, .field > span, legend { font-weight: 700; color: var(--text); }
.field-help { font-size: 0.88rem; color: var(--text-muted); margin: 0; }
.field-check { flex-direction: row; align-items: flex-start; gap: 0.6rem; font-weight: 400; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="url"], input[type="number"], input[type="datetime-local"], input[type="date"], select, textarea {
  font: inherit; color: var(--text); background: var(--midnight); border: 1px solid #2a4170; border-radius: 8px; padding: 0.6rem 0.75rem; min-height: 2.75rem; width: 100%; max-width: 100%;
}
input::placeholder, textarea::placeholder { color: #7f93b5; }
input:focus, select:focus, textarea:focus { border-color: var(--cyan); outline: 2px solid var(--cyan); outline-offset: 1px; }
textarea { min-height: 8rem; resize: vertical; line-height: 1.55; }
.textarea-story { min-height: 26rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.95rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0; min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.req { color: var(--danger); }
.inline-error { color: var(--danger); font-size: 0.9rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; background: var(--midnight); }
tr:last-child td { border-bottom: 0; }

/* ---------- Notices ---------- */
.notice { border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius); padding: 0.9rem 1rem; background: var(--surface); margin-bottom: 1.25rem; color: var(--text-soft); }
.notice p:last-child { margin-bottom: 0; }
.notice-title { display: block; font-weight: 700; color: var(--text); margin-bottom: 0.2rem; }
.notice-info { border-left-color: var(--cyan); }
.notice-ok, .notice-success { border-left-color: var(--ok); }
.notice-warn, .notice-warning { border-left-color: var(--warn-text); background: #1d1404; }
.notice-error, .notice-danger { border-left-color: var(--danger); background: #1d0a0d; }
.notice-config { border-left-color: var(--blue); }

/* ---------- Story page ---------- */
.story-header { padding: clamp(2rem, 6vw, 3.5rem) 0 1.5rem; border-bottom: 1px solid var(--line); background: var(--gradient-hero); }
.story-header-inner { max-width: none; }
.story-header-inner > * { max-width: 46rem; }
@media (min-width: 62rem) { .story-header-inner { padding-left: 8.5rem; } }
.story-title { font-size: clamp(2rem, 5.2vw, 3.2rem); font-weight: 800; letter-spacing: -0.02em; margin-bottom: 0.4rem; }
.story-subtitle { font-size: clamp(1.1rem, 2.2vw, 1.35rem); color: var(--text-soft); margin: 0 0 1rem; font-weight: 500; }
.story-header .meta-row, .story-header .meta { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; align-items: center; color: var(--text-muted); font-size: 0.92rem; }
.story-layout { display: grid; gap: 1.5rem; padding: 2rem 0 3rem; grid-template-columns: 1fr; }
.story-main { min-width: 0; max-width: var(--measure); width: 100%; }
.story-excerpt { font-size: 1.15rem; color: var(--text-soft); font-style: italic; border-left: 3px solid var(--cyan); padding-left: 1rem; margin: 0 0 2rem; }
.story-body {
  font-family: var(--font-story); font-size: var(--story-size); line-height: var(--story-line); color: #f1f5ff;
  text-align: left; hyphens: manual; overflow-wrap: break-word;
}
.story-body p { margin: 0 0 1.1em; }
.story-body h2 { font-family: var(--font-ui); font-size: 1.45em; margin: 1.6em 0 0.6em; }
.story-body h3 { font-family: var(--font-ui); font-size: 1.2em; margin: 1.4em 0 0.5em; }
.story-body strong { font-weight: 700; }
.story-body em { font-style: italic; }
.story-body blockquote { margin: 1.6em 0; padding: 0.2em 0 0.2em 1.2em; border-left: 3px solid var(--blue); color: #d9e6ff; font-style: italic; }
.story-body hr { margin: 2.2em auto; width: 40%; border-top: 1px solid var(--line); }
.story-body a { color: #7fe9ff; }
.story-body ul, .story-body ol { margin-bottom: 1.1em; }
.copyright-note { margin-top: 2.5rem; font-size: 0.9rem; color: var(--text-muted); border-top: 1px solid var(--line); padding-top: 1rem; }
.story-extras { margin-top: 2.5rem; display: grid; gap: 1.25rem; }
.author-note, .discussion { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; }
.author-note .section-title, .discussion .section-title { font-size: 1.1rem; margin-bottom: 0.5rem; }
.author-note p, .discussion p { color: var(--text-soft); margin-bottom: 0.6rem; }
.story-related { margin-top: 3rem; }

/* Reader toolbar. Vertical column on desktop; compact floating bar on small screens. */
.toolbar { display: flex; flex-direction: row; flex-wrap: wrap; gap: 0.6rem; align-items: center; justify-content: center; }
.tool-group { display: flex; flex-direction: row; gap: 0.4rem; align-items: center; }
.tool-form { margin: 0; display: flex; align-items: center; gap: 0.4rem; }
.tool-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem; min-height: 2.75rem; min-width: 2.75rem;
  padding: 0.45rem 0.75rem; border-radius: 999px; border: 1px solid var(--line); background: rgba(7, 18, 49, 0.9);
  color: var(--text); font: inherit; font-size: 0.92rem; font-weight: 700; text-decoration: none; cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.tool-btn:hover { border-color: var(--cyan); color: var(--text); }
.tool-btn[aria-pressed="true"], .tool-btn.is-active { border-color: var(--cyan); color: var(--cyan); }
.tool-btn:disabled { opacity: 0.6; cursor: wait; }
.tool-btn svg { flex: 0 0 auto; }
.tool-btn-small { min-width: 2.4rem; min-height: 2.4rem; padding: 0.3rem 0.6rem; font-size: 0.95rem; color: var(--text-soft); }
.tool-label { white-space: nowrap; }
.tool-count { min-width: 0.5rem; font-variant-numeric: tabular-nums; color: var(--text-soft); font-weight: 600; }
.tool-note { font-size: 0.85rem; color: var(--text-muted); margin: 0; max-width: 14rem; }
.tool-support { border-color: rgba(0, 102, 255, 0.5); }
.tool-size { color: var(--text-muted); }
.size-up-mark { font-size: 0.7em; margin-left: 0.05em; }
.share-status { margin: 0; font-size: 0.85rem; color: var(--text-soft); min-height: 1.2em; text-align: center; }
.share-fallback { width: 100%; display: grid; gap: 0.3rem; }
.share-fallback label { font-size: 0.85rem; color: var(--text-muted); }
.share-fallback input { font-size: 0.85rem; }

@media (min-width: 62rem) {
  .story-layout { grid-template-columns: 5.5rem minmax(0, 1fr); gap: 3rem; }
  .toolbar { position: sticky; top: 6rem; flex-direction: column; align-items: stretch; align-self: start; gap: 0.75rem; }
  .tool-group { flex-direction: column; }
  .tool-form { flex-direction: column; }
  .tool-btn { flex-direction: column; min-height: 4rem; width: 100%; border-radius: var(--radius); padding: 0.6rem 0.3rem; font-size: 0.8rem; }
  .tool-btn-small { min-height: 2.6rem; flex-direction: row; }
  .tool-note, .share-fallback { display: none; }
  .tool-size { flex-direction: column; }
  .toolbar[aria-label] { gap: 1rem; }
  .story-layout > .story-main { grid-column: 2; }
}

@media (max-width: 61.99rem) {
  .toolbar {
    position: sticky; bottom: 0.75rem; z-index: 40; margin: 0 auto; width: calc(100% - 1.25rem); max-width: 34rem;
    background: rgba(4, 13, 33, 0.94); border: 1px solid var(--line); border-radius: 16px; padding: 0.35rem 0.4rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); backdrop-filter: blur(6px); flex-wrap: wrap; justify-content: center;
  }
  .tool-group, .tool-size { flex-wrap: wrap; justify-content: center; }
  .tool-label { font-size: 0.85rem; }
  .tool-btn { min-height: 2.75rem; padding: 0.4rem 0.6rem; }
  .tool-btn-small { padding: 0.3rem 0.45rem; }
  .tool-note, .share-fallback { display: none; }
  .story-layout { display: flex; flex-direction: column; }
  .story-layout > .story-main { order: 1; }
  .story-layout > .toolbar { order: 2; }
}

/* ---------- Audio ---------- */
.audio-list { display: grid; gap: 1rem; list-style: none; padding: 0; margin: 0; }

/* ---------- Footer ---------- */
.site-footer { background: #00030c; border-top: 1px solid var(--line); padding: 3rem 0 2rem; margin-top: 3rem; color: var(--text-soft); font-size: 0.95rem; }
.footer-grid { display: grid; gap: 2rem; grid-template-columns: 1fr; }
@media (min-width: 46rem) { .footer-grid { grid-template-columns: 2fr 1fr 1fr; } }
.footer-brand .wordmark { font-size: 1.3rem; }
.footer-tagline { color: var(--text-muted); max-width: 22rem; margin-top: 0.6rem; }
.footer-heading { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); margin: 0 0 0.7rem; }
.footer-nav ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.45rem; }
.footer-nav a { color: var(--text-soft); text-decoration: none; }
.footer-nav a:hover { color: var(--cyan); text-decoration: underline; }
.footer-bottom { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); color: var(--text-muted); font-size: 0.85rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; justify-content: space-between; }
.footer-note { max-width: 46rem; margin: 0; }

/* ---------- Static and legal pages ---------- */
.page-head { padding: clamp(2rem, 5vw, 3.5rem) 0 1.5rem; }
.page-title { font-size: clamp(1.9rem, 4.2vw, 2.9rem); font-weight: 800; letter-spacing: -0.02em; margin-bottom: 0.5rem; }
.page-body { padding-bottom: 3rem; max-width: var(--measure); }
.page-body h2 { margin-top: 2rem; }
.page-body li { margin-bottom: 0.4rem; }
.placeholder, .todo { background: rgba(255, 210, 122, 0.12); color: var(--warn-text); padding: 0 0.2em; border-radius: 4px; }

/* ---------- Admin ---------- */
.admin { background: #00040e; }
.admin-header { background: #00030c; border-bottom: 1px solid var(--line); }
.admin-header-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem 1.5rem; padding: 0.8rem 0; }
.admin-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0.2rem; padding: 0; margin: 0; }
.admin-nav a { display: inline-block; padding: 0.4rem 0.6rem; border-radius: 8px; color: var(--text-soft); text-decoration: none; font-weight: 600; font-size: 0.92rem; }
.admin-nav a:hover, .admin-nav a[aria-current="page"] { color: var(--text); background: rgba(0, 210, 255, 0.1); }
.admin-account { display: flex; align-items: center; gap: 0.75rem; color: var(--text-muted); font-size: 0.9rem; }
.admin-account form { margin: 0; }
.admin-page { padding: 2rem 0 4rem; }
.admin-page .page-title { font-size: clamp(1.6rem, 3vw, 2.2rem); }
.admin-preview-bar { background: #2a1d00; color: var(--warn-text); padding: 0.6rem 0; border-bottom: 1px solid #5a4000; font-size: 0.92rem; }
.admin-preview-bar .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; align-items: center; }
.admin-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: flex-end; margin-bottom: 1.25rem; }
.head-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { min-width: 10rem; flex: 1 1 10rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.row-actions form { margin: 0; }
.editor-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 60rem) { .editor-grid { grid-template-columns: minmax(0, 1fr) 20rem; } }
.editor-main, .editor-side { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
.editor-side .panel { gap: 0.8rem; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.danger-zone { border: 1px solid #5c1f29; background: #1a070a; border-radius: var(--radius); padding: 1.1rem; }
.danger-zone h2 { color: #ffb3bb; font-size: 1.15rem; }
.readiness, .checklist-panel { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.readiness li { display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.93rem; color: var(--text-soft); }
.readiness .ok { color: var(--ok); font-weight: 800; }
.readiness .todo { background: none; color: var(--warn-text); font-weight: 800; padding: 0; }
.ordered-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; counter-reset: item; }
.ordered-item { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; padding: 0.7rem 0.9rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.ordered-title { font-weight: 700; }
.admin-page .small { color: var(--text-muted); }
.admin-page .btn { min-height: 2.4rem; }
.admin.is-admin .story-body { font-size: 1rem; }
.options { display: grid; gap: 0.4rem; }
.page-intro-text + .panel { margin-top: 1rem; }

/* Login */
.login-card { max-width: 26rem; margin: 3rem auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; }

/* ---------- Motion and contrast preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
@media (prefers-contrast: more) {
  :root { --line: rgba(200, 220, 255, 0.5); --text-soft: #e6eeff; --text-muted: #d0dcf0; }
}

/* Print: readable without the reader tools. */
@media print {
  body { background: #fff; color: #000; }
  .site-header, .site-footer, .toolbar, .story-related, .invite, .skip-link { display: none !important; }
  .story-body, .story-title, .story-excerpt { color: #000; }
  a { color: #000; }
}
