/* =========================================================================
   Asfandiar — site styles

   A quiet, paper-feeling reading site. Two views: a cover-and-contents
   home page, and a single-column chapter reader with a minimal top bar.
   No persistent sidebar. Book branding lives only on the home page.
   ========================================================================= */

:root {
  /* Light mode — warm paper, slate ink */
  --bg: #f7f1e3;
  --bg-deep: #f1e9d4;
  --bg-elev: #efe7d0;
  --paper: #f9f3e6;
  --fg: #1a1410;
  --fg-soft: #4f463c;
  --fg-mute: #8a7f6e;
  --accent: #8a2a1e;
  --accent-soft: #b14538;
  --rule: #d8cdb2;
  --rule-soft: #e3d9bf;
  --link: #6a3b2c;
  --link-hover: #1a1410;
  --shadow: rgba(34, 24, 14, 0.10);
  --shadow-strong: rgba(34, 24, 14, 0.22);
  --grain-opacity: 0.030;

  --max-reading: 34rem;     /* ~62ch with current type size */
  --max-content: 40rem;

  --font-serif: "Source Serif 4", "Source Serif Pro", "Iowan Old Style",
                "Palatino Linotype", Palatino, "Hoefler Text", Georgia, serif;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
             Helvetica, Arial, sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Cover (poppy) palette */
  --cover-petal: #b8362a;
  --cover-petal-dark: #7a1d12;
  --cover-petal-bright: #d04738;
  --cover-center: #1a0e08;
  --cover-center-dark: #000;
  --cover-stem: #4a5a32;
  --cover-leaf: #708545;
  --cover-leaf-dark: #4d5e2d;
  --cover-shadow: #2a1a10;
  --cover-ground: #6b6358;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14110d;
    --bg-deep: #0e0c09;
    --bg-elev: #1d1812;
    --paper: #14110d;
    --fg: #ece6d6;
    --fg-soft: #b8ad97;
    --fg-mute: #7a705e;
    --accent: #d97a68;
    --accent-soft: #c66454;
    --rule: #2d2620;
    --rule-soft: #221d18;
    --link: #d9a08e;
    --link-hover: #ece6d6;
    --shadow: rgba(0, 0, 0, 0.5);
    --shadow-strong: rgba(0, 0, 0, 0.75);
    --grain-opacity: 0.025;

    --cover-petal: #c8362a;
    --cover-petal-dark: #862217;
    --cover-petal-bright: #d8473a;
    --cover-center: #0a0604;
    --cover-center-dark: #000;
    --cover-stem: #6d8245;
    --cover-leaf: #859e54;
    --cover-leaf-dark: #5a6f38;
    --cover-shadow: #000;
    --cover-ground: #3a342d;
  }
}

/* ----------------------------------------------------------------------- */

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

/* CRITICAL: the [hidden] attribute must always win over our display rules. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.65;
  font-feature-settings: "kern" 1, "liga" 1, "onum" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* A very faint paper grain over everything — subtle, never noisy. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply;
}
@media (prefers-color-scheme: dark) {
  body::before { mix-blend-mode: screen; }
}

main, .reading-progress { position: relative; z-index: 2; }

/* Reading progress bar */
.reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  z-index: 200;
  transition: width 0.15s ease-out;
  pointer-events: none;
}

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--fg);
}

/* ======================================================================
   HOME / COVER
   ====================================================================== */

.home {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeIn 0.6s var(--ease);
}

.cover {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  justify-items: center;
  padding: 3rem 1.5rem 2rem;
  position: relative;
}

/* The poppy is the hero. The title sits beneath it, like a foot-note. */
.cover-flower-wrap {
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6rem;
  animation: coverRise 1.4s var(--ease-out) both;
}

.cover-flower {
  width: clamp(16rem, 34vw, 24rem);
  height: auto;
  display: block;
  filter:
    drop-shadow(0 14px 30px rgba(0, 0, 0, 0.18))
    drop-shadow(0 2px 4px rgba(0, 0, 0, 0.10));
}

.cover-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-variation-settings: "opsz" 60;
  font-size: clamp(3.25rem, 9.5vw, 6.75rem);
  margin: 0;
  line-height: 0.95;
  letter-spacing: -0.028em;
  color: var(--fg);
  text-align: center;
}

.cover-subtitle {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.36em;
  color: var(--fg-mute);
  margin: 0.2rem 0 0;
  padding-left: 0.36em; /* compensate optical for tracking on last char */
  text-align: center;
}

/* Scroll affordance — a quiet down-chevron between cover and contents. */
.cover-scroll {
  grid-row: 3;
  align-self: end;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--fg-mute);
  font-family: var(--font-ui);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 999px;
  transition: color 0.2s var(--ease), transform 0.3s var(--ease);
  animation: fadeIn 1.2s 0.6s var(--ease-out) both;
}
.cover-scroll:hover { color: var(--accent); transform: translateY(2px); }
.cover-scroll-chevron {
  width: 14px; height: 14px;
  animation: nudge 2.4s ease-in-out infinite;
}
@keyframes nudge {
  0%, 100% { transform: translateY(0); opacity: 0.55; }
  50%      { transform: translateY(4px); opacity: 0.9; }
}

