:root {
  color-scheme: light;
  --ink: #211a16;
  --muted-ink: #665d52;
  --paper: #fbf7ed;
  --paper-deep: #f1e7d5;
  --rail: #171512;
  --rail-soft: #29231d;
  --rule: #d8cbbb;
  --rubric: #9f2f2b;
  --rubric-deep: #6e2421;
  --moss: #65704f;
  --blue: #51697e;
  --gold: #b28b45;
  --shadow: 0 18px 60px rgba(35, 26, 18, 0.18);
  --serif: "EB Garamond", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #d9d1c5;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 78% 8%, rgba(178, 139, 69, 0.12), transparent 32rem),
    linear-gradient(135deg, #efe8dc 0%, #d9d1c5 52%, #ebe2d6 100%);
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(232px, 18vw) 1fr;
  min-height: 100vh;
}

.reader-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 2rem;
  padding: clamp(1.25rem, 2.2vw, 2.4rem);
  color: #f7f0e4;
  background:
    linear-gradient(rgba(23, 21, 18, 0.9), rgba(23, 21, 18, 0.96)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0, rgba(255, 255, 255, 0.03) 1px, transparent 1px, transparent 9px),
    var(--rail);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

@media (max-height: 760px) and (min-width: 981px) {
  .reader-rail {
    gap: 0.75rem;
    padding: 1rem;
  }

  .brand h1 {
    font-size: 1.7rem;
  }

  .brand-line {
    margin-top: 0.45rem;
    font-size: 0.9rem;
    line-height: 1.32;
  }

  .scene-art img {
    aspect-ratio: 16 / 9;
    max-height: 7rem;
  }

  .scene-art figcaption {
    display: none;
  }

  .mode-nav {
    padding-top: 0.65rem;
  }

  .mode-button {
    min-height: 2.7rem;
    padding-block: 0.42rem;
  }

  .mode-button small {
    font-size: 0.72rem;
  }
}

.brand {
  display: grid;
  gap: 0.45rem;
}

.crown-mark {
  color: var(--rubric);
  font-size: 2.2rem;
  line-height: 1;
}

.brand-kicker,
.work-title,
.scene-title,
.block-speaker,
.section-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.brand-kicker {
  font-size: 0.85rem;
  color: #dfd0bc;
}

.brand h1 {
  margin: 0;
  max-width: 11rem;
  font-family: var(--serif);
  font-size: clamp(1.85rem, 2.8vw, 2.7rem);
  font-weight: 500;
  line-height: 0.98;
}

.brand-line {
  max-width: 13.5rem;
  margin: 1rem 0 0;
  color: #df725f;
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.45;
}

.scene-art {
  margin: 0;
  display: grid;
  gap: 0.7rem;
}

.scene-art img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.16);
  filter: sepia(0.2) contrast(0.96);
}

.scene-art figcaption {
  color: #c5b59f;
  font-family: var(--serif);
  font-size: 0.85rem;
  line-height: 1.35;
}

