/* ==========================================================================
   Skrivna Design System — The Reading Room & Writer's Archive
   A quiet, editorial design with warm paper, dark charcoal ink, Literata serif,
   and zero intrusive algorithmic distraction.

   Rules of the house:
   - Every surface color comes from a token on :root; the dark-mode block
     remaps tokens, never individual rules.
   - Outlines are never removed; keyboard focus shows :focus-visible.
   - Writer language in copy, canonical glyphs (● ◇ ✦ ◌) in ornament.
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Warm Paper & Surface Tokens */
  --bg-paper: #faf8f5;           /* Warm ivory / natural newsprint */
  --bg-surface: #ffffff;         /* Pure paper white card surface */
  --bg-subtle: #f4efe8;          /* Faint parchment for callouts/teasers */
  --bg-highlight: #ece5dc;       /* Focus and hover tone */

  /* Ink & Typography Tokens */
  --text-primary: #1c1917;       /* Deep charcoal ink (never harsh #000) */
  --text-muted: #78716c;         /* Soft slate pencil lead */
  --text-faint: #a8a29e;         /* Subtle timestamp / meta text */

  /* Delicate Lines & Borders */
  --border-delicate: #e7e5e4;    /* Deckle edge divider */
  --border-strong: #d6d3d1;      /* Active outline */

  /* Literary Accents */
  --accent-oxblood: #881337;     /* Crimson wax seal for active tabs & primary CTAs */
  --accent-forest: #14532d;      /* Deep archival forest green for milestones */
  --accent-amber: #b45309;       /* Warm amber for locked/waiting states */
  --accent-on: #ffffff;          /* Ink that sits on an accent fill */

  /* Status Surfaces (gently tinted, never shouty) */
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --success-text: #14532d;

  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #991b1b;

  --warning-bg: #fef3c7;
  --warning-border: #fde68a;
  --warning-text: #92400e;

  /* Ink Surfaces — the "midnight banner" family: a dark card on warm paper
     in light mode, a lifted slate card on charcoal in dark mode */
  --ink-surface: #1c1917;
  --ink-raised: #292524;
  --ink-on: #f5f5f4;
  --ink-on-muted: #d6d3d1;
  --ink-on-faint: #a8a29e;
  --ink-border: #44403c;

  /* Typography Fonts (self-hosted, see @font-face below) */
  --font-serif: 'Literata', 'Source Serif Pro', Charter, 'Georgia', Cambria, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Elevation & Shadows (Calm, non-distracting) */
  --shadow-subtle: 0 1px 3px rgba(28, 25, 23, 0.05);
  --shadow-card: 0 4px 6px -1px rgba(28, 25, 23, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-paper: #18181b;         /* Soft charcoal study at night */
    --bg-surface: #27272a;       /* Matte slate card */
    --bg-subtle: #222225;        /* Subdued callout */
    --bg-highlight: #333338;

    --text-primary: #f4f4f5;     /* Warm cream ink */
    --text-muted: #a1a1aa;       /* Silver grey */
    --text-faint: #71717a;

    --border-delicate: #3f3f46;
    --border-strong: #52525b;

    --accent-oxblood: #fda4af;   /* Soft dusty rose */
    --accent-forest: #86efac;    /* Soft sage */
    --accent-amber: #fde047;
    --accent-on: #27272a;        /* Dark ink on the lightened accents */

    --success-bg: #17251c;
    --success-border: #2e4636;
    --success-text: #86efac;

    --danger-bg: #2b1b1e;
    --danger-border: #55303a;
    --danger-text: #fda4af;

    --warning-bg: #2a2314;
    --warning-border: #4d3f1c;
    --warning-text: #fbd38d;

    --ink-surface: #27272a;
    --ink-raised: #18181b;
    --ink-on: #f4f4f5;
    --ink-on-muted: #d4d4d8;
    --ink-on-faint: #a1a1aa;
    --ink-border: #52525b;
  }
}

/* Brand fonts — self-hosted variable fonts (latin subset), swapped in
   without hiding text while they load. */
