/* Reader stages 0–4. Native CSS, no kit runtime. Home's editorial language,
   shared task-oriented components, and a separate desktop/mobile shell.
   Chapter typography and Admin/Writer intentionally remain out of scope. */
body:not(.in-reader):not(.in-studio) {
  --reader-nav-width: 224px;
  --radius: 5px; --radius-sm: 4px;
  --reader-panel: var(--surface-solid);
  --reader-line: var(--border);
  --reader-pad: clamp(24px, 3vw, 48px);
  --reader-soft: #11272a;
  --reader-shadow: 0 12px 32px rgb(0 0 0 / .12);
}
html[data-theme="light"] body:not(.in-reader):not(.in-studio) {
  --bg: #f3f3ed; --bg-rgb: 243 243 237;
  --surface-solid: #fffef9; --surface-solid-2: #eaece5;
  --surface: #fffef9; --surface-2: #eaece5;
  --surface-inset: #f2f3ec; --surface-3: #dde3d9;
  --text: #1d302d; --text-dim: #42564e; --text-faint: #596b62;
  --border: rgb(29 48 45 / .16); --border-2: rgb(29 48 45 / .3);
  --accent: #765608; --accent-soft: rgb(118 86 8 / .09);
  --chrome: 247 248 241; --glass-bg: #f7f8f1; --modal-bg: #fffef9;
  --reader-soft: #e4ede5; --good: #176951;
  --reader-shadow: 0 12px 32px rgb(29 48 45 / .04);
  background: var(--bg);
}
html[data-theme="light"] body[data-bg-mode="story"][data-bg-blur="true"] .background-layer {
  filter: blur(28px) brightness(1.16) saturate(0.72);
  opacity: 0.2 !important;
}
body:not(.in-reader):not(.in-studio).reader-nav-collapsed { --reader-nav-width: 76px; }
body:not(.in-reader):not(.in-studio) #app { padding-left: var(--reader-nav-width); }
body:not(.in-reader):not(.in-studio) #main {
  padding: var(--reader-pad); border: 0;
  min-height: calc(100dvh - 72px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
}
html[data-theme="light"] body:not(.in-reader):not(.in-studio) #main {
  background: color-mix(in srgb, var(--bg) 90%, transparent);
}
body:not(.in-reader):not(.in-studio) .topbar {
  min-height: 72px; padding: 14px var(--reader-pad);
  border: 0; border-bottom: 1px solid var(--border);
  background: rgb(var(--chrome) / .98); backdrop-filter: none;
}
body:not(.in-reader):not(.in-studio) .topbar .brand .serif { letter-spacing: .06em; }
body:not(.in-reader):not(.in-studio) .access-chip.access-chip-banner,
.access-chip.access-chip-banner {
  height: auto;
  min-height: 0;
  max-width: min(440px, 46vw);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none;
  overflow: visible;
  cursor: pointer;
  transition: transform .18s var(--ease), filter .18s var(--ease);
}
body:not(.in-reader):not(.in-studio) .access-chip.access-chip-banner img,
.access-chip.access-chip-banner img {
  display: block;
  width: auto;
  height: clamp(28px, 3.8vw, 42px);
  max-width: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 2px 8px rgb(0 0 0 / .45));
}
body:not(.in-reader):not(.in-studio) .access-chip.access-chip-banner:hover,
.access-chip.access-chip-banner:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}
body:not(.in-reader):not(.in-studio) .sidenav {
  width: var(--reader-nav-width); padding: 22px 16px 16px; gap: 26px;
  align-items: stretch; background: rgb(var(--chrome)); border-right: 1px solid var(--border);
  box-shadow: none; backdrop-filter: none; overflow-y: auto;
}
body:not(.in-reader):not(.in-studio) .sidenav a {
  display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px; padding: 12px;
  min-height: 46px; border-radius: 4px; color: var(--text-dim);
  font: 500 13px/1.3 var(--ui); white-space: nowrap;
}
body:not(.in-reader):not(.in-studio) .sidenav a span { display: inline; }
body:not(.in-reader):not(.in-studio) .sidenav a svg { flex: 0 0 19px; }
body:not(.in-reader):not(.in-studio) .sidenav a.active {
  background: var(--reader-soft); border-color: transparent; color: var(--text);
}
body:not(.in-reader):not(.in-studio) .sidenav a.active::before {
  background: var(--good); width: 2px; left: -8px; border-radius: 0;
}
body:not(.in-reader):not(.in-studio) .sidenav a.rail-brand {
  width: 100%; height: auto; padding: 0; margin: 0; min-height: 40px;
  border: 0; background: none; color: var(--accent); gap: 10px;
}
.rail-brand b { display: grid; place-items: center; width: 38px; height: 40px; flex: 0 0 38px; border: 1px solid var(--accent); font: 500 23px var(--serif); }
body:not(.in-reader):not(.in-studio) .sidenav .rail-brand span { font: 600 12px var(--serif); letter-spacing: .025em; }
.reader-nav-links { display: grid; gap: 5px; }
.reader-nav-divider { height: 1px; background: var(--border); margin: 15px 10px; }
.reader-nav-toggle { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 12px; margin-top: auto; color: var(--text-faint); text-align: left; font: 500 12px var(--ui); border: 1px solid var(--border); border-radius: 4px; }
.reader-nav-toggle svg { width: 18px; height: 18px; flex: 0 0 18px; }
body:not(.in-reader):not(.in-studio).reader-nav-collapsed .sidenav { padding-inline: 10px; }
body:not(.in-reader):not(.in-studio).reader-nav-collapsed .sidenav a { justify-content: center; padding-inline: 0; }
body:not(.in-reader):not(.in-studio).reader-nav-collapsed .sidenav :is(a span,.reader-nav-toggle span) { display: none; }
body:not(.in-reader):not(.in-studio).reader-nav-collapsed .reader-nav-toggle { justify-content: center; padding-inline: 0; }
.reader-skip-link { position: fixed; top: -100px; left: 16px; padding: 12px 18px; z-index: 200; background: var(--surface-solid); color: var(--text); border: 2px solid var(--accent); }
.reader-skip-link:focus { top: 12px; }
body:not(.in-reader):not(.in-studio) :is(.card,.glass,.story-card,.provider-card,.chapter-card,.chapter-row) { border-radius: 5px; box-shadow: none; backdrop-filter: none; }
body:not(.in-reader):not(.in-studio) :is(.btn,.btn.sm,.tb-btn) { border-radius: 4px; box-shadow: none; }
body:not(.in-reader):not(.in-studio) .btn { font-size: 12px; font-weight: 600; }
body:not(.in-reader):not(.in-studio) .btn.story { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
body:not(.in-reader):not(.in-studio) .btn.ghost:hover { border-color: var(--text-dim); background: var(--surface-2); }
body:not(.in-reader):not(.in-studio) :is(input:not([type="range"]):not([type="checkbox"]):not([type="color"]),select,textarea) { border-radius: 4px; }
body:not(.in-reader):not(.in-studio) .page-title { font-size: clamp(30px, 3.3vw, 48px); line-height: 1.14; letter-spacing: -.035em; margin: 0 0 12px; }
body:not(.in-reader):not(.in-studio) .page-sub { font-size: 14px; line-height: 1.7; max-width: 60ch; margin: 0 0 24px; }
/* Contain every raw empty-state SVG, including legacy routes. Font-size alone
   cannot constrain a viewBox-only SVG and previously produced 1262px icons. */
body:not(.in-reader):not(.in-studio) .reader-workspace svg:not(.cover-art) { width: 18px; height: 18px; flex-shrink: 0; }
body:not(.in-reader):not(.in-studio) .empty { padding: 54px 24px; max-width: 760px; margin: 24px auto; text-align: center; }
body:not(.in-reader):not(.in-studio) .empty .em { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 20px; color: var(--accent); opacity: 1; }
body:not(.in-reader):not(.in-studio) .empty .em svg { width: 36px; height: 36px; max-width: 36px; }
body:not(.in-reader):not(.in-studio) .empty p { max-width: 48ch; margin: 10px auto 20px; color: var(--text-dim); font-size: 14px; line-height: 1.7; }
body:not(.in-reader):not(.in-studio) :is(.section-link,.quicklinks a) > svg { width: 22px; height: 22px; flex-shrink: 0; }
body:not(.in-reader):not(.in-studio) .sheet { border-radius: 8px; box-shadow: var(--shadow); padding: 32px; }
body:not(.in-reader):not(.in-studio) .sheet .grip { display: none; }
body:not(.in-reader):not(.in-studio) .sheet-kicker { display: none; }
.sheet:not(.open) { visibility: hidden; }
.sheet.open { visibility: visible; }
body.has-sheet { overflow: hidden; }
.reader-more-links { display: grid; gap: 6px; margin-top: 24px; }
.reader-more-links a { display: flex; align-items: center; gap: 12px; padding: 12px; min-height: 46px; border-radius: 4px; color: var(--text); }
.reader-more-links a:hover { background: var(--surface-2); }
.reader-more-links svg { width: 20px; height: 20px; }
.reader-workspace { max-width: 1360px; margin: 0 auto; }
.reader-page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--reader-line); }
body:not(.in-reader):not(.in-studio) .reader-page-heading .page-sub { margin-bottom: 0; }
.reader-page-actions { flex-shrink: 0; padding-bottom: 3px; }
.reader-panel { padding: clamp(22px, 2.4vw, 32px); border: 1px solid var(--reader-line); border-radius: 5px; background: var(--reader-panel); min-width: 0; }
.reader-workspace h2 { font: 500 clamp(20px, 1.7vw, 25px)/1.3 var(--serif); letter-spacing: -.025em; margin: 0 0 14px; }
.reader-workspace h3 { font: 600 14px/1.5 var(--ui); margin: 0; }
.reader-workspace p { font-size: 14px; line-height: 1.8; }
.reader-note { color: var(--text-dim); font-size: 13px; line-height: 1.75; }
.reader-text-link { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-size: 13px; font-weight: 600; min-height: 44px; }
.reader-text-link svg { width: 16px; height: 16px; }
.reader-section-icon { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--border-2); color: var(--accent); flex: 0 0 44px; }
.reader-section-icon svg { width: 22px; height: 22px; }
.reader-status { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--border-2); border-radius: 3px; color: var(--text-dim); font-size: 11px; font-weight: 600; }
.reader-status svg { width: 16px; height: 16px; }
.reader-status[data-state="active"],.reader-status[data-state="admin"] { color: var(--good); border-color: color-mix(in srgb,var(--good) 30%,transparent); background: color-mix(in srgb,var(--good) 7%,transparent); }
.reader-status[data-state="expired"] { color: var(--bad); }