.mode-nav {
  align-self: end;
  display: grid;
  gap: 0.45rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.mode-button {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.8rem;
  align-items: center;
  width: 100%;
  min-height: 3.5rem;
  padding: 0.6rem 0.4rem;
  color: #f7f0e4;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.mode-button:hover,
.mode-button:focus-visible,
.mode-button.is-active {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.mode-button:focus-visible,
.mobile-mode:focus-visible,
.icon-button:focus-visible,
.word-mark:focus-visible,
.quote-card:focus-visible,
.share-button:focus-visible,
.scene-picker:focus-visible,
.footer-link:focus-visible {
  outline: 3px solid rgba(178, 139, 69, 0.65);
  outline-offset: 3px;
}

.mode-icon {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  color: #f1e7d5;
  border: 1px solid rgba(255, 255, 255, 0.42);
}

.mode-icon svg,
.icon-button svg,
.selection-popover svg {
  width: 1.12rem;
  height: 1.12rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bookmark-button svg,
.selection-popover svg {
  fill: rgba(159, 47, 43, 0.08);
}

.mode-button strong {
  display: block;
  font-size: 0.94rem;
  font-weight: 650;
}

.mode-button small {
  display: block;
  margin-top: 0.18rem;
  color: #c7b8a5;
  font-family: var(--serif);
  font-size: 0.78rem;
}

.reader-main {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

.reader-topbar,
.reader-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2rem);
}

.reader-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
  background: rgba(251, 247, 237, 0.88);
  border-bottom: 1px solid rgba(123, 100, 70, 0.2);
  backdrop-filter: blur(18px);
}

.lens-bar {
  flex-basis: 100%;
  margin-top: 0.35rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(123, 100, 70, 0.16);
}

.lens-bar .lens-toggle {
  margin: 0;
}

.lens-bar .lens-blurb {
  margin: 0.45rem 0 0;
}

.work-title {
  font-size: 0.82rem;
  font-weight: 800;
}

.scene-title {
  margin-top: 0.25rem;
  color: var(--muted-ink);
  font-size: 0.72rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.scene-picker-label {
  width: 1px;
  height: 1px;
  position: absolute;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.scene-picker {
  min-width: min(18rem, 42vw);
  height: 2.35rem;
  padding: 0 2rem 0 0.7rem;
  color: var(--ink);
  background: #fffaf1;
  border: 1px solid var(--rule);
  border-radius: 6px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  color: var(--ink);
  background: #fffaf1;
  border: 1px solid var(--rule);
  border-radius: 6px;
  cursor: pointer;
}

.icon-button:disabled {
  color: rgba(102, 93, 82, 0.42);
  cursor: not-allowed;
}

.bookmark-button.has-selection {
  color: #fff8ec;
  background: var(--rubric-deep);
  border-color: var(--rubric-deep);
}

.bookmark-button.has-selection svg {
  fill: currentColor;
}

.reader-surface {
  padding: clamp(1rem, 3vw, 2rem);
}

.reader-layout {
  width: min(100%, 1180px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1rem, 2.5vw, 2rem);
  align-items: start;
}

.play-text,
.context-panel,
.word-margin,
.quote-panel,
.about-panel {
  background:
    linear-gradient(rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.1)),
    repeating-linear-gradient(0deg, rgba(101, 112, 79, 0.03) 0, rgba(101, 112, 79, 0.03) 1px, transparent 1px, transparent 5px),
    var(--paper);
  border: 1px solid rgba(123, 100, 70, 0.24);
  box-shadow: var(--shadow);
}

.play-text {
  min-height: calc(100vh - 10rem);
  padding: clamp(1.35rem, 4vw, 3rem);
}

.word-margin {
  position: sticky;
  top: 6rem;
  display: none;
  min-height: 18rem;
  padding: 1rem;
}

.context-panel {
  display: none;
  position: sticky;
  top: 6rem;
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
  padding: clamp(1.1rem, 2.5vw, 1.6rem);
}

.quote-panel {
  display: none;
  min-height: calc(100vh - 10rem);
  padding: clamp(1rem, 2vw, 1.4rem);
}

.reader-layout[data-mode="words"] .word-margin {
  display: block;
}

.reader-layout[data-mode="words"] {
  width: min(100%, 1280px);
  grid-template-columns: minmax(0, 1fr) minmax(13rem, 17rem);
}

.reader-layout[data-mode="facing"] {
  width: min(100%, 1400px);
  grid-template-columns: minmax(0, 1fr);
}

.reader-layout[data-mode="context"] {
  width: min(100%, 1400px);
  grid-template-columns: minmax(0, 1fr) minmax(20rem, 25rem);
}

.reader-layout[data-mode="context"] .context-panel {
  display: block;
}

.reader-layout[data-mode="quotes"] {
  width: min(100%, 1400px);
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
}

.reader-layout[data-mode="quotes"] .quote-panel {
  display: block;
}

.reader-layout[data-mode="quotes"] .word-margin,
.reader-layout[data-mode="quotes"] .context-panel {
  display: none;
}

.about-panel {
  display: none;
  min-height: calc(100vh - 10rem);
  padding: clamp(1.5rem, 5vw, 3.5rem);
}

.reader-layout[data-mode="about"] {
  width: min(100%, 980px);
  grid-template-columns: minmax(0, 1fr);
}

.reader-layout[data-mode="about"] .play-text {
  display: none;
}

.reader-layout[data-mode="about"] .about-panel {
  display: block;
}

.about-essay {
  max-width: 42rem;
  margin: 0 auto;
}

.about-essay h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  letter-spacing: -0.01em;
}

.about-standfirst {
  margin: 0.6rem 0 2rem;
  color: var(--muted-ink);
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.08rem;
  line-height: 1.5;
}

.about-essay section {
  margin-top: 2rem;
}

.about-essay h2 {
  margin: 0 0 0.7rem;
  font-size: 0.82rem;
  font-family: var(--sans);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--rubric-deep);
}

.about-essay p {
  margin: 0 0 1rem;
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.66;
  color: #3b3028;
}

.mobile-mode-strip {
  position: sticky;
  top: 4.4rem;
  z-index: 15;
  display: none;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
  width: min(100%, 1180px);
  margin: 0 auto 0.75rem;
  padding: 0.35rem;
  background: rgba(251, 247, 237, 0.92);
  border: 1px solid var(--rule);
  backdrop-filter: blur(14px);
}

.mobile-mode {
  min-height: 2.1rem;
  padding-inline: 0.2rem;
  color: var(--ink);
  font-size: 0.82rem;
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.mobile-mode.is-active {
  color: #fff8ec;
  background: var(--rubric-deep);
}

/* With the rail collapsed, the strip is the only way to switch modes */
body.rail-collapsed .mobile-mode-strip {
  display: grid;
}

@media (max-width: 980px) {
  .mobile-mode-strip {
    display: grid;
  }
}

.scene-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}

.scene-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.6rem, 4vw, 2.7rem);
  font-weight: 500;
}