@font-face {
  font-family: 'Literata';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/literata-latin-var.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Literata';
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/literata-latin-italic-var.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin-var.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ==========================================================================
   Base Elements & Reset
   ========================================================================== */

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

body {
  margin: 0;
  padding: 0;
  overflow-x: clip;
  background-color: var(--bg-paper);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button, input, textarea, select {
  font: inherit;
}

/* Keyboard focus is always visible (mouse clicks stay clean). */
:focus-visible {
  outline: 2px solid var(--accent-oxblood);
  outline-offset: 2px;
}

/* Form controls follow the paper so dark mode never leaves white inputs
   on charcoal. Radio/checkbox inputs keep their native rendering. */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="number"],
textarea,
select {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 0.625rem 0.75rem;
}

textarea {
  resize: vertical;
}

::placeholder {
  color: var(--text-faint);
  opacity: 1;
}

/* Utilities */
.hidden {
  display: none !important;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 0 0 6px 0;
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
}

.skip-link:focus {
  left: 0;
}

/* ==========================================================================
   Layout Containers & 65ch Measure Reading Room Contract (WEB-01)
   ========================================================================== */

.site-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Column flex lets page-level wrappers (e.g. the login doorway) grow to
   fill the remaining viewport and center themselves in it. */
.site-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.site-main > * {
  width: 100%;
}

/* Strict 65ch measure container */
.reading-room,
.reading-room-measure,
.reading-measure {
  max-width: 65ch;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  width: 100%;
}

.max-w-4xl {
  max-width: 56rem;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* Standard vertical breathing room for a page's content column */
.page-body {
  padding-top: 3rem;
  padding-bottom: 4rem;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.site-header {
  border-bottom: 1px solid var(--border-delicate);
  background-color: var(--bg-paper);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.header-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0.5rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.brand-title:hover {
  text-decoration: none;
}

.brand-tagline {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: none;
}

@media (min-width: 640px) {
  .brand-tagline {
    display: inline;
  }
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Nav interactives keep a ~44px tap target at every width (a11y Q9). */
.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.5rem 0.25rem;
  transition: color 0.15s ease;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.nav-link[aria-current="page"] {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--accent-oxblood);
}

.user-session {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  margin-left: auto;
}

.user-greeting {
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
}

.nav-btn-studio {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  background-color: var(--text-primary);
  color: var(--bg-paper);
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}

.nav-btn-studio:hover {
  opacity: 0.9;
  text-decoration: none;
}

.nav-link-subtle {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  background: none;
  border: none;
  padding: 0.5rem 0.25rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  cursor: pointer;
  white-space: nowrap;
}

.nav-link-subtle:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

@media (max-width: 480px) {
  .site-nav,
  .user-session {
    gap: 0.5rem;
  }
}

.inline-form {
  display: inline;
  margin: 0;
  padding: 0;
}

/* Persona Preview Bar (single definition — writer-only chrome) */
.persona-preview-bar {
  background-color: var(--warning-bg);
  color: var(--warning-text);
  border-bottom: 1px solid var(--warning-border);
  padding: 0.5rem 1.25rem;
  font-size: 0.8125rem;
}

.persona-preview-container {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.persona-preview-lead {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.preview-badge {
  background-color: var(--accent-amber);
  color: var(--accent-on);
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.preview-info {
  color: var(--warning-text);
}

.persona-preview-pills {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.persona-pill {
  padding: 0.3rem 0.625rem;
  font-size: 0.75rem;
  border-radius: 4px;
  border: 1px solid var(--warning-border);
  background-color: transparent;
  color: var(--warning-text);
  text-decoration: none;
  font-weight: 500;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.persona-pill:hover {
  border-color: var(--warning-text);
  text-decoration: none;
}

.persona-pill.active {
  background-color: var(--bg-surface);
  border-color: var(--bg-surface);
  color: var(--warning-text);
  font-weight: 700;
}

.btn-exit-preview {
  background-color: var(--accent-amber);
  color: var(--accent-on);
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.btn-exit-preview:hover {
  opacity: 0.9;
  text-decoration: none;
}

/* Flash notifications */
.flash-container {
  max-width: 48rem;
  margin: 1rem auto 0;
  padding: 0 1.25rem;
}

.flash-banner {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  border: 1px solid transparent;
}

.flash-info {
  background-color: var(--bg-subtle);
  border-color: var(--border-delicate);
  color: var(--text-primary);
}

.flash-success {
  background-color: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-text);
}

.flash-error {
  background-color: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

/* ==========================================================================
   Prose & Reading Room Typography (WEB-01)
   ========================================================================== */

.reading-room-wrapper {
  padding-top: 3rem;
  padding-bottom: 4rem;
}

.story-prose,
.reading-prose {
  font-family: var(--font-serif);
  font-size: 1.1875rem; /* ~19px desktop */
  line-height: 1.75;
  color: var(--text-primary);
  letter-spacing: -0.011em;
}

@media (max-width: 640px) {
  .story-prose,
  .reading-prose {
    font-size: 1.125rem; /* 18px mobile */
    line-height: 1.68;
  }
}

.story-prose p,
.reading-prose p {
  margin-top: 0;
  margin-bottom: 1.5rem;
  text-indent: 0;
}

.story-prose h1, .story-prose h2, .story-prose h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.3;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

.story-prose blockquote,
.reading-prose blockquote {
  border-left: 2px solid var(--border-strong);
  padding-left: 1.25rem;
  margin: 1.75rem 0;
  font-style: italic;
  color: var(--text-muted);
}

/* Distinctive Centered Scene Divider */
.scene-divider {
  margin: 3.5rem auto;
  text-align: center;
  letter-spacing: 0.75rem;
  font-size: 1.25rem;
  font-family: var(--font-serif);
  color: var(--text-muted);
  user-select: none;
}

/* Non-Canonical Prose Banner (Deleted Scene / Alternative) */
.non-canonical-banner {
  background-color: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
  padding: 0.875rem 1.25rem;
  border-radius: 6px;
  margin-bottom: 2rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
}

.non-canonical-title {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.125rem;
  margin-bottom: 0.25rem;
}

.non-canonical-copy {
  margin: 0;
  font-size: 0.875rem;
}

.badge-noncanonical {
  display: inline-block;
  background-color: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
  padding: 0.125rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  margin-bottom: 0;
}

/* Page-level breadcrumb (artifact & revision detail) */
.breadcrumb {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 2px;
}

.breadcrumb a:hover {
  color: var(--text-primary);
}

.breadcrumb-sep {
  margin: 0 0.5rem;
}

.breadcrumb-current {
  color: var(--text-primary);
}

/* Post-Chapter Transition Area (WEB-03) */
.post-chapter-container {
  margin-top: 2rem;
  padding-top: 1.5rem;
}

.post-chapter-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-delicate);
  border-radius: 8px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow-subtle);
}

.completion-affirmation {
  margin-bottom: 1.5rem;
}

.completion-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.quiet-unlock-alert {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  margin-top: 0.75rem;
}

.primary-nav-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (min-width: 640px) {
  .primary-nav-actions {
    flex-direction: row;
  }
}

.btn-primary,
.btn-primary-reading {
  display: inline-block;
  background-color: var(--text-primary);
  color: var(--bg-paper);
  padding: 0.75rem 1.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s ease;
}

.btn-primary:hover,
.btn-primary-reading:hover {
  opacity: 0.9;
  text-decoration: none;
}

.btn-secondary {
  display: inline-block;
  background-color: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  min-height: 44px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-secondary:hover {
  background-color: var(--bg-subtle);
  text-decoration: none;
}

.btn-block {
  width: 100%;
  text-align: center;
}

/* Contextual Behind Chapter Shelf (WEB-11) */
.behind-chapter-shelf {
  border-top: 1px solid var(--border-delicate);
  padding-top: 2rem;
  margin-top: 1.5rem;
  text-align: left;
}

.behind-shelf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.shelf-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.shelf-link {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-decoration: underline;
}

.artifact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .artifact-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.artifact-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-delicate);
  border-radius: 6px;
  padding: 1.25rem;
  box-shadow: var(--shadow-subtle);
  transition: border-color 0.15s ease;
}

.artifact-card:hover {
  border-color: var(--border-strong);
}

.artifact-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.category-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-oxblood);
}

.artifact-card-title {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
}

.artifact-card-summary {
  font-family: var(--font-serif);
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Shielded Locked Cards (WEB-13, POL-02, POL-03) */
.locked-count-card,
.archive-card-locked {
  background-color: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  padding: 1.25rem;
  text-align: center;
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* ==========================================================================
   Story Landing Page & TOC (WEB-18, WEB-19)
   ========================================================================== */

.story-hero {
  text-align: center;
  margin-bottom: 3rem;
}

.creative-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border: 1px solid var(--border-delicate);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  margin-bottom: 0.75rem;
}

.story-title {
  font-family: var(--font-serif);
  font-size: 2.5rem;
  line-height: 1.15;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.75rem 0;
}

@media (min-width: 640px) {
  .story-title {
    font-size: 3.25rem;
  }
}

.story-subtitle {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-style: italic;
  color: var(--text-muted);
  margin: 0 0 1rem 0;
}

.story-author {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.story-synopsis-quote {
  max-width: 36rem;
  margin: 0 auto 2rem;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text-primary);
  border-left: 2px solid var(--border-strong);
  padding-left: 1rem;
  text-align: left;
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

/* Completed Story Dual Paths Hero (WEB-19) */
.completed-story-banner {
  background-color: var(--ink-surface);
  color: var(--ink-on);
  border-radius: 8px;
  padding: 2.5rem 1.5rem;
  margin-bottom: 3rem;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.completed-eyebrow {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-on-faint);
  margin-bottom: 0.5rem;
}

.completed-banner-title {
  font-family: var(--font-serif);
  font-size: 1.875rem;
  margin: 0 0 1rem 0;
}

.completed-banner-copy {
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  color: var(--ink-on-muted);
  max-width: 32rem;
  margin: 0 auto 2rem;
  line-height: 1.6;
}

.dual-path-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

@media (min-width: 640px) {
  .dual-path-actions {
    flex-direction: row;
  }
}

.btn-dual-read {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  padding: 0.75rem 2rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9375rem;
  min-height: 44px;
}

.btn-dual-read:hover {
  background-color: var(--bg-subtle);
  text-decoration: none;
}

.btn-dual-explore {
  background-color: var(--ink-raised);
  color: var(--ink-on);
  border: 1px solid var(--ink-border);
  padding: 0.75rem 2rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9375rem;
  min-height: 44px;
}

.btn-dual-explore:hover {
  background-color: var(--ink-border);
  text-decoration: none;
}

/* Tabs */
.story-tabs {
  border-bottom: 1px solid var(--border-delicate);
  margin-bottom: 2rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.story-tab {
  padding-bottom: 0.75rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.story-tab:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.story-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-oxblood);
}

/* Story Area Sections */
.story-area-section {
  padding: 3rem 0;
  border-bottom: 1px solid var(--border-delicate);
}
.story-area-section:last-of-type {
  border-bottom: none;
}
.area-header {
  margin-bottom: 1.5rem;
}
.area-title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  color: var(--text-primary);
}
.area-glyph {
  color: var(--accent-oxblood);
  margin-right: 0.375rem;
}
.area-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

/* Chapter TOC rows */
.chapter-list {
  max-width: 42rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chapter-row {
  display: block;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-delicate);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  transition: all 0.15s ease;
}

.chapter-row:hover {
  border-color: var(--border-strong);
  text-decoration: none;
  box-shadow: var(--shadow-subtle);
}

.chapter-row-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.chapter-seq-badge {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--text-faint);
}

.chapter-row-title {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
}

.chapter-meta-tag {
  font-size: 0.75rem;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.read-pill {
  color: var(--success-text);
  background-color: var(--success-bg);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
}

.reading-pill {
  color: var(--warning-text);
  background-color: var(--warning-bg);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-weight: 500;
}

/* ==========================================================================
   Behind the Story Archive (WEB-12, WEB-14)
   ========================================================================== */

.archive-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
  justify-content: center;
}

.filter-tab {
  padding: 0.375rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-delicate);
  transition: all 0.15s ease;
}

.filter-tab:hover {
  border-color: var(--border-strong);
  text-decoration: none;
  color: var(--text-primary);
}

.filter-tab.active {
  background-color: var(--text-primary);
  color: var(--bg-paper);
  border-color: var(--text-primary);
}

.archive-masonry {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .archive-masonry {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Artifact Detail Page */
.artifact-detail-header {
  margin-bottom: 2rem;
}

.artifact-title {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0.5rem 0 1rem 0;
  line-height: 1.2;
}

.related-chapter {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.related-chapter a {
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 2px;
  color: var(--text-primary);
}

.related-chapter a:hover {
  text-decoration-color: var(--text-primary);
}

.artifact-media {
  margin: 2rem 0;
  text-align: center;
}

.artifact-media img {
  border-radius: 6px;
  box-shadow: var(--shadow-card);
  margin: 0 auto;
}

.author-commentary {
  background-color: var(--bg-subtle);
  border-left: 3px solid var(--border-strong);
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
  border-radius: 0 6px 6px 0;
}

.commentary-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.commentary-text {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text-primary);
  margin: 0;
}

.artifact-prose {
  margin: 2rem 0;
}

/* ==========================================================================
   Shared Revisions — narrative, not a comparison sheet (WEB-15)
   ========================================================================== */

.section-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.section-back-link {
  font-size: 0.875rem;
  color: var(--text-muted);
  display: inline-block;
  margin-bottom: 0.5rem;
}

.section-back-link:hover {
  color: var(--text-primary);
}

.section-title {
  font-family: var(--font-serif);
  font-size: 2.25rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin: 0;
}

/* Revision rows: stacked narrative rows inside the chapter-row card */
.revision-row-inner {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.revision-row-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.revision-row-link {
  font-size: 0.75rem;
  color: var(--accent-oxblood);
  font-weight: 500;
}

.revision-row-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

.revision-empty {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 2rem;
}

.narrative-diff-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-delicate);
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-subtle);
}

.diff-section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.diff-why-box {
  background-color: var(--bg-subtle);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  font-family: var(--font-serif);
  font-style: italic;
  margin: 0 0 2rem 0;
}

/* Vertical narrative flow: why → before → ↓ → after → actions */
.diff-narrative {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.diff-narrative-step {
  display: flex;
  flex-direction: column;
}

.diff-arrow {
  text-align: center;
  color: var(--text-faint);
  font-size: 1.25rem;
  line-height: 1;
  margin: 0.5rem 0;
  user-select: none;
}

.diff-glyph {
  margin-right: 0.375rem;
}

.diff-label-before {
  color: var(--danger-text);
}

.diff-label-after {
  color: var(--success-text);
}

.diff-box {
  padding: 1.25rem;
  border-radius: 6px;
  font-family: var(--font-serif);
  line-height: 1.6;
  color: var(--text-primary);
}

.diff-before {
  background-color: var(--danger-bg);
  border: 1px solid var(--danger-border);
}

.diff-after {
  background-color: var(--success-bg);
  border: 1px solid var(--success-border);
}

/* Progressive-disclosure tier: the fuller comparison stays folded until
   a reader asks for it. */
.diff-comparison-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .diff-comparison-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.diff-details {
  margin-top: 0.25rem;
}

.diff-details > summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  list-style: none;
  transition: background-color 0.15s ease;
}

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

.diff-details > summary:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.diff-details[open] > summary {
  margin-bottom: 1.5rem;
}

.diff-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

@media (min-width: 640px) {
  .diff-actions {
    flex-direction: row;
  }
}

/* ==========================================================================
   Literary Reactions Palette (WEB-16, SOC-02)
   ========================================================================== */

.reaction-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 2rem 0;
  padding: 1rem 0;
  border-top: 1px solid var(--border-delicate);
  flex-wrap: wrap;
}

.reaction-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 0.5rem;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-delicate);
  border-radius: 9999px;
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  transition: all 0.15s ease;
}