/* Shared subnav & segmented controls (Stages 2–4) */
.reader-subnav { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 24px; padding-bottom: 14px; border-bottom: 1px solid var(--reader-line); }
.reader-back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); font: 600 12px/1.3 var(--ui); min-height: 36px; }
.reader-back-link:hover { color: var(--text); }
.reader-back-link svg { width: 16px; height: 16px; }
.reader-subnav-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.reader-subnav-tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 13px; border: 1px solid transparent; border-radius: 4px; color: var(--text-dim); font: 600 12px/1.2 var(--ui); transition: background .15s, color .15s, border-color .15s; }
.reader-subnav-tabs a:hover { color: var(--text); background: var(--surface-2); }
.reader-subnav-tabs a.active { color: var(--text); background: var(--reader-soft); border-color: var(--border-2); }
.reader-subnav-tabs a small { color: var(--text-faint); font-size: 11px; padding: 2px 6px; border-radius: 99px; background: var(--surface-inset); }
.reader-toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.reader-segmented { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-inset); gap: 4px; }

/* Stage 2: Library & Story Hub */
.library-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.library-search { position: relative; flex: 1 1 320px; max-width: 460px; display: flex; align-items: center; }
.library-search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-faint); pointer-events: none; display: grid; place-items: center; }
.library-search-icon svg { width: 16px; height: 16px; }
.library-search input.pill-input { width: 100%; padding-left: 40px; }
.library-section { margin-bottom: 28px; }
.library-showcase-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 20px; }
.library-story-card { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 22px; align-items: start; }
.library-story-cover, .story-workspace .story-cover-card { position: relative; display: block; width: 100%; aspect-ratio: 2/3; border-radius: 3px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.library-story-cover :is(img, svg), .story-workspace .story-cover-card :is(img, svg) { position: static; inset: auto; width: 100%; height: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; }
.library-story-body { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.library-story-body h2, .library-story-body h3 { margin: 0; font: 500 clamp(20px, 1.8vw, 24px)/1.25 var(--serif); }
.library-story-body :is(h2, h3) a { color: var(--text); }
.library-story-body :is(h2, h3) a:hover { color: var(--accent); }
.library-story-author { font-size: 13px; color: var(--text-dim); }
.library-story-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.library-story-stats { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; color: var(--text-faint); font-size: 12px; margin-top: 2px; }
.library-story-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.library-pinned-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 240px)); gap: 18px; }