@keyframes coverRise {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Contents section below the cover ---- */

.contents {
  width: 100%;
  max-width: var(--max-content);
  padding: 5rem 1.5rem 7rem;
}
.contents-title {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.32em;
  color: var(--fg-mute);
  text-align: center;
  margin: 0 0 3rem;
}
.contents-title::before,
.contents-title::after {
  content: "";
  display: inline-block;
  width: 1.5rem;
  height: 1px;
  background: var(--rule);
  vertical-align: middle;
  margin: 0 1rem;
  transform: translateY(-2px);
}

.chapter-list ol {
  list-style: none;
  padding: 0;
  margin: 0;
}
.chapter-list li {
  border-top: 1px solid var(--rule-soft);
}
.chapter-list li:last-child {
  border-bottom: 1px solid var(--rule-soft);
}
.chapter-link {
  display: grid;
  grid-template-columns: 3.5rem 1fr auto;
  align-items: baseline;
  gap: 1rem;
  padding: 1.35rem 1rem;
  color: var(--fg);
  text-decoration: none;
  font-family: var(--font-serif);
  font-size: 1.18rem;
  line-height: 1.4;
  transition: background 0.18s var(--ease), color 0.18s var(--ease),
              padding-left 0.25s var(--ease);
  position: relative;
}
.chapter-link::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0; bottom: 0;
  border-left: 2px solid transparent;
  pointer-events: none;
  transition: border-color 0.2s var(--ease);
}
.chapter-link:hover {
  color: var(--accent);
  background: var(--bg-elev);
  padding-left: 1.35rem;
}
.chapter-link:hover::after { border-left-color: var(--accent); }
.chapter-link .num {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--fg-mute);
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
}
.chapter-link:hover .num { color: var(--accent); }
.chapter-link .title {
  font-style: italic;
  font-variation-settings: "opsz" 24;
}
.chapter-link .tag-audio {
  font-family: var(--font-ui);
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-mute);
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
}
.chapter-link .tag-audio::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--fg-mute);
  display: inline-block;
}
.chapter-link:hover .tag-audio { color: var(--accent-soft); }
.chapter-link:hover .tag-audio::before { background: var(--accent-soft); }

.contents-note {
  text-align: center;
  font-family: var(--font-ui);
  font-style: italic;
  font-size: 0.78rem;
  color: var(--fg-mute);
  letter-spacing: 0.01em;
  margin: 3.5rem 0 0;
}

.family-link-wrap {
  margin: 3rem 0 0;
}
.family-link {
  display: block;
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
  padding: 1.2rem 1rem;
  text-decoration: none;
  color: var(--fg);
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.family-link:hover {
  background: var(--bg-elev);
  color: var(--accent);
}
.family-link-kicker,
.family-link-text {
  display: block;
  font-family: var(--font-ui);
  color: var(--fg-mute);
}
.family-link-kicker {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.family-link-title {
  display: block;
  font-style: italic;
  font-size: 1.2rem;
  line-height: 1.35;
}
.family-link-text {
  font-size: 0.78rem;
  line-height: 1.5;
  margin-top: 0.25rem;
}

.loading-skeleton {
  padding: 1rem 0;
}
.skeleton-line {
  height: 1.05rem;
  background: linear-gradient(90deg, var(--rule-soft), var(--rule), var(--rule-soft));
  background-size: 200% 100%;
  border-radius: 3px;
  margin: 1rem 0;
  animation: shimmer 1.5s ease-in-out infinite;
}
.skeleton-line.short { width: 70%; }
@keyframes shimmer {
  0%, 100% { background-position: 200% 0; }
  50% { background-position: -200% 0; }
}

/* ======================================================================
   READER (chapter view)
   ====================================================================== */

.reader {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 5rem;
  animation: fadeIn 0.4s var(--ease);
}

.family-page {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 5rem;
  animation: fadeIn 0.4s var(--ease);
}

.family-panel {
  width: 100%;
  max-width: 46rem;
  padding: 5rem 1.5rem 0;
}

.family-head {
  text-align: center;
  margin-bottom: 2.5rem;
}

.family-intro {
  max-width: 36rem;
  margin: 2rem auto 0;
  color: var(--fg-soft);
  font-size: 1.02rem;
  line-height: 1.7;
}

.family-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  padding: 1rem;
  border: 1px solid var(--rule-soft);
  background: var(--bg-elev);
  font-family: var(--font-ui);
}

.family-person {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 10rem;
  margin-right: auto;
  color: var(--fg-soft);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.family-person select,
.question-card textarea {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  color: var(--fg);
  font: inherit;
}

.family-person select {
  padding: 0.55rem 0.65rem;
  font-family: var(--font-ui);
  text-transform: none;
  letter-spacing: 0;
}

.family-tool-btn,
.save-question-btn {
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease),
              border-color 0.18s var(--ease);
}

.family-tool-btn:hover,
.save-question-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--bg);
}

.save-question-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.family-tool-btn.danger {
  color: var(--accent);
}