.reaction-pill:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-subtle);
}

.reaction-pill.active {
  background-color: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--accent-oxblood);
}

.reaction-pill .count {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Moderated Comments Section (WEB-17, SOC-03, POL-05)
   ========================================================================== */

.comments-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-delicate);
}

.comments-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin: 0 0 1.5rem 0;
}

.comment-form {
  margin-bottom: 2.5rem;
}

.comment-textarea {
  width: 100%;
  padding: 0.875rem;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  resize: vertical;
  min-height: 100px;
}

.comment-textarea:focus {
  border-color: var(--text-primary);
}

.comment-tree {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.comment-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-delicate);
  border-radius: 6px;
  padding: 1.25rem;
}

.comment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.author-badge {
  display: inline-block;
  background-color: var(--accent-oxblood);
  color: var(--accent-on);
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  margin-left: 0.375rem;
}

.comment-body {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.reply-list {
  margin-left: 1.5rem;
  margin-top: 1rem;
  padding-left: 1rem;
  border-left: 2px solid var(--border-delicate);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.reply-card {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-delicate);
  border-radius: 6px;
  padding: 1rem 1.25rem;
}

/* ==========================================================================
   Following Feed (WEB-20, TIM-02)
   ========================================================================== */

.feed-header {
  margin-bottom: 2rem;
}

.feed-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  margin: 0 0 0.5rem 0;
}

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.feed-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-delicate);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: var(--shadow-subtle);
}

