/* ============================================================
   False Universe — Main Stylesheet
   ============================================================
   This file styles eight Markdown elements (p, h2, blockquote,
   hr, em, strong, drop-cap, a) plus the page chrome. Adding a
   new story should never require changes here.
   ============================================================ */

/* ============ TYPOGRAPHY VARIABLES ============ */
:root {
  --serif-display:  'Cormorant Garamond', Georgia, serif;
  --serif-body:     'Lora', Georgia, serif;
  --serif-garamond: 'EB Garamond', Georgia, serif;
  --serif-crimson:  'Crimson Pro', Georgia, serif;
  --sans-reading:   'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:           'JetBrains Mono', ui-monospace, Menlo, monospace;
}

/* ============ THEMES ============ */

/* Dark (default) */
:root,
[data-theme="dark"] {
  --bg: #0e0d0b;
  --bg-soft: #181612;
  --bg-elevated: #1c1a16;
  --bg-card: #1c1a16;
  --ink: #ede5d3;
  --ink-soft: #b8ad94;
  --ink-faint: #6b6452;
  --rule: #2a2620;
  --progress-fill: #ede5d3;
}

/* Sepia */
[data-theme="sepia"] {
  --bg: #f4ecd8;
  --bg-soft: #ebe1ca;
  --bg-elevated: #f0e7d2;
  --bg-card: #f0e7d2;
  --ink: #3a2f1f;
  --ink-soft: #6b5a40;
  --ink-faint: #9a8866;
  --rule: #d9cdb0;
  --progress-fill: #3a2f1f;
}

/* Light */
[data-theme="light"] {
  --bg: #faf8f3;
  --bg-soft: #f0ede4;
  --bg-elevated: #f4f1e8;
  --bg-card: #f4f1e8;
  --ink: #1c1a16;
  --ink-soft: #4a463d;
  --ink-faint: #8a8474;
  --rule: #e0dccf;
  --progress-fill: #1c1a16;
}

/* High Contrast */
[data-theme="contrast"] {
  --bg: #ffffff;
  --bg-soft: #f4f4f4;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --ink: #000000;
  --ink-soft: #333333;
  --ink-faint: #666666;
  --rule: #cccccc;
  --progress-fill: #000000;
}

/* Night */
[data-theme="night"] {
  --bg: #0a0d12;
  --bg-soft: #131820;
  --bg-elevated: #161c25;
  --bg-card: #161c25;
  --ink: #d8cfb8;
  --ink-soft: #9a907a;
  --ink-faint: #5a5447;
  --rule: #232932;
  --progress-fill: #d8cfb8;
}

/* ============ GENRE ACCENTS ============ */
:root {
  --accent-novella:    #c4504a;
  --accent-novel:      #6a8db5;
  --accent-radio:      #8a4f6e;
  --accent-short:      #a05a3e;
  --accent-playlist:   #7a8a6e;
  --accent-essay:      #b89556;
  --accent-screenplay: #d4a854;
}

/* ============ RESET ============ */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif-body);
  font-size: 17px;
  line-height: 1.55;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ============ TOP BAR (shared) ============ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 100;
  transition: transform 0.3s ease, background 0.3s ease;
}
.topbar.hidden { transform: translateY(-100%); }

.brand {
  font-family: var(--serif-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.brand em {
  font-style: italic;
  font-weight: 500;
  color: var(--ink-soft);
}

.icon-btn {
  background: none; border: none;
  color: var(--ink);
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s ease;
}
.icon-btn:active { background: var(--bg-soft); }
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; }

.topbar-center {
  flex: 1;
  text-align: center;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.topbar-buttons {
  display: flex;
  gap: 0;
  align-items: center;
}

/* Progress bar */
.progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: var(--progress-fill);
  z-index: 101;
  transition: width 0.1s ease-out;
  width: 0;
}

/* ============ DRAWER (home page menu) ============ */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 200;
}
.drawer-scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(85%, 360px);
  background: var(--bg-soft);
  border-left: 1px solid var(--rule);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 201;
  overflow-y: auto;
  padding: 56px 24px 32px;
}
.drawer.open { transform: translateX(0); }
.drawer-close { position: absolute; top: 8px; right: 8px; }
.drawer-section { margin-bottom: 32px; }
.drawer-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}
.drawer-title {
  font-family: var(--serif-display);
  font-size: 28px;
  font-weight: 600;
  line-height: 1.1;
  margin-bottom: 6px;
}
.drawer-tagline {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
  margin-bottom: 18px;
}
.drawer-bio {
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-soft);
  font-style: italic;
}