.family-note {
  margin: 1rem 0 1.5rem;
  color: var(--fg-mute);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  line-height: 1.6;
  border-left: 3px solid color-mix(in srgb, var(--accent) 42%, transparent);
  border-radius: 0 8px 8px 0;
  padding: 0.58rem 0.7rem;
  background: color-mix(in srgb, var(--paper) 74%, var(--bg) 26%);
}

.family-note.is-error {
  color: var(--accent);
}

.question-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.35rem;
  border: 1px solid var(--rule-soft);
  background: var(--bg-elev);
  margin: 0 0 1.5rem;
}

.question-tab {
  flex: 1;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--fg-soft);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.7rem 0.5rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.question-tab.is-active {
  background: var(--paper);
  color: var(--accent);
  box-shadow: 0 1px 3px var(--shadow);
}

.question-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55rem;
  height: 1.55rem;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: #b3541a;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.question-tab-count.is-empty {
  background: #1f5f34;
  color: #fff;
}

.question-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.question-card {
  border-top: 1px solid var(--rule-soft);
  padding: 1.25rem 0 0;
}

.question-top {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.75rem;
  align-items: baseline;
  margin-bottom: 0.75rem;
}

.question-num {
  color: var(--fg-mute);
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.question-card h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.45;
}

.question-card textarea {
  min-height: 7rem;
  position: relative;
  padding: 0.85rem;
  resize: vertical;
  font-family: var(--font-serif);
  font-size: 1.12rem;
  line-height: 1.55;
  border-color: var(--rule);
  transition: border-color 0.2s var(--ease),
              box-shadow 0.2s var(--ease),
              background-color 0.2s var(--ease);
}
.question-input-shell {
  position: relative;
}

.question-input-shell textarea {
  width: 100%;
  box-sizing: border-box;
}

.question-card textarea::placeholder {
  color: var(--fg-mute);
  font-weight: 400;
  font-style: italic;
}
.question-card.is-focused textarea,
.question-card.is-typing textarea {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent);
  background: color-mix(in srgb, var(--paper) 90%, var(--accent) 10%);
}

.question-input-guide {
  margin: 0.72rem 0 0;
  color: #2b251f;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.55;
  border: 1px dashed color-mix(in srgb, var(--rule) 70%, transparent);
  background: color-mix(in srgb, var(--paper) 88%, var(--bg) 12%);
  border-radius: 8px;
  padding: 0.62rem 0.7rem;
}

.question-input-guide:empty {
  display: none;
}

.question-instruction-title {
  display: block;
  font-weight: 700;
  margin-bottom: 0.42rem;
  color: var(--accent);
  font-size: 1.02rem;
}

.question-instruction-step {
  display: block;
  margin-top: 0.32rem;
  font-size: 0.98rem;
}

.question-function-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  margin: 0 0.22rem;
  width: 4.05rem;
  height: 2.65rem;
}

.question-function-key svg {
  width: 100%;
  height: 100%;
}

.question-function-key rect {
  fill: var(--paper);
  stroke: #2b251f;
  stroke-width: 1.6;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.25));
}

.question-function-key text {
  fill: var(--fg);
  font-family: var(--font-ui);
  font-size: 0.98rem;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
}

.question-input-guide .question-function-key {
  transform: translateY(0.15rem);
}

.question-input-guide.is-active {
  color: var(--accent);
}

.question-input-guide strong {
  color: var(--accent);
}

.question-saved-meta {
  margin: 0.28rem 0 0;
  color: var(--fg-soft);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  line-height: 1.35;
  font-weight: 500;
}

.question-card.is-focused .question-input-guide {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 65%, transparent);
  background: color-mix(in srgb, var(--paper) 74%, var(--accent) 26%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.question-card.is-focused {
  border-left: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  padding-left: 0.75rem;
}

.question-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.75rem;
  font-family: var(--font-ui);
}

.save-status {
  color: var(--fg-mute);
  font-size: 0.8rem;
  line-height: 1.4;
  min-height: 1.1rem;
}

.save-status.is-error {
  color: var(--accent);
}

.save-status.is-success {
  color: #1f5f34;
}

.family-save-toast {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translate(-50%, 8px);
  z-index: 170;
  max-width: min(38rem, calc(100% - 1.5rem));
  background: color-mix(in srgb, var(--paper) 88%, var(--bg) 12%);
  color: var(--fg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 0.72rem 0.9rem;
  border-left: 5px solid #1f5f34;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 14px 32px var(--shadow), 0 5px 14px var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.family-save-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.family-save-toast.is-error {
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--paper) 94%, var(--accent) 6%);
}

.family-save-toast.is-success {
  border-left-color: #1f5f34;
}

@media (max-width: 560px) {
  .family-save-toast {
    font-size: 0.75rem;
    padding: 0.68rem 0.8rem;
    left: 0.75rem;
    right: 0.75rem;
    max-width: none;
    transform: translateY(8px);
  }

  .family-save-toast.is-visible {
    transform: translateY(0);
  }
}

.reader-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--rule-soft);
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1.5rem;
  font-family: var(--font-ui);
}
.reader-home {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--fg-soft);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 0.45rem 0.7rem;
  margin-left: -0.7rem;
  border-radius: 999px;
  transition: color 0.18s var(--ease), background 0.18s var(--ease);
  justify-self: start;
}
.reader-home svg { transition: transform 0.2s var(--ease); }
.reader-home:hover { color: var(--accent); background: var(--bg-elev); }
.reader-home:hover svg { transform: translateX(-2px); }