/* Applied to the whole card (article.feed-card.feed-card-locked) inside
   .feed-list — the list gap provides the spacing, no extra margin. */
.feed-card-locked {
  background-color: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  padding: 1rem 1.25rem;
}

.feed-card-locked .feed-card-title {
  color: var(--text-muted);
  font-size: 1.125rem;
}

.feed-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.feed-card-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
}

.feed-card-copy {
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 1rem 0;
}

.feed-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-delicate);
  font-size: 0.75rem;
}

.feed-card-badge {
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  background-color: var(--bg-subtle);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
}

/* Library list — the same cards, one step quieter than the feed */
.library-item {
  padding: 1.25rem;
}

.library-item .feed-card-title {
  font-size: 1.125rem;
}

.library-item .feed-card-copy {
  margin-bottom: 0.75rem;
}

.library-item .feed-card-footer {
  padding-top: 0.5rem;
  margin-top: 0.5rem;
}

/* Positive Quiet Caught-Up Terminal (WEB-20) */
.caught-up-banner {
  text-align: center;
  margin: 3rem 0 2rem;
  padding: 2.5rem 1rem;
  border-top: 1px solid var(--border-delicate);
}

.caught-up-asterisk {
  font-size: 1rem;
  letter-spacing: 0.5em;
  color: var(--text-faint);
  margin-bottom: 0.75rem;
}