.scene-heading p {
  margin: 0.25rem 0 0;
  color: var(--muted-ink);
  font-size: 0.85rem;
}

.act-pill {
  flex: 0 0 auto;
  padding: 0.45rem 0.65rem;
  color: var(--rubric-deep);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid rgba(159, 47, 43, 0.34);
  border-radius: 999px;
}

.text-block {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.35rem;
  padding: 0.85rem 0;
  scroll-margin-top: 5.5rem;
}

.text-block + .text-block {
  border-top: 1px solid rgba(216, 203, 187, 0.55);
}

.block-speaker {
  padding-top: 0;
  color: #3b3028;
  font-size: 0.72rem;
  font-weight: 800;
}

.stage-direction .block-speaker {
  color: var(--rubric-deep);
}

.lines {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.08rem, 1.15vw, 1.26rem);
  line-height: 1.68;
}

.stage-direction .lines {
  color: var(--rubric-deep);
  font-style: italic;
}

.line {
  display: block;
}

.word-mark {
  padding: 0 0.08em;
  color: var(--rubric-deep);
  text-decoration-line: underline;
  text-decoration-thickness: 0.12em;
  text-decoration-color: rgba(159, 47, 43, 0.45);
  text-underline-offset: 0.18em;
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: help;
}

.word-mark.is-active,
.word-mark:hover {
  background: rgba(159, 47, 43, 0.1);
}

/* In Read mode the marks are always present but stay quiet until hovered,
   so the page reads clean while Word Help is available on every hard word. */
#readerLayout[data-mode="read"] .word-mark {
  color: inherit;
  text-decoration-color: rgba(159, 47, 43, 0.24);
  text-decoration-thickness: 0.08em;
}

#readerLayout[data-mode="read"] .word-mark:hover,
#readerLayout[data-mode="read"] .word-mark.is-active {
  color: var(--rubric-deep);
  background: rgba(159, 47, 43, 0.1);
}

.margin-empty {
  display: grid;
  place-items: center;
  min-height: 12rem;
  color: var(--muted-ink);
  font-family: var(--serif);
  text-align: center;
}

.margin-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--rule);
}

.margin-heading h2 {
  margin: 0.2rem 0 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 500;
}

.gloss-list {
  display: grid;
  gap: 0.55rem;
}