.reader-bar-title {
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-variation-settings: "opsz" 14;
  font-size: 0.92rem;
  color: var(--fg-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.reader-bar-wordmark {
  justify-self: end;
  font-family: var(--font-serif);
  font-style: italic;
  font-variation-settings: "opsz" 14;
  font-size: 0.84rem;
  color: var(--fg-mute);
  text-decoration: none;
  letter-spacing: 0.01em;
  padding: 0.35rem 0.5rem;
  margin-right: -0.5rem;
  border-radius: 4px;
  transition: color 0.18s var(--ease);
}
.reader-bar-wordmark:hover { color: var(--accent); }

.chapter {
  width: 100%;
  max-width: var(--max-reading);
  padding: 5rem 1.5rem 0;
}

.chapter-header { margin: 0 0 3rem; text-align: center; }
.chapter-num {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--fg-mute);
  margin: 0 0 1.1rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
}
.chapter-title {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-variation-settings: "opsz" 48;
  font-size: clamp(2.1rem, 5.5vw, 3.1rem);
  margin: 0;
  line-height: 1.08;
  letter-spacing: -0.018em;
  color: var(--fg);
}
.chapter-rule {
  width: 2.25rem;
  height: 1px;
  background: var(--accent);
  margin: 1.75rem auto 0;
  opacity: 0.65;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chapter-rule::before,
.chapter-rule::after {
  content: "";
  display: block;
  position: relative;
  width: 3px; height: 3px;
  background: var(--accent);
  border-radius: 50%;
}
.chapter-rule::before { left: -8px; }
.chapter-rule::after  { right: -8px; }

/* ---- Audio player — thoughtful, quiet, never a generic widget ---- */

.player {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 0.85rem 1rem 0.85rem 0.85rem;
  margin: 0 0 3.5rem;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 1px 3px var(--shadow);
  font-family: var(--font-ui);
  position: relative;
}
@media (prefers-color-scheme: dark) {
  .player {
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.04) inset,
      0 1px 3px var(--shadow);
  }
}
.player audio { display: none; }

.player-play {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fbf8f2;
  border: none;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.2s var(--ease),
              box-shadow 0.2s var(--ease);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 40%, transparent);
}
.player-play:hover {
  transform: scale(1.05);
  background: var(--accent-soft);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 50%, transparent);
}
.player-play:active { transform: scale(0.97); }
.player-play svg { width: 18px; height: 18px; }
.player-play .icon-play  { display: block; margin-left: 2px; }
.player-play .icon-pause { display: none; }
.player.is-playing .player-play .icon-play  { display: none; }
.player.is-playing .player-play .icon-pause { display: block; }

.player-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.player-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}
.player-label {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--fg-soft);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.player-time {
  font-size: 0.72rem;
  color: var(--fg-mute);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.player-scrub {
  cursor: pointer;
  padding: 8px 0;
  outline: none;
  touch-action: none;
}
.player-scrub-track {
  position: relative;
  height: 3px;
  background: var(--rule);
  border-radius: 2px;
  transition: height 0.15s var(--ease);
}
.player:hover .player-scrub-track,
.player.is-playing .player-scrub-track {
  height: 4px;
}
.player-scrub-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
}
.player-scrub-handle {
  position: absolute;
  left: 0%;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.18s var(--ease);
  box-shadow: 0 1px 3px var(--shadow-strong);
}
.player:hover .player-scrub-handle,
.player.is-playing .player-scrub-handle,
.player-scrub:focus-visible ~ * .player-scrub-handle,
.player-scrub:focus-visible .player-scrub-handle {
  opacity: 1;
}

.player-speed {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--fg-soft);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  min-width: 2.8rem;
  letter-spacing: 0.01em;
}
.player-speed:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

/* ---- Prose ---- */

.prose {
  font-size: 1.135rem;
  line-height: 1.75;
  color: var(--fg);
  font-variation-settings: "opsz" 14;
}
.prose p {
  margin: 0 0 1.35rem;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  text-indent: 1.5em;
  hanging-punctuation: first last;
}
.prose p:first-child { text-indent: 0; }

/* Drop cap on the first paragraph and on the first paragraph after a section break */
.prose > p:first-of-type::first-letter,
.prose > hr + p::first-letter {
  font-family: var(--font-serif);
  font-style: normal;
  font-weight: 500;
  font-variation-settings: "opsz" 60;
  float: left;
  font-size: 4em;
  line-height: 0.82;
  padding: 0.08em 0.1em 0 0;
  margin: 0.02em 0.08em -0.05em 0;
  color: var(--accent);
}