.caught-up-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
}

.caught-up-copy {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

/* ==========================================================================
   Sign-In Doorway
   ========================================================================== */

/* Centers the card in the viewport height left over by header & footer. */
.auth-doorway {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.25rem;
}

.auth-card {
  width: 100%;
  max-width: 24rem;
  background-color: var(--bg-surface);
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid var(--border-delicate);
  box-shadow: var(--shadow-subtle);
}

.auth-title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  margin: 0 0 0.5rem 0;
  text-align: center;
}

.auth-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 2rem 0;
}

.form-error-banner {
  background-color: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
  padding: 0.75rem;
  border-radius: 4px;
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

/* Shared form vocabulary (login now; studio forms next) */
.form-field {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--text-primary);
}

.form-help {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0.375rem 0 0;
}

.form-input,
.form-select {
  width: 100%;
}

.form-textarea {
  width: 100%;
  min-height: 8rem;
}

/* Serif prose field — the writer's chapter/scene textarea */
.form-prose {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.7;
}

/* ==========================================================================
   Error Page (POL-01, POL-03)
   ========================================================================== */

.error-container {
  padding-top: 4rem;
  padding-bottom: 4rem;
  text-align: center;
}

.error-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-delicate);
  border-radius: 8px;
  padding: 3rem 2rem;
  box-shadow: var(--shadow-subtle);
}

.error-status {
  font-family: var(--font-serif);
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-faint);
  margin-bottom: 1rem;
}

.error-title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  margin: 0 0 1rem 0;
}

.error-message {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 28rem;
  margin: 0 auto 2rem;
}

.error-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--border-delicate);
  padding: 2rem 1.25rem;
  margin-top: 4rem;
  background-color: var(--bg-paper);
}

.footer-inner {
  max-width: 64rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

@media (min-width: 640px) {
  .footer-inner {
    flex-direction: row;
  }
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.colophon-text {
  margin: 0;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--text-muted);
}

/* ==========================================================================
   Studio — the Writer's Desk (consumed by the studio templates)
   Centered workspace, zone cards, text state badges, form rows,
   serif chapter editor, calm grids.
   ========================================================================== */

/* Centered workspace (~1100px) with side padding */
.studio-container {
  max-width: 68.75rem;
  margin: 0 auto;
  padding: 3rem 1.25rem 4rem;
  width: 100%;
}

.studio-header {
  margin-bottom: 2rem;
}

.studio-header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.studio-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
}

.studio-subtitle {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin: 0.25rem 0 0;
}