.story-workspace .story-hub { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 28px; align-items: start; }
.story-workspace .story-sidebar { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 16px; }
.story-workspace .story-sidebar .story-cover-card { max-width: 220px; margin: 0 auto; }
.story-workspace .story-sidebar .story-title, .story-workspace .story-sidebar .story-sidebar-title { font: 500 clamp(22px, 2vw, 28px)/1.2 var(--serif); margin: 4px 0 0; }
.story-workspace .story-sidebar .story-sub { margin: 0; color: var(--text-dim); font-size: 13px; }
.story-workspace .story-progress-block, .story-workspace .story-sidebar-progress { width: 100%; padding: 14px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-inset); }
.story-progress-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); margin-top: 8px; }
.story-workspace .story-main { min-width: 0; display: flex; flex-direction: column; gap: 28px; }
.story-main-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.story-main-heading h2 { margin: 0; }
.story-cta-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--reader-line); }
.story-section { display: flex; flex-direction: column; gap: 14px; }

/* Stage 3: Shelf, Saved items, Benefits, Notifications */
.shelf-layout, .help-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 24px; align-items: start; }
.shelf-main, .shelf-aside, .help-main, .help-aside { min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.shelf-threads-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.shelf-thread-card { display: flex; flex-direction: column; gap: 8px; width: 100%; padding: 18px 20px; border: 1px solid var(--reader-line); border-left: 3px solid var(--s, var(--accent)); border-radius: 4px; background: var(--surface-inset); text-align: left; color: var(--text); cursor: pointer; transition: border-color .15s, background .15s; }
.shelf-thread-card:hover { border-color: var(--border-2); background: var(--surface-2); }
.shelf-thread-card .bar { width: 100%; margin: 4px 0 2px; }
.shelf-thread-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.shelf-shortcut-list { display: flex; flex-direction: column; margin-top: 8px; }
.shelf-shortcut-list a { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--reader-line); color: var(--text); font-size: 13px; font-weight: 500; }
.shelf-shortcut-list a:last-child { border-bottom: 0; padding-bottom: 0; }
.shelf-shortcut-list a:hover { color: var(--accent); }
.shelf-shortcut-list a > div { flex: 1; min-width: 0; }
.shelf-shortcut-list a > div p { margin: 2px 0 0; }
.shelf-shortcut-list a > svg { width: 18px; height: 18px; flex: 0 0 18px; color: var(--text-faint); }
.shelf-shortcut-label { display: inline-flex; align-items: center; gap: 10px; }
.shelf-shortcut-label svg { width: 18px; height: 18px; color: var(--accent); flex-shrink: 0; }
.shelf-shortcut-list small { color: var(--text-faint); font-size: 12px; }

