:root {
  --black: #0a0a0b;
  --near-black: #141416;
  --panel: #1b1b1e;
  --red: #c81424;
  --red-dark: #8f0e19;
  --cream: #f3efe8;
  --paper: #fffdf9;
  --ink: #1d1a18;
  --muted: #746e69;
  --line: #dcd5ce;
  --white: #ffffff;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-height: 100%; background: var(--black); }
body { min-height: 100vh; margin: 0; background: var(--cream); color: var(--ink); }
button, textarea, input { font: inherit; }
a { color: inherit; }

.login-page {
  display: grid;
  place-items: center;
  padding: 32px 18px;
  background:
    radial-gradient(circle at 15% 10%, rgba(200, 20, 36, 0.24), transparent 35%),
    linear-gradient(145deg, #050506, #17171a 70%, #080809);
}

.login-shell { width: min(100%, 520px); }
.login-card {
  padding: clamp(32px, 7vw, 58px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 15, 17, 0.94);
  color: var(--white);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.2em;
}

h1, h2 { font-family: Georgia, "Times New Roman", serif; }
h1 { margin: 0; font-size: clamp(2.5rem, 8vw, 4.5rem); line-height: 0.96; }
h2 { font-size: clamp(1.7rem, 4vw, 2.4rem); }

.login-copy { margin: 24px 0 30px; color: #d2ced0; font-size: 1.05rem; line-height: 1.7; }
.auth-actions { display: grid; gap: 12px; }

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: 0.65; transform: none; }
.button-primary { background: var(--red); color: var(--white); }
.button-primary:hover { background: var(--red-dark); }
.button-secondary { border-color: rgba(255, 255, 255, 0.25); background: transparent; color: var(--white); }
.button-secondary:hover { border-color: var(--white); }
.button-neutral { border-color: #b7ada5; background: transparent; color: var(--ink); }
.button-neutral:hover { border-color: var(--ink); background: rgba(29, 26, 24, 0.05); }
.button.compact { min-height: 40px; padding: 9px 14px; font-size: 0.9rem; }

.text-link { font-weight: 700; text-underline-offset: 3px; }
.signed-in-copy, .status-message { margin: 0; }
.privacy-note { margin: 26px 0 0; color: #9f999d; font-size: 0.78rem; line-height: 1.6; }
.status-message { min-height: 1.4em; color: #bdb7ba; font-size: 0.9rem; }

.auth-loading {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px 18px;
  background: var(--cream);
  color: var(--muted);
  font-weight: 800;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  padding: 14px clamp(18px, 4vw, 54px);
  background: var(--black);
  color: var(--white);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.brand { min-width: 0; font-weight: 900; letter-spacing: 0.08em; overflow-wrap: anywhere; text-decoration: none; }
.brand span { margin-left: 8px; color: #aaa4a7; font-weight: 500; letter-spacing: normal; }
.header-actions { display: flex; flex: 0 0 auto; min-width: 0; align-items: center; gap: 16px; font-size: 0.88rem; }
.reader-label { color: #c8c2c5; }

.theme-toggle {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 8px 10px;
  background: transparent;
  color: var(--white);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}
.theme-toggle:hover { border-color: rgba(255, 255, 255, 0.7); background: rgba(255, 255, 255, 0.08); }
.theme-toggle:focus-visible { outline: 2px solid var(--white); outline-offset: 2px; }
.theme-icon { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.theme-icon-moon { fill: currentColor; stroke: none; }
html[data-theme="light"] .theme-icon-sun, html[data-theme="dark"] .theme-icon-moon { display: none; }

.reader-page, .library-page, .listen-page {
  --reader-canvas: #e9e3dc;
  --reader-paper: #fffdf9;
  --reader-raised: #ffffff;
  --reader-subtle: #f7f2ec;
  --reader-ink: #1d1a18;
  --reader-muted: #746e69;
  --reader-line: #dcd5ce;
  --reader-input: #ffffff;
  --reader-neutral-border: #b7ada5;
  --reader-neutral-hover: rgba(29, 26, 24, 0.05);
  --reader-shadow: var(--shadow);
  background: var(--reader-canvas);
  color: var(--reader-ink);
}

html[data-theme="dark"] .reader-page, html[data-theme="dark"] .library-page, html[data-theme="dark"] .listen-page {
  --reader-canvas: #0d0d0f;
  --reader-paper: #171719;
  --reader-raised: #202023;
  --reader-subtle: #1c1c1f;
  --reader-ink: #eeeae5;
  --reader-muted: #b8b0aa;
  --reader-line: #3b393b;
  --reader-input: #111113;
  --reader-neutral-border: #6b6562;
  --reader-neutral-hover: rgba(255, 255, 255, 0.07);
  --reader-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.library-page .auth-loading, .listen-page .auth-loading { background: var(--reader-canvas); color: var(--reader-muted); }

/* Keep the listening experience locked to the viewport like an app. */
html:has(body.listen-page),
body.listen-page {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
.listen-page .site-header,
.listen-page .listen-shell,
.listen-page .audio-player-card { max-width: 100%; }

.library-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 100px; }
.library-intro { display: flex; align-items: end; justify-content: space-between; gap: 36px; border-bottom: 1px solid var(--reader-line); padding-bottom: 26px; }
.library-intro h1 { color: var(--reader-ink); overflow-wrap: anywhere; }
.library-intro > p:last-child { max-width: 470px; margin: 0; color: var(--reader-muted); font-size: 1rem; line-height: 1.65; }
.library-status { margin: 34px 0 0; color: var(--reader-muted); font-weight: 800; }
.library-status:empty { display: none; }
.library-dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(280px, .8fr); align-items: start; gap: 28px; margin-top: 32px; }
.library-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.library-section-heading h2 { margin: 0; color: var(--reader-ink); }
.library-section-heading > p { max-width: 390px; margin: 0; color: var(--reader-muted); line-height: 1.5; text-align: right; }
.library-books-panel { min-width: 0; }
.book-grid { display: grid; grid-template-columns: 1fr; gap: 18px; margin-top: 18px; }
.book-card { overflow: hidden; border: 1px solid var(--reader-line); border-radius: 14px; background: var(--reader-raised); box-shadow: var(--reader-shadow); }
.book-card-layout { display: grid; grid-template-columns: 180px minmax(0, 1fr); min-height: 270px; }
.cover-placeholder {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: flex-end;
  padding: 24px 20px;
  background:
    linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.82)),
    radial-gradient(circle at 45% 20%, #84111b, #12090b 65%);
  color: var(--white);
}
.cover-author { overflow-wrap: anywhere; font-size: 0.6rem; font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase; }
.book-details { display: flex; min-width: 0; flex-direction: column; align-items: flex-start; justify-content: center; padding: 28px; }
.book-details h2 { max-width: 100%; margin: 4px 0 10px; overflow-wrap: anywhere; }
.book-details p { color: var(--reader-muted); line-height: 1.6; }
.book-card-labels { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.availability { margin: 0; color: var(--red) !important; font-size: 0.76rem; font-weight: 900; letter-spacing: 0.1em; text-transform: uppercase; }
.round-stage-label { margin: 0; border-left: 1px solid var(--reader-line); padding-left: 12px; color: var(--reader-muted) !important; font-size: 0.72rem; font-weight: 900; text-transform: uppercase; }
.book-card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.book-card-actions .button { margin: 0; }
.library-page .book-card-actions .button-neutral { border-color: var(--reader-neutral-border); color: var(--reader-ink); }
.book-card.unavailable { box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2); }
.book-card.unavailable .availability { color: var(--reader-muted) !important; }
.book-closed-note { color: var(--reader-muted); font-size: 0.78rem; font-weight: 800; }

.library-profile-card { position: sticky; top: 96px; min-width: 0; border: 1px solid var(--reader-line); border-radius: 14px; padding: 26px; background: var(--reader-raised); box-shadow: var(--reader-shadow); }
.library-profile-photo-wrap { margin-bottom: 20px; }
.library-profile-photo, .library-profile-placeholder { width: 88px; height: 88px; border-radius: 50%; }
.library-profile-photo { border: 3px solid var(--red); object-fit: cover; }
.library-profile-placeholder { display: grid; place-items: center; background: var(--near-black); color: var(--white); font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-weight: 900; }
.library-profile-card h2 { margin: 0; color: var(--reader-ink); overflow-wrap: anywhere; }
.library-profile-contact { margin: 14px 0 0; color: var(--reader-muted); line-height: 1.55; }
.library-profile-details { display: grid; gap: 12px; margin: 22px 0; }
.library-profile-details div { border-top: 1px solid var(--reader-line); padding-top: 10px; }
.library-profile-details dt { color: var(--reader-muted); font-size: 0.68rem; font-weight: 900; letter-spacing: 0.07em; text-transform: uppercase; }
.library-profile-details dd { margin: 4px 0 0; color: var(--reader-ink); overflow-wrap: anywhere; font-size: 0.86rem; font-weight: 800; }
.library-profile-card .button { width: 100%; }
.library-page .library-profile-card .button-neutral { border-color: var(--reader-neutral-border); color: var(--reader-ink); }
.library-profile-privacy { margin: 14px 0 0; color: var(--reader-muted); font-size: 0.72rem; line-height: 1.5; }

.reader-shell { width: min(940px, calc(100% - 28px)); margin: 0 auto; padding: 32px 0 100px; }
.reader-nav { margin-bottom: 18px; }
.back-link { font-weight: 800; text-decoration: none; }
.chapter-card { overflow: hidden; background: var(--reader-paper); box-shadow: var(--reader-shadow); }
.chapter-heading { min-width: 0; padding: clamp(34px, 7vw, 72px) clamp(24px, 8vw, 92px) 30px; border-bottom: 1px solid var(--reader-line); }
.chapter-heading-centered { text-align: center; }
.chapter-heading-centered .eyebrow { justify-content: center; }
.chapter-heading .eyebrow, .chapter-heading .chapter-note { overflow-wrap: anywhere; }
.chapter-heading h1 { max-width: 100%; color: var(--reader-ink); font-size: clamp(2.2rem, 7vw, 5.3rem); overflow-wrap: anywhere; }
.chapter-heading-centered h1 { line-height: 1.06; }
.chapter-point-of-view { margin: 20px 0 0; color: var(--reader-muted); font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.1rem, 3vw, 1.45rem); font-style: italic; line-height: 1.35; }
.chapter-note { max-width: 700px; margin: 22px auto 0; color: var(--reader-muted); line-height: 1.7; }
.loading-state { padding: 80px 30px; text-align: center; color: var(--reader-muted); }
.chapter-content { padding: 34px clamp(18px, 7vw, 74px) 56px; }
.paragraph-block { padding: 10px 0; }
.paragraph-row { position: relative; min-height: 42px; padding-right: 104px; }
.chapter-paragraph { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.08rem, 2.2vw, 1.28rem); line-height: 1.9; }
.reader-page:not(.preview-page) .chapter-paragraph { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.paragraph-comment-toggle {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  gap: 2px;
  min-width: 82px;
  border: 0;
  padding: 8px;
  background: transparent;
  color: var(--reader-muted);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 800;
}
.paragraph-comment-toggle:hover, .paragraph-comment-toggle[aria-expanded="true"] { color: var(--red); }
.paragraph-comment-toggle:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.paragraph-comment-icon { line-height: 1; }
.paragraph-comment-plus, .paragraph-comment-mobile-icon, .paragraph-comment-badge { display: none; }
.paragraph-comment-toggle.no-comments {
  display: flex;
  width: 2.25rem;
  height: 2.25rem;
  min-width: 0;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--reader-line);
  color: #979391;
  font-size: 1.25rem;
  line-height: 1;
}
.paragraph-comment-toggle.no-comments:not(:hover):not(:focus-visible) { opacity: 0.58; }
html[data-theme="dark"] .paragraph-comment-toggle.no-comments { color: #858186; }
.paragraph-comment-toggle.no-comments .paragraph-comment-plus { display: block; }
.paragraph-comment-panel { margin: 20px 0 6px; border-left: 3px solid var(--red); padding: 4px 0 4px 22px; }

.comment-form { display: grid; gap: 10px; margin-top: 22px; }
.comment-form label { font-size: 0.9rem; font-weight: 800; }
.comment-form textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--reader-line);
  border-radius: 0;
  padding: 12px;
  background: var(--reader-input);
  color: var(--reader-ink);
  line-height: 1.5;
}
.comment-form textarea:focus { outline: 2px solid rgba(200, 20, 36, 0.25); border-color: var(--red); }
.form-footer { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.form-actions { display: flex; gap: 10px; }
.reader-page .button-neutral { border-color: var(--reader-neutral-border); color: var(--reader-ink); }
.reader-page .button-neutral:hover { border-color: var(--reader-ink); background: var(--reader-neutral-hover); }
.character-note { color: var(--reader-muted); font-size: 0.75rem; }
.comment-list { display: grid; gap: 12px; }
.comment-item { border: 1px solid var(--reader-line); padding: 14px 16px; background: var(--reader-raised); }
.comment-item.mine { border-left: 4px solid var(--red); }
.comment-meta { display: flex; justify-content: space-between; gap: 16px; color: var(--reader-muted); font-size: 0.76rem; }
.comment-meta strong { color: var(--reader-ink); }
.comment-item p { margin: 8px 0 0; white-space: pre-wrap; line-height: 1.55; }
.empty-comments { margin: 0; color: var(--reader-muted); font-style: italic; }

.reaction-section, .chapter-comments-section { padding: 44px clamp(24px, 8vw, 92px); border-top: 1px solid var(--reader-line); }
.reaction-section { background: var(--near-black); color: var(--white); }

.reaction-section h2, .chapter-comments-section h2 { margin: 0 0 14px; }
.reaction-instructions { margin: 0 0 24px; color: #c9c3c6; line-height: 1.5; }
.reaction-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.reaction-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  border: 1px solid #555156;
  padding: 10px 14px;
  background: #242427;
  color: var(--white);
  cursor: pointer;
}
.reaction-button:hover, .reaction-button.selected { border-color: var(--red); background: #3a171b; }
.reaction-button:focus-visible { outline: 3px solid rgba(255, 255, 255, 0.75); outline-offset: 2px; }
.reaction-button:disabled { cursor: wait; opacity: 0.65; }
.reaction-emoji { font-size: 1.45rem; }
.reaction-label { font-weight: 800; }
.reaction-count { min-width: 1.7em; border-left: 1px solid #555156; padding-left: 8px; color: #d2cccf; font-weight: 900; text-align: center; }
.reaction-button.selected .reaction-count { border-color: #803039; }
.reaction-section .status-message { margin-top: 14px; }
.chapter-comments-section { background: var(--reader-subtle); }
.chapter-comments-section > .comment-list { margin-top: 30px; }
.chapter-navigation {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border-top: 1px solid var(--reader-line);
  background: var(--reader-line);
}
.chapter-navigation-link, .chapter-navigation-end {
  display: flex;
  min-height: 112px;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 24px clamp(24px, 6vw, 52px);
  background: var(--reader-paper);
}
.chapter-navigation-link {
  color: var(--reader-ink);
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease;
}
.chapter-navigation-link:hover { background: var(--reader-raised); color: var(--red); }
.chapter-navigation-link:focus-visible { z-index: 1; outline: 3px solid var(--red); outline-offset: -3px; }
.chapter-navigation-link.previous { grid-column: 1; align-items: flex-start; }
.chapter-navigation-link.next { grid-column: 2; align-items: flex-end; text-align: right; }
.chapter-navigation.only-next .chapter-navigation-link.next { grid-column: 1 / -1; }
.chapter-navigation.only-end .chapter-navigation-end { grid-column: 1 / -1; align-items: center; text-align: center; }
.chapter-navigation-direction, .chapter-navigation-end span {
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.chapter-navigation-link strong, .chapter-navigation-end strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.2rem, 3vw, 1.55rem);
}
.chapter-navigation-end { grid-column: 2; align-items: flex-end; color: var(--reader-muted); text-align: right; }
.chapter-navigation-end span { color: var(--reader-muted); }
.dnf-section { border-top: 1px solid var(--reader-line); padding: 28px clamp(24px, 8vw, 92px); background: var(--reader-subtle); }
.dnf-state { display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.dnf-state h2 { margin: 3px 0 8px; color: var(--reader-ink); font-size: clamp(1.45rem, 3vw, 1.9rem); }
.dnf-state p:last-child { max-width: 640px; margin: 0; color: var(--reader-muted); line-height: 1.55; }
.danger-button { border-color: #a84f58 !important; color: #9f101c !important; }
html[data-theme="dark"] .danger-button { border-color: #a85a62 !important; color: #ff8992 !important; }
.error-message { margin: 0; padding: 0 24px 34px; color: #a40c19; font-weight: 800; }
html[data-theme="dark"] .reader-page .error-message { color: #ff7782; }

@media (max-width: 650px) {
  .brand span, .reader-label { display: none; }
  .site-header { padding-inline: 16px; }
  .header-actions { gap: 10px; }
  .theme-toggle { width: 40px; padding: 8px; justify-content: center; }
  .theme-toggle span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .book-card-layout { grid-template-columns: 1fr; min-height: 0; }
  .chapter-content { padding-right: 42px; }
  .paragraph-row { min-height: 0; padding-right: 0; }
  .paragraph-comment-toggle {
    top: auto;
    right: -34px;
    bottom: 0;
    display: flex;
    width: 2.25rem;
    height: 2.25rem;
    min-width: 0;
    align-items: center;
    justify-content: center;
    padding: 0;
  }
  .paragraph-comment-icon, .paragraph-comment-label { display: none; }
  .paragraph-comment-toggle.no-comments { border-color: transparent; }
  .paragraph-comment-mobile-icon {
    position: relative;
    display: block;
    width: 1.05rem;
    height: 0.8rem;
    border: 1.5px solid currentColor;
    border-radius: 0.42rem;
  }
  .paragraph-comment-mobile-icon::after {
    position: absolute;
    right: 0.08rem;
    bottom: -0.25rem;
    width: 0.35rem;
    height: 0.35rem;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    background: var(--reader-paper);
    content: "";
    transform: skewY(35deg);
  }
  .paragraph-comment-badge {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    min-width: 1rem;
    height: 1rem;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0 0.2rem;
    background: var(--red);
    color: var(--white);
    font-size: 0.62rem;
    font-weight: 900;
    line-height: 1;
  }
  .paragraph-comment-panel { padding-left: 14px; }
  .dnf-state { align-items: flex-start; flex-direction: column; }
  .chapter-navigation-link, .chapter-navigation-end { min-height: 96px; padding: 20px 18px; }
  .chapter-navigation-direction, .chapter-navigation-end span { font-size: 0.62rem; }
  .chapter-navigation-link strong, .chapter-navigation-end strong { font-size: 1.05rem; }
  .form-footer, .comment-meta { align-items: flex-start; flex-direction: column; }
  .form-actions { width: 100%; }
  .form-actions .button { flex: 1; }
}

.field-label {
  color: #d8d3d6;
  font-size: 0.86rem;
  font-weight: 800;
}

.code-input {
  width: 100%;
  min-height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 0;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--white);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.code-input::placeholder { color: #777176; }
.code-input:focus { outline: 2px solid rgba(200, 20, 36, 0.5); border-color: var(--red); }

.text-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button.light { color: var(--white); }

.admin-auth-state { color: #d2ced0; line-height: 1.6; }
.admin-auth-state p { margin-top: 0; }
.admin-page { background: #e9e3dc; }
.admin-page h3, .admin-page h4 { font-family: Georgia, "Times New Roman", serif; }
.admin-shell { width: min(1240px, calc(100% - 36px)); margin: 0 auto; padding: 64px 0 110px; }
.admin-intro { max-width: 820px; }
.admin-intro h1 { max-width: 100%; color: var(--black); font-size: clamp(2.5rem, 7vw, 5rem); overflow-wrap: anywhere; }
.admin-intro > p:last-child { margin: 20px 0 0; color: var(--muted); font-size: 1.08rem; line-height: 1.7; }
.foundation-card { margin-top: 38px; padding: clamp(24px, 4vw, 38px); background: var(--paper); box-shadow: var(--shadow); }
.foundation-card h2 { margin: 0; }
.admin-summary-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; }
.foundation-message { max-width: 560px; margin: 0; color: var(--muted); line-height: 1.6; }
.foundation-counts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; margin: 28px 0 0; background: var(--line); }
.foundation-counts div { padding: 16px; background: var(--white); }
.foundation-counts dt { color: var(--muted); font-size: 0.68rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.foundation-counts dd { margin: 6px 0 0; color: var(--black); font-family: Georgia, "Times New Roman", serif; font-size: 1.8rem; font-weight: 800; }

.admin-notice, .admin-error { margin: 24px 0 0; border-left: 4px solid; padding: 14px 18px; background: var(--paper); font-weight: 800; line-height: 1.5; }
.admin-notice { border-color: #217a45; color: #155a32; }
.admin-error { min-height: 0; border-color: transparent; padding-block: 0; background: transparent; color: #a40c19; }
.admin-error:empty { display: none; }

.admin-tabs { display: flex; gap: 4px; margin-top: 42px; border-bottom: 1px solid #bfb6ae; }
.admin-tab { min-height: 52px; border: 0; border-bottom: 4px solid transparent; padding: 12px 20px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 900; }
.admin-tab:hover { color: var(--black); }
.admin-tab.active { border-color: var(--red); color: var(--black); }
.admin-tab:focus-visible { outline: 3px solid rgba(200, 20, 36, 0.3); outline-offset: 2px; }

.admin-panel { padding-top: 34px; }
.admin-panel-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; }
.admin-panel-heading h2 { margin: 0; color: var(--black); font-size: clamp(2rem, 5vw, 3rem); }
.admin-panel-heading > div > p:last-child { max-width: 760px; margin: 12px 0 0; color: var(--muted); line-height: 1.65; }

.admin-editor { margin-top: 28px; border-top: 5px solid var(--red); padding: clamp(24px, 4vw, 38px); background: var(--paper); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.15); }
.admin-editor-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.admin-editor-heading h3 { margin: 0; color: var(--black); font-size: clamp(1.7rem, 4vw, 2.3rem); }
.admin-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.admin-field { display: grid; align-content: start; gap: 8px; }
.admin-field > span, .admin-fieldset legend { color: #2c2724; font-size: 0.82rem; font-weight: 900; letter-spacing: 0.04em; }
.admin-field input, .admin-field textarea, .admin-field select {
  width: 100%;
  border: 1px solid #bdb3aa;
  border-radius: 0;
  padding: 12px 13px;
  background: var(--white);
  color: var(--ink);
  line-height: 1.5;
}
.admin-field input, .admin-field select { min-height: 48px; }
.admin-field textarea { resize: vertical; }
.admin-field input:focus, .admin-field textarea:focus, .admin-field select:focus { outline: 3px solid rgba(200, 20, 36, 0.17); border-color: var(--red); }
.admin-field input:disabled, .admin-field textarea:disabled, .admin-field select:disabled { background: #eee9e3; color: #746e69; }
.admin-field.full-width { grid-column: 1 / -1; }
.admin-field.small-field { max-width: 160px; }
.admin-fieldset { margin: 28px 0 0; border: 1px solid var(--line); padding: 20px; }
.admin-fieldset legend { padding: 0 8px; }
.admin-fieldset > p { margin: 0 0 18px; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }
.admin-check-card { display: flex; align-items: flex-start; gap: 12px; border: 1px solid #bdb3aa; padding: 14px; background: var(--white); cursor: pointer; }
.admin-check-card:has(input:checked) { border-color: var(--red); background: #fff5f5; }
.admin-check-card input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--red); }
.admin-check-card span { display: grid; gap: 4px; }
.admin-check-card strong { color: var(--black); font-size: 0.86rem; }
.admin-check-card small { color: var(--muted); line-height: 1.4; }
.admin-form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.admin-form-status { min-height: 1.4em; margin: 14px 0 0; color: #4e4844; font-size: 0.88rem; font-weight: 800; }
.admin-form-status.error { color: #a40c19; }
.admin-safety-note { margin: 16px 0 0; color: var(--muted); font-size: 0.82rem; line-height: 1.55; }

.admin-content-workspace { display: grid; grid-template-columns: minmax(240px, 0.32fr) minmax(0, 1fr); gap: 24px; margin-top: 28px; }
.admin-list-column, .admin-detail-card { min-height: 430px; background: var(--paper); box-shadow: 0 12px 34px rgba(0, 0, 0, 0.12); }
.admin-record-list { display: grid; align-content: start; }
.admin-record-button { display: grid; gap: 6px; width: 100%; border: 0; border-left: 5px solid transparent; border-bottom: 1px solid var(--line); padding: 20px; background: transparent; color: var(--black); cursor: pointer; text-align: left; }
.admin-record-button:hover { background: #f6f1eb; }
.admin-record-button.selected { border-left-color: var(--red); background: #f4ede6; }
.admin-record-button strong { font-family: Georgia, "Times New Roman", serif; font-size: 1.18rem; }
.admin-record-button span { color: var(--muted); font-size: 0.78rem; line-height: 1.4; }
.admin-detail-card { padding: clamp(24px, 4vw, 38px); }
.admin-empty-state { margin: 0; color: var(--muted); line-height: 1.65; }
.admin-empty-state.compact { padding: 18px 0; font-size: 0.9rem; }
.book-detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.book-detail-heading h3 { margin: 0; color: var(--black); font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1; }
.book-detail-heading > div > p:last-child { max-width: 700px; margin: 14px 0 0; color: var(--muted); line-height: 1.6; }
.book-detail-actions { display: grid; flex: 0 0 auto; justify-items: end; gap: 10px; }
.admin-subsection { margin-top: 34px; border-top: 1px solid var(--line); padding-top: 24px; }
.admin-subsection-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.admin-subsection-heading h4 { margin: 0; color: var(--black); font-size: 1.35rem; }
.round-summary-list, .chapter-management-list { display: grid; gap: 10px; margin-top: 16px; }
.round-summary-card, .chapter-management-row { display: flex; align-items: center; gap: 14px; border: 1px solid var(--line); padding: 14px 16px; background: var(--white); }
.round-summary-card > div:first-child, .chapter-management-copy { display: grid; flex: 1; gap: 4px; min-width: 0; }
.round-summary-card strong, .chapter-management-copy strong { color: var(--black); }
.round-summary-card span:not(.status-badge), .chapter-management-copy span { color: var(--muted); font-size: 0.76rem; line-height: 1.4; }
.chapter-management-meta { color: #6d2028; font-size: 0.72rem; font-weight: 900; line-height: 1.4; }
.chapter-order-number { display: grid; flex: 0 0 34px; height: 34px; place-items: center; background: var(--near-black); color: var(--white); font-family: Georgia, "Times New Roman", serif; font-weight: 900; }
.chapter-drag-handle { flex: 0 0 auto; padding: 8px 4px; color: var(--muted); cursor: grab; font-weight: 900; letter-spacing: -0.18em; }
.chapter-drag-handle:active { cursor: grabbing; }
.chapter-management-row.dragging { border-color: var(--red); opacity: 0.55; }
.chapter-management-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.chapter-move-button { width: 34px; height: 34px; border: 1px solid var(--line); background: var(--white); color: var(--black); cursor: pointer; font-weight: 900; }
.chapter-move-button:hover { border-color: var(--red); color: var(--red); }
.chapter-reorder-note { margin: 16px 0 0; color: var(--muted); font-size: 0.8rem; }
.status-badge { display: inline-flex; align-items: center; border: 1px solid; padding: 4px 7px; font-size: 0.64rem; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.status-badge.active { border-color: #7aaf8d; background: #eef8f1; color: #155a32; }
.status-badge.draft { border-color: #c5a56d; background: #fff7e7; color: #6e4b0e; }
.status-badge.disabled { border-color: #c8bfc0; background: #f3eeee; color: #6f5b5d; }

.chapter-editor { margin-top: 28px; }
.chapter-fields { grid-template-columns: minmax(0, 1fr) 150px minmax(220px, 0.65fr); }
.chapter-formatting-bar { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-bottom: 0; padding: 8px 10px; background: #f1ebe5; color: var(--muted); font-size: 0.76rem; font-weight: 600; }
.chapter-format-button { min-height: 34px; border: 1px solid #b7ada5; padding: 6px 10px; background: var(--white); color: var(--black); cursor: pointer; font-weight: 800; }
.chapter-format-button:hover { border-color: var(--black); }
.chapter-format-button:focus-visible { outline: 3px solid rgba(200, 20, 36, 0.2); border-color: var(--red); }
.chapter-rich-editor { display: block; min-height: 540px; overflow-y: auto; border: 1px solid #b7ada5; padding: 18px; background: var(--white); color: var(--black); font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem; line-height: 1.75; white-space: pre-wrap; }
.chapter-rich-editor:empty::before { color: #8a827c; content: attr(data-placeholder); }
.chapter-rich-editor:focus { outline: 3px solid rgba(200, 20, 36, 0.17); border-color: var(--red); }
.chapter-rich-editor div, .chapter-rich-editor p { margin: 0 0 1em; }
.chapter-rich-editor div:last-child, .chapter-rich-editor p:last-child { margin-bottom: 0; }
.chapter-editor-footer { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.chapter-editor-footer .admin-form-actions { margin-top: 18px; }
.chapter-text-count { margin: 18px 0 0; color: var(--muted); font-size: 0.82rem; font-weight: 800; }

.reader-code-result { display: grid; gap: 18px; margin-top: 28px; border: 2px solid var(--red); padding: clamp(24px, 4vw, 36px); background: #171719; color: var(--white); box-shadow: var(--shadow); }
.reader-code-result h3 { margin: 0; font-size: 2rem; }
.reader-code-result p:not(.eyebrow) { margin: 10px 0 0; color: #d4ced0; line-height: 1.6; }
.reader-code-copy-row { display: flex; align-items: center; gap: 12px; }
.reader-code-copy-row code { flex: 1; overflow-wrap: anywhere; border: 1px dashed #756b70; padding: 16px; background: #09090a; color: var(--white); font-size: clamp(1.05rem, 3vw, 1.55rem); font-weight: 900; letter-spacing: 0.08em; }
.reader-code-result > .text-button { justify-self: start; color: #d4ced0; }
.round-option-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.round-option { display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--line); padding: 13px; background: var(--white); cursor: pointer; }
.round-option:has(input:checked) { border-color: var(--red); background: #fff5f5; }
.round-option input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--red); }
.round-option span { display: grid; gap: 4px; }
.round-option strong { color: var(--black); font-size: 0.9rem; }
.round-option small { color: var(--muted); line-height: 1.4; }
.reader-management-list { display: grid; gap: 12px; margin-top: 28px; }
.reader-management-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px; background: var(--paper); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1); }
.reader-management-heading { display: flex; align-items: center; gap: 14px; min-width: 0; }
.reader-management-heading > div { display: grid; gap: 5px; }
.reader-management-heading strong { color: var(--black); font-family: Georgia, "Times New Roman", serif; font-size: 1.16rem; }
.reader-management-heading span:not(.status-badge) { color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.reader-admin-traits { color: #6d2028; font-size: 0.72rem; font-weight: 900; line-height: 1.4; text-transform: capitalize; }
.admin-profile-photo-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
.admin-reader-photo-preview { width: 68px; height: 68px; border: 2px solid var(--red); border-radius: 50%; object-fit: cover; }
.admin-reader-photo-state { border: 1px solid var(--line); padding: 10px 12px; background: var(--white); color: var(--muted); font-size: 0.8rem; font-weight: 800; }
.admin-check-inline { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.82rem; font-weight: 800; }
.admin-check-inline input { width: 18px; height: 18px; accent-color: var(--red); }

.profile-shell { width: min(900px, calc(100% - 28px)); margin: 0 auto; padding: 52px 0 100px; }
.profile-card { padding: clamp(28px, 6vw, 58px); background: var(--reader-paper); box-shadow: var(--reader-shadow); }
.profile-card h1 { margin: 0; color: var(--reader-ink); font-size: clamp(2.4rem, 7vw, 4.5rem); }
.profile-intro { max-width: 720px; margin: 18px 0 30px; color: var(--reader-muted); line-height: 1.7; }
.profile-photo-editor { display: flex; align-items: center; gap: 20px; margin-bottom: 30px; }
.profile-photo, .profile-photo-placeholder { width: 92px; height: 92px; flex: 0 0 92px; border-radius: 50%; object-fit: cover; }
.profile-photo { border: 3px solid var(--red); }
.profile-photo-placeholder { display: grid; place-items: center; border: 2px dashed var(--reader-line); background: var(--reader-subtle); color: var(--reader-muted); font-size: 2rem; }
.profile-photo-editor > div:last-child { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.profile-photo-editor p { flex-basis: 100%; margin: 0; color: var(--reader-muted); font-size: 0.78rem; }
.profile-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.profile-field { display: grid; gap: 8px; }
.profile-field.full-width { grid-column: 1 / -1; }
.profile-field span, .profile-address legend { color: var(--reader-ink); font-size: 0.82rem; font-weight: 900; }
.profile-field input { width: 100%; min-height: 48px; border: 1px solid var(--reader-line); padding: 12px 13px; background: var(--reader-input); color: var(--reader-ink); }
.profile-field input:focus { outline: 3px solid rgba(200, 20, 36, 0.17); border-color: var(--red); }
.profile-field input:disabled { cursor: not-allowed; background: var(--reader-subtle); color: var(--reader-muted); opacity: 1; }
.profile-field small { color: var(--reader-muted); font-size: 0.72rem; line-height: 1.45; }
.profile-address { margin: 30px 0 0; border: 1px solid var(--reader-line); padding: 22px; }
.profile-address legend { padding: 0 8px; }
.profile-address > p { margin: 0 0 18px; color: var(--reader-muted); line-height: 1.55; }
.profile-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }
.profile-card .status-message { color: var(--reader-muted); font-weight: 800; }
.preview-badge { border: 1px solid #777078; padding: 6px 8px; color: #ded8dc; font-size: 0.65rem; font-weight: 900; letter-spacing: 0.07em; text-transform: uppercase; }

.survey-shell { width: min(980px, calc(100% - 28px)); margin: 0 auto; padding: 52px 0 100px; }
.survey-card { overflow: hidden; padding: clamp(28px, 6vw, 58px); background: var(--reader-paper); box-shadow: var(--reader-shadow); }
.survey-card > h1 { margin: 0; color: var(--reader-ink); font-size: clamp(2.5rem, 7vw, 4.8rem); overflow-wrap: anywhere; }
.survey-intro { max-width: 700px; margin: 18px 0 0; color: var(--reader-muted); font-size: 1.03rem; line-height: 1.7; }
.survey-locked { margin: 24px 0 0; border-left: 5px solid var(--red); padding: 16px 18px; background: var(--reader-subtle); color: var(--reader-ink); font-weight: 800; line-height: 1.55; }
.survey-section { margin-top: 38px; border-top: 1px solid var(--reader-line); padding-top: 30px; }
.survey-section > h2 { margin: 0 0 22px; color: var(--reader-ink); font-size: clamp(1.6rem, 4vw, 2.2rem); }
.survey-rating-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.survey-rating-field { min-width: 0; margin: 0; border: 1px solid var(--reader-line); padding: 18px; background: var(--reader-subtle); }
.survey-rating-field legend { padding: 0 6px; color: var(--reader-ink); font-size: 0.82rem; font-weight: 900; }
.survey-stars { display: flex; align-items: center; gap: 2px; }
.survey-stars button { border: 0; padding: 2px; background: transparent; color: var(--reader-line); cursor: pointer; font-size: clamp(1.55rem, 3vw, 2.05rem); line-height: 1; }
.survey-stars button.selected { color: #c88912; }
.survey-stars button:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.survey-stars button:disabled { cursor: default; }
.survey-field { display: grid; gap: 9px; margin-top: 22px; }
.survey-field > span { color: var(--reader-ink); font-size: 0.82rem; font-weight: 900; }
.survey-field textarea { width: 100%; resize: vertical; border: 1px solid var(--reader-line); padding: 14px; background: var(--reader-input); color: var(--reader-ink); font: inherit; line-height: 1.65; }
.survey-field textarea:focus { outline: 3px solid rgba(200, 20, 36, 0.17); border-color: var(--red); }
.survey-field textarea:disabled { resize: none; background: var(--reader-subtle); color: var(--reader-muted); opacity: 1; }
.survey-field select { width: 100%; border: 1px solid var(--reader-line); padding: 14px; background: var(--reader-input); color: var(--reader-ink); font: inherit; }
.mock-review-field { margin-top: 24px; }
.survey-character-checks { display: flex; flex-wrap: wrap; gap: 12px; }
.survey-character-checks label, .survey-dnf-check { display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--reader-line); padding: 13px 16px; background: var(--reader-subtle); color: var(--reader-ink); font-weight: 900; }
.survey-character-checks input, .survey-dnf-check input { width: 19px; height: 19px; accent-color: var(--red); }
.survey-dnf-section { border: 1px solid var(--reader-line); padding: 24px; background: var(--reader-subtle); }
.survey-dnf-section .survey-field textarea { background: var(--reader-paper); }
.survey-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 30px; }
.survey-card .status-message { min-height: 1.5em; margin: 16px 0 0; color: var(--reader-muted); font-weight: 800; text-align: right; }

.feedback-filter-card { margin-top: 28px; border-top: 5px solid var(--red); padding: clamp(22px, 4vw, 32px); background: var(--paper); box-shadow: 0 12px 34px rgba(0, 0, 0, 0.12); }
.feedback-filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.feedback-filter-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 20px; }
.feedback-export-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.feedback-status { margin: 18px 0 0; }
.feedback-summary { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; margin: 28px 0 0; background: #bfb6ae; }
.feedback-summary div { padding: 18px; background: var(--paper); }
.feedback-summary dt { color: var(--muted); font-size: 0.68rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.feedback-summary dd { margin: 6px 0 0; color: var(--black); font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-weight: 900; }
.feedback-section { margin-top: 28px; padding: clamp(22px, 4vw, 34px); background: var(--paper); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); }
.feedback-section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
.feedback-section-heading h3 { margin: 4px 0 0; color: var(--black); font-size: clamp(1.55rem, 4vw, 2.1rem); }
.feedback-reaction-summary { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.feedback-reaction-total { display: grid; grid-template-columns: auto auto; align-items: center; gap: 2px 10px; min-width: 108px; border: 1px solid var(--line); padding: 13px 15px; background: var(--white); }
.feedback-reaction-total > span { grid-row: 1 / 3; font-size: 1.7rem; }
.feedback-reaction-total strong { color: var(--black); font-size: 1.2rem; }
.feedback-reaction-total small { color: var(--muted); font-size: 0.68rem; font-weight: 800; }
.feedback-comment-list, .feedback-reaction-list { display: grid; gap: 14px; margin-top: 20px; }
.feedback-survey-list { display: grid; gap: 16px; margin-top: 20px; }
.feedback-survey-card { border: 1px solid var(--line); border-left: 5px solid var(--red); padding: 20px; background: var(--white); }
.survey-feedback-ratings { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; margin: 18px 0 0; background: var(--line); }
.survey-feedback-ratings div { padding: 12px; background: var(--paper); }
.survey-feedback-ratings dt { color: var(--muted); font-size: 0.64rem; font-weight: 900; text-transform: uppercase; }
.survey-feedback-ratings dd { margin: 4px 0 0; color: var(--black); font-weight: 900; }
.survey-feedback-response { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.survey-feedback-response strong { color: var(--black); }
.survey-feedback-response p { margin: 7px 0 0; color: var(--muted); line-height: 1.65; white-space: pre-wrap; }
.survey-feedback-response.dnf { border-left: 3px solid var(--red); padding-left: 14px; }
.feedback-comment-card { border: 1px solid var(--line); border-left: 5px solid var(--red); padding: 20px; background: var(--white); }
.feedback-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.feedback-card-heading > div { display: grid; gap: 4px; }
.feedback-card-heading strong { color: var(--black); font-family: Georgia, "Times New Roman", serif; font-size: 1.08rem; }
.feedback-card-heading span, .feedback-location { color: var(--muted); font-size: 0.76rem; line-height: 1.45; }
.feedback-scope-badge { border: 1px solid #bcaeb0; padding: 5px 8px; background: #f5edef; color: #6d2028 !important; font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.feedback-location { margin: 14px 0 0; font-weight: 900; }
.feedback-paragraph-context { margin: 16px 0 0; border-left: 3px solid #c9bfc0; padding: 12px 16px; background: #f5f1ed; color: #59524e; font-family: Georgia, "Times New Roman", serif; font-size: 0.9rem; line-height: 1.65; }
.feedback-comment-text { margin: 18px 0 0; color: var(--black); white-space: pre-wrap; line-height: 1.65; }
.feedback-card-actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.text-button.danger { color: #9f101c; }
.text-button.danger:hover { color: #6f0710; }
.feedback-reaction-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 14px; border: 1px solid var(--line); padding: 14px 16px; background: var(--white); }
.feedback-reaction-emoji { font-size: 1.7rem; text-align: center; }
.feedback-reaction-row > div { display: grid; gap: 4px; }
.feedback-reaction-row strong { color: var(--black); }
.feedback-reaction-row span:not(.feedback-reaction-emoji), .feedback-reaction-row time { color: var(--muted); font-size: 0.76rem; line-height: 1.45; }
.feedback-reaction-row time { text-align: right; white-space: nowrap; }

.progress-filter-card { margin-top: 28px; border-top: 5px solid var(--red); padding: clamp(22px, 4vw, 32px); background: var(--paper); box-shadow: 0 12px 34px rgba(0, 0, 0, 0.12); }
.progress-filter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.progress-filter-actions { display: flex; justify-content: flex-end; margin-top: 20px; }
.progress-status-message { margin-top: 18px; }
.progress-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; margin: 28px 0 0; background: #bfb6ae; }
.progress-summary div { padding: 18px; background: var(--paper); }
.progress-summary dt { color: var(--muted); font-size: 0.68rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.progress-summary dd { margin: 6px 0 0; color: var(--black); font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-weight: 900; }
.progress-table-card { margin-top: 28px; padding: clamp(22px, 4vw, 34px); background: var(--paper); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); }
.progress-table-wrap { overflow-x: auto; margin-top: 20px; }
.progress-table { width: 100%; border-collapse: collapse; background: var(--white); color: var(--black); font-size: 0.82rem; }
.progress-table th, .progress-table td { border-bottom: 1px solid var(--line); padding: 14px 12px; text-align: left; vertical-align: top; }
.progress-table th { background: #f1ebe5; color: #4e4844; font-size: 0.66rem; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
.progress-table td { color: var(--muted); line-height: 1.45; }
.progress-table td strong, .progress-table td small { display: block; }
.progress-table td strong { color: var(--black); }
.progress-table td small { margin-top: 3px; color: var(--muted); }
.progress-table time { white-space: nowrap; }
.progress-table .admin-empty-state { padding: 26px 14px; text-align: center; }
.progress-badge { display: inline-flex; border: 1px solid; padding: 5px 8px; font-size: 0.64rem; font-weight: 900; letter-spacing: 0.05em; text-transform: uppercase; white-space: nowrap; }
.progress-badge.completed { border-color: #7aaf8d; background: #eef8f1; color: #155a32; }
.progress-badge.opened { border-color: #c5a56d; background: #fff7e7; color: #6e4b0e; }
.progress-badge.not-started { border-color: #c8bfc0; background: #f3eeee; color: #6f5b5d; }
.progress-badge.finished { border-color: #7aaf8d; background: #eef8f1; color: #155a32; }
.progress-badge.reading { border-color: #c5a56d; background: #fff7e7; color: #6e4b0e; }
.progress-badge.dnf { border-color: #bd7880; background: #fff0f1; color: #871421; }
.progress-dnf-reason { max-width: 210px; margin-top: 7px !important; white-space: normal; }

.analytics-filter-card { margin-top: 28px; border-top: 5px solid var(--red); padding: clamp(22px, 4vw, 32px); background: var(--paper); box-shadow: 0 12px 34px rgba(0, 0, 0, 0.12); }
.analytics-filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.analytics-filter-actions { display: flex; justify-content: flex-end; margin-top: 20px; }
.analytics-status { margin-top: 18px; }
.analytics-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 28px 0 0; background: #bfb6ae; }
.analytics-summary div { min-width: 0; padding: 18px; background: var(--paper); }
.analytics-summary dt { color: var(--muted); font-size: 0.68rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.analytics-summary dd { margin: 6px 0 0; color: var(--black); font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.45rem, 3vw, 2rem); font-weight: 900; overflow-wrap: anywhere; }
.analytics-chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 24px; margin-top: 28px; }
.analytics-card { min-width: 0; padding: clamp(20px, 3vw, 30px); background: var(--paper); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); }
.analytics-card-wide { grid-column: 1 / -1; }
.analytics-card-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.analytics-card-heading h3 { margin: 3px 0 0; color: var(--black); font-size: clamp(1.4rem, 3vw, 1.9rem); }
.analytics-card-heading > p { max-width: 430px; margin: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.45; text-align: right; }
.analytics-chart { min-height: 220px; margin-top: 22px; }
.analytics-empty { display: grid; min-height: 200px; place-items: center; margin: 0; color: var(--muted); line-height: 1.6; text-align: center; }
.analytics-line-svg { display: block; width: 100%; height: auto; min-height: 230px; overflow: visible; }
.analytics-grid-line { stroke: #a9a09a; stroke-width: 1; }
.analytics-grid-line.faint { stroke: #ded7d1; stroke-dasharray: 5 6; }
.analytics-axis-label { fill: #746e69; font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: 12px; font-weight: 800; }
.analytics-line { fill: none; stroke: var(--red); stroke-linecap: round; stroke-linejoin: round; stroke-width: 4; }
.analytics-line-point { fill: var(--paper); stroke: var(--red); stroke-width: 3; }
.analytics-donut-layout { display: grid; grid-template-columns: 170px minmax(0, 1fr); align-items: center; gap: 26px; min-height: 220px; }
.analytics-donut { display: grid; width: 170px; height: 170px; place-items: center; }
.analytics-donut > svg { display: block; grid-area: 1 / 1; width: 170px; height: 170px; }
.analytics-donut-base, .analytics-donut-segment { fill: none; stroke-width: 7; }
.analytics-donut-base { stroke: #e5ddd6; }
.status-color-1 { stroke: #aaa2a0; background: #aaa2a0; }
.status-color-2 { stroke: #d29a35; background: #d29a35; }
.status-color-3 { stroke: #217a45; background: #217a45; }
.status-color-4 { stroke: #c81424; background: #c81424; }
.analytics-donut > span { z-index: 1; display: grid; grid-area: 1 / 1; text-align: center; }
.analytics-donut strong { color: var(--black); font-family: Georgia, "Times New Roman", serif; font-size: 2rem; }
.analytics-donut small { color: var(--muted); font-size: 0.66rem; font-weight: 900; text-transform: uppercase; }
.analytics-legend { display: grid; gap: 10px; }
.analytics-legend div { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 9px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.analytics-legend i { width: 10px; height: 10px; }
.analytics-legend span { color: var(--muted); font-size: 0.78rem; }
.analytics-legend strong { color: var(--black); }
.analytics-bar-list { display: grid; gap: 22px; }
.analytics-bar-group { display: grid; gap: 8px; }
.analytics-bar-label { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; }
.analytics-bar-label strong { max-width: 78%; color: var(--black); font-size: 0.84rem; overflow-wrap: anywhere; }
.analytics-bar-label span { color: var(--muted); font-size: 0.7rem; font-weight: 800; white-space: nowrap; }
.analytics-bar-series { display: grid; grid-template-columns: 100px minmax(0, 1fr) 58px; align-items: center; gap: 10px; }
.analytics-bar-series > span { color: var(--muted); font-size: 0.68rem; font-weight: 800; }
.analytics-bar-series > strong { color: var(--black); font-size: 0.74rem; text-align: right; }
.analytics-bar-track { display: block; width: 100%; height: 12px; overflow: hidden; }
.analytics-bar-base { fill: #e5ddd6; }
.analytics-bar-fill { fill: var(--red); }
.analytics-bar-fill.series-2 { fill: #383336; }
.analytics-svg-scroll { width: 100%; overflow-x: auto; padding-bottom: 4px; }
.analytics-combo-svg { display: block; width: max(100%, 720px); height: auto; min-height: 310px; }
.analytics-reader-bar { fill: var(--red); }
.analytics-binge-line { fill: none; stroke: #292629; stroke-linecap: round; stroke-linejoin: round; stroke-width: 3.5; }
.analytics-binge-point { fill: var(--paper); stroke: #292629; stroke-width: 3; }
.analytics-chart-key, .analytics-reaction-legend { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 14px; color: var(--muted); font-size: 0.72rem; font-weight: 800; }
.analytics-chart-key span, .analytics-reaction-legend span { display: inline-flex; align-items: center; gap: 6px; }
.analytics-chart-key i, .analytics-reaction-legend i { display: inline-block; width: 14px; height: 10px; }
.analytics-chart-key .reader-key { background: var(--red); }
.analytics-chart-key .binge-key { height: 3px; background: #292629; }
.analytics-reaction-segment { stroke: var(--paper); stroke-width: 1; }
.reaction-color-1 { fill: #171719; background: #171719; }
.reaction-color-2 { fill: #c81424; background: #c81424; }
.reaction-color-3 { fill: #b8652b; background: #b8652b; }
.reaction-color-4 { fill: #80556e; background: #80556e; }
.reaction-color-5 { fill: #5b5d91; background: #5b5d91; }
.reaction-color-6 { fill: #8e7770; background: #8e7770; }
.reaction-color-7 { fill: #496477; background: #496477; }
.reaction-color-8 { fill: #84242d; background: #84242d; }
.reaction-color-9 { fill: #9b7a28; background: #9b7a28; }
.reaction-color-10 { fill: #606b55; background: #606b55; }
.reaction-color-11 { fill: #3c6f68; background: #3c6f68; }
.reaction-color-12 { fill: #77777d; background: #77777d; }
.reaction-color-13 { fill: #9f4152; background: #9f4152; }
.analytics-definitions { margin-top: 24px; border: 1px solid #bfb6ae; padding: 18px 20px; background: var(--paper); }
.analytics-definitions summary { color: var(--black); cursor: pointer; font-weight: 900; }
.analytics-definitions dl { display: grid; gap: 12px; margin: 18px 0 0; }
.analytics-definitions dl div { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 18px; border-top: 1px solid var(--line); padding-top: 10px; }
.analytics-definitions dt { color: var(--black); font-weight: 900; }
.analytics-definitions dd { margin: 0; color: var(--muted); line-height: 1.5; }

@media (max-width: 950px) {
  .foundation-counts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .admin-content-workspace { grid-template-columns: 1fr; }
  .admin-list-column { min-height: 0; }
  .admin-record-list { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
  .admin-record-button { border-left: 0; border-top: 5px solid transparent; border-right: 1px solid var(--line); }
  .admin-record-button.selected { border-top-color: var(--red); }
  .chapter-fields { grid-template-columns: minmax(0, 1fr) 130px; }
  .chapter-fields > .admin-field:nth-child(3) { grid-column: 1 / -1; }
  .feedback-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .progress-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .progress-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .analytics-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .analytics-chart-grid { grid-template-columns: 1fr; }
  .analytics-card-wide { grid-column: auto; }
}

@media (max-width: 650px) {
  .admin-shell { width: min(100% - 24px, 1240px); padding-top: 42px; }
  .admin-summary-heading, .admin-panel-heading, .book-detail-heading, .chapter-editor-footer, .analytics-card-heading { align-items: flex-start; flex-direction: column; }
  .admin-panel-heading .button { width: 100%; }
  .foundation-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-tabs { display: grid; grid-template-columns: repeat(2, 1fr); }
  .admin-tab { padding-inline: 8px; }
  .admin-form-grid, .chapter-fields, .round-option-list { grid-template-columns: 1fr; }
  .admin-field.full-width, .chapter-fields > .admin-field:nth-child(3) { grid-column: auto; }
  .admin-field.small-field { max-width: none; }
  .admin-form-actions, .reader-form-actions { width: 100%; }
  .admin-form-actions .button { flex: 1; }
  .round-summary-card, .chapter-management-row { align-items: flex-start; flex-wrap: wrap; }
  .chapter-management-copy { min-width: calc(100% - 52px); }
  .chapter-management-row > .button { width: 100%; }
  .chapter-drag-handle { display: none; }
  .chapter-management-actions { width: 100%; justify-content: flex-start; }
  .chapter-management-actions .button { flex: 1; }
  .reader-management-card { align-items: stretch; flex-direction: column; }
  .reader-management-card > .button { width: 100%; }
  .reader-management-heading { align-items: flex-start; justify-content: space-between; }
  .reader-code-copy-row { align-items: stretch; flex-direction: column; }
  .chapter-formatting-bar { align-items: flex-start; flex-direction: column; }
  .chapter-rich-editor { min-height: 430px; }
  .feedback-filter-grid { grid-template-columns: 1fr; }
  .feedback-filter-actions { align-items: stretch; flex-direction: column; }
  .feedback-export-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .feedback-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .feedback-card-heading { align-items: flex-start; flex-direction: column; }
  .feedback-reaction-row { grid-template-columns: 42px minmax(0, 1fr); }
  .feedback-reaction-row time { grid-column: 2; text-align: left; }
  .progress-filter-grid { grid-template-columns: 1fr; }
  .progress-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-filter-grid { grid-template-columns: 1fr; }
  .analytics-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-card-heading > p { text-align: left; }
  .analytics-donut-layout { grid-template-columns: 1fr; justify-items: center; }
  .analytics-legend { width: 100%; }
  .analytics-bar-series { grid-template-columns: 74px minmax(0, 1fr) 50px; }
  .analytics-definitions dl div { grid-template-columns: 1fr; gap: 4px; }
  .progress-table, .progress-table tbody, .progress-table tr, .progress-table td { display: block; width: 100%; }
  .progress-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .progress-table tr { border: 1px solid var(--line); border-left: 5px solid var(--red); margin-bottom: 14px; background: var(--white); }
  .progress-table td { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; border-bottom: 1px solid var(--line); padding: 11px 13px; }
  .progress-table td:last-child { border-bottom: 0; }
  .progress-table td::before { color: var(--muted); content: attr(data-label); font-size: 0.66rem; font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase; }
  .progress-table td.admin-empty-state { display: block; border: 0; }
  .progress-table td.admin-empty-state::before { display: none; }
  .profile-form-grid { grid-template-columns: 1fr; }
  .profile-field.full-width { grid-column: auto; }
  .profile-photo-editor { align-items: flex-start; }
  .profile-actions .button { flex: 1; }
  .survey-card { padding-inline: 22px; }
  .survey-rating-grid { grid-template-columns: 1fr; }
  .survey-character-checks { display: grid; }
  .survey-character-checks label { width: 100%; }
  .survey-actions { align-items: stretch; flex-direction: column-reverse; }
  .survey-actions .button { width: 100%; }
  .survey-card .status-message { text-align: left; }
  .survey-feedback-ratings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preview-badge { display: none; }
}

@media (max-width: 850px) {
  .library-shell { width: min(100% - 24px, 680px); padding-top: 30px; }
  .library-intro { align-items: start; flex-direction: column; gap: 12px; }
  .library-intro > p:last-child { max-width: none; }
  .library-dashboard-grid { grid-template-columns: 1fr; }
  .library-profile-card { position: static; grid-row: auto; }
  .book-card-layout { grid-template-columns: 1fr; min-height: 0; }
  .book-card .cover-placeholder { display: none; }
  .book-details { min-height: 0; padding: 24px; }
}
.gift-book-button { cursor: pointer; }
.gift-modal-open { overflow: hidden; }
.reader-gift-modal { position: fixed; z-index: 1000; inset: 0; display: grid; place-items: center; padding: 24px; }
.reader-gift-modal[hidden] { display: none; }
.reader-gift-modal-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(5, 5, 7, .78); backdrop-filter: blur(5px); cursor: default; }
.reader-gift-dialog { position: relative; width: min(900px, 100%); max-height: min(860px, calc(100vh - 48px)); overflow: auto; border: 1px solid var(--reader-line); border-radius: 18px; padding: clamp(22px, 4vw, 36px); background: var(--reader-paper); color: var(--reader-ink); box-shadow: 0 30px 90px rgba(0,0,0,.65); }
.reader-gift-dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--reader-line); padding-bottom: 20px; }
.reader-gift-dialog-header h2 { margin: 0; color: var(--reader-ink); }
.reader-gift-dialog-header > div > p:last-child { margin: 8px 0 0; color: var(--reader-muted); }
.reader-gift-dialog-close { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; border: 1px solid var(--reader-line); border-radius: 50%; background: var(--reader-subtle); color: var(--reader-ink); cursor: pointer; font-size: 1.7rem; line-height: 1; }
.reader-gift-list { display: grid; gap: 16px; }
.reader-gift-card { display: grid; gap: 20px; padding: clamp(18px, 3vw, 28px); border: 1px solid var(--reader-line); border-radius: 14px; background: var(--reader-subtle); }
.reader-gift-card > header { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.reader-gift-card h3, .reader-gift-card h4, .reader-gift-card p { margin: 0; }
.gift-current-status { padding: 8px 12px; border: 1px solid var(--accent); border-radius: 999px; color: var(--accent-soft); font-weight: 800; }
.gift-progress { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin: 0; padding: 0; list-style: none; }
.gift-progress li { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 10px; min-height: 82px; padding: 14px; border: 1px solid var(--reader-line); border-radius: 10px; opacity: .55; }
.gift-progress li.complete { border-color: var(--accent); opacity: 1; }
.gift-progress i { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: var(--ink); background: var(--line); font-style: normal; font-weight: 900; }
.gift-progress li.complete i { color: white; background: var(--accent); }
.gift-progress span { display: grid; gap: 4px; }
.gift-progress small { color: var(--muted); line-height: 1.4; }
.gift-detail-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.gift-detail-grid section, .gift-tracking { display: grid; align-content: start; gap: 8px; padding: 16px; border: 1px solid var(--reader-line); border-radius: 10px; background: var(--reader-raised); }
.gift-detail-grid ul { margin: 0; padding-left: 18px; }
.gift-detail-grid address { display: grid; gap: 3px; font-style: normal; }
.gift-tracking > span { color: var(--muted); font-size: .8rem; font-weight: 800; text-transform: uppercase; }
.library-page .gift-tracking .button-neutral { border-color: var(--red); background: var(--red); color: #fff; }
.library-page .gift-tracking .button-neutral:hover { border-color: #9f1420; background: #9f1420; color: #fff; }
.gift-confirmation { display: grid; grid-template-columns: minmax(220px, 1fr) auto; align-items: center; gap: 18px; padding: 18px; border: 1px solid var(--accent); border-radius: 10px; background: var(--reader-raised); }
.gift-confirmation h4 { margin-bottom: 5px; }
.gift-confirmation p { color: var(--reader-muted); line-height: 1.5; }
.gift-confirmation-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.library-page .gift-confirmation .button-neutral { border-color: var(--reader-neutral-border); color: var(--reader-ink); background: transparent; }
.library-page .gift-confirmation .button-neutral:hover { border-color: var(--reader-ink); background: var(--reader-neutral-hover); }
.gift-correction-field { display: grid; grid-column: 1 / -1; gap: 7px; }
.gift-correction-field[hidden] { display: none; }
.gift-correction-field > span { color: var(--reader-ink); font-size: .82rem; font-weight: 900; }
.gift-correction-field textarea { width: 100%; min-height: 92px; resize: vertical; border: 1px solid var(--reader-line); padding: 12px; background: var(--reader-input); color: var(--reader-ink); font: inherit; }
.gift-confirmed { color: var(--success); font-weight: 800; }
.gift-change-requested { color: var(--accent-soft); font-weight: 800; }
@media (max-width: 720px) {
  .reader-gift-modal { align-items: end; padding: 0; }
  .reader-gift-dialog { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; padding: 22px 16px calc(24px + env(safe-area-inset-bottom)); }
  .library-section-heading { align-items: start; flex-direction: column; gap: 8px; }
  .library-section-heading > p { max-width: none; text-align: left; }
  .gift-progress, .gift-detail-grid { grid-template-columns: 1fr; }
  .reader-gift-card > header { align-items: stretch; flex-direction: column; }
  .gift-current-status { align-self: flex-start; }
  .gift-confirmation { grid-template-columns: 1fr; }
  .gift-confirmation-actions { display: grid; justify-content: stretch; }
  .gift-confirmation-actions .button { width: 100%; }
}

/* Reader feedback type controls */
.feedback-type-picker { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; }
.feedback-type-picker legend { width: 100%; margin-bottom: 2px; font-size: 0.82rem; font-weight: 900; color: var(--reader-muted); }
.feedback-type-picker label { position: relative; display: inline-flex; align-items: center; min-height: 38px; margin: 0; padding: 0; cursor: pointer; }
.feedback-type-picker input { position: absolute; opacity: 0; pointer-events: none; }
.feedback-type-picker span { display: inline-flex; align-items: center; min-height: 36px; padding: 7px 12px; border: 1px solid var(--reader-line); border-radius: 999px; background: var(--reader-panel); font-size: 0.82rem; font-weight: 900; }
.feedback-type-picker input:checked + span { border-color: var(--red); color: var(--red); box-shadow: 0 0 0 2px rgba(200, 20, 36, 0.08); }
.feedback-type-picker input:focus-visible + span { outline: 2px solid var(--red); outline-offset: 2px; }
.feedback-note-optional { font-weight: 600; color: var(--reader-muted); }
.feedback-type-badge { display: inline-flex; align-items: center; margin: 2px 0 4px; padding: 2px 7px; border-radius: 999px; font-size: 0.68rem; font-weight: 950; letter-spacing: 0.08em; }
.feedback-type-badge.typo { border: 1px solid rgba(200, 20, 36, 0.35); color: var(--red); background: rgba(200, 20, 36, 0.06); }
.reader-scene-break { display: flex; justify-content: center; gap: 12px; margin: 2.3rem 0; color: var(--reader-muted); font-size: 0.6rem; letter-spacing: 0.18em; user-select: none; }

/* ========================================================================== 
   Reader Room Phase 1 — reader-first home
   ========================================================================== */
.library-page {
  --accent: var(--red);
  --accent-soft: #a81b28;
}
html[data-theme="dark"] .library-page { --accent-soft: #ff6d78; }

.reader-home-header {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  gap: clamp(18px, 3vw, 36px);
  min-height: 76px;
}
.reader-home-header .header-actions { justify-content: flex-end; }
.reader-primary-nav { display: flex; align-items: center; justify-content: center; gap: 4px; }
.reader-primary-nav a {
  border-radius: 999px;
  padding: 9px 13px;
  color: #aaa4a7;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .03em;
  text-decoration: none;
  white-space: nowrap;
}
.reader-primary-nav a:hover, .reader-primary-nav a.active { background: rgba(255,255,255,.09); color: #fff; }
.reader-primary-nav a.active { box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }

.reader-home-shell { width: min(1120px, calc(100% - 40px)); padding: 42px 0 110px; }
.reader-home-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 34px;
  overflow: hidden;
  border: 1px solid #252529;
  border-radius: 20px;
  padding: clamp(30px, 5vw, 58px);
  background:
    radial-gradient(circle at 88% 14%, rgba(200,20,36,.30), transparent 31%),
    linear-gradient(135deg, #0b0b0d, #17171a 72%);
  color: #fff;
  box-shadow: 0 22px 54px rgba(0,0,0,.28);
}
.reader-home-hero::after {
  position: absolute;
  right: -70px;
  bottom: -105px;
  width: 280px;
  height: 280px;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 50%;
  content: "";
}
.reader-home-copy { position: relative; z-index: 1; max-width: 760px; }
.reader-home-copy .eyebrow { color: #ee5360; }
.reader-home-copy h1 { max-width: 780px; color: #fff; font-size: clamp(2.5rem, 6vw, 4.65rem); }
.reader-home-copy > p:last-child { max-width: 620px; margin: 22px 0 0; color: #c7c0c2; font-size: 1.02rem; line-height: 1.7; }
.reader-home-profile-link {
  position: relative;
  z-index: 1;
  display: grid;
  min-width: 200px;
  gap: 7px;
  border-left: 1px solid rgba(255,255,255,.17);
  padding: 8px 0 8px 24px;
  color: #fff;
  text-decoration: none;
}
.reader-home-profile-link span { color: #8e898b; font-size: .68rem; font-weight: 900; letter-spacing: .12em; }
.reader-home-profile-link strong { font-size: .9rem; }
.reader-home-profile-link:hover strong { color: #ff7480; }

.reader-alert-region { display: grid; gap: 12px; margin-top: 22px; }
.reader-system-alert {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px;
  border: 1px solid var(--reader-line);
  border-left: 5px solid #6f7075;
  border-radius: 13px;
  padding: 18px 20px;
  background: var(--reader-raised);
  box-shadow: 0 12px 30px rgba(0,0,0,.1);
}
.reader-system-alert.important { border-left-color: #b16b13; }
.reader-system-alert.outage { border-left-color: var(--red); background: color-mix(in srgb, var(--reader-raised) 93%, var(--red)); }
.reader-system-alert-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: var(--reader-subtle); color: var(--reader-ink); font-weight: 950; }
.reader-system-alert.important .reader-system-alert-mark { color: #c47b18; }
.reader-system-alert.outage .reader-system-alert-mark { background: var(--red); color: #fff; }
.reader-system-alert-copy span { color: var(--reader-muted); font-size: .67rem; font-weight: 950; letter-spacing: .1em; }
.reader-system-alert-copy h2 { margin: 3px 0 4px; color: var(--reader-ink); font-size: 1.05rem; }
.reader-system-alert-copy p { margin: 0; color: var(--reader-muted); line-height: 1.5; }
.reader-alert-dismiss { border: 0; padding: 6px 0; background: transparent; color: var(--reader-muted); cursor: pointer; font: inherit; font-size: .76rem; font-weight: 850; }
.reader-alert-dismiss:hover { color: var(--reader-ink); }

.reader-home-section { margin-top: 48px; scroll-margin-top: 104px; }
.reader-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 18px; }
.reader-section-heading h2 { margin: 0; color: var(--reader-ink); font-size: clamp(1.75rem, 3.5vw, 2.45rem); }
.reader-section-heading > p { max-width: 390px; margin: 0; color: var(--reader-muted); line-height: 1.55; text-align: right; }

.continue-round-card {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr) auto;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--reader-line);
  border-radius: 16px;
  background: var(--reader-raised);
  box-shadow: 0 16px 42px rgba(0,0,0,.14);
}
.continue-round-mark {
  display: grid;
  place-items: center;
  min-height: 190px;
  background:
    radial-gradient(circle at 50% 20%, rgba(200,20,36,.62), transparent 32%),
    linear-gradient(160deg, #171719, #050506);
  color: #fff;
}
.continue-round-mark span { border: 1px solid rgba(255,255,255,.18); padding: 12px 9px; font-family: Georgia, "Times New Roman", serif; font-size: .86rem; font-weight: 900; letter-spacing: .14em; }
.continue-round-copy { min-width: 0; align-self: center; padding: 28px 30px; }
.continue-round-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--reader-muted); font-size: .7rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.continue-round-meta span:first-child { color: var(--red); }
.continue-round-copy h3 { margin: 10px 0 8px; color: var(--reader-ink); font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.85rem, 4vw, 2.8rem); line-height: 1.04; }
.continue-round-copy p { margin: 0; color: var(--reader-muted); line-height: 1.55; }
.continue-round-action { display: grid; min-width: 215px; align-content: center; gap: 13px; border-left: 1px solid var(--reader-line); padding: 28px; background: var(--reader-subtle); }
.continue-round-action > span { color: var(--reader-muted); font-size: .76rem; font-weight: 800; line-height: 1.4; }

.bookmail-section { border-top: 1px solid var(--reader-line); padding-top: 42px; }
.bookmail-summary { display: grid; gap: 12px; }
.bookmail-home-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--reader-line);
  border-left: 5px solid var(--red);
  border-radius: 13px;
  padding: 20px 22px;
  background: var(--reader-raised);
}
.bookmail-home-icon { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 50%; background: var(--reader-subtle); color: var(--red); font-size: 1.15rem; }
.bookmail-home-copy { min-width: 0; }
.bookmail-home-copy > span { color: var(--red); font-size: .68rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.bookmail-home-copy h3 { margin: 4px 0 3px; color: var(--reader-ink); font-family: Georgia, "Times New Roman", serif; font-size: 1.25rem; }
.bookmail-home-copy p { margin: 0; color: var(--reader-muted); font-size: .86rem; line-height: 1.45; }
.library-page .bookmail-home-card .button-neutral { border-color: var(--reader-neutral-border); color: var(--reader-ink); }

.library-books-panel { min-width: 0; border-top: 1px solid var(--reader-line); padding-top: 42px; }
.library-status { margin: 22px 0 0; }
.book-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.book-card {
  position: relative;
  display: grid;
  grid-template-columns: 5px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--reader-line);
  border-radius: 14px;
  background: var(--reader-raised);
  box-shadow: 0 10px 30px rgba(0,0,0,.10);
}
.book-card-accent { background: var(--red); }
.book-card.unavailable .book-card-accent { background: var(--reader-line); }
.book-details { display: block; min-height: 0; padding: 26px 26px 24px; }
.book-details h3 { margin: 12px 0 4px; color: var(--reader-ink); font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.45rem, 2.5vw, 1.9rem); line-height: 1.08; }
.book-card-labels { gap: 7px 10px; }
.book-card-labels p { line-height: 1.2; }
.book-round-name { margin: 0 !important; color: var(--reader-ink) !important; font-size: .8rem; font-weight: 850; }
.book-description { display: -webkit-box; overflow: hidden; margin: 15px 0 0 !important; color: var(--reader-muted) !important; line-height: 1.55 !important; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.book-chapter-cue { margin: 18px 0 0 !important; border-top: 1px solid var(--reader-line); padding-top: 13px; color: var(--reader-muted) !important; font-size: .74rem; font-weight: 800; }
.book-card-actions { margin-top: 18px; }
.library-page .book-card-actions .button-neutral { border-color: var(--reader-neutral-border); color: var(--reader-ink); }
.book-card.unavailable { box-shadow: none; }

/* Old cover placeholder remains defined for compatibility with older cached markup. */
.book-card .cover-placeholder { display: none; }

@media (max-width: 980px) {
  .reader-home-header { grid-template-columns: 1fr auto; gap: 10px 18px; }
  .reader-home-header .brand { grid-column: 1; }
  .reader-home-header .header-actions { grid-column: 2; }
  .reader-primary-nav { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; overflow-x: auto; padding-top: 2px; }
  .reader-home-hero { grid-template-columns: 1fr; align-items: start; }
  .reader-home-profile-link { width: fit-content; min-width: 0; border-left: 0; border-top: 1px solid rgba(255,255,255,.17); padding: 18px 0 0; }
  .continue-round-card { grid-template-columns: 82px minmax(0, 1fr); }
  .continue-round-action { grid-column: 2; min-width: 0; border-top: 1px solid var(--reader-line); border-left: 0; padding: 18px 30px 26px; }
  .continue-round-action .button { justify-self: start; }
}

@media (max-width: 760px) {
  .reader-home-shell { width: min(100% - 24px, 680px); padding-top: 22px; }
  .reader-home-header { position: sticky; min-height: 0; padding: 11px 14px 10px; }
  .reader-home-header .brand span { display: none; }
  .reader-home-header .reader-label { display: none; }
  .reader-home-header .theme-toggle span { display: none; }
  .reader-home-header .theme-toggle { width: 40px; justify-content: center; padding: 8px; }
  .reader-home-header .header-actions { gap: 9px; }
  .reader-primary-nav { gap: 2px; }
  .reader-primary-nav a { padding: 7px 10px; font-size: .72rem; }
  .reader-home-hero { gap: 28px; border-radius: 16px; padding: 30px 24px; }
  .reader-home-copy h1 { font-size: clamp(2.35rem, 13vw, 3.55rem); }
  .reader-home-section { margin-top: 38px; }
  .reader-section-heading { align-items: start; flex-direction: column; gap: 8px; margin-bottom: 14px; }
  .reader-section-heading > p { max-width: none; text-align: left; }
  .continue-round-card { grid-template-columns: 1fr; }
  .continue-round-mark { min-height: 80px; }
  .continue-round-copy { padding: 23px 22px 18px; }
  .continue-round-action { grid-column: 1; padding: 18px 22px 23px; }
  .continue-round-action .button { width: 100%; }
  .bookmail-home-card { grid-template-columns: auto minmax(0,1fr); align-items: start; padding: 18px; }
  .bookmail-home-card .button { grid-column: 1 / -1; width: 100%; }
  .book-grid { grid-template-columns: 1fr; }
  .book-details { padding: 23px 21px 21px; }
  .book-card-actions { display: grid; }
  .book-card-actions .button { width: 100%; }
}

@media (max-width: 650px) {
  .reader-system-alert { grid-template-columns: auto minmax(0,1fr); padding: 16px; }
  .reader-alert-dismiss { grid-column: 2; justify-self: start; }
}


/* Phase 4: private audiobook player */
.listen-shell {
  width: min(920px, calc(100% - 40px));
  margin: 0 auto;
  padding: 34px 0 100px;
}
.listen-back-link {
  display: inline-flex;
  margin-bottom: 28px;
  color: var(--reader-muted);
  font-size: .82rem;
  font-weight: 850;
  text-decoration: none;
}
.listen-back-link:hover { color: var(--reader-ink); }
.listen-book-heading { margin-bottom: 24px; }
.listen-book-heading h1 {
  margin: 3px 0 8px;
  color: var(--reader-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.35rem, 7vw, 4.8rem);
  line-height: 1;
  overflow-wrap: anywhere;
}
.listen-book-heading > p:last-child { margin: 0; color: var(--reader-muted); font-weight: 750; }
.audio-player-card {
  overflow: hidden;
  border: 1px solid var(--reader-line);
  border-radius: 20px;
  padding: clamp(24px, 5vw, 46px);
  background: var(--reader-paper);
  box-shadow: var(--reader-shadow);
}
.audio-player-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}
.audio-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}
.audio-heading-actions .button { white-space: nowrap; }
.audio-player-heading h2 {
  margin: 5px 0 7px;
  color: var(--reader-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 3.35rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}
.audio-chapter-meta { margin: 0; color: var(--reader-muted); line-height: 1.5; }
#private-audio { display: none; }
.audio-timeline { margin-top: 8px; }
.audio-timeline input[type="range"] { width: 100%; accent-color: var(--red); cursor: pointer; }
.audio-time-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 5px;
  color: var(--reader-muted);
  font-variant-numeric: tabular-nums;
  font-size: .76rem;
  font-weight: 800;
}
.audio-primary-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(26px, 7vw, 64px);
  margin: 30px 0;
}
.audio-play-button, .audio-skip-button {
  border: 0;
  background: transparent;
  color: var(--reader-ink);
  cursor: pointer;
}
.audio-play-button {
  display: grid;
  width: 82px;
  height: 82px;
  place-items: center;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  box-shadow: 0 10px 28px rgba(0,0,0,.22);
  font-size: 1.55rem;
}
.audio-play-button:hover { transform: translateY(-1px); }
.audio-skip-button { display: grid; min-width: 46px; place-items: center; gap: 1px; font-size: .9rem; }
.audio-skip-button span { font-size: 1.65rem; line-height: .9; }
.audio-skip-button b { font-size: .7rem; }
.audio-secondary-controls {
  display: grid;
  grid-template-columns: minmax(130px, .65fr) minmax(220px, 1.35fr);
  gap: 18px;
  border-top: 1px solid var(--reader-line);
  border-bottom: 1px solid var(--reader-line);
  padding: 20px 0;
}
.audio-secondary-controls label { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; }
.audio-secondary-controls label > span { color: var(--reader-muted); font-size: .72rem; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
.audio-secondary-controls select {
  min-height: 42px;
  border: 1px solid var(--reader-line);
  border-radius: 9px;
  padding: 7px 10px;
  background: var(--reader-input);
  color: var(--reader-ink);
  font: inherit;
  font-weight: 800;
}
.audio-volume-control input { width: 100%; accent-color: var(--red); }
.audio-chapter-list {
  display: grid;
  max-height: 390px;
  overflow-y: auto;
  margin: -12px 0 26px;
  border: 1px solid var(--reader-line);
  border-radius: 12px;
  background: var(--reader-subtle);
}
.audio-chapter-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--reader-line);
  padding: 15px 17px;
  color: var(--reader-ink);
  text-decoration: none;
}
.audio-chapter-list-item:last-child { border-bottom: 0; }
.audio-chapter-list-item:hover, .audio-chapter-list-item.current { background: var(--reader-raised); }
.audio-chapter-list-item.current { box-shadow: inset 4px 0 0 var(--red); }
.audio-chapter-list-item span { display: grid; min-width: 0; gap: 3px; }
.audio-chapter-list-item b { overflow-wrap: anywhere; }
.audio-chapter-list-item small { color: var(--reader-muted); }
.audio-chapter-list-item i { color: var(--reader-muted); font-style: normal; font-size: .78rem; font-weight: 900; white-space: nowrap; }
.audio-chapter-navigation {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin-top: 28px;
}
.audio-chapter-navigation > span { color: var(--reader-muted); font-size: .76rem; font-weight: 900; text-align: center; }
.audio-chapter-navigation .button:first-child { justify-self: start; }
.audio-chapter-navigation .button:last-child { justify-self: end; }
.audio-chapter-navigation .button:disabled { opacity: .35; cursor: default; }
.listen-page .button-neutral { border-color: var(--reader-neutral-border); color: var(--reader-ink); }
.audio-complete-panel {
  margin-top: 28px;
  border-top: 1px solid var(--reader-line);
  padding-top: 26px;
  text-align: center;
}
.audio-complete-panel h3 { margin: 5px 0 18px; color: var(--reader-ink); font-size: 1.35rem; }

@media (max-width: 760px) {
  .listen-shell { width: min(100% - 24px, 680px); padding-top: 20px; }
  .audio-player-card { border-radius: 16px; padding: 24px 20px; }
  .audio-player-heading { align-items: stretch; flex-direction: column; gap: 16px; margin-bottom: 26px; }
  .audio-heading-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; }
  .audio-player-heading .audio-heading-actions .button { width: 100%; }
  .audio-chapter-list { max-height: min(55vh, 390px); margin: -4px 0 24px; }
  .audio-primary-controls { gap: 28px; }
  .audio-play-button { width: 74px; height: 74px; }
  .audio-secondary-controls { grid-template-columns: 1fr; }
  .audio-chapter-navigation { grid-template-columns: 1fr 1fr; }
  .audio-chapter-navigation > span { grid-column: 1 / -1; grid-row: 1; }
  .audio-chapter-navigation .button { width: 100%; }
}

@media (max-width: 480px) {
  .audio-primary-controls { justify-content: space-around; gap: 12px; }
  .audio-chapter-list-item { align-items: start; gap: 10px; padding: 14px; }
  .audio-chapter-navigation { grid-template-columns: 1fr; }
  .audio-chapter-navigation > span, .audio-chapter-navigation .button { grid-column: 1; }
  .audio-chapter-navigation .button:first-child, .audio-chapter-navigation .button:last-child { justify-self: stretch; }
}

/* Audiobook in-chapter reactions, notes, and freeform feedback */
.audio-live-feedback {
  margin-top: 28px;
  border: 1px solid var(--reader-line);
  border-radius: 14px;
  padding: 22px;
  background: var(--reader-subtle);
}
.audio-feedback-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 22px;
}
.audio-feedback-heading h3 { margin: 4px 0 7px; color: var(--reader-ink); font-size: 1.28rem; }
.audio-feedback-heading p:last-child { max-width: 610px; margin: 0; color: var(--reader-muted); line-height: 1.5; }
.audio-note-moment-button { white-space: nowrap; }
.audio-live-feedback .audio-reaction-buttons { justify-content: flex-start; margin: 20px 0 6px; }
.audio-live-feedback .status-message { min-height: 1.2em; margin: 8px 0 0; }
.audio-chapter-feedback-form {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  border-top: 1px solid var(--reader-line);
  padding-top: 20px;
}
.audio-chapter-feedback-form > label,
.audio-note-dialog label { color: var(--reader-ink); font-size: .78rem; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; }
.audio-chapter-feedback-form textarea,
.audio-note-dialog textarea {
  width: 100%;
  border: 1px solid var(--reader-line);
  border-radius: 10px;
  padding: 13px 14px;
  background: var(--reader-input);
  color: var(--reader-ink);
  font: inherit;
  line-height: 1.55;
  resize: vertical;
}
.audio-chapter-feedback-form textarea:focus,
.audio-note-dialog textarea:focus { outline: 3px solid color-mix(in srgb, var(--red) 22%, transparent); border-color: var(--red); }
.audio-feedback-save-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.audio-feedback-save-row .status-message { flex: 1; margin: 0; }
.audio-timestamp-notes { margin-top: 18px; border-top: 1px solid var(--reader-line); padding-top: 16px; }
.audio-timestamp-notes summary {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  color: var(--reader-ink);
  cursor: pointer;
  font-weight: 900;
  list-style: none;
}
.audio-timestamp-notes summary::-webkit-details-marker { display: none; }
.audio-timestamp-notes summary::after { content: '+'; margin-left: auto; color: var(--red); font-size: 1.2rem; }
.audio-timestamp-notes[open] summary::after { content: '−'; }
.audio-timestamp-notes summary span:last-child {
  min-width: 28px;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--reader-raised);
  color: var(--reader-muted);
  font-size: .72rem;
  text-align: center;
}
.audio-timestamp-note-list { display: grid; gap: 9px; margin-top: 14px; }
.audio-timestamp-empty { margin: 0; color: var(--reader-muted); font-size: .86rem; line-height: 1.5; }
.audio-timestamp-note {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  border: 1px solid var(--reader-line);
  border-left: 4px solid var(--red);
  border-radius: 10px;
  padding: 12px 13px;
  background: var(--reader-raised);
}
.audio-timestamp-note p { margin: 2px 0 0; color: var(--reader-ink); line-height: 1.5; white-space: pre-wrap; }
.audio-note-jump,
.audio-note-delete { border: 0; background: transparent; cursor: pointer; font: inherit; font-weight: 900; }
.audio-note-jump { padding: 2px 0; color: var(--red); font-variant-numeric: tabular-nums; }
.audio-note-delete { padding: 2px 0; color: var(--reader-muted); font-size: .72rem; }
.audio-note-delete:hover { color: var(--red); }
.audio-note-dialog {
  width: min(620px, calc(100% - 28px));
  border: 1px solid var(--reader-line);
  border-radius: 16px;
  padding: 0;
  background: var(--reader-paper);
  color: var(--reader-ink);
  box-shadow: 0 26px 80px rgba(0,0,0,.5);
}
.audio-note-dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(2px); }
.audio-note-dialog form { display: grid; gap: 14px; margin: 0; padding: 24px; }
.audio-note-dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.audio-note-dialog-heading h3 { margin: 4px 0 0; color: var(--reader-ink); font-size: 1.5rem; }
.audio-note-close { border: 0; padding: 0 4px; background: transparent; color: var(--reader-muted); cursor: pointer; font-size: 1.9rem; line-height: 1; }
.audio-note-time { margin: 0; color: var(--reader-muted); }
.audio-note-time strong { color: var(--red); font-variant-numeric: tabular-nums; }
.audio-note-actions { display: flex; justify-content: flex-end; gap: 10px; }

.audio-chapter-questions-block {
  margin-top: 22px;
  border-top: 1px solid var(--reader-line);
  padding-top: 20px;
}
.audio-chapter-questions-heading h3 { margin: 4px 0 7px; color: var(--reader-ink); font-size: 1.18rem; }
.audio-chapter-questions-heading p:last-child { margin: 0; color: var(--reader-muted); line-height: 1.5; }
.audio-chapter-questions-block .audio-chapter-survey { max-width: none; margin: 16px 0 0; }
.audio-chapter-questions-block .audio-feedback-actions { justify-content: flex-end; }

/* Phase 5: audiobook chapter feedback */
.audio-feedback-intro {
  max-width: 650px;
  margin: -6px auto 20px;
  color: var(--reader-muted);
  line-height: 1.55;
}
.audio-reaction-buttons {
  justify-content: center;
  margin: 0 auto 8px;
}
.audio-chapter-survey {
  display: grid;
  gap: 18px;
  max-width: 720px;
  margin: 24px auto 0;
  text-align: left;
}
.audio-survey-questions { display: grid; gap: 14px; }
.audio-survey-question {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin: 0;
  border: 1px solid var(--reader-line);
  border-radius: 12px;
  padding: 17px;
  background: var(--reader-subtle);
}
.audio-survey-question legend {
  max-width: 100%;
  padding: 0 6px;
  color: var(--reader-ink);
  font-weight: 850;
  line-height: 1.4;
}
.audio-question-meta {
  color: var(--reader-muted);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.audio-question-required { color: var(--red); }
.audio-survey-question textarea,
.audio-survey-question select {
  width: 100%;
  border: 1px solid var(--reader-line);
  border-radius: 9px;
  padding: 10px 12px;
  background: var(--reader-input);
  color: var(--reader-ink);
  font: inherit;
}
.audio-survey-question textarea { resize: vertical; }
.audio-survey-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
}
.audio-survey-choice-row label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--reader-ink);
  font-weight: 750;
}
.audio-feedback-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}
.audio-feedback-no-survey { margin-top: 18px; }
.audio-final-survey-link { margin-top: 16px; }

@media (max-width: 600px) {
  .audio-feedback-heading { flex-direction: column; }
  .audio-live-feedback .audio-reaction-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .audio-live-feedback .reaction-button { min-width: 0; justify-content: flex-start; gap: 7px; padding: 9px 9px; }
  .audio-live-feedback .reaction-emoji { flex: 0 0 auto; font-size: 1.25rem; }
  .audio-live-feedback .reaction-label { min-width: 0; overflow: visible; font-size: .78rem; line-height: 1.15; overflow-wrap: anywhere; white-space: normal; text-align: left; }
  .audio-feedback-save-row { align-items: stretch; flex-direction: column; }
  .audio-feedback-save-row .button { width: 100%; }
  .audio-timestamp-note { grid-template-columns: auto minmax(0, 1fr); }
  .audio-note-delete { grid-column: 2; justify-self: end; }
  .audio-note-actions { display: grid; grid-template-columns: 1fr; }
  .audio-note-actions .button { width: 100%; }
  .audio-feedback-actions { display: grid; grid-template-columns: 1fr; }
  .audio-feedback-actions .button { width: 100%; }
  .audio-survey-question { padding: 14px; }
}


/* Phase 6: audiobook hardening, recovery, and small-screen polish */
.listen-error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: -8px 0 22px;
}
.listen-error-actions[hidden] { display: none !important; }
.listen-error-actions .button { min-height: 44px; }
.audio-play-button,
.audio-skip-button,
.audio-timeline input[type="range"],
.audio-volume-control input[type="range"] { touch-action: manipulation; }
.audio-play-button:focus-visible,
.audio-skip-button:focus-visible,
.audio-chapter-list-item:focus-visible,
.audio-timeline input[type="range"]:focus-visible,
.audio-volume-control input[type="range"]:focus-visible {
  outline: 3px solid var(--reader-ink);
  outline-offset: 4px;
}
@media (max-width: 480px) {
  .listen-page .reader-home-header { width: 100%; grid-template-columns: minmax(0, 1fr) auto; overflow: hidden; }
  .listen-page .reader-primary-nav { max-width: 100%; overflow-x: visible; flex-wrap: wrap; }
  .listen-page .header-actions { max-width: 100%; }
  .listen-page .audio-heading-actions { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .listen-page .audio-heading-actions .button { min-width: 0; padding-inline: 10px; font-size: .78rem; white-space: normal; }
  .listen-error-actions { display: grid; grid-template-columns: 1fr; }
  .listen-error-actions .button { width: 100%; }
  .audio-secondary-controls label { grid-template-columns: 1fr; align-items: stretch; }
  .audio-secondary-controls label > span { margin-bottom: -3px; }
}
@media (max-width: 360px) {
  .listen-shell { width: min(100% - 16px, 680px); }
  .audio-player-card { padding: 20px 14px; }
  .audio-primary-controls { margin: 24px 0; }
  .audio-play-button { width: 68px; height: 68px; }
  .audio-skip-button { min-width: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  .audio-play-button:hover { transform: none; }
}