.studio-switcher {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.studio-switcher select {
  width: auto;
}

/* Two-zone desk: single column on phones, two calm columns from 640px */
.zone-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 640px) {
  .zone-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Generic calm two-column grid with a 640px breakpoint */
.grid-two {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .grid-two {
    grid-template-columns: repeat(2, 1fr);
  }
}

.zone-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-delicate);
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: var(--shadow-subtle);
}

.studio-zone {
  transition: box-shadow 0.2s ease;
}

.studio-zone:hover {
  box-shadow: var(--shadow-card);
}

.zone-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.zone-card-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0;
}

.zone-card-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-delicate);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Object state badges — always text, never color alone */
.state-badge,
.status-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.state-badge-private,
.state-badge-draft,
.status-badge-draft {
  color: var(--text-muted);
  background-color: var(--bg-subtle);
  border-color: var(--border-delicate);
}

.state-badge-shared,
.state-badge-published,
.status-badge-published {
  color: var(--success-text);
  background-color: var(--success-bg);
  border-color: var(--success-border);
}

.state-badge-shared-later {
  color: var(--warning-text);
  background-color: var(--warning-bg);
  border-color: var(--warning-border);
}

.state-badge-withdrawn {
  color: var(--danger-text);
  background-color: var(--danger-bg);
  border-color: var(--danger-border);
}

/* Quiet destructive-adjacent action (Withdraw), still a 44px target */
.btn-danger-quiet {
  display: inline-block;
  background-color: transparent;
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  min-height: 44px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-danger-quiet:hover {
  background-color: var(--danger-bg);
  text-decoration: none;
}

/* Chapter editor — a writer's desk at the 65ch measure */
.editor-measure-container {
  max-width: 65ch;
  margin: 0 auto;
}

.editor-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.editor-breadcrumb {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.editor-title {
  width: 100%;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: none;
  border-bottom: 1px solid var(--border-strong);
  border-radius: 0;
  padding: 0.5rem 0;
  margin-bottom: 1.5rem;
}

.editor-title:focus {
  border-bottom-color: var(--text-primary);
}

.editor-prose {
  width: 100%;
  min-height: 55vh;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  line-height: 1.7;
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-delicate);
  border-radius: 6px;
  padding: 1.5rem;
}

/* Empty states */
.studio-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  background-color: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  color: var(--text-muted);
}

.studio-empty-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
}

.studio-empty-copy {
  font-size: 0.875rem;
  margin: 0 0 1.5rem 0;
}

/* Centered narrow card (~40rem) for forms & publish review */
.workspace-narrow {
  max-width: 40rem;
  margin: 0 auto;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-delicate);
  border-radius: 8px;
  padding: 2rem;
  box-shadow: var(--shadow-subtle);
}

.readonly-prose-block {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--text-primary);
  max-width: 65ch;
}

/* ==========================================================================
   Studio round 2 — writer's desk details
   Item rows, choice rows, artifact grid, review screen, form fieldsets.
   Everything below appends to the system above; tokens only, no new colors.
   ========================================================================== */

/* The desk reads its status in lowercase prose, not uppercase machinery. */
.studio-container .creative-status-pill {
  text-transform: none;
  letter-spacing: 0.02em;
  margin-bottom: 0.5rem;
}

/* Editor page: the writing surface keeps a bookish width, not the full desk */
.studio-container--editor {
  max-width: 44rem;
}

.editor-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-delicate);
}

/* Calm lists inside zone cards */
.studio-item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.studio-item-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border-delicate);
}

.studio-item-row:last-child {
  border-bottom: none;
}

.studio-item-row p {
  margin: 0.125rem 0;
}

.studio-item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.zone-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* Artifacts page: section rhythm + responsive card grid */
.studio-section {
  margin-bottom: 3rem;
}

.studio-artifact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .studio-artifact-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .studio-artifact-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.artifact-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-delicate);
}

.artifact-card-withdrawn {
  background-color: var(--bg-subtle);
  border-style: dashed;
}

.studio-quiet-line {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* Section dots — decoration beside the text badge, never instead of it */
.section-glyph {
  font-size: 0.625rem;
  margin-right: 0.25rem;
}

.section-glyph-private { color: var(--text-faint); }
.section-glyph-shared { color: var(--success-text); }
.section-glyph-later { color: var(--warning-text); }
.section-glyph-withdrawn { color: var(--danger-text); }

/* Publish review screen */
.review-meta-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.review-section {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-delicate);
}

.review-section .zone-card-title {
  margin-bottom: 0.75rem;
}

.review-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-delicate);
}

/* Plain-text prose block: keep the writer's line breaks without HTML */
.prose-plain {
  white-space: pre-line;
}

/* Wider card for the revision desk (65ch prose + two excerpt columns) */
.workspace-narrow--wide {
  max-width: 48rem;
}

/* Radio choices as one clickable row each */
.choice-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border-delicate);
  border-radius: 6px;
  margin-bottom: 0.625rem;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.choice-row:hover {
  border-color: var(--border-strong);
  background-color: var(--bg-subtle);
}

.choice-row:focus-within {
  outline: 2px solid var(--accent-oxblood);
  outline-offset: 2px;
}