.reader-list-grid { display: grid; gap: 14px; }
.reader-saved-card { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.reader-saved-main { min-width: 0; flex: 1; cursor: pointer; }
.reader-saved-main h2 { font-size: 19px; margin: 4px 0 6px; }
.reader-saved-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.reader-quote-card { display: flex; flex-direction: column; gap: 14px; }
.reader-quote-body { display: flex; gap: 16px; align-items: flex-start; margin: 0; color: var(--text); }
.reader-quote-body blockquote { margin: 0 0 6px; padding-left: 14px; border-left: 2px solid var(--accent); font: italic 17px/1.65 var(--serif); color: var(--text); }
.reader-quote-body p { margin: 0; }
.reader-quote-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.notification-card { display: flex; align-items: flex-start; gap: 16px; }
.notification-copy { flex: 1; min-width: 0; }
.notification-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; color: var(--text); }
.notification-body { font-size: 13px; color: var(--text-dim); line-height: 1.6; }
.notification-time { font-size: 11px; color: var(--text-faint); margin-top: 6px; }
.notification-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.reader-benefits-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 24px; }
.benefit-card { display: flex; flex-direction: column; gap: 16px; }
.benefit-card p { margin: 0; }
.benefits-cta { display: flex; justify-content: space-between; align-items: center; gap: 24px; }