/* Small caps follow the drop cap, classic NYT-book style. */
.prose > p:first-of-type::first-line,
.prose > hr + p::first-line {
  font-variant-caps: all-small-caps;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.prose blockquote {
  margin: 1.75rem 0;
  padding: 0.25rem 1.5rem;
  border-left: 2px solid var(--accent);
  font-style: italic;
  font-variation-settings: "opsz" 14;
  color: var(--fg);
}
.prose blockquote p { margin: 0.5rem 0; text-indent: 0; }
.prose blockquote p:last-child { margin-bottom: 0; }

.prose em {
  font-style: italic;
  font-variation-settings: "opsz" 14;
}
.prose strong { font-weight: 600; }

.prose h1, .prose h2, .prose h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  margin: 2.75rem 0 1rem;
  font-variation-settings: "opsz" 24;
}
.prose h2 {
  font-size: 1.4rem;
  text-align: center;
  font-style: italic;
  font-weight: 400;
  color: var(--fg-soft);
  margin-top: 3.5rem;
  letter-spacing: -0.01em;
}

/*
 * Section break: render markdown's --- as three small dots, drawn as CSS
 * pseudo-elements. No Unicode dingbats, so it never renders as emoji on
 * any platform.
 */
.prose hr {
  border: none;
  height: 4px;
  width: 100%;
  margin: 3rem auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
}
.prose hr::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.55;
  box-shadow:
    -1.1em 0 0 var(--accent),
    1.1em 0 0 var(--accent);
}
.prose hr::after { content: none; }

.prose a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s var(--ease);
}
.prose a:hover { color: var(--link-hover); }

/* ---- Pager ---- */

.pager {
  margin-top: 5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.pager-btn {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--fg);
  padding: 1.1rem 1.25rem;
  font-family: var(--font-ui);
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.95rem;
  border-radius: 10px;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease),
              color 0.2s var(--ease), transform 0.2s var(--ease);
  min-height: 4.75rem;
  min-width: 0;
  overflow: hidden;
}
.pager-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.pager-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.pager-next { justify-content: flex-end; text-align: right; }
.pager-arrow {
  flex-shrink: 0;
  color: var(--fg-soft);
  transition: transform 0.25s var(--ease), color 0.25s var(--ease);
}
.pager-btn:hover:not(:disabled) .pager-arrow { color: var(--accent); }
.pager-prev:hover:not(:disabled) .pager-arrow { transform: translateX(-4px); }
.pager-next:hover:not(:disabled) .pager-arrow { transform: translateX(4px); }

.pager-label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.pager-direction {
  font-size: 0.62rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--fg-mute);
}
.pager-target {
  font-family: var(--font-serif);
  font-style: italic;
  font-variation-settings: "opsz" 18;
  font-size: 1.02rem;
  color: var(--fg);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ======================================================================
   RESPONSIVE
   ====================================================================== */

@media (max-width: 700px) {
  html, body { font-size: 17px; }
  .cover { padding: 2rem 1rem 1.5rem; }
  .cover-flower-wrap { gap: 1.6rem; }
  .contents { padding: 4rem 1.25rem 4.5rem; }
  .contents-title { margin-bottom: 2.25rem; }
  .contents-title::before,
  .contents-title::after { width: 1rem; margin: 0 0.6rem; }

  .reader-bar { padding: 0.5rem 0.85rem; grid-template-columns: auto 1fr auto; }
  .reader-bar-title { font-size: 0.8rem; }
  .reader-bar-wordmark { font-size: 0.82rem; padding: 0.6rem 0.65rem;
                         margin-right: -0.4rem; min-height: 44px;
                         display: inline-flex; align-items: center; }
  .reader-home span { display: none; }
  .reader-home { padding: 0.6rem; margin-left: -0.4rem; min-width: 44px;
                 min-height: 44px; justify-content: center; }

  .chapter { padding: 3rem 1.25rem 0; }
  .chapter-title { font-size: clamp(1.85rem, 7vw, 2.3rem); }
  .player {
    flex-wrap: wrap;
    padding: 0.7rem 0.85rem;
    gap: 0.7rem;
  }
  .player-body { flex: 1 1 calc(100% - 60px); order: 2; flex-basis: 100%; }
  .player-play { order: 1; }
  .player-speed { order: 1; margin-left: auto; min-height: 44px;
                  padding: 0.55rem 0.9rem; }
  .pager { grid-template-columns: 1fr; gap: 0.7rem; }
  .pager-next { justify-content: flex-start; text-align: left; }
  .pager-next .pager-label { order: 1; }
  .prose { font-size: 1.06rem; line-height: 1.7; }
  .prose p { text-align: left; hyphens: none; }
  .prose > p:first-of-type::first-letter,
  .prose > hr + p::first-letter { font-size: 3.4em; }
  .chapter-link { padding: 1.15rem 0.5rem; font-size: 1.05rem;
                  grid-template-columns: 2.5rem 1fr auto; gap: 0.75rem; }
  .chapter-link:hover { padding-left: 0.85rem; }
  .chapter-link .tag-audio span { display: none; }
}

@media (max-width: 380px) {
  .chapter { padding: 2.5rem 1rem 0; }
  .contents { padding: 3rem 1rem 4rem; }
}

/* Tablet — between phone and desktop */
@media (min-width: 700px) and (max-width: 1024px) {
  .cover-flower { width: clamp(14rem, 32vw, 18rem); }
  .cover-title { font-size: clamp(4rem, 12vw, 6rem); }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ======================================================================
   FEEDBACK WIDGET
   Small fixed action buttons for feedback and family questions. Quiet,
   paper-toned, matches site palette.
   ====================================================================== */

.feedback-fab,
.family-fab {
  position: fixed;
  bottom: 1.25rem;
  z-index: 150;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.7rem 1.05rem;
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  color: var(--fg-soft);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 6px 22px var(--shadow), 0 2px 6px var(--shadow);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  transition: transform 0.2s var(--ease),
              background 0.2s var(--ease),
              color 0.2s var(--ease),
              border-color 0.2s var(--ease);
}
.feedback-fab {
  right: 1.25rem;
}
.family-fab {
  left: 1.25rem;
}
.feedback-fab:hover,
.family-fab:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  transform: translateY(-2px);
}
.feedback-fab:active,
.family-fab:active { transform: translateY(0); }
.feedback-fab svg,
.family-fab svg { flex-shrink: 0; }

@media (max-width: 600px) {
  .feedback-fab,
  .family-fab {
    bottom: 0.85rem;
    padding: 0.6rem 0.85rem;
    font-size: 0.74rem;
  }
  .feedback-fab { right: 0.85rem; }
  .family-fab { left: 0.85rem; }
}

/* Hide while reading-progress animation runs to avoid jitter on slow phones */
@media (prefers-reduced-motion: reduce) {
  .feedback-fab,
  .family-fab { transition: none; }
}

/* ---- Dialog ---- */

.feedback-dialog {
  border: none;
  padding: 0;
  margin: auto;
  background: var(--paper);
  color: var(--fg);
  border-radius: 14px;
  max-width: min(30rem, 92vw);
  width: 100%;
  box-shadow: 0 30px 80px var(--shadow-strong), 0 8px 24px var(--shadow);
}
.feedback-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}
.feedback-dialog[open] {
  animation: feedbackPop 0.28s var(--ease-out) both;
}
@keyframes feedbackPop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  padding: 1.75rem 1.75rem 1.5rem;
}