.choice-row input[type="radio"] {
  margin-top: 0.3rem;
  min-width: 16px;
  min-height: 16px;
}

.choice-row label {
  display: block;
  cursor: pointer;
}

.choice-row-title {
  display: block;
  font-weight: 600;
  font-size: 0.9375rem;
}

.choice-row-help {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Fieldsets: gentle framed groups, tokens only */
.form-fieldset {
  border: 1px solid var(--border-delicate);
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.form-fieldset legend {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  padding: 0 0.5rem;
}

.form-fieldset-inner {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-delicate);
}

.form-fieldset .form-field {
  margin-bottom: 1rem;
}

/* Field-level errors (form failures re-render, never the error page) */
.form-input-error {
  border-color: var(--danger-border);
}

.form-field-error {
  color: var(--danger-text);
  font-size: 0.8125rem;
  margin: 0.375rem 0 0;
}

.form-required {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.form-help-inline {
  color: var(--text-muted);
  font-weight: 400;
}

.form-callout {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-delicate);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.form-callout p {
  margin: 0.25rem 0;
}

/* Live sharing-outcome summary on the artifact form */
.share-outcome {
  background-color: var(--bg-subtle);
  border-left: 3px solid var(--border-strong);
  border-radius: 0 6px 6px 0;
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-top: 1rem;
}

/* Before/after excerpts: a whisper of direction, tokens only */
.form-prose-before {
  border-color: var(--danger-border);
}

.form-prose-after {
  border-color: var(--success-border);
}

/* ==========================================================================
   Reader round — story-page studio events, touch targets, quiet reveal
   Everything below appends to the system above; tokens only, no new colors.
   ========================================================================== */

/* Story page — "Recently in the studio": quiet glyph events, never a
   dashboard. Rows render oldest-first in the DOM and display newest-first. */
.studio-recent {
  max-width: 42rem;
  margin: 0 auto 2.5rem;
}

.studio-recent-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 0.875rem 0;
  text-align: center;
}

.studio-event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.625rem;
}

.studio-event {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.625rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Canonical glyphs stay small and always sit beside their text. */
.studio-event-glyph {
  font-size: 0.625rem;
  color: var(--accent-forest);
}

.studio-event-copy em {
  font-family: var(--font-serif);
  color: var(--text-primary);
}

.studio-event-time {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-faint);
  white-space: nowrap;
}

/* Story tabs keep a 44px touch target at every width (a11y Q9); the active
   underline stays anchored to the bottom of the tab row. */
.story-tab {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.25rem 0.75rem;
}

/* Persona preview pills meet the same 44px floor as the header controls. */
.persona-pill {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* Locked shelf state: framed as discovery, amber waiting tone, canonical
   glyph — never a padlock emoji. */
.locked-ahead-label {
  margin: 0 0 0.375rem 0;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-amber);
}

.locked-ahead-label span {
  margin-right: 0.25rem;
}

.locked-ahead-copy {
  margin: 0;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--text-muted);
}

/* The unlock moment surfaces with a gentle rise; stillness for readers
   who prefer reduced motion. */
@keyframes quiet-reveal {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.quiet-unlock-alert {
  animation: quiet-reveal 0.6s ease-out both;
}

@media (prefers-reduced-motion: reduce) {
  .quiet-unlock-alert {
    animation: none;
  }
}

/* ==========================================================================
   Archive Drawer — grouped making-of sections (RESEARCH / FROM THE DRAFTS /
   DELETED). The masonry wrapper stays the grid root for the HTMX partial;
   each grouped section spans the full drawer width and carries its own
   card grid beneath a quiet shelf heading.
   ========================================================================== */

.archive-masonry .archive-section {
  grid-column: 1 / -1;
}

.archive-section {
  margin: 0 0 2.5rem 0;
}

.archive-section:last-child {
  margin-bottom: 0;
}

.archive-section-heading {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 1.25rem 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-delicate);
}

.archive-section-glyph {
  color: var(--accent-oxblood);
}

.archive-section-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .archive-section-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Locked pieces are shields: something exists here, never its title or
   content. Same dashed parchment surface as the locked-count card. */
.archive-card-locked .archive-locked-glyph {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  color: var(--accent-amber);
  margin: 0 0 0.5rem 0;
  line-height: 1;
}

.archive-card-locked .category-badge {
  display: block;
  margin-bottom: 0.625rem;
}

.archive-card-locked .archive-locked-title {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
}

.archive-card-locked .archive-locked-note {
  font-size: 0.75rem;
  color: var(--accent-amber);
  margin: 0;
}

/* An empty drawer is never a silent void: one calm sentence invites the
   reader onward. */
.archive-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--text-muted);
}

.archive-empty p {
  margin: 0;
}

/* Filter pills keep a comfortable touch target on phones and coarse
   pointers without gaining visual weight on the desktop page. */
@media (pointer: coarse), (max-width: 640px) {
  .filter-tab {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
  }
}

/* ==========================================================================
   Revisions — an editorial timeline of the story becoming itself: a dated
   vertical rail with glyph nodes and human captions, never an audit log.
   ========================================================================== */