/* Stage 4: Help Center & Support */
.reader-faq-list { display: flex; flex-direction: column; }
.reader-faq-item { border-bottom: 1px solid var(--reader-line); padding: 14px 0; }
.reader-faq-item:first-child { padding-top: 0; }
.reader-faq-item:last-child { border-bottom: 0; padding-bottom: 0; }
.reader-faq-item summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; cursor: pointer; font: 600 14px/1.4 var(--ui); color: var(--text); }
.reader-faq-item summary::-webkit-details-marker { display: none; }
.reader-faq-item summary svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--text-faint); transition: transform .18s; }
.reader-faq-item[open] summary svg { transform: rotate(90deg); color: var(--accent); }
.reader-faq-item p { margin: 10px 0 0; }
.reader-feature-item { display: flex; flex-direction: column; gap: 6px; }
.reader-feature-item h3 { display: inline-flex; align-items: center; gap: 8px; }
.reader-feature-item h3 svg { width: 17px; height: 17px; color: var(--accent); }
.reader-glossary-list { display: flex; flex-direction: column; gap: 14px; }
.reader-glossary-row { display: flex; align-items: flex-start; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--reader-line); }
.reader-glossary-row:last-child { border-bottom: 0; padding-bottom: 0; }
.reader-glossary-row .ax { flex: 0 0 32px; height: 32px; display: grid; place-items: center; }
.reader-glossary-row .ax svg { width: 18px; height: 18px; }
.reader-glossary-row p { margin: 3px 0 0; }

