:root {
  color-scheme: light;
  --bg: #eef1f9;
  --surface: #fff;
  --ink: #17213b;
  --muted: #56638b;
  --line: #e1e6f2;
  --primary: #5b4bdb;
  --primary-ink: #4132ae;
  --primary-soft: #edeafb;
  --primary-hover: #4939c6;
  --focus: #674fe0;
  --control-line: #a9a4d5;
  --well: #f5f6fc;
  --ok-ink: #087451;
  --ok-bg: #e4f6ee;
  --shadow: 0 1px 2px rgba(23, 33, 59, .04), 0 12px 34px rgba(23, 33, 59, .07);
  --brand-glow: radial-gradient(1000px 480px at 100% -10%, #5b4bdb1a, transparent 65%),
    radial-gradient(800px 420px at 0 0, #e8459b13, transparent 60%);
  --sans: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  --verse: Georgia, "Times New Roman", serif;
  font: 16px/1.5 var(--sans);
  color: var(--ink);
  background: var(--bg);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1424;
  --surface: #171f34;
  --ink: #f0f2ff;
  --muted: #b0bcdd;
  --line: #323b57;
  --primary: #6854e5;
  --primary-ink: #c8beff;
  --primary-soft: #2b254e;
  --primary-hover: #5945d0;
  --focus: #b4a5ff;
  --control-line: #8079b5;
  --well: #1c253c;
  --ok-ink: #9de8c6;
  --ok-bg: #1a3a35;
  --shadow: 0 10px 30px #06091655;
  --brand-glow: radial-gradient(1000px 480px at 100% -10%, #7857ef26, transparent 65%),
    radial-gradient(800px 420px at 0 0, #b0529720, transparent 60%);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--brand-glow), var(--bg); }
h1, h2, p { margin: 0; }
a { color: inherit; text-underline-offset: .18em; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.frame { width: min(1140px, calc(100% - 56px)); margin-inline: auto; }

.site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.site-nav {
  min-height: 65px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: .91rem;
  font-weight: 600;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -.035em;
  text-decoration: none;
}
.brand span { color: #d53587; }
:root[data-theme="dark"] .brand span { color: #fa8dc2; }
.site-section { color: var(--muted); }
.brand img { display: block; border-radius: 9px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 370px) minmax(0, 1fr);
  gap: 20px 26px;
  align-items: start;
  padding-block: 34px 48px;
}
.introduction {
  grid-row: span 2;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.cover {
  position: relative;
  isolation: isolate;
  min-height: 354px;
  display: flex;
  align-items: end;
  background: #20264b;
  color: #fff;
}
.painting, .cover::after {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}
.painting { object-fit: cover; object-position: 52% 50%; }
.cover::after {
  content: "";
  background: linear-gradient(180deg, transparent 31%, rgba(22, 23, 55, .78) 75%, #191c3e 100%);
}
.cover-copy { padding: 24px 28px 28px; }
.cover-copy p { font-size: .9rem; color: #f3efff; }
.cover h1 {
  margin-top: 9px;
  font: 800 clamp(3.15rem, 4.8vw, 4.55rem)/.98 var(--sans);
  letter-spacing: -.045em;
}
.painting-credit {
  position: absolute;
  top: 15px;
  right: 15px;
  padding: 4px 8px;
  border-radius: 5px;
  color: #fff;
  background: #181f3bd9;
  font-size: .72rem;
}
.listening { padding: 21px 23px 23px; }
.listening h2 { font-size: 1rem; }
.listening audio { display: block; width: 100%; height: 44px; margin-top: 9px; }
.listening p, .source { color: var(--muted); font-size: .8rem; margin-top: 10px; }

.trainer, .full-text {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
}
.trainer { border-radius: 20px; overflow: clip; box-shadow: var(--shadow); }
.route {
  display: grid;
  grid-template-columns: repeat(var(--steps, 3), minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  background: var(--well);
  margin: 14px 18px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.route button {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  border: 0;
  border-radius: 8px;
  padding: 8px 3px;
  min-height: 42px;
  background: transparent;
  font-size: .87rem;
  font-weight: 650;
}
.route button[aria-current="step"] { color: var(--primary-ink); background: var(--primary-soft); }
.route button:not([aria-current]):hover { background: var(--surface); }
.route button:focus-visible { outline-offset: -4px; }
.route b {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  color: var(--primary-ink);
  background: var(--primary-soft);
  font-size: .72rem;
}
.route button[aria-current="step"] b { background: var(--primary); color: #fff; }

.exercise { padding: 27px 34px 30px; }
.exercise h2 { font: 800 clamp(1.6rem, 3vw, 2.25rem)/1.16 var(--sans); letter-spacing: -.035em; }
#instruction { margin-top: 7px; color: var(--muted); }
#stanza-nav { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
#stanza-nav:empty { display: none; }
#stanza-nav button {
  border: 1px solid var(--line);
  background: var(--well);
  color: var(--ink);
  border-radius: 9px;
  min-width: 44px;
  min-height: 44px;
  font-size: .86rem;
  font-weight: 650;
}
#stanza-nav button[data-result="solo"]:not([aria-current]) { background: var(--ok-bg); color: var(--ok-ink); }
#stanza-nav button[data-result="help"]:not([aria-current]) { border-style: dashed; }
#stanza-nav button[aria-current] { border-color: var(--primary-ink); color: var(--primary-ink); background: var(--primary-soft); }

.recitation { margin-top: 19px; }
.verse-sheet {
  padding: 14px 19px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--well);
}
.verse-line, .prompt-line {
  font: 400 clamp(1.12rem, 2.1vw, 1.52rem)/1.3 var(--verse);
}
.verse-line { display: block; padding-block: .21em; }
.prompt-line {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 44px;
  width: 100%;
  padding: 6px 7px;
  border: 0;
  border-bottom: 1px dashed var(--control-line);
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.prompt-line:last-child { border-bottom-color: transparent; }
.prompt-line:hover, .prompt-line:focus-visible { background: var(--primary-soft); border-radius: 6px; }
.line-number { font: 600 .78rem/1 system-ui, sans-serif; color: var(--primary-ink); min-width: 1ch; }
.prompt-cue { min-width: 0; }
.prompt-line[aria-disabled="true"] { cursor: default; }
.verse-sheet p + p { margin-top: 17px; }
.words-sheet .verse-line { padding-block: .18em; }
.missing-word {
  display: inline-block;
  vertical-align: baseline;
  min-width: 62px;
  min-height: 38px;
  margin-inline: 2px;
  border: 1px dashed var(--control-line);
  border-radius: 7px;
  padding: 2px 9px;
  color: var(--primary-ink);
  background: var(--surface);
}
.missing-word[aria-pressed="true"] {
  border-style: solid;
  border-color: var(--primary-ink);
  background: var(--primary-soft);
}
.filled-word { color: var(--ok-ink); background: var(--ok-bg); padding-inline: .15em; border-radius: 4px; font-weight: 700; }
.word-picker { margin-top: 12px; }
.word-feedback { color: var(--muted); }
.word-options { display: flex; flex-wrap: wrap; gap: 8px; }
.word-options:not(:empty) { margin-top: 8px; }
.word-option { min-width: 74px; }

.actions:empty { display: none; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; }
.action {
  border-radius: 10px;
  min-height: 46px;
  padding: 10px 15px;
  font-size: .91rem;
  font-weight: 700;
  color: var(--primary-ink);
  border: 1px solid var(--control-line);
  background: var(--surface);
}
.action:hover { background: var(--primary-soft); }
.action.primary { color: white; background: var(--primary); border-color: var(--primary); }
.action.primary:hover { background: var(--primary-hover); }

.full-text {
  grid-column: 2;
  padding: 0 22px;
  border-radius: 14px;
  color: var(--ink);
}
.full-text > summary {
  cursor: pointer;
  padding: 12px 0;
  font-size: .91rem;
  font-weight: 650;
  min-height: 46px;
}
.full-text[open] { padding-bottom: 18px; }
.original-text { font: 1.16rem/1.56 var(--verse); }
.stanza + .stanza { margin-top: 14px; }
.stanza span { display: block; }

@media (max-width: 850px) {
  .layout { grid-template-columns: minmax(0, .72fr) minmax(0, 1fr); gap: 16px; }
  .frame { width: calc(100% - 36px); }
  .exercise { padding-inline: 21px; }
  .route { margin-inline: 12px; }
  .cover-copy { padding-inline: 22px; }
  .listening { padding-inline: 16px; }
}

@media (max-width: 660px) {
  .frame { width: calc(100% - 26px); }
  .site-nav { min-height: 54px; }
  .layout { grid-template-columns: minmax(0, 1fr); padding-block: 12px 24px; gap: 12px; }
  .introduction { grid-row: auto; border-radius: 17px; }
  .cover { min-height: 153px; }
  .cover-copy { padding: 42px 15px 14px; }
  .cover h1 { font-size: clamp(1.9rem, 9.2vw, 3.15rem); margin-top: 4px; }
  .cover h1 br { display: none; }
  .painting { object-position: 49% 44%; }
  .painting-credit { right: 8px; top: 8px; }
  .listening { padding: 10px 12px 11px; }
  .listening audio { margin-top: 4px; }
  .listening p { margin-top: 4px; }
  .trainer { border-radius: 17px; }
  .route { padding: 5px; margin: 9px 9px 0; }
  .route button { gap: 4px; font-size: .78rem; min-height: 44px; }
  .exercise { padding: 15px 13px 16px; }
  #instruction { font-size: .88rem; }
  #stanza-nav { margin-top: 10px; }
  .recitation { margin-top: 13px; }
  .verse-sheet { padding: 9px 10px; }
  .actions { margin-top: 13px; }
  .full-text { grid-column: auto; padding-inline: 13px; }
}

.scope-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 34px;
  min-height: 44px;
  background: var(--well);
  border-bottom: 1px solid var(--line);
  margin-top: 12px;
  color: var(--muted);
  font-size: .81rem;
}
.scope-bar button {
  border: 0;
  padding: 4px 0 4px 6px;
  min-height: 44px;
  color: var(--primary-ink);
  background: transparent;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: .2em;
}
/* The border follows the selected lines. The gutter keeps touch controls off the text. */
.poem-window {
  max-height: min(390px, 49vh);
  min-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--well);
  scrollbar-color: var(--control-line) var(--well);
}
.poem-canvas { position: relative; padding: 18px 28px 18px 9px; }
.selection-stanza + .selection-stanza { margin-top: 12px; }
.selection-line {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: baseline;
  gap: 5px;
  width: 100%;
  min-height: 35px;
  padding: 5px 7px;
  text-align: left;
  border: 0;
  border-radius: 2px;
  color: var(--muted);
  background: transparent;
  font: 1.2rem/1.25 var(--verse);
}
.selection-line[aria-pressed="true"] { color: var(--ink); background: var(--primary-soft); }
.selection-line:hover { box-shadow: inset 0 0 0 1px var(--control-line); }
.selection-line:focus-visible { outline-offset: -3px; }
.selection-number {
  color: var(--primary-ink);
  font: 600 .7rem/1 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
.selection-frame {
  position: absolute;
  inset-inline: 9px 26px;
  border: 2px solid var(--primary-ink);
  border-radius: 7px;
  pointer-events: none;
}
.frame-grip {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  pointer-events: auto;
  touch-action: none;
  cursor: ns-resize;
  width: 46px;
  height: 44px;
  right: -25px;
}
.frame-grip.top { top: -16px; align-items: start; }
.frame-grip.bottom { bottom: -16px; align-items: end; }
.frame-grip.move { top: 50%; translate: 0 -50%; cursor: grab; }
.short-frame .frame-grip.move { right: auto; left: -9px; width: 30px; }
.frame-grip:focus-visible { outline: none; }
.frame-grip:focus-visible::after { outline: 2px solid var(--primary-ink); outline-offset: 2px; }
.frame-grip.move:active { cursor: grabbing; }
.frame-grip.move[aria-valuemax="1"] { display: none; }
.selection-frame:has(.frame-grip.top:is(:hover, :focus-visible)) { border-top-width: 3px; }
.selection-frame:has(.frame-grip.bottom:is(:hover, :focus-visible)) { border-bottom-width: 3px; }
.frame-grip::after {
  content: "";
  display: block;
  border: 2px solid var(--well);
  background: var(--primary);
  border-radius: 12px;
  width: 26px;
  height: 13px;
}
.frame-grip.move::after {
  content: "↕";
  display: grid;
  place-items: center;
  width: 21px;
  height: 30px;
  color: #fff;
  font: 700 21px/1 system-ui, sans-serif;
}
.frame-grip.top::after { margin-top: 7px; }
.frame-grip.bottom::after { margin-bottom: 7px; }
.range-summary { margin-top: 12px; font-weight: 700; font-size: .91rem; color: var(--primary-ink); }
.move-hint { margin-top: 3px; color: var(--muted); font-size: .81rem; }
.selection-footer { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.action:disabled { cursor: default; color: var(--muted); background: var(--well); border-color: var(--line); }
#listen-selection { margin-top: 8px; }

@media (max-width: 850px) {
  .scope-bar { padding-inline: 21px; }
}
@media (max-width: 660px) {
  .scope-bar { padding-inline: 13px; }
  .range-grid { gap: 5px; }
  .poem-window { max-height: min(345px, 49vh); }
  .poem-canvas { padding-inline: 5px 25px; }
  .selection-frame { inset-inline: 5px 23px; }
  .selection-line { font-size: 1.01rem; min-height: 35px; padding-inline: 5px; grid-template-columns: 17px minmax(0, 1fr); }
}

.cover-plain {
  min-height: 238px;
  background: radial-gradient(ellipse at 90% 0, #8768ef 0%, transparent 62%),
    linear-gradient(140deg, #5847cc, #272255 88%);
}
.cover-plain h1 { font-size: clamp(1.9rem, 3.15vw, 3rem); line-height: 1.1; overflow-wrap: anywhere; }
.catalog { max-width: 944px; padding-block: 34px 56px; }
.catalog-intro { padding: 28px 32px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); box-shadow: var(--shadow); }
.catalog h1 { font: 800 clamp(1.8rem, 4vw, 2.75rem)/1.12 var(--sans); letter-spacing: -.04em; }
.catalog-intro p { margin-top: 9px; color: var(--muted); }
.catalog-search { display: grid; gap: 6px; max-width: 430px; margin-top: 20px;
  color: var(--muted); font-size: .83rem; font-weight: 700; }
.catalog-search input { width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--control-line);
  border-radius: 10px; background: var(--well); color: var(--ink); font: 600 1rem var(--sans); }
.grades-nav { display: flex; flex-wrap: wrap; gap: 7px; margin-block: 20px 25px; }
.grades-nav a { display: grid; align-items: center; min-height: 44px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--primary-ink);
  text-decoration: none; font-size: .87rem; font-weight: 750; }
.grades-nav a:hover { background: var(--primary-soft); }
.poem-grade { margin-top: 22px; scroll-margin-top: 16px; }
.poem-grade h2 { font-size: 1.35rem; margin: 0; }
.poetry-grade-heading { display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; }
.poetry-course-link, .poetry-literature a { color: var(--primary);
  text-underline-offset: 3px; }
.poetry-literature { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 14px;
  font-size: .9rem; }
.poetry-literature span { flex-basis: 100%; color: var(--muted); }
.poem-grade ul { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px; margin: 0; padding: 0; }
.poem-grade li a { display: flex; min-height: 63px; height: 100%; flex-direction: column;
  justify-content: center; padding: 9px 12px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface); text-decoration: none; overflow-wrap: anywhere; }
.poem-grade li a:hover { border-color: var(--primary); }
.poem-grade li a span { margin-top: 2px; color: var(--muted); font-size: .82rem; }
.catalog-note { margin-top: 28px; }
@media (max-width: 660px) {
  .cover-plain { min-height: 132px; }
  .cover-plain .cover-copy { padding-top: 25px; }
  .catalog { padding-block: 14px 34px; }
  .catalog-intro { padding: 18px 15px; }
  .poem-grade ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