.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--ink-soft);
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 13px;
  border-radius: 2px;
}
.search-input::placeholder { color: var(--ink-faint); }
.search-input:focus { outline: none; border-color: var(--ink-soft); }

/* ============ HOME PAGE: DECK ============ */
/* On mobile (default), the deck spans the full viewport.
   On wider screens, we cap it at 600px centered, so the card
   reads like a book cover rather than a giant billboard. */
.deck {
  position: fixed;
  top: 56px; left: 0; right: 0; bottom: 0;
  overflow-x: scroll;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  display: flex;
}
.deck::-webkit-scrollbar { display: none; }
body.home { overflow: hidden; position: fixed; width: 100%; height: 100vh; height: 100dvh; }

.card-slot {
  flex: 0 0 100vw;
  width: 100vw;
  height: 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  padding: 20px 22px 90px;
  display: flex;
  flex-direction: column;
}

/* On desktop (above 700px wide), constrain the deck to a centered column.
   Each card-slot becomes 600px wide instead of 100vw, and the deck itself
   is centered using padding on its container. */
@media (min-width: 700px) {
  .deck {
    /* center the deck by padding the container so each 600px slot
       sits in the middle of the viewport */
    padding-left:  calc((100vw - 600px) / 2);
    padding-right: calc((100vw - 600px) / 2);
  }
  .card-slot {
    flex: 0 0 600px;
    width: 600px;
    padding: 32px 0 90px;
  }
}
.card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset, 0 30px 60px -20px rgba(0,0,0,0.5);
}
.card::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 4px;
  background: var(--card-accent, var(--ink-soft));
}

.card-cover {
  height: 38%;
  min-height: 220px;
  position: relative;
  overflow: hidden;
  background: var(--card-accent, var(--ink-soft));
  flex-shrink: 0;
}
.card-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(255,255,255,0.18), transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(0,0,0,0.45), transparent 70%);
  mix-blend-mode: overlay;
  pointer-events: none;
}
.card-cover .fade {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(to bottom, transparent, var(--bg-card));
  z-index: 5;
  pointer-events: none;
}
.cover-base {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.45;
  z-index: 1;
}
.cover-base svg { width: 90%; height: 90%; }
.cover-glyph {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -55%);
  z-index: 2;
  width: 88px; height: 88px;
  display: flex; align-items: center; justify-content: center;
}
.cover-glyph svg {
  width: 100%; height: 100%;
  stroke: #ede5d3;
  fill: none;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.92;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
}
.cover-custom {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cover-custom svg { width: 100%; height: 100%; }
.cover-tag {
  position: absolute;
  top: 14px; right: 14px;
  z-index: 6;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(237,229,211,0.85);
  background: rgba(14,13,11,0.4);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(237,229,211,0.15);
  padding: 5px 9px;
  border-radius: 2px;
}

.card-body {
  flex: 1;
  padding: 24px 26px 28px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.card-category {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--card-accent, var(--ink-soft));
  margin-bottom: 14px;
}
.card-title {
  font-family: var(--serif-display);
  font-size: 38px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.005em;
  margin-bottom: 8px;
}
.card-meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}
.card-meta .dot { display: inline-block; margin: 0 8px; opacity: 0.5; }
.card-description {
  font-family: var(--serif-body);
  font-size: 19px;
  font-style: italic;
  line-height: 1.45;
  color: var(--ink-soft);
  flex: 1;
}
.card-cta {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
}