/* Stage 1: Vault & Settings */
.vault-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 24px; align-items: start; }
.vault-membership { min-width: 0; display: grid; grid-template-columns: minmax(0,1fr) 135px; gap: 28px; align-items: center; padding: 32px; border: 1px solid var(--border-2); border-radius: 5px; background: linear-gradient(130deg,var(--reader-soft),var(--surface-solid) 80%); box-shadow: var(--reader-shadow); }
.vault-membership-body { min-width: 0; }
.vault-membership h2 { font-size: clamp(26px,2.6vw,38px); margin: 26px 0 18px; }
.vault-membership p { color: var(--text-dim); margin-bottom: 24px; }
.vault-cover { margin: 0; align-self: center; }
.vault-cover img { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 2px; box-shadow: 8px 10px 0 color-mix(in srgb,var(--accent) 12%,transparent); }
.vault-cover figcaption { margin-top: 16px; color: var(--text-faint); font: 500 10px/1.6 var(--ui); }
.vault-counts { grid-column: 1/-1; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); margin: 0; padding-top: 24px; border-top: 1px solid var(--border-2); gap: 24px; }
.vault-counts div { display: flex; flex-direction: column-reverse; gap: 8px; }
.vault-counts dt { font-size: 12px; color: var(--text-dim); }
.vault-counts dd { font: 500 36px/1 var(--serif); margin: 0; color: var(--accent); }
.vault-connections { grid-column: 2; grid-row: 1 / span 2; }
.provider-list { margin: 24px 0 12px; }
.reader-provider { padding: 24px 0; border-top: 1px solid var(--reader-line); }
.reader-provider-heading { display: flex; align-items: center; gap: 12px; }
.provider-monogram { width: 36px; height: 36px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; font: 600 18px var(--serif); }
.provider-state { color: var(--text-faint); font-size: 11px; }
.reader-provider p { font-size: 12px; line-height: 1.7; margin: 14px 0; overflow-wrap: anywhere; }
.reader-provider .provider-verification { color: var(--text-faint); font-size: 11px; }
.vault-key { display: flex; gap: 20px; grid-column: 1; }
.vault-key p { margin-bottom: 18px; }
.vault-help { grid-column: 2; padding: 8px 0; }
.vault-help a { display: flex; justify-content: space-between; align-items: center; min-height: 44px; font-size: 13px; color: var(--text-dim); border-bottom: 1px solid var(--border); gap: 10px; }
.vault-help a svg { width: 16px; height: 16px; }
.vault-records { grid-column: 1; grid-row: 3; }
.vault-records ul { list-style: none; padding: 0; margin: 16px 0 0; }
.vault-records li { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; font-size: 13px; }
.vault-records small { display: block; color: var(--text-faint); margin-top: 5px; }
.reader-settings-layout,.reader-support-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 24px; align-items: start; }
.reader-theme-options { display: grid; grid-template-columns: repeat(auto-fit,minmax(130px,1fr)); gap: 14px; margin: 28px 0; }
.reader-theme-option { padding: 8px; border: 1px solid var(--border-2); border-radius: 5px; text-align: left; color: var(--text); }
.reader-theme-option.selected { outline: 2px solid var(--good); outline-offset: 2px; }
.reader-theme-option.is-locked { opacity: .57; cursor: not-allowed; }
.reader-theme-option.is-locked .theme-preview { filter: grayscale(.55); }
.reader-theme-option small { color: var(--text-dim); font-size: 10px; font-weight: 500; }
.reader-theme-option > span:last-child { display: flex; justify-content: space-between; align-items: center; padding: 12px 3px 4px; font: 600 12px var(--ui); }
.reader-theme-option svg { width: 15px; height: 15px; }
.theme-preview { display: grid; grid-template-columns: 24% 1fr; grid-template-rows: 20px 60px; padding: 10px; gap: 7px; border: 1px solid rgb(128 128 128 / .2); border-radius: 2px; }
.theme-preview i { background: rgb(128 155 147 / .16); }
.theme-preview i:first-child { grid-row: 1/3; }
.theme-preview-dark { background: #0c161b; }
.theme-preview-light { background: #fffef9; }
.theme-preview-evil { background: #000; border-color: rgb(229 25 43 / .55); position: relative; overflow: hidden; }
.theme-preview-evil i { background: rgb(229 25 43 / .22); border: 1px solid rgb(229 25 43 / .35); }
.theme-preview-evil::after { content: ""; position: absolute; right: 4px; bottom: 4px; width: 28px; height: 34px; background: url("../assets/evil-theme/crest-emblem.png") center/contain no-repeat; pointer-events: none; }
.settings-reading-note { display: flex; gap: 20px; grid-column: 1/-1; padding: 24px 0; border-top: 1px solid var(--border); }
.settings-reading-note p { max-width: 70ch; color: var(--text-dim); }
.notification-preferences-form .toggle-row { align-items: flex-start; padding: 20px 0; }
.notification-preferences-form .switch { flex: 0 0 42px; }
.notification-preferences-form .settings-actions { border: 0; background: none; padding: 12px 0 0; }
.reader-support-packet { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.9 var(--ui); color: var(--text-dim); background: var(--surface-2); border-left: 2px solid var(--accent); padding: 20px; margin: 24px 0; }
.reader-check-row { padding: 16px 0; border-top: 1px solid var(--border); }
.reader-check-row p { margin: 6px 0; }

/* =====================================================================
   Site-Wide Resident Evil Theme (html[data-theme="evil"])
   Pure black & crimson palette + custom transparent PNG UI ornaments
   ===================================================================== */
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) {
  color-scheme: dark;
  --bg: #000000; --bg-rgb: 0 0 0;
  --chrome: 0 0 0;
  --surface-rgb: 5 1 2;
  --surface: rgb(6 1 2 / .92);
  --surface-solid: #050102; --surface-solid-2: #0a0204;
  --surface-2: #140306; --surface-3: #22050a;
  --surface-inset: #030001;
  --modal-bg: #000000; --glass-bg: rgb(4 1 2 / .95);
  --reader-panel: #040102; --reader-soft: #1a0307;
  --text: #f3efea; --text-dim: #bfb5b7; --text-faint: #8c7b7e;
  --accent: #e5192b; --accent-2: #ff4757; --accent-channels: 229 25 43;
  --accent-rgb: 229, 25, 43; --accent-soft: rgb(229 25 43 / .15);
  --on-accent: #ffffff;
  --good: #e5192b; --info: #ff5465; --key: #c91829; --bad: #ff3b4e;
  --border: rgb(229 25 43 / .26); --border-2: rgb(229 25 43 / .42);
  --reader-line: rgb(229 25 43 / .24);
  --reader-shadow: 0 18px 48px rgb(0 0 0 / .88);
  background: #000000;
}
html[data-theme="evil"] body[data-bg-mode="story"] .background-layer {
  filter: blur(26px) saturate(1.15) brightness(0.24) contrast(1.2);
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) #main {
  background: rgb(0 0 0 / .9);
}
/* Topbar & Navigation Rail with Gothic Crest Emblem & Divider Ornaments */
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) .topbar {
  background: #000000;
  border-bottom: 1px solid rgb(229 25 43 / .34);
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) .topbar .brand .mark {
  display: none;
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) .topbar .brand::before {
  content: "";
  width: 28px; height: 34px; flex: 0 0 28px;
  background: url("../assets/evil-theme/crest-emblem.png") center/contain no-repeat;
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) .sidenav {
  background: #000000;
  border-right: 1px solid rgb(229 25 43 / .3);
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) .sidenav a.rail-brand b {
  border: 0;
  background: url("../assets/evil-theme/crest-emblem.png") center/contain no-repeat;
  color: transparent;
  width: 40px; height: 46px; flex: 0 0 40px;
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) .reader-nav-divider {
  height: 18px;
  margin: 12px 4px;
  background: url("../assets/evil-theme/divider-ornament.png") center/contain no-repeat;
}
/* Ornate Gothic Corner Brackets on Hero, Panels, Vault & Modal Sheets */
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) :is(.rh-hero,.rh-panel,.reader-panel,.vault-membership) {
  position: relative;
  background-color: #030001;
  border-color: rgb(229 25 43 / .36);
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) .sheet {
  background-color: #030001;
  border-color: rgb(229 25 43 / .36);
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) :is(.rh-hero,.rh-panel,.reader-panel,.vault-membership,.sheet)::before,
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) :is(.rh-hero,.rh-panel,.reader-panel,.vault-membership,.sheet)::after,
body:not(.in-reader):not(.in-studio) .sheet.profile-evil-sheet::before,
body:not(.in-reader):not(.in-studio) .sheet.profile-evil-sheet::after {
  content: "";
  position: absolute;
  width: 68px; height: 68px;
  background: url("../assets/evil-theme/corner-ornament.png") left top/contain no-repeat;
  pointer-events: none;
  z-index: 2;
  opacity: .92;
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) :is(.rh-hero,.rh-panel,.reader-panel,.vault-membership,.sheet)::before,
body:not(.in-reader):not(.in-studio) .sheet.profile-evil-sheet::before {
  top: -2px;
  left: -2px;
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) :is(.rh-hero,.rh-panel,.reader-panel,.vault-membership,.sheet)::after,
body:not(.in-reader):not(.in-studio) .sheet.profile-evil-sheet::after {
  bottom: -2px;
  right: -2px;
  transform: scale(-1, -1);
}
/* Ornate Gothic Buttons using 9-slice transparent PNG button-frame */
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) :is(.btn.story,.btn.primary) {
  position: relative;
  border-style: solid;
  border-width: 0 24px;
  border-image: url("../assets/evil-theme/button-frame.png") 0 150 fill / 0 24px / 3px 4px stretch;
  background: none !important;
  color: #fff !important;
  padding-inline: 14px;
  text-shadow: 0 1px 4px #000;
  box-shadow: none !important;
  transition: transform .15s, filter .15s;
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) :is(.btn.story,.btn.primary):hover {
  transform: translateY(-1px);
  filter: brightness(1.14) drop-shadow(0 0 10px rgb(229 25 43 / .45));
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) :is(.btn.ghost,.btn.secondary,.tb-btn) {
  background: #080103;
  border-color: rgb(229 25 43 / .32);
  color: var(--text);
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) :is(.btn.ghost,.btn.secondary,.tb-btn):hover {
  background: #180307;
  border-color: #e5192b;
  color: #fff;
}
/* Loading / Progress Bars & Section Dividers with Gothic Filigree */
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) .bar {
  position: relative;
  height: 9px;
  border-radius: 2px;
  border: 1px solid rgb(229 25 43 / .45);
  background: #080103;
  overflow: visible;
  margin-bottom: 14px;
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) .bar > i {
  border-radius: 1px;
  background: repeating-linear-gradient(120deg, #8a0a17 0 8px, #e5192b 8px 16px), linear-gradient(90deg, #6e0711, #ff2a3d);
  box-shadow: 0 0 10px rgb(229 25 43 / .6);
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) .bar::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -13px;
  transform: translateX(-50%);
  width: min(180px, 75%);
  height: 18px;
  background: url("../assets/evil-theme/divider-ornament.png") center/contain no-repeat;
  pointer-events: none;
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) :is(.reader-page-heading,.rh-panel-head) {
  position: relative;
  border-bottom-color: rgb(229 25 43 / .34);
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) :is(.reader-page-heading,.rh-panel-head)::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -12px;
  transform: translateX(-50%);
  width: 150px; height: 22px;
  background: url("../assets/evil-theme/divider-ornament.png") center/contain no-repeat;
  pointer-events: none;
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) .empty .em {
  width: 68px; height: 78px;
  background: url("../assets/evil-theme/crest-emblem.png") center/contain no-repeat;
}
html[data-theme="evil"] body:not(.in-reader):not(.in-studio) .empty .em svg {
  display: none;
}