.gloss-card {
  display: grid;
  gap: 0.3rem;
  width: 100%;
  padding: 0.7rem;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 250, 241, 0.68);
  border: 1px solid rgba(216, 203, 187, 0.9);
  border-radius: 6px;
  cursor: pointer;
}

.gloss-card:hover,
.gloss-card.is-active {
  border-color: rgba(159, 47, 43, 0.52);
  box-shadow: 0 8px 20px rgba(35, 26, 18, 0.1);
}

.gloss-card span {
  color: var(--rubric-deep);
  font-family: var(--serif);
  font-size: 1.05rem;
}

.gloss-card strong {
  font-size: 0.85rem;
}

.gloss-card small {
  color: var(--muted-ink);
  font-family: var(--serif);
  font-size: 0.82rem;
  line-height: 1.35;
}

.definition-card {
  display: grid;
  gap: 0.75rem;
}

.compact-definition {
  gap: 0.55rem;
}

.definition-card h3 {
  margin: 0;
  color: var(--rubric-deep);
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 500;
}

.definition-card p {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.48;
}

.definition-card dl {
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.definition-card dt {
  color: var(--muted-ink);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.definition-card dd {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.45;
}

.definition-actions {
  padding-top: 0.5rem;
  border-top: 1px solid var(--rule);
}

.definition-actions button {
  color: var(--muted-ink);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.word-popover {
  position: absolute;
  z-index: 55;
  width: min(260px, calc(100vw - 24px));
  padding: 0.9rem;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.18)),
    var(--paper);
  border: 1px solid var(--rule);
  box-shadow: 0 14px 36px rgba(35, 26, 18, 0.2);
}

.word-popover[hidden] {
  display: none;
}

/* Facing page: original and help locked together, row by row */

.lens-toggle {
  display: inline-flex;
  gap: 0;
  margin-bottom: 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 250, 241, 0.7);
}

.lens-button {
  min-height: 2.2rem;
  padding: 0.3rem 0.95rem;
  color: var(--muted-ink);
  font-size: 0.85rem;
  font-weight: 650;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.lens-button + .lens-button {
  border-left: 1px solid var(--rule);
}

.lens-button.is-active {
  color: #fff8ec;
  background: var(--rubric-deep);
}

.lens-blurb {
  margin: 0 0 1.4rem;
  color: var(--muted-ink);
  font-family: var(--serif);
  font-size: 0.95rem;
}

.facing-grid {
  display: grid;
  gap: 0;
}

.facing-pair {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(1rem, 3vw, 2.5rem);
  padding: 0.85rem 0;
  scroll-margin-top: 5.5rem;
}

.facing-pair + .facing-pair {
  border-top: 1px solid rgba(216, 203, 187, 0.55);
}

.facing-pair .text-block {
  padding: 0;
}

.facing-pair .text-block + .text-block {
  border-top: 0;
}

.facing-help {
  padding-top: 1.15rem;
  border-left: 1px solid rgba(216, 203, 187, 0.7);
  padding-left: clamp(0.9rem, 2vw, 1.6rem);
}

.facing-help p {
  margin: 0;
  color: #4d4338;
  font-family: var(--serif);
  font-size: 1.02rem;
  line-height: 1.55;
}

.facing-help .scholar-title {
  margin-bottom: 0.3rem;
  color: var(--rubric-deep);
  font-size: 0.78rem;
  font-family: var(--sans);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.facing-pair.is-unannotated .facing-help {
  border-left-color: transparent;
}

.facing-pair.is-unannotated .lines {
  color: rgba(33, 26, 22, 0.82);
}

.stage-note {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.stage-note-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  margin-top: 0.05rem;
  border-radius: 50%;
  color: var(--rubric);
  background: rgba(159, 47, 43, 0.08);
}

.stage-note p {
  margin: 0;
}

.quote-workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1fr);
  gap: 1rem;
  min-height: 100%;
}

.quote-list,
.quote-detail {
  min-width: 0;
}

.quote-list-heading,
.quote-detail-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--rule);
}