/* indicator */
.indicator {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 8px 16px;
  z-index: 50;
}
.indicator.hidden { display: none; }
.home-copyright {
  position: fixed;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  white-space: nowrap;
  z-index: 40;
  pointer-events: auto;
}
.home-copyright a {
  color: var(--ink-faint);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.home-copyright a:hover { color: var(--ink-soft); }
.indicator-count {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  min-width: 48px;
  text-align: center;
}
.indicator-count .current { color: var(--ink); font-weight: 500; }
.nav-btn {
  background: none; border: none;
  color: var(--ink-soft);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border-radius: 999px;
}
.nav-btn:active { background: var(--bg-soft); color: var(--ink); }
.nav-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

/* list view (filter results) */
.list-view {
  position: fixed;
  top: 56px; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  overflow-y: auto;
  padding: 24px 22px 80px;
  display: none;
}
.list-view.active { display: block; }
.deck.hidden { display: none; }
.list-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}
.list-header-count {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.list-header-clear {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: none;
  border: none;
  cursor: pointer;
}
.list-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: inherit;
}
.list-item-cat {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--item-accent, var(--ink-faint));
  margin-bottom: 4px;
}
.list-item-title {
  font-family: var(--serif-display);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.15;
  color: var(--ink);
}
.list-item-date {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

/* ============ STORY PAGE ============ */
body.story-page { font-size: var(--reader-size, 18px); }

.story {
  max-width: 36rem;
  margin: 0 auto;
  padding: 90px 24px 100px;
}
.story[data-font="serif-display"]  { --reader-font: var(--serif-display); }
.story[data-font="serif-body"]     { --reader-font: var(--serif-body); }
.story[data-font="serif-garamond"] { --reader-font: var(--serif-garamond); }
.story[data-font="serif-crimson"]  { --reader-font: var(--serif-crimson); }
.story[data-font="sans-reading"]   { --reader-font: var(--sans-reading); }

.story-header { margin-bottom: 48px; text-align: center; }
.story-category {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--ink);
  padding: 6px 11px;
  border-radius: 2px;
  margin-bottom: 24px;
}
.story-title {
  font-family: var(--serif-display);
  font-size: clamp(36px, 9vw, 56px);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}
.story-subtitle {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 32px;
}
.story-meta {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.story-meta .dot { opacity: 0.5; }

.story-rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 48px auto;
  width: 60%;
}

.story-epigraph {
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 1.1em;
  color: var(--ink-soft);
  text-align: center;
  margin: 0 auto 56px;
  max-width: 28rem;
  line-height: 1.5;
}
.story-epigraph .attribution {
  display: block;
  font-style: normal;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  margin-top: 14px;
}

/* The eight allowed body elements */
.story-body {
  font-family: var(--reader-font, var(--serif-body));
  --story-accent: var(--card-accent, var(--ink-soft));
}
.story-body p {
  margin-bottom: 1.4em;
  text-align: left;
}
.story-body p:first-of-type::first-letter {
  font-family: var(--serif-display);
  font-size: 4em;
  font-weight: 600;
  float: left;
  line-height: 0.85;
  margin: 0.05em 0.1em 0 0;
  color: var(--story-accent);
}
.story-body h2 {
  font-family: var(--serif-display);
  font-size: 1.6em;
  font-weight: 600;
  margin: 2.4em 0 1em;
  text-align: center;
  letter-spacing: -0.005em;
}
.story-body blockquote {
  border-left: 3px solid var(--story-accent);
  margin: 1.8em 0;
  padding: 0.2em 0 0.2em 1.4em;
  font-style: italic;
  color: var(--ink-soft);
}
.story-body em { font-style: italic; }
.story-body strong { font-weight: 600; }
.story-body a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--story-accent);
}
.story-body hr {
  border: 0;
  text-align: center;
  margin: 2.4em 0;
  height: 1em;
}
.story-body hr::before {
  content: '◆ ◆ ◆';
  color: var(--ink-faint);
  font-size: 0.7em;
  letter-spacing: 1em;
}