.feedback-form-head h3 {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: 1.55rem;
  margin: 0 0 0.4rem;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.feedback-form-head p {
  font-family: var(--font-serif);
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--fg-soft);
  margin: 0;
}

.feedback-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.feedback-field span {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--fg-mute);
}
.feedback-field span em {
  font-style: italic;
  text-transform: none;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--fg-mute);
  opacity: 0.8;
}
.feedback-field input,
.feedback-field textarea {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.5;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--fg);
  border-radius: 7px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s var(--ease),
              box-shadow 0.15s var(--ease);
}
.feedback-field input:focus,
.feedback-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.feedback-field textarea {
  resize: vertical;
  min-height: 5rem;
}

.feedback-note {
  font-family: var(--font-ui);
  font-size: 0.73rem;
  line-height: 1.55;
  color: var(--fg-mute);
  margin: 0.25rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px solid var(--rule-soft);
}
.feedback-note a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.15s var(--ease);
}
.feedback-note a:hover { color: var(--link-hover); }

.feedback-status {
  min-height: 1.1rem;
  margin: -0.15rem 0 0;
  color: var(--fg-mute);
  font-family: var(--font-ui);
  font-size: 0.76rem;
  line-height: 1.4;
}
.feedback-status.is-error {
  color: var(--accent);
}

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.35rem;
}
.feedback-actions button {
  padding: 0.6rem 1.05rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid var(--rule);
  background: none;
  color: var(--fg);
  transition: all 0.15s var(--ease);
}
.feedback-cancel:hover {
  background: var(--bg-elev);
  border-color: var(--fg-mute);
}
.feedback-submit {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}
.feedback-submit:hover {
  background: var(--link-hover);
  border-color: var(--link-hover);
}
.feedback-submit:disabled {
  cursor: wait;
  opacity: 0.7;
}

/* ---- Identity bar (sticky, color-coded per set) ---- */
.identity-bar {
  position: sticky;
  top: 0;
  z-index: 60;
  margin: 0 -1.25rem 1.25rem;
  padding: 0.85rem 1.25rem 0.95rem;
  background: var(--paper);
  border-bottom: 1px solid var(--rule-soft);
  box-shadow: 0 6px 12px -8px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.identity-bar[data-active-set="dad"] {
  background: #f3f7ee;
  border-bottom-color: #b3c79e;
}

.identity-bar[data-active-set="mom"] {
  background: #ebf2f7;
  border-bottom-color: #8fb0c8;
}

.identity-bar[data-active-set="either"] {
  background: #f7f1e3;
  border-bottom-color: #d6c7a1;
}

.identity-bar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  justify-content: space-between;
}

.identity-label {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}

.identity-kicker {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-soft);
}

.identity-name {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  line-height: 1.15;
  font-weight: 500;
  color: #2b251f;
}

.identity-bar[data-active-set="dad"] .identity-name {
  color: #2d5e2a;
}

.identity-bar[data-active-set="mom"] .identity-name {
  color: #20567a;
}

.identity-bar .question-tabs {
  margin: 0;
  background: var(--paper);
}

.identity-bar .family-person {
  margin: 0;
  display: inline-flex;
  align-items: center;
}

.identity-bar .family-person select {
  min-width: 14rem;
  font-size: 0.9rem;
}