.revision-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.revision-timeline::before {
  content: "";
  position: absolute;
  left: 0.5625rem;
  top: 0.75rem;
  bottom: 0.75rem;
  width: 1px;
  background-color: var(--border-delicate);
}

.revision-timeline-item {
  position: relative;
  padding: 0 0 2.25rem 2.25rem;
}

.revision-timeline-item:last-child {
  padding-bottom: 0.25rem;
}

.revision-timeline-glyph {
  position: absolute;
  left: 0;
  top: 0.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.125rem;
  height: 1.125rem;
  color: var(--accent-oxblood);
  background-color: var(--bg-paper);
  font-size: 0.75rem;
  line-height: 1;
}

.revision-timeline-entry {
  display: block;
  text-decoration: none;
}

.revision-timeline-date {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.revision-timeline-title {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.375rem 0;
}

.revision-timeline-entry:hover .revision-timeline-title {
  color: var(--accent-oxblood);
}

.revision-timeline-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
}

.revision-timeline-link {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent-oxblood);
}

/* ==========================================================================
   Notifications Inbox & Quiet Indicator (Workstream W4)
   ========================================================================== */

/* Shell Header Notifications Indicator */
.nav-link-notifications {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link-notifications .nav-unread-dot {
  display: inline-block;
  font-size: 0.5rem;
  line-height: 1;
  color: var(--accent-oxblood);
  vertical-align: middle;
  margin-left: 0.25rem;
}

.nav-link-notifications.has-unread {
  color: var(--text-primary);
}

/* Notifications Page Header */
.notifications-page {
  max-width: 44rem;
  margin: 0 auto;
}

.notifications-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-delicate);
  flex-wrap: wrap;
}

.notifications-title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  color: var(--text-primary);
  margin: 0 0 0.25rem 0;
  letter-spacing: -0.01em;
}

.notifications-subtitle {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin: 0;
}

.btn-mark-all-read {
  font-size: 0.8125rem;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border-delicate);
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.btn-mark-all-read:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background-color: var(--bg-subtle);
}

/* Notification Card */
.notification-card {
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-delicate);
  border-radius: 6px;
  transition: border-color 0.15s ease;
  position: relative;
}

.notification-card.notification-unread {
  border-left: 3px solid var(--accent-oxblood);
  background-color: var(--bg-surface);
}

.notification-card.notification-read {
  border-left: 3px solid transparent;
  opacity: 0.88;
}

.notification-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.625rem;
  font-size: 0.8125rem;
}

.notification-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.notification-story-link {
  font-weight: 500;
  color: var(--text-primary);
}

.notification-story-link:hover {
  text-decoration: underline;
}

.notification-type-badge {
  font-weight: 500;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.notification-glyph {
  font-size: 0.75rem;
  color: var(--accent-oxblood);
}

.notification-meta-sep {
  color: var(--text-faint);
}

.notification-status {
  font-size: 0.75rem;
  white-space: nowrap;
}

.notification-unread-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 600;
  color: var(--accent-oxblood);
}

.notification-read-indicator {
  color: var(--text-faint);
}

.notification-card-body {
  margin-bottom: 0.875rem;
}

.notification-card-title {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.375rem 0;
  line-height: 1.4;
}

.notification-card-title a {
  color: var(--text-primary);
  text-decoration: none;
}

.notification-card-title a:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent-oxblood);
}

.notification-body {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0;
}

.notification-card.notification-unread .notification-body {
  color: var(--text-primary);
}

.notification-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-delicate);
  font-size: 0.8125rem;
}

.notification-action-link {
  font-weight: 500;
  color: var(--accent-oxblood);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.notification-action-link:hover {
  text-decoration: underline;
}

.notification-mark-read-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8125rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.notification-mark-read-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-subtle);
  text-decoration: underline;
}

/* Empty State & Caught-up Banner */
.notifications-empty {
  text-align: center;
  padding: 4rem 1.5rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-delicate);
  border-radius: 8px;
}

.caught-up-banner {
  text-align: center;
  padding: 2.5rem 1.5rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border-delicate);
}

.caught-up-asterisk {
  color: var(--accent-oxblood);
  font-size: 1rem;
  letter-spacing: 0.4em;
  margin-bottom: 0.75rem;
}

.caught-up-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
}

.caught-up-copy {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

.notifications-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-delicate);
}

/* ==========================================================================
   Media Storage & Rendering (W6)
   ========================================================================== */

.artifact-media {
  margin: 1.5rem 0 2rem;
  text-align: center;
}

.artifact-image {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: var(--shadow-subtle, 0 1px 3px rgba(0, 0, 0, 0.08));
  display: inline-block;
  object-fit: contain;
}

.artifact-card-media {
  margin-bottom: 0.75rem;
  border-radius: 4px;
  overflow: hidden;
  background-color: var(--bg-subtle, #f8f8f8);
  max-height: 140px;
}

.artifact-card-image {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}

.artifact-card:hover .artifact-card-image {
  transform: scale(1.02);
}

.current-cover-preview img,
.current-media-preview img {
  border: 1px solid var(--border-delicate, #e5e5e5);
}
