/* Fjord theme (2026-09-29). Fonts are bundled under src/fonts (SIL Open Font License); the CSP allows only this origin. */
@font-face { font-family: Figtree; src: url("fonts/figtree.woff2") format("woff2"); font-weight: 300 900; font-style: normal; font-display: swap; }
@font-face { font-family: Figtree; src: url("fonts/figtree-italic.woff2") format("woff2"); font-weight: 300 900; font-style: italic; font-display: swap; }
@font-face { font-family: Literata; src: url("fonts/literata.woff2") format("woff2"); font-weight: 200 900; font-style: normal; font-display: swap; }
@font-face { font-family: Literata; src: url("fonts/literata-italic.woff2") format("woff2"); font-weight: 200 900; font-style: italic; font-display: swap; }
:root {
  color-scheme: light;
  --ink: #13262b;
  --muted: #4f6a71;
  --soft: #edf3f4;
  --line: #d6e2e4;
  --surface: #ffffff;
  --primary: #0b6e8a;
  --primary-dark: #085a72;
  --violet: #0b6e8a;
  --cyan: #ff6b57;
  --navy: #10222a;
  --green: #236a41;
  --amber: #785117;
  --danger: #a12e36;
  --canvas: #edf3f4;
  --paper: #fbfdfd;
  --primary-hover: #085a72;
  --on-primary: #ffffff;
  --primary-soft: #e2eef0;
  --control-border: #7b949a;
  --focus: #0b6e8a;
  --accent: #ff6b57;
  --success: #236a41;
  --warning: #785117;
  --reader-dark: #10222a;
  --reader-dark-text: #e8f0f2;
  --reader-dark-border: #26414a;
  --reader-dark-kicker: #8fd3e3;
  --reader-dark-control: #18323b;
  --reader-dark-control-border: #35535c;
  --shadow-sm: 0 4px 18px rgba(19, 38, 43, 0.07);
  --shadow-md: 0 18px 50px rgba(19, 38, 43, 0.11);
  --shadow-lg: 0 30px 80px rgba(8, 20, 24, 0.28);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --sidebar: 236px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-family: Figtree, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* rem, not px, so body and form text follow a larger browser font setting. */
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* Focus teal: about 5.9:1 on paper and 5.3:1 on canvas, above the 3:1 minimum. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: 8px;
  background: white;
  color: var(--ink);
}
.skip-link:focus { transform: translateY(0); }

/* Shown by index.html until the first render replaces #app. */
.boot-loading { display: grid; min-height: 100vh; place-content: center; justify-items: center; gap: 14px; color: var(--muted); font-size: .95rem; }
.boot-spinner { width: 28px; height: 28px; border: 3px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: boot-spin 800ms linear infinite; }
@keyframes boot-spin { to { transform: rotate(360deg); } }

.icon {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 780;
  letter-spacing: -0.02em;
}
.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  color: white;
  background: var(--primary);
  box-shadow: 0 6px 16px rgba(21, 79, 94, 0.22);
}
.brand-mark .icon { width: 17px; height: 17px; }

.btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  color: var(--on-primary);
  background: var(--primary);
  box-shadow: 0 8px 20px rgba(21, 79, 94, 0.2);
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 10px 24px rgba(21, 79, 94, 0.28); }
.btn-secondary { border-color: var(--line); background: var(--surface); }
.btn-secondary:hover { border-color: #d5dbdd; background: #f9fbfb; }
.btn-ghost:hover { background: rgba(23, 83, 98, 0.08); }
.btn-danger { color: #ffffff; background: var(--danger); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 0.82rem; }
.btn-lg { min-height: 50px; padding: 0 22px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 14px;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.tiny { font-size: 0.74rem; }
.serif { font-family: Literata, Georgia, "Times New Roman", serif; }

.field { display: grid; gap: 7px; }
.field label, .field-label { font-size: 0.82rem; font-weight: 700; color: #465356; }
.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #e3e7e8;
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 13px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.textarea { min-height: 104px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: #1c6679;
  outline: none;
  box-shadow: 0 0 0 4px rgba(28, 102, 121, 0.18);
}
.form-grid { display: grid; gap: 16px; }
.form-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.checkbox-line { display: flex; align-items: flex-start; gap: 9px; color: var(--muted); font-size: 0.78rem; }
.checkbox-line input { margin-top: 3px; accent-color: var(--primary); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 29px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f3f6f7;
  color: #1a5e6f;
  font-size: 0.75rem;
  font-weight: 750;
}
.pill.success { background: #e9f5f8; color: #116d84; }
.pill.warning { background: #fff5df; color: #a76b0c; }
.divider { height: 1px; background: var(--line); }

/* Landing */
.landing { min-height: 100vh; overflow: hidden; color: #f8fafb; background: #0f1b1e; }
.landing-nav {
  position: absolute;
  inset: 0 0 auto;
  z-index: 5;
  display: flex;
  height: 78px;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: auto;
  padding: 0 28px;
  border-bottom: 1px solid rgba(255, 255, 255,0.12);
}
.landing-nav-links, .landing-actions { display: flex; align-items: center; gap: 26px; }
.landing-nav-links a, .landing-actions .sign-in { color: #cbd2d4; font-size: 0.82rem; }
.landing-nav-links a:hover, .landing-actions .sign-in:hover { color: #ffffff; }
.hero {
  position: relative;
  display: grid;
  min-height: 720px;
  place-items: center;
  padding: 116px 24px 54px;
  isolation: isolate;
}
.hero::before {
  position: absolute;
  inset: 0;
  z-index: -2;
  content: "";
  background: linear-gradient(180deg, rgba(12, 22, 24, .84), rgba(12, 22, 24, .66) 55%, rgba(12, 22, 24, .94)), url('/assets/hero-night.jpg') center/cover no-repeat;
}
.hero::after {
  position: absolute;
  inset: auto 0 0;
  z-index: -1;
  height: 210px;
  content: "";
  background: linear-gradient(transparent, #0f1b1e);
}
.hero-content { width: min(1100px, 100%); margin: auto; text-align: center; }
.hero-copy { max-width: 770px; margin: auto; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid rgba(163, 197, 206, 0.25);
  border-radius: 999px;
  background: rgba(20, 38, 43, .62);
  color: #c1d8de;
  backdrop-filter: blur(12px);
  font-size: 0.76rem;
}
.hero h1 {
  max-width: 760px;
  margin: 18px auto 14px;
  font-family: Literata, Georgia, "Times New Roman", serif;
  font-size: clamp(2.8rem, 5vw, 4.7rem);
  line-height: 1.02;
  letter-spacing: -0.045em;
}
.hero h1 span { color: #93bbc5; }
.hero-copy > p { max-width: 610px; margin-inline: auto; color: #c6cfd1; font-size: 1rem; }
.hero-ctas { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 24px; }
.hero .btn-secondary { border-color: rgba(255, 255, 255,.2); color: #ffffff; background: rgba(255, 255, 255,.06); }
.hero-books { display: flex; max-width: 790px; align-items: flex-end; justify-content: center; gap: 12px; margin: 42px auto 0; perspective: 900px; }
.hero-book { position: relative; width: clamp(92px, 12vw, 142px); aspect-ratio: 2/3; overflow: hidden; margin: 0; border: 1px solid rgba(255, 255, 255,.18); border-radius: 8px; background: #132428; box-shadow: 0 18px 35px rgba(0, 0, 0,.36); }
.hero-book img { width: 100%; height: 100%; object-fit: cover; }
.hero-book figcaption { position: absolute; inset: auto 8px 9px; z-index: 1; color: white; font-family: Literata, Georgia, serif; font-size: clamp(.58rem, .9vw, .74rem); line-height: 1.15; text-shadow: 0 2px 7px #000000; }
.hero-book::after { position: absolute; inset: 42% 0 0; content: ""; background: linear-gradient(transparent, rgba(6, 10, 11,.88)); }
.hero-book-1, .hero-book-5 { transform: translateY(20px) rotateY(7deg); }
.hero-book-2, .hero-book-4 { transform: translateY(8px); }
.landing-section { padding: 100px 24px; background: #ffffff; color: var(--ink); }
.landing-section.dark { background: #0f1b1e; color: white; }
.section-inner { width: min(1160px, 100%); margin: auto; }
.section-heading { max-width: 650px; margin-bottom: 42px; }
.section-heading h2 { margin: 0 0 14px; font-size: clamp(2rem, 4vw, 3.2rem); letter-spacing: -0.045em; line-height: 1.05; }
.section-heading p { color: var(--muted); }
.dark .section-heading p { color: #a5b2b5; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.feature-card { padding: 26px; border: 1px solid var(--line); border-radius: 18px; background: #f8fafb; }
.feature-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 12px; background: #f0f5f6; color: var(--primary); }
.feature-card h3 { margin: 19px 0 8px; font-size: 1rem; }
.feature-card p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.showcase { display: grid; grid-template-columns: .9fr 1.1fr; align-items: center; gap: 70px; }
.cover-fan { position: relative; min-height: 470px; }
.cover-fan .cover { position: absolute; width: 230px; aspect-ratio: 2/3; overflow: hidden; border-radius: 10px; box-shadow: var(--shadow-lg); }
.cover-fan .cover:nth-child(1) { left: 6%; top: 45px; transform: rotate(-7deg); }
.cover-fan .cover:nth-child(2) { left: 39%; top: 0; z-index: 2; transform: rotate(3deg); }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 20px 16px; background: linear-gradient(rgba(6, 10, 11,.18), transparent 45%, rgba(6, 10, 11,.88)); color: #ffffff; text-align: center; }
.cover-overlay strong { font-family: Literata, Georgia, serif; font-size: 1.35rem; line-height: 1.05; letter-spacing: .08em; text-transform: uppercase; }
.cover-overlay span { font-size: .68rem; letter-spacing: .18em; text-transform: uppercase; }
.footer { padding: 32px 24px; border-top: 1px solid rgba(255, 255, 255,.1); background: #0a1416; color: #a5b2b5; }
.footer-inner { display: flex; width: min(1160px,100%); align-items: center; justify-content: space-between; margin: auto; }

/* Auth and onboarding */
.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 34px 20px;
  background: radial-gradient(circle at top, #f8fafb, #ebf3f5 64%);
}
.auth-art { position: relative; min-height: 100vh; overflow: hidden; background: #0e1a1d; }
.auth-art img { width: 100%; height: 100%; object-fit: cover; opacity: .62; }
.auth-art::after { position: absolute; inset: 0; content: ""; background: linear-gradient(180deg, rgba(12, 23, 26,.1), rgba(12, 23, 26,.8)); }
.auth-quote { position: absolute; z-index: 2; left: 8%; right: 8%; bottom: 8%; color: #ffffff; }
.auth-quote h2 { max-width: 560px; margin: 0 0 12px; font-family: Literata, Georgia, serif; font-size: 2.5rem; line-height: 1.1; }
.auth-panel { display: grid; width: 100%; place-items: center; }
.auth-card { width: min(460px, 100%); padding: 38px 40px; border: 1px solid var(--line); border-radius: 18px; background: #ffffff; box-shadow: var(--shadow-md); }
.auth-card > .brand { margin-bottom: 34px; }
.auth-card h1 { margin: 0; font-size: 2rem; letter-spacing: -.04em; }
.auth-card .lead { margin: 7px 0 28px; color: var(--muted); }
.social-sign-in { display: grid; gap: 10px; margin-top: 18px; }
.btn-social { display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; }
.btn-social:hover { border-color: #d5dbdd; background: #f9fbfb; }
.btn-social:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 6px; color: var(--muted); font-size: 13px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.social-stack { display: grid; gap: 10px; }
.or { display: flex; align-items: center; gap: 13px; margin: 20px 0; color: #8d9ea2; font-size: .75rem; }
.or::before, .or::after { flex: 1; height: 1px; content: ""; background: var(--line); }
.auth-footer { margin-top: 20px; color: var(--muted); text-align: center; font-size: .82rem; }
.text-link { color: var(--primary); font-weight: 700; cursor: pointer; }

.center-page { display: grid; min-height: 100vh; place-items: center; padding: 32px; background: radial-gradient(circle at top, #f7f9fa, #eff5f7 50%); }
.center-card { width: min(880px, 100%); padding: 42px; border: 1px solid var(--line); border-radius: 20px; background: #ffffff; box-shadow: var(--shadow-md); text-align: center; }
.verify-card { max-width: 560px; }
.big-icon { display: grid; width: 76px; height: 76px; place-items: center; margin: 0 auto 25px; border-radius: 24px; background: #f1f6f7; color: var(--primary); }
.big-icon .icon { width: 34px; height: 34px; }
.center-card h1 { margin: 0 0 8px; font-size: 2rem; letter-spacing: -.04em; }
.center-card > p { margin: 0 auto 25px; color: var(--muted); }
.legal-card { text-align: left; }
.legal-card h2 { margin: 22px 0 6px; font-size: 1.1rem; letter-spacing: -.02em; }
.legal-card p { color: var(--muted); line-height: 1.6; }
.legal-card .divider { margin: 28px 0 18px; }

.plan-card-wrap { width: min(1080px, 100%); }
.plans-page { padding-block: 60px; }
.plan-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 30px; text-align: left; }
.plan-heading .brand { margin-bottom: 34px; }
.plan-heading h1 { margin-bottom: 6px; }
.billing-toggle { display: inline-flex; padding: 4px; border-radius: 11px; background: #ebf4f6; }
.billing-toggle button { min-height: 36px; border: 0; border-radius: 8px; padding: 0 14px; background: transparent; color: var(--muted); cursor: pointer; font-size: .8rem; font-weight: 700; }
.billing-toggle button.active { background: #ffffff; color: var(--primary); box-shadow: var(--shadow-sm); }
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.plan { position: relative; padding: 26px; border: 1px solid var(--line); border-radius: 16px; text-align: left; }
.plan.popular { border: 2px solid var(--primary); box-shadow: 0 18px 40px rgba(28, 102, 121,.13); }
.popular-badge { position: absolute; top: -13px; right: 18px; padding: 4px 10px; border-radius: 999px; background: var(--primary); color: white; font-size: .67rem; font-weight: 800; }
.plan h2 { margin: 0; font-size: 1.1rem; }
.plan-price { margin: 8px 0 18px; font-size: 2rem; font-weight: 800; }
.plan-price span { color: var(--muted); font-size: .75rem; font-weight: 500; }
.plan-description { min-height: 50px; margin: 8px 0 18px; color: var(--muted); font-size: .8rem; }
.plan-list { display: grid; min-height: 125px; gap: 10px; margin: 0 0 20px; padding: 0; list-style: none; }
.plan-list li { display: flex; gap: 8px; color: #4a585b; font-size: .82rem; }
.plan-list .icon { width: 16px; color: var(--primary); }

.onboarding-page { min-height: 100vh; background: #f5f9fa; }
.onboarding-top { display: flex; max-width: 1200px; margin: auto; padding: 24px 28px; align-items: center; justify-content: space-between; }
.step-count { color: var(--muted); font-size: .8rem; font-weight: 700; }
.onboarding-body { display: grid; min-height: calc(100vh - 80px); grid-template-columns: 1.25fr .75fr; }
.onboarding-form { display: grid; place-items: center; padding: 30px; }
.onboarding-card { width: min(610px, 100%); padding: 42px; border: 1px solid var(--line); border-radius: 20px; background: #ffffff; box-shadow: var(--shadow-sm); }
.onboarding-card h1 { margin: 0 0 8px; font-size: 2.2rem; letter-spacing: -.045em; }
.onboarding-card > p { margin: 0 0 28px; color: var(--muted); }
.onboarding-art { min-height: 100%; overflow: hidden; border-radius: 30px 0 0 0; background: #101e22; }
.onboarding-art img { width: 100%; height: 100%; object-fit: cover; opacity: .7; }
.option-grid { display: grid; gap: 10px; }
.option-card { display: flex; min-height: 56px; align-items: center; gap: 13px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 11px; background: #ffffff; cursor: pointer; font-weight: 700; font-size: .88rem; }
.option-card.selected { border-color: #aac9d1; background: #f3f7f8; color: #195a6a; }
.option-check { display: grid; width: 22px; height: 22px; place-items: center; border: 1px solid #d4dadb; border-radius: 7px; }
.selected .option-check { border-color: var(--primary); background: var(--primary); color: white; }
.onboarding-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 30px; }
.onboarding-split { display: grid; min-height: 100vh; grid-template-columns: minmax(310px, .78fr) minmax(0, 1.22fr); background: #ffffff; }
.onboarding-split .flow-content { display: grid; align-items: center; }
.onboarding-visual { position: relative; min-height: 100vh; overflow: hidden; background: #0e1a1d; }
.onboarding-visual img { width: 100%; height: 100%; object-fit: cover; opacity: .65; }
.onboarding-visual.goal img { object-position: center 35%; }
.onboarding-visual::after { position: absolute; inset: 0; content: ""; background: linear-gradient(180deg, rgba(10, 19, 21,.08), rgba(10, 19, 21,.9)); }
.onboarding-visual > div { position: absolute; z-index: 1; inset: auto 10% 9%; color: #ffffff; }
.onboarding-visual h2 { max-width: 480px; margin: 18px 0 9px; font-family: Literata, Georgia, serif; font-size: clamp(2rem, 3.4vw, 3.5rem); line-height: 1.08; }
.onboarding-visual p { max-width: 470px; margin: 0; color: #c8d0d2; }

/* App shell */
.app-shell { display: grid; min-height: 100vh; grid-template-columns: var(--sidebar) minmax(0, 1fr); background: #f4f8f9; }
.sidebar { position: sticky; top: 0; display: flex; height: 100vh; flex-direction: column; padding: 21px 16px; border-right: 1px solid var(--line); background: #ffffff; z-index: 30; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; }
.sidebar .brand { padding: 0 7px 20px; }
.sidebar .sidebar-close { display: none; }
.nav-section { display: grid; gap: 4px; margin-top: 8px; }
.nav-label { padding: 14px 10px 5px; color: #97a6aa; font-size: .66rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.nav-item { display: flex; min-height: 42px; align-items: center; gap: 11px; padding: 0 11px; border: 0; border-radius: 9px; background: transparent; color: #57666a; cursor: pointer; font-size: .84rem; font-weight: 650; text-align: left; }
.nav-item:hover { background: #f1f7f8; color: #203c43; }
.nav-item.active { background: #f2f6f7; color: #1a5f70; }
.sidebar-spacer { flex: 1; }
.upgrade-card { margin: 12px 0; padding: 15px; border-radius: 13px; background: linear-gradient(145deg, #172c31, #2e555f); color: white; }
.upgrade-card strong { display: block; font-size: .84rem; }
.upgrade-card p { margin: 5px 0 12px; color: #c3ccce; font-size: .7rem; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 12px 8px 3px; border-top: 1px solid var(--line); }
.avatar { display: grid; width: 36px; height: 36px; place-items: center; flex: 0 0 auto; border-radius: 50%; background: #eef4f5; color: #195b6c; font-size: .75rem; font-weight: 800; }
.avatar.gold { background: #fff2d8; color: #a56b0e; }
.avatar.violet { background: #eef4f5; color: #185666; }
.user-card strong { display: block; font-size: .78rem; }
.user-card span { color: var(--muted); font-size: .68rem; }
.app-main { min-width: 0; }
.mobile-top { display: none; }
.mobile-top-spacer { width: 40px; height: 40px; }
.page { width: min(1220px, 100%); margin: auto; padding: 35px 38px 60px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 28px; }
.page-header h1 { margin: 0 0 4px; font-size: 1.8rem; letter-spacing: -.04em; }
.page-header p { margin: 0; color: var(--muted); font-size: .87rem; }
.page-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 20px; }
.search-wrap { position: relative; flex: 1; min-width: 220px; }
.search-wrap .icon { position: absolute; top: 50%; left: 13px; width: 17px; color: #8d9ea2; transform: translateY(-50%); }
.search-wrap input { padding-left: 39px; }
.segmented { display: flex; flex-wrap: wrap; gap: 5px; padding: 4px; border-radius: 11px; background: #e8f2f4; }
.segmented button { min-height: 34px; padding: 0 13px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: .78rem; font-weight: 700; }
.segmented button.active { background: white; color: var(--primary); box-shadow: 0 3px 10px rgba(33, 63, 70,.08); }

.book-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.template-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.template-card { display: flex; min-height: 220px; flex-direction: column; padding: 23px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, #ffffff, #f7f9fa); }
.template-card h2 { margin: 12px 0 7px; font-size: 1.1rem; }
.template-card p { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.55; }
.template-card .btn { margin-top: auto; }
.template-type { width: fit-content; padding: 5px 8px; border-radius: 99px; background: #f1f5f6; color: var(--primary); font-size: .65rem; font-weight: 800; }
.template-meta { display: flex; gap: 10px; margin: 16px 0; color: var(--muted); font-size: .7rem; }
.dashboard-activity { max-width: 680px; margin-top: 30px; padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: #ffffff; }
.dashboard-activity h2 { margin: 4px 0 15px; font-size: 1rem; }
.book-card { overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: #ffffff; box-shadow: 0 7px 20px rgba(25, 46, 51,.04); cursor: pointer; transition: transform 180ms ease, box-shadow 180ms ease; }
.book-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.book-cover { position: relative; aspect-ratio: 2/3; overflow: hidden; background: #14262a; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; object-position: center 42%; }
.book-cover::after { position: absolute; inset: 0; content: ""; background: linear-gradient(transparent 35%, rgba(8, 14, 16,.78)); }
.book-cover-title { position: absolute; z-index: 2; inset: auto 14px 14px; color: #ffffff; font-family: Literata, Georgia, serif; font-size: 1rem; line-height: 1.1; text-shadow: 0 2px 10px #000000; }
.book-info { padding: 15px; }
.book-info h3 { margin: 0 0 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .94rem; }
.book-meta { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .7rem; }
.book-info .book-meta + .book-meta { margin-top: 8px; }
/* List layout: one compact row per book, the default manuscript list. */
.library-view { margin: 0 0 14px auto; width: max-content; }
.book-grid.is-list { grid-template-columns: minmax(0, 1fr); gap: 10px; }
.book-grid.is-list .book-card { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: stretch; }
.book-grid.is-list .book-cover { aspect-ratio: auto; height: 100%; min-height: 110px; }
.book-grid.is-list .book-cover-text { border-bottom: 0; border-right: 1px solid var(--line); }
.book-grid.is-list .book-cover-name { font-size: 1rem; }
/* Delete sits over the card's corner as a sibling, so the card stays one button. */
.book-item { position: relative; min-width: 0; }
.book-delete { position: absolute; z-index: 3; top: 10px; right: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--danger); }
.book-delete:hover { background: #fbeced; }
.book-grid.is-list .book-delete { top: 12px; right: 12px; }
.book-grid.is-list .book-info { padding-right: 60px; }
.undo-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 16px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.danger-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; border-color: #e7c9cc; }
.danger-card h2 { margin: 0 0 4px; font-size: 1rem; }
.danger-card p { margin: 0; }
/* Scenes: author-chosen starts inside a chapter, a preview, and ratings waiting for a part. */
.rhythm-chapter-break { stroke: var(--muted); stroke-dasharray: 3 4; opacity: .55; }
.scene-section .row-actions { flex-wrap: wrap; }
.scene-blocks { max-height: 26rem; margin: 10px 0; padding: 0; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; list-style: none; }
.scene-block { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: start; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.scene-block:last-child { border-bottom: 0; }
.scene-block.is-start { background: var(--primary-soft); }
.scene-block-choice { display: flex; gap: 8px; align-items: flex-start; min-width: 0; cursor: pointer; }
.scene-block-choice input { margin-top: 3px; flex: none; }
.scene-block-choice > span { min-width: 0; overflow-wrap: anywhere; }
.scene-block-kind { margin-right: 4px; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.scene-title { grid-column: 1 / -1; }
.scene-preview { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.scene-preview h4 { margin: 0; }
.scene-preview-list { margin: 8px 0; padding-left: 1.3rem; }
.scene-preview-list li + li { margin-top: 8px; }
.scene-preview-list p { margin: 2px 0 0; }
.unresolved-list { margin: 8px 0 0; padding: 0; list-style: none; }
.unresolved-rating { padding: 10px 0; border-top: 1px solid var(--line); }
.unresolved-rating p { margin: 0 0 6px; }
.unresolved-rating .row-actions { flex-wrap: wrap; }
.unresolved-rating .input { width: auto; max-width: 100%; min-width: 0; }
/* AI review: suggestions shown apart from rule checks and the author's own records. */
.ai-review { margin-top: 18px; }
.ai-review-controls { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin: 10px 0; }
.ai-review-controls .field { flex: 1 1 12rem; min-width: 0; margin: 0; }
.ai-review-controls .ai-usage { margin: 6px 0 0; }
.ai-finding .issue-dot { font-size: .62rem; letter-spacing: .02em; }
.ai-finding.is-dismissed { opacity: .62; }
.ai-evidence { margin: 6px 0 10px; padding-left: 1.2rem; }
.ai-evidence li { overflow-wrap: anywhere; }
.ai-evidence li + li { margin-top: 4px; }
.ai-levels { margin: 10px 0; }
.ai-twist { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.ai-twist > h4 { margin: 0 0 4px; }
.ai-option h4 { margin: 4px 0 6px; }
/* Read mode: choosing a passage by keyboard, also used to move a changed note. */
.reader-pick { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; }
.reader-pick h3 { margin: 0 0 8px; font-size: .95rem; }
.reader-pick select { max-width: 100%; }
.reader-pick .row-actions { flex-wrap: wrap; }
/* Find in chapter: matches are painted with highlights, never inserted into the manuscript. */
.find-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.find-bar .input { flex: 1 1 12rem; min-width: 0; max-width: 24rem; min-height: 36px; }
.find-bar #find-count { min-width: 5.5rem; }
::highlight(find-match) { background-color: #f1e2ad; color: inherit; }
::highlight(find-current) { background-color: #e3a94f; color: #161b1c; }
/* Book activities on small screens, where the sidebar is a drawer. */
.mobile-activities { display: none; }
@media (max-width: 820px) {
  .mobile-activities { display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
  .mobile-activities button { flex: none; min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-weight: 700; font-size: .85rem; }
  .mobile-activities button.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
}
@media (max-width: 560px) {
  .book-grid.is-list .book-card { grid-template-columns: 96px minmax(0, 1fr); }
  .book-grid.is-list .book-cover-name { font-size: .78rem; overflow-wrap: normal; hyphens: auto; }
}
/* A book without its own cover: a short text header, not a full-height 2:3 panel. */
.book-cover-text { display: flex; aspect-ratio: auto; min-height: 118px; flex-direction: column; justify-content: space-between; gap: 10px; padding: 16px 16px 14px; border-bottom: 1px solid var(--line); border-left: 4px solid var(--primary); background: var(--paper); color: var(--ink); }
.book-cover-text::after { display: none; }
.book-cover-type { color: var(--primary); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.book-cover-name { font-family: Literata, Georgia, "Times New Roman", serif; font-size: 1.25rem; line-height: 1.2; overflow-wrap: anywhere; }
.stage-badge { padding: 2px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.stage-badge.stage-setting-up { background: #f3ead6; color: var(--warning); }
.stage-badge.stage-completed { background: #e3edf0; color: var(--success); }
.book-resume { margin-top: 10px; color: var(--primary); font-size: .78rem; font-weight: 700; }
.progress-bar { height: 5px; margin: 13px 0 8px; overflow: hidden; border-radius: 99px; background: #e6f0f3; }
.progress-bar span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
/* One equal-width segment per step, not a percentage fill — see runProgressBar's comment in auto-book.js. */
.run-progress-track { display: flex; gap: 10px; margin: 13px 0 18px; }
.run-progress-group { display: flex; gap: 3px; min-width: 0; }
.run-progress-seg { flex: 1; height: 7px; border-radius: 99px; background: #e6f0f3; }
.run-progress-seg-done { background: var(--primary); }
.run-progress-seg-active { background: var(--primary); opacity: .55; animation: run-progress-pulse 1.4s ease-in-out infinite; }
.run-progress-seg-stuck { background: var(--warning); }
@keyframes run-progress-pulse { 0%, 100% { opacity: .35; } 50% { opacity: .85; } }
.new-book-card { display: grid; min-height: 390px; place-items: center; border: 1.5px dashed #dbe0e1; border-radius: 15px; background: rgba(255, 255, 255,.55); color: var(--primary); cursor: pointer; }
.new-book-card:hover { border-color: #9ec2cb; background: #ffffff; }
.new-book-card div { text-align: center; font-weight: 750; font-size: .84rem; }
.new-book-card .plus { display: grid; width: 48px; height: 48px; place-items: center; margin: 0 auto 12px; border-radius: 14px; background: #f1f6f7; }
.activity-card { margin-top: 28px; padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: #ffffff; }
.activity-card h2 { margin: 0 0 12px; font-size: 1rem; }
.activity-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 11px; padding: 11px 0; border-top: 1px solid #ebf3f5; }
.activity-row:first-of-type { border-top: 0; }
.activity-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 9px; background: #f3f6f7; color: var(--primary); }
.activity-row p { margin: 0; font-size: .78rem; }
.activity-row time { color: var(--muted); font-size: .7rem; }

/* Wizard and detail pages */
.wizard-layout { display: grid; min-height: 100vh; grid-template-columns: 210px minmax(0, 1fr); background: white; }
.wizard-stepper { padding: 24px 18px; border-right: 1px solid var(--line); background: #f8fafb; }
.wizard-stepper .brand { margin-bottom: 28px; }
.step { display: flex; align-items: center; gap: 10px; padding: 11px 8px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.step-number { display: grid; width: 24px; height: 24px; place-items: center; border-radius: 50%; background: #ebedee; font-size: .7rem; }
.step.active { color: var(--primary); }
.step.active .step-number { background: var(--primary); color: white; }
.wizard-content { display: grid; min-width: 0; grid-template-rows: auto 1fr; }
.wizard-top { display: flex; padding: 20px 26px; align-items: center; justify-content: flex-end; border-bottom: 1px solid var(--line); }
.chat-shell { display: grid; width: min(760px, calc(100% - 40px)); height: calc(100vh - 104px); margin: 20px auto; grid-template-rows: 1fr auto; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: #ffffff; box-shadow: var(--shadow-sm); }
.messages { overflow-y: auto; padding: 28px; }
.message { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 16px; }
.message.user { justify-content: flex-end; }
.message-bubble { max-width: 72%; padding: 11px 14px; border-radius: 4px 14px 14px 14px; background: #edf5f7; color: #2d4c54; font-size: .86rem; }
.message.user .message-bubble { border-radius: 14px 4px 14px 14px; background: var(--primary); color: var(--on-primary); }
.message .avatar { width: 30px; height: 30px; }
.suggestion-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 7px 0 20px 41px; }
.chip { min-height: 34px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px; background: #ffffff; cursor: pointer; color: #4d5b5e; font-size: .75rem; font-weight: 700; }
.chip:hover, .chip.selected { border-color: #a6c7cf; background: #f2f6f7; color: var(--primary); }
.chat-input { display: flex; gap: 9px; padding: 15px; border-top: 1px solid var(--line); }
.chat-input .input { flex: 1; }
.send-button { width: 44px; padding: 0; }
.prompt-library { width: min(760px, calc(100% - 40px)); margin: 0 auto 32px; padding: 24px; border: 1px solid #e6e9ea; border-radius: 16px; background: linear-gradient(145deg, #f9fbfc, #ffffff); box-shadow: var(--shadow-sm); }
.prompt-library-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 17px; }
.prompt-library-head h2 { margin: 0 0 5px; font-size: 1.05rem; letter-spacing: -.02em; }
.prompt-library-head p { max-width: 460px; margin: 0; color: var(--muted); font-size: .78rem; }
.prompt-library-head .select { width: 190px; flex: 0 0 auto; }
.prompt-library > .textarea { min-height: 128px; margin: 7px 0 13px; font-size: .82rem; line-height: 1.6; }
.start-choice { width: min(760px, calc(100% - 40px)); margin: 0 auto 22px; display: grid; grid-template-columns: minmax(0, .8fr) minmax(280px, 1.2fr); gap: 18px; align-items: stretch; }
.start-choice-three { width: min(900px, 100%); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.start-method { display: flex; min-height: 250px; flex-direction: column; }
.start-method .btn { margin-top: auto; }
.start-choice > div, .import-start-card { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: #ffffff; box-shadow: var(--shadow-sm); }
.start-choice h2, .voice-panel h2, .publishing-card h2 { margin: 10px 0 6px; font-size: 1.05rem; }
.start-choice p { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.55; }
.import-start-card { gap: 12px; }
.import-review pre { max-height: 440px; overflow: auto; margin: 18px 0; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: #f5f9fa; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; font: .82rem/1.65 var(--font-sans); text-align: left; }
.import-summary { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .76rem; }
.import-summary strong { color: var(--ink); }
.voice-panel { align-self: start; }
.voice-panel .textarea { min-height: 105px; }
.voice-sample-list { display: grid; gap: 8px; margin: 15px 0; }
.compact-resource { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.compact-resource strong, .compact-resource span { display: block; }
.compact-resource span { margin-top: 2px; color: var(--muted); font-size: .68rem; }
.publishing-card { max-width: 900px; margin: 22px auto 0; text-align: left; }
.illustration-panel { margin-top: 18px; }
.illustration-panel .chapter-row { display: block; margin-top: 10px; }
.chapter-illustration { margin: 12px 0 0; }
.chapter-illustration img { display: block; width: 100%; max-height: 240px; object-fit: cover; border-radius: 10px; }
.chapter-illustration figcaption { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.prompt-result { margin-bottom: 15px; padding: 14px; border-left: 3px solid #207287; border-radius: 0 10px 10px 0; background: #f4f7f8; }
.prompt-result p { margin: 9px 0 0; color: #485558; font-family: Literata, Georgia, serif; font-size: .87rem; line-height: 1.65; }

.flow-layout { display: grid; min-height: 100vh; grid-template-columns: 190px minmax(0, 1fr); background: #ffffff; }
.flow-content { padding: 28px 32px 80px; }
.flow-main { width: min(900px, 100%); margin: 0 auto; }
.flow-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.flow-header h1 { margin: 0 0 3px; font-size: 1.5rem; letter-spacing: -.035em; }
.flow-card { padding: 25px; border: 1px solid var(--line); border-radius: 15px; background: #ffffff; }
.book-details-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 28px; }
.book-details-layout.details-single { grid-template-columns: minmax(0, 760px); }
.detail-cover { position: sticky; top: 28px; }
.detail-cover .cover { position: relative; width: 100%; aspect-ratio: 2/3; overflow: hidden; border-radius: 9px; box-shadow: var(--shadow-md); }
.save-state { display: inline-flex; align-items: center; gap: 6px; color: var(--green); font-size: .75rem; font-weight: 700; }
.flow-actions { display: flex; justify-content: space-between; margin-top: 25px; }

/* Guided interview */
.interview-steps { margin: 0 0 18px; padding: 0; list-style: none; }
.step.done .step-number { background: #e6edef; color: var(--primary); }
.interview-chat { display: grid; gap: 18px; }
.interview-log { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.interview-message { display: flex; }
.interview-message p { max-width: min(560px, 85%); margin: 0; padding: 11px 14px; border-radius: 4px 14px 14px 14px; background: #edf5f7; color: #2d4c54; font-size: .9rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.interview-message.from-author { justify-content: flex-end; }
.interview-message.from-author p { border-radius: 14px 4px 14px 14px; background: var(--primary); color: var(--on-primary); }
.interview-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.interview-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.interview-form { display: grid; gap: 8px; }
.interview-input { display: flex; align-items: flex-end; gap: 10px; }
.interview-input .textarea { min-height: 72px; }
.interview-restart { display: flex; justify-content: flex-end; margin-top: 10px; }
.interview-summary { margin-top: 18px; }
.interview-summary h2 { margin: 0 0 14px; font-size: 1.05rem; }
.interview-summary dl { display: grid; gap: 12px; margin: 0; }
.interview-summary dt { color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.interview-summary dd { margin: 3px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.start-choice-four { width: min(900px, 100%); grid-template-columns: repeat(2, minmax(0, 1fr)); }

.list-stack { display: grid; gap: 12px; }
.person-row, .chapter-row { display: grid; align-items: center; gap: 14px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #ffffff; }
.person-row { grid-template-columns: auto 1fr auto; }
.chapter-row { grid-template-columns: auto 1fr auto; }
.drag-handle { color: #a2b0b3; cursor: grab; }
.person-row h3, .chapter-row h3 { margin: 0 0 2px; font-size: .9rem; }
.person-row p, .chapter-row p { margin: 0; color: var(--muted); font-size: .75rem; }
.row-actions { display: flex; gap: 5px; }
.icon-btn { display: grid; width: 36px; height: 36px; place-items: center; border: 0; border-radius: 9px; background: transparent; color: #6a7d82; cursor: pointer; }
.icon-btn:hover { background: #ebf4f6; color: var(--ink); }
.icon-btn .icon { width: 17px; height: 17px; }
.empty-box { padding: 45px 20px; border: 1.5px dashed #dde3e4; border-radius: 14px; background: #f8fafb; text-align: center; }
.empty-box .big-icon { width: 58px; height: 58px; margin-bottom: 15px; border-radius: 17px; }
.empty-box h3 { margin: 0 0 6px; }
.empty-box p { max-width: 420px; margin: 0 auto 17px; color: var(--muted); font-size: .82rem; }

/* Editor */
.editor-shell { display: grid; height: 100vh; grid-template-columns: 212px minmax(0, 1fr) 302px; background: #f1f7f8; overflow: hidden; }
/* Focus view: only the manuscript, its title bar and save state. display:none also
   keeps the hidden panels out of the keyboard order. */
.editor-shell.focus-mode { grid-template-columns: minmax(0, 1fr); }
.focus-mode .editor-nav, .focus-mode .ai-panel, .focus-mode .editor-toolbar, .focus-mode [data-action="toggle-ai"], .focus-mode [data-action="toggle-sidebar"] { display: none !important; }
.focus-mode .editor-workspace { grid-template-rows: auto 1fr auto; }
[data-action="toggle-focus"][aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.editor-nav { display: flex; min-height: 0; flex-direction: column; padding: 20px 13px 15px; border-right: 1px solid #eaedee; background: #ffffff; }
.editor-nav-close { display: none; align-self: flex-end; }
.editor-nav .brand { padding: 0 6px 18px; }
.editor-nav .btn-ghost { justify-content: flex-start; margin-bottom: 18px; }
.editor-chapters { overflow-y: auto; margin: 9px -4px 14px; padding: 0 4px; }
.editor-chapter { display: block; width: 100%; margin: 2px 0; padding: 10px 11px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: #617377; cursor: pointer; text-align: left; font-size: .75rem; transition: background 150ms ease, color 150ms ease; }
.editor-chapter:hover { background: #f4f8f9; color: var(--ink); }
.editor-chapter.active { border-color: #ebf1f3; background: #f2f6f7; color: var(--primary); font-weight: 750; }
.editor-export { margin-top: 9px; }
.editor-workspace { display: grid; min-width: 0; min-height: 0; grid-template-rows: auto auto 1fr auto; }
.editor-top { display: flex; height: 62px; padding: 0 24px; align-items: center; justify-content: space-between; border-bottom: 1px solid #ebedee; background: rgba(255, 255, 255,.94); }
.editor-top > div:first-child { display: flex; align-items: center; gap: 8px; min-width: 0; }
.breadcrumbs { overflow: hidden; color: var(--muted); font-size: .74rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumbs span { color: #c8d0d2; }
.editor-toolbar { display: flex; min-height: 52px; padding: 7px 24px; align-items: center; gap: 4px; border-bottom: 1px solid #ebedee; background: #ffffff; }
.toolbar-label { margin-right: 7px; color: #8a9b9f; font-size: .66rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.toolbar-divider { width: 1px; height: 22px; margin: 0 5px; background: var(--line); }
.editor-scroll { overflow-y: auto; padding: 42px 30px 84px; background: radial-gradient(circle at top, #f9fbfc 0, #f1f7f8 58%); }
.paper { width: min(760px, 100%); min-height: calc(100vh - 242px); margin: 0 auto; padding: 68px 76px; border: 1px solid #e7eaeb; border-radius: 3px; background: #ffffff; box-shadow: 0 14px 42px rgba(33, 61, 68,.08), 0 2px 5px rgba(33, 61, 68,.04); }
.paper-head { padding-bottom: 29px; border-bottom: 1px solid #eaeded; margin-bottom: 31px; }
.editor-kicker { margin: 0 0 8px; color: var(--primary); font-size: .64rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.paper h1 { margin: 0; color: #1d363c; font-family: Literata, Georgia, "Times New Roman", serif; font-size: clamp(1.8rem, 3vw, 2.35rem); font-weight: 600; letter-spacing: -.025em; line-height: 1.2; }
.manuscript { min-height: 440px; color: #253f46; font-family: Literata, Georgia, "Times New Roman", serif; font-size: 1.08rem; line-height: 1.95; outline: none; }
.manuscript p { margin: 0 0 1.2em; }
.editor-statusbar { display: flex; height: 37px; padding: 0 24px; align-items: center; justify-content: space-between; border-top: 1px solid #ebedee; background: #ffffff; color: #7a8d92; font-size: .68rem; }
.ai-panel { display: flex; min-height: 0; flex-direction: column; overflow-y: auto; border-left: 1px solid #eaedee; background: #ffffff; }
/* Nothing in the panel may be squeezed to zero height when it holds more than
   fits: the answer box was, so an answer arrived and could not be seen. The
   panel scrolls instead. */
.ai-panel > * { flex-shrink: 0; }
.ai-panel-head { display: flex; padding: 20px 20px 12px; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ai-panel-head h3 { margin: 0; color: #1f3940; font-size: 1rem; }
.ai-panel-copy { margin: 0; padding: 0 20px 15px; color: var(--muted); font-size: .73rem; line-height: 1.55; }
.ai-actions { display: grid; gap: 6px; padding: 0 15px 16px; }
.ai-actions .btn { justify-content: flex-start; padding-left: 12px; }
.ai-action { display: flex; min-height: 39px; align-items: center; gap: 9px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: #4f5d61; cursor: pointer; font-size: .76rem; text-align: left; }
.ai-action:hover { background: #f1f7f8; color: var(--primary); }
.ai-custom-form { display: grid; gap: 10px; margin-top: auto; padding: 16px; border-top: 1px solid #e4eff2; background: #fafcfc; }
.ai-custom-form .field { gap: 6px; }
.ai-custom-form .textarea { min-height: 82px; resize: vertical; }
.ai-result { max-height: 32%; overflow-y: auto; }
.ai-settings { margin: 12px 15px 16px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.ai-settings summary { cursor: pointer; color: var(--ink); font-size: .74rem; font-weight: 750; }
.ai-settings[open] summary { margin-bottom: 12px; }
.ai-settings .textarea { min-height: 90px; }
.capability-note { margin: 10px 0 0; color: var(--warning); font-size: .72rem; line-height: 1.5; }
/* Inside the AI panel the note lines up with the panel's own 20px gutter. */
.ai-panel .capability-note { padding: 0 20px; }
.verify-notice, .draft-offer { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 16px 28px 0; padding: 10px 14px; border: 1px solid currentColor; border-radius: 10px; font-size: .8rem; }
.ai-result-empty { margin: 0; padding: 4px 18px 18px; color: var(--muted); font-size: .72rem; line-height: 1.55; }
.ai-preview { margin: 4px 13px 13px; padding: 14px; border: 1px solid #e6e9ea; border-radius: 11px; background: #f7f9fa; font-size: .76rem; }
.ai-preview p { margin: 0 0 12px; }
.ai-preview-actions { display: flex; gap: 7px; }
.ai-prompt { display: flex; gap: 7px; margin-top: auto; padding: 13px; border-top: 1px solid var(--line); }
.ai-prompt .input { min-width: 0; min-height: 39px; }

/* Analysis, covers, audio, publish */
.analysis-grid { display: grid; grid-template-columns: 260px 1fr; gap: 22px; }
.analysis-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.rhythm-card h3, .story-section h3 { margin: 0 0 4px; font-size: .95rem; }
.rhythm-summary { margin: 0 0 4px; font-size: .85rem; }
.rhythm-controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.rhythm-chart-wrap { overflow-x: auto; margin: 8px 0 4px; padding-bottom: 6px; }
.rhythm-chart { display: block; }
.rhythm-grid { stroke: var(--line); stroke-width: 1; }
.rhythm-axis { fill: var(--muted); font-family: Figtree, system-ui, sans-serif; font-size: 11px; }
.rhythm-line { stroke: var(--primary); stroke-width: 2.5; }
.rhythm-line.is-stale { opacity: .55; stroke-dasharray: 3 4; }
.rhythm-target { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 7 6; }
.rhythm-dot { fill: var(--primary); stroke: #ffffff; stroke-width: 2; }
.rhythm-dot.is-stale { fill: #ffffff; stroke: var(--primary); stroke-dasharray: 2 2; stroke-width: 2; }
.rhythm-dot.is-selected { stroke: var(--focus); stroke-width: 3; }
.rhythm-gap { fill: var(--muted); font-family: Figtree, system-ui, sans-serif; font-size: 10px; }
.rhythm-points { display: flex; }
.rhythm-point-button { flex: none; min-height: 36px; padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink); font-size: .8rem; font-weight: 700; cursor: pointer; }
.rhythm-point-button[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.table-wrap { overflow-x: auto; }
.rhythm-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.rhythm-table th, .rhythm-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.rhythm-table tr.is-selected { background: var(--primary-soft); }
.link-button { padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-weight: 700; text-align: left; cursor: pointer; }
.story-part-form { display: grid; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
/* One explicit column: a child placed in column 2 by another rule would otherwise
   create a second column and squeeze the form at phone width. */
.story-part-form, .story-thread-new, .story-plan-form { grid-template-columns: minmax(0, 1fr); }
.story-part-form > *, .story-thread-new > *, .story-plan-form > * { grid-column: 1 / -1; min-width: 0; }
.story-level-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.causal-flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.story-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.story-thread, .story-plan { margin: 10px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.story-thread-head { display: grid; gap: 2px; margin-bottom: 8px; }
.story-thread-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.story-thread-new, .story-plan-form { display: grid; gap: 10px; margin-top: 12px; }
.story-choices { display: grid; gap: 6px; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.story-choices legend { padding: 0 4px; font-size: .8rem; font-weight: 700; }
.story-choice { display: flex; align-items: center; gap: 8px; font-size: .85rem; }
.story-plans-title { margin: 16px 0 4px; font-size: .85rem; }
.story-plan.declined { opacity: .7; }
.story-plan p { margin: 0 0 6px; }
.score-card { padding: 26px; border: 1px solid var(--line); border-radius: 16px; background: #ffffff; text-align: center; }
.score-ring { position: relative; display: grid; width: 132px; height: 132px; margin: 8px auto 22px; place-items: center; border-radius: 50%; background: conic-gradient(var(--green) calc(var(--score) * 1%), #ebeeef 0); }
.score-ring::before { position: absolute; inset: 11px; border-radius: 50%; background: #ffffff; content: ""; }
.score-ring strong { position: relative; font-size: 2.1rem; }
.score-ring span { position: relative; display: block; color: var(--muted); font-size: .65rem; }
.score-list { display: grid; gap: 13px; }
.score-item-head { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: .75rem; font-weight: 700; }
.suggestions-card { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: #ffffff; }
.suggestions-card h2 { margin: 0 0 14px; font-size: 1rem; }
.issue-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; padding: 15px 0; border-top: 1px solid var(--line); }
.issue-row:first-of-type { border-top: 0; }
.issue-dot { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 50%; background: #f2f6f7; color: var(--primary); font-size: .7rem; font-weight: 800; }
.issue-row h3 { margin: 0 0 3px; font-size: .83rem; }
.issue-row p { margin: 0; color: var(--muted); font-size: .75rem; }
.ai-panel .ai-usage { margin: 10px 0 0; padding: 0 20px; }
.reader-layout { padding-bottom: 48px; }
.reader-bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--canvas); }
.reader-title { display: grid; min-width: 0; flex: 1 1 200px; }
.reader-title strong { overflow-wrap: anywhere; }
.reader-title span { color: var(--muted); font-size: .75rem; }
.reader-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.reader-panel { max-width: 46rem; margin: 16px auto 0; padding: 16px 20px; border: 1px solid var(--line); border-radius: 12px; background: #ffffff; }
.reader-panel h2 { margin: 0 0 8px; font-size: 1rem; }
.reader-contents { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.reader-contents button { width: 100%; justify-content: flex-start; text-align: left; white-space: normal; overflow-wrap: anywhere; }
.reader-contents button[aria-current="true"] { background: #f2f6f7; }
.reader-setting-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.reader-page { max-width: 46rem; margin: 16px auto 0; padding: clamp(24px, 5vw, 48px) clamp(16px, 5vw, 64px); border: 1px solid var(--line); border-radius: 12px; background: #fafcfd; color: #1c2122; font-family: Literata, Georgia, "Times New Roman", serif; }
.reader-width-narrow { max-width: 38rem; }
.reader-width-wide { max-width: 58rem; }
.reader-sans { font-family: Figtree, system-ui, -apple-system, "Segoe UI", sans-serif; }
.reader-dark { border-color: var(--reader-dark-border); background: var(--reader-dark); color: var(--reader-dark-text); }
.reader-dark .editor-kicker { color: var(--reader-dark-kicker); }
.reader-chapter-title { margin: 4px 0 24px; font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.2; overflow-wrap: anywhere; }
.reader-text { font-size: var(--reader-size, 19px); line-height: var(--reader-line, 1.7); overflow-wrap: break-word; }
.reader-text > * { scroll-margin-top: 90px; }
.reader-text p { margin: 0 0 1em; }
.reader-mark { border-radius: 2px; background: #fff1b8; color: inherit; }
.reader-dark .reader-mark { background: #5c4d12; }
.reader-dark .reader-turns .btn { border-color: var(--reader-dark-control-border); background: var(--reader-dark-control); color: var(--reader-dark-text); }
@media (max-width: 640px) {
  .reader-layout { padding: 0 12px 48px; }
  .reader-bar { margin: 0 -12px; }
}
.reader-turns { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 32px; font-family: Figtree, system-ui, sans-serif; }
.reader-note-bar { position: fixed; bottom: 20px; left: 50%; z-index: 20; transform: translateX(-50%); }
.reader-note-form { position: fixed; right: 16px; bottom: 16px; left: 16px; z-index: 25; display: grid; gap: 10px; max-width: 560px; max-height: 70vh; margin: 0 auto; padding: 16px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: #ffffff; box-shadow: 0 12px 32px rgba(20, 37, 41, .18); }
.reader-note { padding: 12px 0; border-top: 1px solid var(--line); }
.reader-note.resolved { opacity: .7; }
.reader-note p { margin: 0 0 6px; }
.anchor-state { color: #8a4b00; font-size: .8rem; font-weight: 700; }
.form-error { margin: 0; color: #a1261b; font-size: .875rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.preview-scope { margin: 0 0 6px; font-size: .75rem; }
.preview-text { white-space: pre-wrap; }
.preview-diff del { background: #fde8e8; color: #8a1f1f; text-decoration: line-through; }
.preview-diff ins, .preview-text ins { background: #e3f4ea; color: #17613b; text-decoration: underline; }
.ai-preview.is-stale { opacity: .75; }
.context-used { margin-top: 10px; font-size: .75rem; }
.context-used summary { cursor: pointer; font-weight: 700; }
.context-used ul { margin: 6px 0; padding-left: 18px; }
.context-used li { margin-bottom: 3px; }
/* Voice guide (FR-12) */
.ai-settings [hidden] { display: none; }
.voice-guide { display: grid; gap: 14px; margin-top: 18px; }
.voice-guide h2 { margin: 6px 0 4px; font-size: 1.05rem; }
.voice-guide .textarea { min-height: 96px; }
.voice-kept h3 { margin: 0 0 4px; font-size: .9rem; }
.kept-phrases { list-style: none; display: grid; gap: 8px; margin: 10px 0 0; padding: 0; }
.kept-phrase { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.kept-phrase > div { min-width: 0; }
.kept-phrase q { display: block; overflow-wrap: anywhere; font-family: Literata, Georgia, 'Times New Roman', serif; }
.kept-phrase span { display: block; margin-top: 2px; }
.kept-phrase.is-changed { border-color: #e2c48f; background: #fdf6e7; }
.voice-editor-tools { display: grid; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.voice-editor-tools p { margin: 0; }
.voice-check { margin-top: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: .75rem; }
.voice-checks { margin: 4px 0; padding-left: 18px; color: #7a4a00; }
.voice-checks li { margin-bottom: 3px; overflow-wrap: anywhere; }
.voice-rubric summary { cursor: pointer; font-weight: 700; }
.voice-rubric ul { list-style: none; margin: 6px 0; padding: 0; }
.voice-rubric li { margin-bottom: 4px; }
.voice-rubric label { display: flex; gap: 6px; align-items: flex-start; }
.analysis-grid-even { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.measure-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 0 0 18px; }
.measure-list div { padding: 12px; border-radius: 12px; background: #f3f8f9; }
.measure-list dt { color: var(--muted); font-size: .72rem; font-weight: 700; }
.measure-list dd { margin: 4px 0 0; font-size: 1.1rem; font-weight: 800; }
.analysis-subheading { margin: 0 0 10px; font-size: .8rem; }
.chapter-bars { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.chapter-bars li { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(60px, 2fr) auto; gap: 10px; align-items: center; font-size: .75rem; }
.chapter-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-list, .review-checklist { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.check-list li { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: start; }
.check-state { padding: 2px 8px; border-radius: 999px; font-size: .68rem; font-weight: 800; text-align: center; white-space: nowrap; }
.check-state.ran { background: #e3f4ea; color: #17613b; }
.check-state.skipped { background: #e6f0f3; color: #485558; }
.check-list h3 { margin: 0 0 2px; font-size: .8rem; }
.check-list p { margin: 0; color: var(--muted); font-size: .74rem; }
.issue-row .finding-meta, .series-view-entry .finding-meta, .beta-answer .finding-meta, .story-plan .finding-meta { margin: 0 0 3px; font-size: .68rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.finding-excerpt { margin: 6px 0; padding: 8px 12px; border-left: 3px solid var(--primary); border-radius: 0 8px 8px 0; background: #f3f8f9; font-size: .8rem; overflow-wrap: anywhere; }
.finding-actions { display: flex; flex-direction: column; gap: 6px; }
.dismissed-findings { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.dismissed-findings summary { cursor: pointer; font-size: .8rem; font-weight: 700; }
.review-checklist label { display: flex; gap: 10px; align-items: flex-start; font-size: .85rem; cursor: pointer; }
.review-checklist input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; }
.export-check { margin: 18px 0; padding: 18px; border: 1px solid #e3b457; border-radius: 14px; background: #fff8e6; text-align: left; }
.export-check h2 { margin: 0 0 6px; font-size: 1rem; }
.export-check ul { margin: 8px 0; padding-left: 20px; }
.export-check-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 640px) {
  .issue-row { grid-template-columns: auto 1fr; }
  .finding-actions { grid-column: 2; flex-direction: row; flex-wrap: wrap; }
  .chapter-bars li { grid-template-columns: 1fr auto; }
  .chapter-bars .progress-bar { grid-column: 1 / -1; grid-row: 2; }
}

.studio-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 24px; }
.control-card { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: #ffffff; }
.control-card h2 { margin: 0 0 18px; font-size: 1rem; }
.palette-row { display: flex; gap: 8px; }
.swatch { width: 28px; height: 28px; border: 3px solid white; border-radius: 50%; box-shadow: 0 0 0 1px #e1e5e6; cursor: pointer; }
.cover-workbench { display: grid; grid-template-columns: minmax(260px, 430px) 110px; gap: 14px; justify-content: center; }
.cover-controls { display: grid; gap: 10px; margin: 18px 0; }
.cover-controls .field { gap: 4px; }
.cover-controls .suggestion-chips { margin: 0; }
.main-cover { position: relative; aspect-ratio: 2/3; overflow: hidden; border-radius: 12px; background: #122226; box-shadow: var(--shadow-lg); }
.main-cover img { width: 100%; height: 100%; object-fit: cover; }
.main-cover .cover-overlay { padding: 34px 26px 25px; }
.main-cover .cover-overlay strong { font-size: clamp(1.5rem, 3vw, 2.5rem); }
.cover-thumbs, .cover-grid { display: grid; align-content: start; gap: 10px; }
.cover-thumb { position: relative; overflow: hidden; aspect-ratio: 2/3; border: 3px solid transparent; border-radius: 8px; background: #122226; cursor: pointer; }
.cover-thumb.active, .cover-thumb.selected { border-color: var(--primary); }
.cover-thumb img { width: 100%; height: 100%; object-fit: cover; }

.audio-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 30px; }
.audio-book { position: relative; width: 240px; aspect-ratio: 2/3; overflow: hidden; border-radius: 12px; box-shadow: var(--shadow-md); }
.audio-book img { width: 100%; height: 100%; object-fit: cover; }
.voice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.voice-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: white; cursor: pointer; }
.voice-card.selected { border-color: #9ec2cb; background: #f4f8f9; }
.voice-card strong { display: block; font-size: .82rem; }
.voice-card span { color: var(--muted); font-size: .7rem; }
.radio-dot { width: 16px; height: 16px; border: 2px solid #cad1d3; border-radius: 50%; }
.selected .radio-dot { border: 4px solid var(--primary); }
.player { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin: 22px 0; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #ffffff; }
.player-line { height: 5px; border-radius: 99px; background: linear-gradient(90deg, var(--primary) 23%, #eaeded 23%); }

.ready-hero { padding: 28px; border: 1px solid #e5e8e9; border-radius: 18px; background: linear-gradient(135deg, #f4f8f9, #ffffff); text-align: center; }
.ready-hero h1 { margin: 10px 0 4px; font-size: 2rem; }
.export-tabs { display: flex; justify-content: center; gap: 6px; margin: 24px 0 18px; }
.export-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.export-card { padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: #ffffff; text-align: center; }
.file-icon { display: grid; width: 45px; height: 52px; margin: 0 auto 11px; place-items: center; border-radius: 8px 8px 12px 8px; background: #f1f6f7; color: var(--primary); font-weight: 850; font-size: .68rem; }
.export-card h3 { margin: 0 0 3px; font-size: .84rem; }
.export-card p { min-height: 34px; margin: 0 0 13px; color: var(--muted); font-size: .68rem; }
.publish-note { display: flex; gap: 13px; margin-top: 17px; padding: 18px; border: 1px solid #f1dfbb; border-radius: 13px; background: #f5f9fa; text-align: left; }
.publish-note h3 { margin: 0 0 3px; font-size: .84rem; }
.publish-note p { margin: 0; color: #417784; font-size: .75rem; }
.completion-note { align-items: center; border-color: #e5e8e9; background: #ffffff; }
.completion-note > div { flex: 1; }
.completion-note .btn { flex: 0 0 auto; }

/* Dialog and toast */
.dialog-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(15, 27, 30, .58); backdrop-filter: blur(4px); }
.dialog { width: min(520px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 24px; border-radius: 17px; background: #ffffff; box-shadow: var(--shadow-lg); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 20px; }
.dialog-head h2 { margin: 0 0 4px; font-size: 1.2rem; }
.dialog-head p { margin: 0; color: var(--muted); font-size: .78rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.character-details { padding: 14px; border: 1px solid #e6eaeb; border-radius: 11px; background: #f9fbfb; }
.character-details summary { color: #2c525b; cursor: pointer; font-size: .8rem; font-weight: 750; }
.character-details summary span { margin-left: 5px; color: var(--muted); font-weight: 500; }
.character-details[open] summary { margin-bottom: 14px; }
.conflict-dialog { width: min(760px, 100%); }
.conflict-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.conflict-pane { min-width: 0; }
.conflict-pane h3 { margin: 0 0 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.conflict-text { height: 150px; overflow-y: auto; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #f9fbfb; font-size: .82rem; line-height: 1.55; white-space: pre-wrap; }
.toast-region { position: fixed; z-index: 200; right: 22px; bottom: 22px; display: grid; gap: 9px; }
.toast { display: flex; width: min(360px, calc(100vw - 44px)); align-items: center; gap: 10px; padding: 13px 15px; border: 1px solid rgba(255, 255, 255,.12); border-radius: 12px; background: #182d32; color: white; box-shadow: var(--shadow-md); font-size: .8rem; animation: toast-in 220ms ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes pulse { 50% { opacity: .55; } }
.thinking { animation: pulse 1s ease infinite; }

@media (max-width: 1080px) {
  :root { --sidebar: 205px; }
  .book-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .editor-shell { grid-template-columns: 175px minmax(0, 1fr); }
  /* The panel is pinned to the screen here, so it has to scroll itself: without
     this, everything below the screen's edge — the answer included — was unreachable. */
  .ai-panel { position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: 300px; max-width: 100vw; overflow-y: auto; overscroll-behavior: contain; box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform 200ms ease; }
  .ai-panel .ai-result { max-height: none; }
  .ai-panel.open { transform: translateX(0); }
  .showcase { gap: 30px; }
}

@media (max-width: 820px) {
  .landing-nav-links { display: none; }
  .hero { min-height: 700px; }
  .feature-grid { grid-template-columns: 1fr 1fr; }
  .showcase { grid-template-columns: 1fr; }
  .cover-fan { width: min(500px, 100%); margin: auto; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .plans { grid-template-columns: 1fr; }
  .plan-list { min-height: 0; }
  .plan-heading { align-items: flex-start; flex-direction: column; }
  .onboarding-body { grid-template-columns: 1fr; }
  .onboarding-art { display: none; }
  .onboarding-split { grid-template-columns: 1fr; }
  .onboarding-visual { min-height: 300px; }
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; visibility: hidden; transform: translateX(-105%); box-shadow: var(--shadow-lg); transition: visibility 0s linear 200ms, transform 200ms ease; }
  .sidebar.open { visibility: visible; transform: translateX(0); transition-delay: 0s; }
  .sidebar.open .sidebar-close { display: grid; margin: -8px -4px 12px 0; }
  .sidebar-is-open .mobile-nav-open { visibility: hidden; }
  .mobile-top { position: sticky; top: 0; z-index: 20; display: flex; height: 60px; padding: 0 15px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255,.92); backdrop-filter: blur(14px); }
  .page { padding: 25px 20px 60px; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wizard-layout, .flow-layout { display: block; }
  .wizard-stepper { display: none; }
  .wizard-top { justify-content: space-between; }
  .flow-layout > .wizard-stepper { display: none; }
  .flow-content { padding: 24px 18px 70px; }
  .book-details-layout { grid-template-columns: 1fr; }
  .detail-cover { display: none; }
  .editor-shell { grid-template-columns: 1fr; }
  /* Hidden, not just moved: a closed drawer's links must not take keyboard focus. */
  .editor-nav { position: fixed; inset: 0 auto 0 0; z-index: 45; width: 230px; visibility: hidden; transform: translateX(-105%); transition: visibility 0s linear 200ms, transform 200ms ease; }
  .editor-nav.open { visibility: visible; transform: translateX(0); transition-delay: 0s; }
  .editor-nav.open .editor-nav-close { display: grid; }
  /* The actions wrap to a second row on narrow screens; a fixed height clipped them. */
  .editor-top { height: auto; min-height: 62px; padding: 8px 12px; gap: 8px; }
  .editor-top .page-actions { justify-content: flex-end; align-items: center; }
  .paper { padding: 40px 35px; }
  .analysis-grid, .studio-grid, .audio-layout { grid-template-columns: 1fr; }
  .audio-book { width: 200px; margin: auto; }
  .export-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .landing-nav { height: 68px; padding: 0 17px; }
  .landing-actions .sign-in { display: none; }
  .hero { min-height: 680px; padding-inline: 17px; }
  .hero h1 { font-size: 2.65rem; }
  .hero-books { gap: 6px; margin-top: 35px; }
  .hero-book { width: 19%; border-radius: 5px; }
  .hero-book figcaption { display: none; }
  .landing-section { padding: 70px 18px; }
  .feature-grid { grid-template-columns: 1fr; }
  .cover-fan { min-height: 380px; }
  .cover-fan .cover { width: 190px; }
  .cover-fan .cover:nth-child(2) { left: 35%; }
  .footer-inner { align-items: flex-start; flex-direction: column; gap: 16px; }
  .auth-panel { padding: 36px 20px; }
  .center-page { padding: 16px; }
  .center-card, .onboarding-card { padding: 26px 20px; }
  .onboarding-form { padding: 18px; }
  .onboarding-card h1 { font-size: 1.8rem; }
  .form-two { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .book-grid { grid-template-columns: 1fr; }
  .new-book-card { min-height: 150px; }
  .activity-row { grid-template-columns: 34px 1fr; }
  .activity-row time { grid-column: 2; }
  .chat-shell { width: 100%; height: calc(100vh - 80px); margin: 0; border: 0; border-radius: 0; }
  .messages { padding: 20px 14px; }
  .message-bubble { max-width: 84%; }
  .prompt-library { width: 100%; margin: 0; padding: 20px 14px 36px; border: 0; border-top: 1px solid var(--line); border-radius: 0; }
  .prompt-library-head { flex-direction: column; }
  .prompt-library-head .select { width: 100%; }
  .start-choice { width: 100%; grid-template-columns: 1fr; margin: 0; }
  .start-choice-three, .start-choice-four { grid-template-columns: 1fr; }
  .interview-input { flex-direction: column; align-items: stretch; }
  .flow-header { align-items: flex-start; flex-direction: column; }
  .person-row, .chapter-row { grid-template-columns: auto 1fr; }
  /* Only these rows: unscoped, it pushed the buttons of every grid form into a second column. */
  .person-row > .row-actions, .chapter-row > .row-actions { grid-column: 2; }
  .editor-scroll { padding: 18px 10px 60px; }
  .paper { min-height: calc(100vh - 205px); padding: 32px 24px; }
  .editor-toolbar { overflow-x: auto; }
  .cover-workbench { grid-template-columns: 1fr; }
  .cover-thumbs { grid-template-columns: repeat(2, 1fr); }
  .voice-grid { grid-template-columns: 1fr; }
  .export-grid { grid-template-columns: 1fr; }
  .completion-note { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  body { background: white; }
  .sidebar, .mobile-top, .editor-nav, .editor-top, .editor-toolbar, .editor-statusbar, .ai-panel { display: none !important; }
  .editor-shell, .editor-workspace { display: block; height: auto; }
  .editor-scroll { overflow: visible; padding: 0; }
  .paper { width: 100%; min-height: 0; padding: 0; border: 0; box-shadow: none; }
}

.ai-model-field { padding: 0 16px; margin-bottom: 4px; }
.ai-model-field label { font-size: .68rem; }

/* Scene board and story changes (FR-09) */
.board-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 260px)); gap: 10px; margin: 12px 0; }
.scene-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.board-column { flex: 0 0 240px; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.board-column h3 { margin: 0 0 8px; font-size: .82rem; }
.board-cards { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.board-card { padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #ffffff; }
.board-card.is-selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(33, 63, 70, .15); }
.board-card p { margin: 6px 0 0; overflow-wrap: anywhere; }
.board-card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; }
.board-card-title { font-weight: 700; text-align: left; }
.board-meta { display: grid; gap: 2px; margin: 6px 0 0; font-size: .75rem; }
.board-meta div { display: flex; gap: 4px; }
.board-meta dt { color: var(--muted); }
.board-meta dt::after { content: ":"; }
.board-meta dd { margin: 0; overflow-wrap: anywhere; }
.board-form { margin-top: 16px; }
.story-changes { margin-top: 16px; }
.change-list { display: grid; gap: 6px; margin: 0 0 12px; padding-left: 18px; }
.change-list [aria-pressed="true"] { font-weight: 800; }
.change-new { margin-top: 14px; }
.change-new summary { cursor: pointer; font-weight: 700; font-size: .85rem; }
.change-detail { margin: 12px 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.change-detail h3 { margin: 0; font-size: .95rem; }
.change-passage.is-done, .change-passage.is-unaffected { opacity: .72; }
.change-passage .finding-actions { display: grid; gap: 6px; justify-items: end; }
@media (max-width: 560px) {
  .scene-board { flex-direction: column; overflow-x: visible; }
  .board-column { flex-basis: auto; }
  .change-passage { grid-template-columns: auto 1fr; }
  .change-passage .finding-actions { grid-column: 1 / -1; justify-items: start; }
}

/* Source ledger (FR-10) */
.ledger-source { margin: 8px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.ledger-source summary { cursor: pointer; overflow-wrap: anywhere; }
.ledger-source[open] summary { margin-bottom: 8px; }
.ledger-reference { overflow-wrap: anywhere; }
.ledger-claims { margin-top: 16px; }
.ledger-claims .segmented { margin: 8px 0; }
.ledger-gaps { margin: 6px 0; padding-left: 18px; color: var(--muted); font-size: .8rem; }
.ledger-claim.is-supported .issue-dot { background: var(--primary-soft); }
.ledger-claim-edit summary { cursor: pointer; font-size: .8rem; font-weight: 700; margin-top: 6px; }
.ledger-linked { border-left-style: dashed; }

/* Beta-reader links (FR-11) */
.beta-shares .beta-share { margin: 10px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.beta-link { margin: 12px 0; padding: 14px; border: 2px solid var(--primary); border-radius: 12px; background: var(--primary-soft); }
.beta-link h3 { margin: 0 0 6px; font-size: .95rem; }
.beta-link-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.beta-link-row .input { flex: 1 1 220px; min-width: 0; }
.beta-feedback { margin-top: 10px; }
.beta-feedback h4 { margin: 12px 0 4px; font-size: .85rem; }
.beta-answer { padding: 8px 0; border-top: 1px solid var(--line); }
.beta-reader { max-width: 760px; margin: 0 auto; padding: 32px 20px 64px; }
.beta-head { margin-bottom: 24px; }
.beta-head h1 { margin: 4px 0 8px; }
.beta-name { max-width: 360px; margin-top: 12px; }
.beta-chapter { margin: 28px 0; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: #ffffff; }
.beta-chapter h2 { margin: 0 0 12px; }
.beta-text { font-family: Literata, Georgia, "Times New Roman", serif; font-size: 1.08rem; line-height: 1.7; overflow-wrap: anywhere; }
.beta-comment { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.beta-comment-title { margin: 0; font-size: .9rem; }
.beta-questions { margin: 28px 0; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: #ffffff; }
.beta-questions h2 { margin: 0 0 12px; }
@media (max-width: 560px) { .beta-reader { padding: 20px 16px 48px; } .beta-chapter, .beta-questions { padding: 16px; } }

/* Series canon (FR-13) */
.series-grid { display: grid; gap: 16px; }
.series-page .suggestions-card { margin-top: 16px; }
.series-books { display: grid; gap: 6px; margin: 0; padding-left: 0; list-style: none; }
.series-book { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); overflow-wrap: anywhere; }
.series-add-book, .series-rename { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-top: 12px; }
.series-add-book label, .series-rename label { flex-basis: 100%; font-size: .8rem; font-weight: 700; }
.series-add-book .input, .series-rename .input { flex: 1 1 220px; min-width: 0; }
.series-view-entry { padding: 12px 0; border-top: 1px solid var(--line); }
.series-view-entry h3 { margin: 2px 0 4px; font-size: .95rem; }
.series-view-entry.is-omitted h3 { text-decoration: line-through; color: var(--muted); }

/* Translations (FR-14) */
.translate-page .suggestions-card { margin-top: 16px; }
.translation-export { margin: 14px 0; }
.translation-export h3 { margin: 0 0 6px; font-size: .9rem; }
.translation-review .translation-head { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; font-size: .75rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); }
.translation-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.translation-row .finding-meta { margin: 0 0 3px; font-size: .68rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; }
.translation-row.is-approved .translation-source .finding-meta { color: var(--primary); }
.translation-source p:last-child { margin: 0; overflow-wrap: anywhere; }
.translation-target { display: grid; gap: 6px; }
.translation-save { position: sticky; bottom: 0; padding: 10px 0; background: #ffffff; }
.translation-outdated { margin: 10px 0; }
.translation-outdated summary { cursor: pointer; font-weight: 700; font-size: .85rem; }
@media (max-width: 720px) {
  .translation-review .translation-head { display: none; }
  .translation-row { grid-template-columns: 1fr; gap: 6px; }
}

/* ---- FR-20 Simple mode ---- */
.start-choice-modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.start-method-primary { border-color: var(--primary); box-shadow: var(--shadow-md); }
.rich-input { width: 100%; min-height: 180px; max-height: 60vh; overflow-y: auto; border: 1px solid var(--control-border, #ced5d7); border-radius: 10px; background: #ffffff; color: var(--ink); padding: 12px 14px; line-height: 1.6; transition: border-color 150ms ease, box-shadow 150ms ease; }
.rich-input:empty::before { content: attr(data-placeholder); color: var(--muted); }
.rich-input:focus { border-color: #1c6679; outline: none; box-shadow: 0 0 0 4px rgba(28, 102, 121, 0.18); }
/* FR-21 "Other": the Brief's description box shows only for that type; the kit reads as a list. */
[data-type-description][hidden] { display: none; }
.kit-card .kit-preview { margin-top: 16px; padding: 16px; border: 1px solid var(--control-border, #ced5d7); border-radius: 10px; }
.kit-grid { display: grid; gap: 10px; margin: 12px 0; }
.kit-grid > div { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 12px; }
.kit-grid dt { font-weight: 600; }
.kit-grid dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kit-tools { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
@media (max-width: 640px) { .kit-grid > div { grid-template-columns: 1fr; gap: 2px; } }
.rich-input[aria-invalid="true"] { border-color: var(--danger); }
.flow-details { margin-top: 4px; }
.flow-details > summary { cursor: pointer; font-weight: 600; }
.flow-details[open] > summary { margin-bottom: 14px; }
.notice { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: 10px; background: var(--primary-soft, #eef4f6); color: var(--ink); font-size: .85rem; line-height: 1.55; }
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.notice-warn { border-left-color: var(--warning); background: #fff8ec; }
.notice-error { border-color: var(--danger); border-left-color: var(--danger); background: #fdf0f1; color: var(--danger); font-weight: 600; }
.scope-card { margin-top: 18px; }
.scope-card h2 { margin: 0 0 12px; }
.scope-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; margin: 0 0 14px; }
.scope-grid dt { color: var(--muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.scope-grid dd { margin: 3px 0 0; }
.scope-list, .draft-units, .outline-list { margin: 0 0 14px; padding-left: 20px; line-height: 1.6; }
.outline-list li, .draft-units li { margin-bottom: 6px; }
.step-list { margin: 14px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.step-list .step-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .85rem; }
.step-name { flex: 1 1 140px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .78rem; }
.step-state { color: var(--muted); }
.step-row.step-done .step-state { color: var(--success, #1c6679); font-weight: 600; }
.step-row.step-in_flight .step-state { color: var(--primary); font-weight: 600; }
.step-row.step-failed .step-state, .step-row.step-uncertain .step-state, .step-row.step-stale .step-state { color: var(--danger); font-weight: 600; }
.step-error { flex-basis: 100%; color: var(--danger); font-size: .78rem; }
@media (max-width: 640px) {
  .start-choice-modes, .scope-grid { grid-template-columns: minmax(0, 1fr); }
  .flow-content .flow-actions, .center-card .flow-actions { flex-wrap: wrap; gap: 10px; }
  .flow-content .flow-actions .btn, .center-card .flow-actions .btn { flex: 1 1 100%; justify-content: center; }
}

/* ---- Tools and checks per book type ---- */
.ai-type-tools { display: grid; gap: 6px; padding: 12px 15px 16px; border-top: 1px dashed var(--line); }
.ai-type-tools > p { margin: 0 0 2px 5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.type-check-list { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.type-check { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--warning); border-radius: 10px; background: #ffffff; }
.type-check strong { flex: 1 1 100%; font-size: .88rem; }
.type-check-ok { border-left-color: var(--success, #1c6679); }