.identity-mismatch {
  display: block;
  background: #fff2d6;
  border: 1px solid #d99744;
  border-left: 5px solid #b3541a;
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  line-height: 1.45;
  color: #2b251f;
}

.identity-mismatch strong {
  display: block;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: #8a3a0f;
  font-size: 1rem;
}

.identity-mismatch em {
  font-style: normal;
  font-weight: 700;
  color: #2b251f;
}

.identity-mismatch-fix {
  display: inline-block;
  margin-top: 0.5rem;
  background: #b3541a;
  color: #fff;
  border: 0;
  font-family: var(--font-ui);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
}

.identity-mismatch-fix:hover {
  background: #8a3a0f;
}

/* Per-set page tint */
body[data-family-set="dad"] .family-panel {
  background: linear-gradient(180deg, #f3f7ee 0%, transparent 30%);
}

body[data-family-set="mom"] .family-panel {
  background: linear-gradient(180deg, #ebf2f7 0%, transparent 30%);
}

@media (max-width: 600px) {
  .identity-bar {
    margin-left: -0.85rem;
    margin-right: -0.85rem;
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
  .identity-bar .question-tabs {
    width: 100%;
  }
  .identity-bar .family-person select {
    min-width: 0;
    width: 100%;
  }
  .identity-bar-row {
    flex-direction: column;
    align-items: stretch;
  }
  .identity-name {
    font-size: 1.15rem;
  }
}

/* ---- Family outstanding-questions banner ---- */
.family-outstanding {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0 0 1.5rem;
  padding: 0.95rem 1.1rem;
  border-radius: 10px;
  background: #fff5e6;
  border: 1px solid #e0b07a;
  border-left: 6px solid #b3541a;
  color: #2b251f;
  font-family: var(--font-ui);
  font-size: 1.05rem;
  line-height: 1.4;
}

.family-outstanding strong {
  font-size: 1.6rem;
  font-weight: 700;
  color: #8a3a0f;
  font-variant-numeric: tabular-nums;
}

.family-outstanding.is-done {
  background: #ecf6ed;
  border-color: #88c19a;
  border-left-color: #1f5f34;
  color: #1f4a2a;
}

.family-outstanding.is-done strong {
  color: #1f5f34;
  font-size: 1.05rem;
}

/* ---- Section headers in question list ---- */
.question-section-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.1rem 0 0.4rem;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-family: var(--font-ui);
}

.question-section-head.is-unanswered {
  background: #fff5e6;
  border-left: 4px solid #b3541a;
}

.question-section-head.is-answered {
  background: color-mix(in srgb, var(--bg-elev) 70%, transparent);
  border-left: 4px solid #88c19a;
}

.question-section-head.is-all-done {
  background: #ecf6ed;
  border-left: 4px solid #1f5f34;
}

.question-section-marker {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.question-section-head.is-unanswered .question-section-marker {
  background: #b3541a;
  box-shadow: 0 0 0 4px rgba(179, 84, 26, 0.18);
}

.question-section-head.is-answered .question-section-marker {
  background: #1f5f34;
}

.question-section-head.is-all-done .question-section-marker {
  background: #1f5f34;
  box-shadow: 0 0 0 4px rgba(31, 95, 52, 0.2);
}

.question-section-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  flex: 1;
  min-width: 0;
}

.question-section-title {
  font-weight: 700;
  font-size: 1rem;
  color: #2b251f;
}

.question-section-head.is-unanswered .question-section-title {
  color: #8a3a0f;
}

.question-section-head.is-answered .question-section-title,
.question-section-head.is-all-done .question-section-title {
  color: #1f5f34;
}

.question-section-subtitle {
  font-size: 0.82rem;
  color: var(--fg-soft);
  font-weight: 500;
}

.question-section-toggle {
  border: 1px solid var(--rule-soft);
  background: var(--paper);
  color: var(--fg-soft);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.question-section-head.is-collapsed .question-section-toggle svg {
  transform: rotate(-90deg);
}

.question-section-toggle svg {
  transition: transform 0.2s var(--ease);
}

.question-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
  transition: max-height 0.25s var(--ease), opacity 0.2s var(--ease);
}

.question-group.is-collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* ---- Question card states ---- */
.question-card.is-unanswered {
  border-top: 0;
  border-left: 5px solid #b3541a;
  background: #fffaf2;
  padding: 1.1rem 1.1rem 0.7rem;
  border-radius: 0 10px 10px 0;
  margin-top: 0.6rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.question-card.is-unanswered h3 {
  font-weight: 500;
  color: #2b251f;
}

.question-card.is-unanswered textarea {
  border: 2px solid #b3541a;
  background: #ffffff;
  box-shadow: 0 0 0 4px color-mix(in srgb, #b3541a 18%, transparent);
}

.question-card.is-unanswered.is-focused textarea,
.question-card.is-unanswered.is-typing textarea {
  border-color: #2d5e2a;
  box-shadow: 0 0 0 6px color-mix(in srgb, #2d5e2a 22%, transparent);
}

.question-card.is-answered {
  border-top: 1px solid var(--rule-soft);
  border-left: 0;
  background: transparent;
  opacity: 0.65;
  padding: 0.85rem 0 0.35rem;
  border-radius: 0;
  box-shadow: none;
  transition: opacity 0.25s var(--ease);
}

.question-card.is-answered:hover {
  opacity: 0.92;
}

.question-card.is-answered h3 {
  color: var(--fg-soft);
  font-size: 1.05rem;
  font-weight: 400;
}

.question-card.is-answered textarea {
  background: color-mix(in srgb, var(--bg-elev) 50%, transparent);
  border: 1px solid var(--rule-soft);
  box-shadow: none;
}

.question-card.is-just-saved {
  animation: question-card-saved-flash 2.4s var(--ease);
}

@keyframes question-card-saved-flash {
  0%   { background: #d6ecda; box-shadow: 0 0 0 4px #88c19a; }
  100% { background: transparent; box-shadow: none; }
}

/* ---- Click-here hint (unanswered only) ---- */
.question-click-hint {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: #fff2d6;
  border: 1px solid #d99744;
  border-left: 5px solid #b3541a;
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  margin: 0 0 0.65rem;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.45;
  color: #2b251f;
}

.question-click-hint[aria-hidden="true"] {
  display: none;
}

.question-click-hint strong {
  font-weight: 700;
  color: #8a3a0f;
}

.question-click-hint svg {
  flex-shrink: 0;
  color: #b3541a;
  animation: click-hint-bounce 1.4s ease-in-out infinite;
}

@keyframes click-hint-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(4px); }
}

/* ---- Giant "Click here" overlay inside the textbox ---- */
.question-click-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  pointer-events: none;
  color: #b3541a;
  font-family: var(--font-ui);
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 0 #ffffff, 0 0 14px #ffffff;
  background: linear-gradient(180deg, rgba(255, 245, 220, 0.6) 0%, rgba(255, 245, 220, 0) 60%);
  border-radius: 8px;
  z-index: 2;
  animation: click-overlay-pulse 1.6s ease-in-out infinite;
}

.question-click-overlay[aria-hidden="true"] {
  display: none;
}

.question-click-overlay svg {
  animation: click-overlay-bounce 1.4s ease-in-out infinite;
}

.question-card.is-unanswered .question-input-shell {
  position: relative;
}

.question-card.is-unanswered .question-input-shell textarea {
  position: relative;
  z-index: 1;
}

@keyframes click-overlay-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

@keyframes click-overlay-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(6px); }
}

@media (max-width: 600px) {
  .question-click-overlay {
    font-size: 1.3rem;
  }
}

/* ---- Saved banner (answered only) ---- */
.question-saved-banner {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: #ecf6ed;
  border: 1px solid #88c19a;
  border-left: 5px solid #1f5f34;
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  margin: 0 0 0.7rem;
  font-family: var(--font-ui);
  line-height: 1.4;
  color: #1f4a2a;
}

.question-saved-banner[aria-hidden="true"] {
  display: none;
}

.question-saved-banner svg {
  flex-shrink: 0;
}

.question-saved-banner-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.question-saved-banner-text strong {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1f5f34;
}

.question-saved-banner-text span {
  font-size: 0.88rem;
  color: #4a4339;
}

/* Pill upgrade — bigger when unanswered to grab attention */
.question-card.is-unanswered .question-status-pill {
  font-size: 0.8rem;
  padding: 0.32rem 0.7rem;
  box-shadow: 0 0 0 3px color-mix(in srgb, #b3541a 25%, transparent);
}

.question-card.is-answered .question-status-pill {
  font-size: 0.74rem;
  padding: 0.2rem 0.55rem;
}

.question-card.is-answered .question-input-guide {
  display: none;
}

@media (max-width: 600px) {
  .question-click-hint,
  .question-saved-banner {
    font-size: 0.95rem;
    padding: 0.65rem 0.75rem;
  }
}

.question-top {
  grid-template-columns: 2rem 1fr auto;
}

.question-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  align-self: start;
}

.question-card.is-unanswered .question-status-pill {
  background: #b3541a;
  color: #fff;
}

.question-card.is-answered .question-status-pill {
  background: #ecf6ed;
  color: #1f5f34;
  border: 1px solid #88c19a;
}

.question-status-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  animation: question-status-pulse 1.6s ease-in-out infinite;
}

@keyframes question-status-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

@media (max-width: 600px) {
  .question-top {
    grid-template-columns: 2rem 1fr;
  }
  .question-status-pill {
    grid-column: 1 / -1;
    margin-top: 0.25rem;
    align-self: start;
    width: fit-content;
  }
  .family-outstanding {
    font-size: 1rem;
    padding: 0.85rem 0.9rem;
  }
  .family-outstanding strong {
    font-size: 1.4rem;
  }
}

/* ---- Print ---- */
@media print {
  .reader-bar, .player, .pager, .reading-progress, .home { display: none !important; }
  .feedback-fab, .family-fab, .feedback-dialog { display: none !important; }
  body { background: white; color: black; }
  body::before { display: none; }
  .reader, .chapter { padding: 0; max-width: none; }
  .prose { font-size: 11pt; line-height: 1.5; }
  .prose p { orphans: 3; widows: 3; }
}