@media (max-width: 1180px) and (min-width: 921px) {
  body:not(.in-reader):not(.in-studio) { --reader-pad: 24px; }
  .vault-layout, .shelf-layout, .help-layout { grid-template-columns: minmax(0,1fr) 290px; gap: 18px; }
  .story-workspace .story-hub { grid-template-columns: 240px minmax(0,1fr); gap: 20px; }
  .vault-membership { grid-template-columns: 1fr; padding: 26px; }
  .vault-cover { display: none; }
  .reader-page-heading { align-items: flex-start; }
  .reader-page-actions .btn { padding-inline: 12px; }
}
@media (max-width: 920px) {
  body:not(.in-reader):not(.in-studio) #app { padding-left: 0; }
  body:not(.in-reader):not(.in-studio) #main { padding: 28px 20px calc(100px + env(safe-area-inset-bottom)); }
  body:not(.in-reader):not(.in-studio) .sidenav { display: none; }
  body:not(.in-reader):not(.in-studio) .topbar { min-height: 62px; padding: 10px 16px; }
  body:not(.in-reader):not(.in-studio) .bottomnav { grid-template-columns: repeat(5,minmax(0,1fr)); padding-bottom: env(safe-area-inset-bottom); }
  body:not(.in-reader):not(.in-studio) .bottomnav :is(a,button) { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60px; gap: 5px; color: var(--text-faint); font: 600 10px var(--ui); border: 0; background: none; padding: 8px 2px; }
  body:not(.in-reader):not(.in-studio) .bottomnav :is(a,button).active { color: var(--accent); }
  body:not(.in-reader):not(.in-studio) .bottomnav svg { width: 20px; height: 20px; }
  .vault-layout, .shelf-layout, .help-layout { grid-template-columns: minmax(0,1fr) minmax(260px,.85fr); gap: 18px; }
  .story-workspace .story-hub { grid-template-columns: 1fr; }
  .story-workspace .story-sidebar { position: static; }
  /* The redesigned sidebar owns these controls on mobile too; override the
     legacy rules that expected duplicate controls in the main column. */
  .story-workspace .story-sidebar-meta,
  .story-workspace .story-sidebar-progress { display: block; }
  .story-workspace .story-sidebar-actions { display: flex; }
  .vault-membership { grid-template-columns: 1fr; padding: 26px; }
  .vault-cover { display: none; }
}
@media (max-width: 680px) {
  body:not(.in-reader):not(.in-studio) #main { padding: 24px 16px calc(90px + env(safe-area-inset-bottom)); }
  body:not(.in-reader):not(.in-studio) .page-title { font-size: 32px; }
  body:not(.in-reader):not(.in-studio) .topbar > [data-nav="/settings"] { display: none; }
  .reader-page-heading { display: block; padding-bottom: 20px; margin-bottom: 22px; }
  .reader-page-actions { margin-top: 18px; }
  .vault-layout,.reader-settings-layout,.reader-support-grid,.shelf-layout,.help-layout { display: flex; flex-direction: column; gap: 18px; }
  .vault-layout > *, .reader-settings-layout > *, .reader-support-grid > *, .shelf-layout > *, .help-layout > * { width: 100%; }
  .library-showcase-grid { grid-template-columns: 1fr; }
  .library-story-card { grid-template-columns: 92px minmax(0, 1fr); gap: 14px; }
  .reader-saved-card, .benefits-cta { flex-direction: column; align-items: flex-start; }
  .vault-membership { padding: 24px; }
  .vault-membership h2 { font-size: 30px; }
  .vault-counts { gap: 18px; }
  .vault-counts dd { font-size: 32px; }
  .vault-key { gap: 16px; }
  .vault-help { padding: 18px 4px; }
  .reader-panel { padding: 24px; }
  .settings-reading-note { padding: 24px 4px; }
  body:not(.in-reader):not(.in-studio) .sheet { border-radius: 10px 10px 0 0; padding: 28px 22px; }
  .reader-more-links { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 4px; }
  .reader-more-links a { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .reader-workspace *, .reader-nav-links *, .reader-nav-toggle { animation: none !important; transition: none !important; }
}