.quote-list-heading h2,
.quote-detail h2 {
  margin: 0.2rem 0 0;
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 500;
}

.quote-detail-top p {
  margin: 0.25rem 0 0;
  color: var(--muted-ink);
  font-family: var(--serif);
}

.quote-card {
  display: grid;
  gap: 0.45rem;
  width: 100%;
  margin-bottom: 0.6rem;
  padding: 0.8rem;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 250, 241, 0.72);
  border: 1px solid var(--rule);
  border-radius: 7px;
  cursor: pointer;
}

.quote-card:hover,
.quote-card.is-active {
  border-color: rgba(159, 47, 43, 0.45);
  box-shadow: 0 8px 22px rgba(35, 26, 18, 0.1);
}

.quote-card span,
.quote-card small {
  color: var(--muted-ink);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.quote-card strong {
  font-family: var(--serif);
  font-size: 0.96rem;
  font-weight: 500;
  line-height: 1.35;
}

.quote-detail blockquote {
  margin: 0 0 1.1rem;
  padding: 1rem;
  color: var(--ink);
  background: rgba(255, 250, 241, 0.68);
  border-left: 3px solid var(--rubric);
  font-family: var(--serif);
  font-size: clamp(1.08rem, 1.4vw, 1.28rem);
  line-height: 1.5;
}

.quote-detail blockquote span {
  display: block;
}

.quote-note-label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--muted-ink);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.quote-detail textarea {
  width: 100%;
  resize: vertical;
  padding: 0.75rem;
  color: var(--ink);
  background: #fffaf1;
  border: 1px solid var(--rule);
  border-radius: 6px;
  font: inherit;
}

.quote-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0.85rem 0 1rem;
}

.share-button {
  min-height: 2.15rem;
  padding: 0.38rem 0.7rem;
  color: var(--ink);
  background: #fffaf1;
  border: 1px solid var(--rule);
  border-radius: 6px;
  cursor: pointer;
}

.share-button:hover {
  color: #fff8ec;
  background: var(--rubric-deep);
  border-color: var(--rubric-deep);
}

.share-card {
  padding: clamp(1rem, 3vw, 1.5rem);
  color: #f6ead7;
  background:
    linear-gradient(rgba(81, 39, 31, 0.88), rgba(55, 32, 27, 0.94)),
    var(--rubric-deep);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 30px rgba(35, 26, 18, 0.18);
}

.share-card p {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.5;
}

.share-card span {
  display: block;
  margin-top: 1rem;
  color: #e9cbb8;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.quote-detail.is-empty {
  display: grid;
  place-items: center;
  min-height: 20rem;
  color: var(--muted-ink);
  text-align: center;
}

.reader-footer {
  color: var(--muted-ink);
  font-size: 0.78rem;
}