/* Footer */
.story-footer {
  margin-top: 80px;
  padding-top: 32px;
  border-top: 1px solid var(--rule);
  text-align: center;
}
.end-mark {
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.4em;
  color: var(--ink-faint);
  margin-bottom: 32px;
}
.footer-meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-faint);
  line-height: 1.8;
}
.footer-meta a {
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.footer-meta a:hover { color: var(--ink); }

.story-prev-next {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 40px;
}
.story-prev-next a {
  display: block;
  padding: 16px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  text-decoration: none;
  color: inherit;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.story-prev-next a:hover { border-color: var(--ink-soft); }
.story-prev-next .pn-label { color: var(--ink-faint); display: block; margin-bottom: 6px; }
.story-prev-next .pn-title {
  font-family: var(--serif-display);
  font-size: 18px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

/* ============ READER CONTROLS ============ */
.controls-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 200;
}
.controls-scrim.open { opacity: 1; pointer-events: auto; }
.controls-panel {
  position: fixed;
  top: 56px;
  right: 8px;
  width: min(320px, calc(100% - 16px));
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 20px 60px -10px rgba(0,0,0,0.5);
  transform: translateY(-8px) scale(0.96);
  transform-origin: top right;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 201;
  overflow: hidden;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
.controls-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.control-section {
  padding: 18px;
  border-bottom: 1px solid var(--rule);
}
.control-section:last-child { border-bottom: none; }
.control-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 12px;
}

.size-control {
  display: flex;
  gap: 1px;
  background: var(--rule);
  border-radius: 4px;
  padding: 1px;
}
.size-btn {
  flex: 1;
  background: var(--bg);
  border: none;
  color: var(--ink-soft);
  font-family: var(--serif-display);
  cursor: pointer;
  padding: 12px 0;
  border-radius: 3px;
}
.size-btn:nth-child(1) { font-size: 12px; }
.size-btn:nth-child(2) { font-size: 14px; }
.size-btn:nth-child(3) { font-size: 16px; }
.size-btn:nth-child(4) { font-size: 19px; }
.size-btn:nth-child(5) { font-size: 23px; }
.size-btn.active { background: var(--ink); color: var(--bg); }

.theme-control {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.theme-btn {
  aspect-ratio: 1;
  border: 1px solid var(--rule);
  border-radius: 50%;
  cursor: pointer;
  position: relative;
}
.theme-btn.active { border-color: var(--ink); border-width: 2px; }
.theme-btn[data-theme="dark"]     { background: #0e0d0b; }
.theme-btn[data-theme="sepia"]    { background: #f4ecd8; }
.theme-btn[data-theme="light"]    { background: #faf8f3; }
.theme-btn[data-theme="contrast"] { background: #ffffff; border-color: #000; }
.theme-btn[data-theme="night"]    { background: #0a0d12; }
.theme-btn .checkmark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}
.theme-btn.active .checkmark { opacity: 1; }
.theme-btn[data-theme="dark"] .checkmark     { color: #ede5d3; }
.theme-btn[data-theme="sepia"] .checkmark    { color: #3a2f1f; }
.theme-btn[data-theme="light"] .checkmark    { color: #1c1a16; }
.theme-btn[data-theme="contrast"] .checkmark { color: #000000; }
.theme-btn[data-theme="night"] .checkmark    { color: #d8cfb8; }
.theme-btn .checkmark svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.5; }

.font-control { display: flex; flex-direction: column; gap: 6px; }
.font-btn {
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 12px 14px;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.font-btn .font-name { font-size: 17px; }
.font-btn .font-id {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--ink-faint);
}
.font-btn[data-font="serif-body"]     .font-name { font-family: 'Lora', serif; }
.font-btn[data-font="serif-garamond"] .font-name { font-family: 'EB Garamond', serif; }
.font-btn[data-font="serif-crimson"]  .font-name { font-family: 'Crimson Pro', serif; }
.font-btn[data-font="serif-display"]  .font-name { font-family: 'Cormorant Garamond', serif; }
.font-btn[data-font="sans-reading"]   .font-name { font-family: 'Inter', sans-serif; }
.font-btn.active { border-color: var(--ink); background: var(--bg-soft); }

/* download and feedback buttons in topbar */
.icon-btn#downloadBtn,
.icon-btn#feedbackTopBtn {
  /* Use standard icon-btn styles */
}
.feedback-scrim,
.download-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 300;
}
.feedback-scrim.open,
.download-scrim.open { opacity: 1; pointer-events: auto; }

/* Generic modal */
.feedback-modal,
.download-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: min(360px, calc(100% - 32px));
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: 0 20px 60px -10px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 301;
}
.feedback-modal.open,
.download-modal.open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

/* Modal header */
.modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 {
  font-family: var(--serif-body);
  font-size: 18px;
  font-weight: 500;
  margin: 0;
}
.close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-soft);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.close-btn:hover { color: var(--ink); }
.close-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Modal body */
.modal-body {
  padding: 20px;
}
.modal-body p {
  font-family: var(--serif-body);
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 16px;
  line-height: 1.6;
}

/* Download modal buttons */
.download-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.download-format-btn {
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 16px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  text-decoration: none;
}
.download-format-btn:hover { border-color: var(--ink-soft); background: var(--bg-soft); }
.download-format-btn svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.download-format-btn div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.format-name {
  font-family: var(--serif-body);
  font-size: 14px;
  font-weight: 500;
}
.format-ext {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--ink-faint);
}

/* Feedback modal buttons */
.feedback-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.feedback-method-btn {
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 16px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  font-family: var(--serif-body);
  font-size: 14px;
  font-weight: 500;
}
.feedback-method-btn:hover { border-color: var(--ink-soft); background: var(--bg-soft); }
.feedback-method-btn svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* old feedback button inside controls panel (for backwards compat if needed) */
.controls-feedback-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 12px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.controls-feedback-btn:hover { border-color: var(--ink-soft); }
.controls-feedback-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* download buttons inside controls panel */
.download-control {
  display: flex;
  gap: 8px;
}
.download-btn {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 12px 10px;
  border-radius: 4px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: border-color 0.15s ease;
}
.download-btn:hover { border-color: var(--ink-soft); }
.download-btn svg {
  width: 18px; height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  margin-bottom: 2px;
}
.download-btn .dl-label {
  font-family: var(--serif-body);
  font-size: 14px;
}
.download-btn .dl-ext {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--ink-faint);
}
.download-note {
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.5;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  margin-top: 10px;
  text-align: center;
}

/* ============ RESUME TOAST ============ */
.resume-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 12px 8px 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 12px 32px -8px rgba(0,0,0,0.5);
  z-index: 90;
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  max-width: calc(100% - 32px);
}
.resume-toast.show { transform: translateX(-50%) translateY(0); }
.resume-text {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.resume-text .resume-pct { color: var(--ink); font-weight: 500; }
.resume-btn {
  background: var(--ink);
  color: var(--bg);
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  font-weight: 500;
}
.resume-dismiss {
  background: none;
  border: none;
  color: var(--ink-faint);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.resume-dismiss svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ============ 404 ============ */
.not-found {
  min-height: calc(100vh - 56px);
  margin-top: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.not-found-inner { max-width: 28rem; }
.not-found h1 {
  font-family: var(--serif-display);
  font-size: clamp(48px, 12vw, 96px);
  font-weight: 600;
  line-height: 1;
  margin-bottom: 16px;
  color: var(--ink);
}
.not-found p {
  font-family: var(--serif-body);
  font-style: italic;
  color: var(--ink-soft);
  margin-bottom: 32px;
}
.not-found a {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--rule);
  padding: 12px 20px;
  border-radius: 2px;
  display: inline-block;
}
.not-found a:hover { border-color: var(--ink-soft); }

/* ============ SAFE AREA ============ */
@supports (padding: env(safe-area-inset-bottom)) {
  .indicator { bottom: calc(24px + env(safe-area-inset-bottom)); }
  .card-slot { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
}

/* ============ ACCESSIBILITY: REDUCE MOTION ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}

/* =========================================================================
   HIDE BUTTON & UNHIDE FEATURE
   ========================================================================= */

/* Topbar actions container */
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Hidden count badge in topbar */
.hidden-count-badge {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: inherit;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.hidden-count-badge:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
}

.hidden-count-badge:active {
    transform: scale(0.98);
}

/* Hide button on cards */
.card-hide-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 101;
    transition: background 0.2s ease;
    padding: 0;
    font-size: 16px;
    line-height: 1;
}

.card-hide-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.card-hide-btn:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.card-hide-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    .hidden-count-badge {
        background: rgba(255, 255, 255, 0.1);
        border-color: rgba(255, 255, 255, 0.2);
    }
    
    .hidden-count-badge:hover {
        background: rgba(255, 255, 255, 0.15);
        border-color: rgba(255, 255, 255, 0.3);
    }
    
    .card-hide-btn {
        background: rgba(255, 255, 255, 0.2);
    }
    
    .card-hide-btn:hover {
        background: rgba(255, 255, 255, 0.4);
    }
}

/* Hidden card slot */
.card-slot.hidden {
    display: none;
}

/* Hidden stories list in drawer */
.hidden-stories-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.hidden-story-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-tertiary, #f1f5f9);
    border-radius: 0.5rem;
    gap: 0.5rem;
}

.hidden-story-title {
    font-size: 0.9rem;
    font-weight: 500;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unhide-btn {
    background: var(--text-primary, #1e293b);
    color: var(--bg-primary, #ffffff);
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.unhide-btn:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.unhide-btn:active {
    transform: scale(0.95);
}

/* Dark mode adjustments for hidden stories */
@media (prefers-color-scheme: dark) {
    .hidden-story-item {
        background: var(--bg-tertiary, #334155);
    }
    
    .unhide-btn {
        background: var(--text-primary, #f1f5f9);
        color: var(--bg-primary, #0f172a);
    }
}





/* =========================================================================
   HIDE STORY BUTTON & TOAST — Story page
   ========================================================================= */

/* Hide story confirmation toast */
.hide-story-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(calc(100% + 40px));
    background: #1fc26f;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: transform 0.3s ease;
    font-size: 0.95rem;
}

.hide-story-toast.visible {
    transform: translateX(-50%) translateY(0);
}

.hide-story-text {
    flex: 1;
    font-weight: 500;
}

.hide-story-back {
    color: white;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.hide-story-back:hover {
    opacity: 0.9;
}

.hide-story-dismiss {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;
    flex-shrink: 0;
}

.hide-story-dismiss:hover {
    background: rgba(255, 255, 255, 0.3);
}

.hide-story-dismiss svg {
    width: 16px;
    height: 16px;
    display: block;
    stroke: white;
    stroke-width: 2;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    .hide-story-toast {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }
}



/* =========================================================================
   SPINE SHELF VIEW — book-spine list on home page
   ========================================================================= */

/* The shelf container — same position as .deck */
.spine-shelf {
  position: fixed;
  top: 56px; left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 0 80px;
  display: none;
  background: var(--bg);
}
.spine-shelf.active {
  display: block;
}

/* One spine row */
.spine-row {
  position: relative;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background 0.12s ease;
}
.spine-row::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 3px;
  background: var(--spine-accent, var(--ink-faint));
  transition: width 0.15s ease;
}
.spine-row:hover::before,
.spine-row.open::before {
  width: 5px;
}
.spine-row:hover { background: var(--bg-soft); }
.spine-row.open  { background: var(--bg-elevated); }

/* The main (always-visible) spine strip */
.spine-strip-row {
  display: flex;
  align-items: center;
}

/* The main (always-visible) spine strip */
.spine-strip {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px 0 20px;
  min-height: 52px;
  text-decoration: none;
  color: inherit;
  user-select: none;
}

.spine-cat {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--spine-accent, var(--ink-faint));
  flex-shrink: 0;
  width: 72px;   /* fixed column so titles align */
}

.spine-title {
  font-family: var(--serif-display);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.15;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spine-meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  flex-shrink: 0;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.spine-meta-year { color: var(--ink-faint); }
.spine-meta-length { font-size: 9px; opacity: 0.7; }

/* Chevron toggle button */
.spine-toggle {
  background: none;
  border: none;
  color: var(--ink-faint);
  width: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s ease;
}
.spine-toggle:hover { color: var(--ink); }
.spine-toggle svg {
  width: 14px; height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.spine-row.open .spine-toggle svg {
  transform: rotate(180deg);
}

/* Expandable drawer */
.spine-drawer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.spine-row.open .spine-drawer {
  max-height: 220px;
}

.spine-drawer-inner {
  padding: 0 20px 20px 20px;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.spine-description {
  font-family: var(--serif-body);
  font-size: 15px;
  font-style: italic;
  line-height: 1.5;
  color: var(--ink-soft);
  padding-top: 14px;
}

.spine-read-link {
  align-self: flex-start;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 2px;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.spine-read-link:hover {
  color: var(--spine-accent, var(--ink));
  border-color: var(--spine-accent, var(--ink));
}

/* Desktop: constrain width like the deck */
@media (min-width: 700px) {
  .spine-shelf {
    padding-left:  calc((100vw - 600px) / 2);
    padding-right: calc((100vw - 600px) / 2);
  }
}