.footer-link {
  color: var(--ink);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.footer-link:disabled {
  color: rgba(102, 93, 82, 0.45);
  cursor: not-allowed;
}

.progress-track {
  position: relative;
  flex: 1 1 auto;
  max-width: 22rem;
  height: 2px;
  background: rgba(102, 93, 82, 0.25);
}

.progress-track span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 34%;
  background: var(--rubric);
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  transform: translateY(1rem);
  opacity: 0;
  max-width: min(20rem, calc(100vw - 2rem));
  padding: 0.8rem 1rem;
  color: var(--ink);
  background: #fffaf1;
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.selection-popover {
  position: absolute;
  z-index: 50;
  width: 132px;
  padding: 0.25rem;
  color: #fff8ec;
  background: var(--rail);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 10px 28px rgba(35, 26, 18, 0.24);
}

.selection-popover[hidden] {
  display: none;
}

.selection-popover button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
  min-height: 2rem;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.selection-popover button:hover,
.selection-popover button:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

body.rail-collapsed .reader-rail {
  display: none;
}

body.rail-collapsed .app-shell {
  grid-template-columns: 1fr;
}

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .reader-rail {
    position: static;
    height: auto;
    grid-template-columns: 1fr 11rem;
    grid-template-rows: auto auto;
    gap: 1rem;
  }

  .mode-nav {
    grid-column: 1 / -1;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .mode-button {
    grid-template-columns: 1fr;
    gap: 0.35rem;
    align-content: start;
  }

  .mode-icon {
    display: none;
  }

  .reader-layout,
  .reader-layout[data-mode="words"],
  .reader-layout[data-mode="facing"],
  .reader-layout[data-mode="context"],
  .reader-layout[data-mode="quotes"] {
    grid-template-columns: 1fr;
  }

  .reader-layout[data-mode="words"] .word-margin {
    position: static;
    display: block;
    min-height: 0;
  }

  .reader-layout[data-mode="context"] .context-panel {
    position: static;
    max-height: none;
    order: -1;
  }

  .quote-panel {
    min-height: 0;
  }

  .quote-workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .reader-rail {
    display: none;
  }

  .reader-topbar {
    padding: 0.75rem 0.85rem;
  }

  .reader-surface {
    padding: 0.75rem;
  }

  .mobile-mode-strip {
    top: 3.9rem;
  }

  .play-text,
  .context-panel,
  .word-margin {
    box-shadow: 0 12px 36px rgba(35, 26, 18, 0.13);
  }

  .facing-pair {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }

  .facing-help {
    padding-top: 0.2rem;
    padding-left: 0.9rem;
    border-left: 2px solid rgba(159, 47, 43, 0.3);
  }

  .facing-pair.is-unannotated .facing-help {
    display: none;
  }

  .play-text {
    min-height: 0;
    padding: 1rem;
  }

  .scene-picker {
    min-width: 8.2rem;
    max-width: 38vw;
  }

  .scene-heading {
    align-items: start;
    margin-bottom: 1rem;
  }

  .text-block {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .block-speaker {
    padding-top: 0;
  }

  .lines {
    font-size: 1.04rem;
    line-height: 1.6;
  }

  .facing-row {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .facing-icon {
    width: 1.6rem;
    height: 1.6rem;
    font-size: 0.8rem;
  }

  .quote-panel {
    padding: 1rem;
  }

  .quote-list-heading,
  .quote-detail-top {
    align-items: start;
  }
}

/* =========================================================
   Context mode
   ========================================================= */

.context-synopsis {
  margin: 0 0 1rem;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.05rem;
  font-style: italic;
  line-height: 1.5;
}

.context-card {
  margin-bottom: 0.8rem;
  padding: 0.9rem;
  background: rgba(255, 250, 241, 0.72);
  border: 1px solid rgba(216, 203, 187, 0.9);
  border-radius: 6px;
}

.context-tag {
  margin: 0 0 0.3rem;
  color: var(--rubric-deep);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.context-card h3 {
  margin: 0 0 0.4rem;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 500;
}

.context-card p:last-child {
  margin: 0;
  color: #4d4338;
  font-family: var(--serif);
  font-size: 0.96rem;
  line-height: 1.52;
}

.play-context {
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.play-context summary {
  margin-bottom: 0.8rem;
  color: var(--muted-ink);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.play-context summary:hover {
  color: var(--rubric-deep);
}

/* =========================================================
   Listen-from-here affordance on every block
   ========================================================= */

.block-speaker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.block-play {
  display: inline-grid;
  place-items: center;
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  color: var(--rubric-deep);
  background: transparent;
  border: 1px solid rgba(159, 47, 43, 0.35);
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transition: opacity 140ms ease;
}

.block-play svg {
  width: 0.7rem;
  height: 0.7rem;
  fill: currentColor;
  stroke: none;
}

.text-block:hover .block-play,
.block-play:focus-visible,
body.sync-pinning .block-play {
  opacity: 1;
}

.block-play:hover {
  color: #fff8ec;
  background: var(--rubric-deep);
}

@media (hover: none) {
  .block-play {
    opacity: 0.55;
  }
}

/* The line being spoken */

.is-playing-block {
  position: relative;
  /* Pull left + pad right by the same amount so the red marker sits in a gutter
     and never overlaps the text, with no layout shift when a line starts. */
  margin-left: -0.9rem;
  padding-left: 0.9rem;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(159, 47, 43, 0.07), rgba(159, 47, 43, 0.02) 70%, transparent);
  box-shadow: inset 3px 0 0 var(--rubric);
}

.is-playing-block .block-play {
  opacity: 1;
  color: #fff8ec;
  background: var(--rubric-deep);
}

body.sync-pinning .text-block,
body.sync-pinning .facing-pair {
  cursor: crosshair;
}

body.sync-pinning .text-block:hover,
body.sync-pinning .facing-pair:hover {
  background: rgba(178, 139, 69, 0.12);
}

/* =========================================================
   Audio dock
   ========================================================= */

body.audio-open .reader-footer {
  padding-bottom: 5.4rem;
}

body.audio-open .toast {
  bottom: 5.6rem;
}

.audio-dock {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem clamp(0.8rem, 2.5vw, 1.6rem);
  color: #f7f0e4;
  background:
    linear-gradient(rgba(23, 21, 18, 0.94), rgba(23, 21, 18, 0.98)),
    var(--rail);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 -10px 36px rgba(20, 14, 9, 0.35);
}

.audio-dock[hidden] {
  display: none;
}

.audio-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.3rem;
  padding: 0.3rem 0.6rem;
  color: #f1e7d5;
  font-size: 0.78rem;
  font-weight: 650;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  cursor: pointer;
}

.audio-control svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.audio-control:hover,
.audio-control:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.audio-control:focus-visible {
  outline: 3px solid rgba(178, 139, 69, 0.65);
  outline-offset: 2px;
}

.audio-control.is-on {
  color: #1d160f;
  background: var(--gold);
  border-color: var(--gold);
}

.audio-play {
  width: 2.7rem;
  height: 2.7rem;
  padding: 0;
  border-radius: 50%;
  background: var(--rubric);
  border-color: var(--rubric);
}

.audio-play svg {
  fill: #fff8ec;
  stroke: none;
  width: 1.15rem;
  height: 1.15rem;
}

.audio-play:hover {
  background: var(--rubric-deep);
}

.audio-meta {
  min-width: 6.5rem;
}

.audio-meta p {
  margin: 0;
}

.audio-act {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.audio-time {
  color: #c7b8a5;
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.audio-status {
  color: var(--gold);
  font-size: 0.7rem;
}

.audio-scrub-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 2rem;
  display: grid;
  align-items: center;
}

.audio-scrub {
  width: 100%;
  height: 4px;
  margin: 0;
  appearance: none;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 2px;
  cursor: pointer;
}

.audio-scrub::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f1e7d5;
  border: 2px solid var(--rubric);
}

.audio-scrub::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f1e7d5;
  border: 2px solid var(--rubric);
}

.audio-ticks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scene-tick {
  position: absolute;
  top: 50%;
  width: 3px;
  height: 12px;
  padding: 0;
  transform: translate(-50%, -50%);
  background: rgba(178, 139, 69, 0.85);
  border: 0;
  border-radius: 2px;
  cursor: pointer;
  pointer-events: auto;
}

.scene-tick:hover,
.scene-tick:focus-visible {
  background: #f1e7d5;
  outline: none;
}

.audio-speed {
  height: 2.3rem;
  padding: 0 0.4rem;
  color: #f1e7d5;
  font-size: 0.78rem;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
}

.audio-speed option {
  color: var(--ink);
}

.audio-close {
  font-size: 1.1rem;
  border-color: transparent;
}

.rail-credit {
  align-self: end;
  margin: 0;
  color: #8d8172;
  font-size: 0.72rem;
  line-height: 1.4;
}

@media (max-width: 860px) {
  .audio-dock {
    flex-wrap: wrap;
    gap: 0.45rem;
    padding-bottom: max(0.6rem, env(safe-area-inset-bottom));
  }

  .audio-scrub-wrap {
    order: 10;
    flex-basis: 100%;
  }

  .audio-meta {
    min-width: 0;
  }

  .audio-control span {
    display: none;
  }

  .audio-status {
    display: none;
  }

  body.audio-open .reader-footer {
    padding-bottom: 7.5rem;
  }
}

.audio-dock [hidden] {
  display: none !important;
}
