:root {
  --paper: #f8f1e9;
  --ink: #27201e;
  --muted: #63564f;
  --wine: #592e3e;
  --wine-deep: #351e2a;
  --copper: #e6af90;
  --blush: #efe1d7;
  --card: #fcf7f0;
  --rule: #b5a395;
  --display: Georgia, Cambria, serif;
  --sans: system-ui, sans-serif;
  --mono: Consolas, 'Courier New', monospace;
  --gutter: clamp(16px, 5vw, 80px);
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body, h1, h2, h3, p, dl, dd, blockquote { margin: 0; }
a { color: inherit; }
button { font: inherit; }
:is(a, button, audio):focus-visible { outline: 3px solid currentColor; outline-offset: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.shell { width: min(100% - var(--gutter) * 2, 1320px); margin-inline: auto; }
.skip-link { position: fixed; z-index: 2; left: 1rem; top: 1rem; padding: .75rem; background: var(--paper); }
.skip-link:not(:focus) { clip-path: inset(50%); }
.label { font: 700 .82rem/1.3 var(--mono); letter-spacing: .035em; text-transform: uppercase; }
.text-link { display: inline-flex; align-items: center; min-height: 44px; text-underline-offset: 4px; }
.mast, .section-line, .foot { display: flex; align-items: center; justify-content: space-between; gap: 4px 20px; }
.mast { min-height: 70px; border-bottom: 1px solid var(--ink); flex-wrap: wrap; }
.signature { font: 700 1.25rem/1.2 var(--display); text-decoration: none; }
.mast nav { display: flex; flex-wrap: wrap; gap: 0 20px; }
.mast nav a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; font-size: .94rem; font-weight: 650; }
.mast a:hover { color: var(--wine); text-decoration: underline; text-underline-offset: 4px; }

.cover {
  display: grid;
  grid-template-columns: 1.32fr 1fr;
  border-bottom: 1px solid var(--ink);
}
.cover-copy { min-width: 0; padding: clamp(24px, 3.8vw, 54px) clamp(12px, 3vw, 44px) clamp(24px, 3vw, 44px) 0; }
.cover h1 {
  color: var(--wine);
  font: 700 clamp(4.5rem, 9.5vw, 9rem)/.81 var(--display);
  letter-spacing: -.087em;
  overflow-wrap: anywhere;
  margin-block: .18em .25em;
}
.cover-summary { font-size: clamp(1rem, 1.5vw, 1.24rem); line-height: 1.5; max-width: 32ch; }
.cover-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 20px; }
.listen-link {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  gap: 10px;
  padding: 0 15px;
  background: var(--wine);
  color: var(--paper);
  border: 1px solid var(--wine);
  font-weight: 740;
  text-decoration: none;
  transition: background-color 160ms, color 160ms;
}
.listen-link:hover { color: var(--wine-deep); background: var(--copper); }
.listen-link:focus-visible { outline-color: var(--wine); }
.play-mark { width: 0; height: 0; border: 6px solid transparent; border-left: 9px solid currentColor; border-right: 0; }
.cover-art {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 280px;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
  background: radial-gradient(ellipse at 35% 25%, var(--wine), var(--wine-deep) 108%);
  color: var(--copper);
  text-decoration: none;
}
.cover-art:focus-visible { outline-offset: -5px; }
.record {
  position: absolute;
  z-index: -1;
  inset: 50% auto auto 50%;
  width: 120%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: repeating-radial-gradient(circle closest-side, transparent 0 11px, #e6af9040 12px, transparent 13px 17px);
}
.cover-letter {
  font: italic 700 clamp(13rem, 28vw, 26rem)/.8 var(--display);
  letter-spacing: -.12em;
  padding-right: .18em;
  padding-bottom: .12em;
  transition: transform 220ms ease-out;
}
.art-word { position: absolute; bottom: 15px; left: 15px; padding: 5px 8px; background: var(--wine-deep); font: 700 1rem/1.3 var(--mono); }
.art-word span:last-child { color: var(--paper); font-weight: 400; }
.art-arrow { position: absolute; right: 18px; bottom: 17px; display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid currentColor; border-radius: 50%; background: var(--wine-deep); font-size: 1.2rem; transition: background-color 160ms, color 160ms; }
.cover-art:is(:hover, :focus-visible) .cover-letter { transform: rotate(-3deg) scale(1.025); }
.cover-art:is(:hover, :focus-visible) .art-arrow { color: var(--wine-deep); background: var(--copper); }

.lexicon { padding-block: 22px 60px; scroll-margin-top: 12px; }
.section-line { flex-wrap: wrap; min-height: 68px; border-bottom: 1px solid currentColor; padding-block: 8px; }
.section-line h2 { font: 700 clamp(1.8rem, 3.4vw, 3.5rem)/1.04 var(--display); letter-spacing: -.043em; }
.word-tools { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-block: 18px 16px; }
.mode-switch { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--rule); border-radius: 999px; }
.mode-switch button {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--wine);
  font-weight: 700;
  cursor: pointer;
  transition: background-color 160ms, color 160ms;
}
.mode-switch button:hover { background: var(--blush); }
.mode-switch button[aria-pressed="true"] { background: var(--wine); color: var(--paper); }
.mode-switch button:focus-visible { outline-color: var(--wine); outline-offset: 2px; }
.word-search input {
  display: block;
  min-height: 46px;
  width: min(100%, 280px);
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  background: var(--card);
}
.word-search input:focus-visible { outline: 2px solid var(--wine); outline-offset: 2px; }
.practice-hint, .no-words { color: var(--muted); margin-bottom: 16px; }
.word-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(10px, 1.6vw, 22px); }
.word {
  position: relative;
  min-height: 142px;
  min-width: 0;
  padding: 16px clamp(12px, 2vw, 26px);
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--card);
  transition: transform 180ms ease-out, border-color 180ms, background-color 180ms, box-shadow 180ms;
}
.word.is-featured { background: var(--blush); }
.word dt { font: 700 clamp(1.36rem, 2.8vw, 2.7rem)/1.06 var(--display); letter-spacing: -.05em; overflow-wrap: anywhere; }
.word dd { margin-top: 9px; font-size: 1rem; line-height: 1.35; color: var(--wine-deep); }
.word a { text-decoration-thickness: 1px; text-underline-offset: .16em; }
.card-control {
  display: block;
  max-width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  text-align: start;
  color: var(--wine);
  background: transparent;
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
}
.card-control::after, .word a::after { position: absolute; inset: 0; border-radius: 10px; content: ''; }
.card-control:focus-visible { outline: none; }
.card-control:focus-visible::after { outline: 2px solid var(--wine); outline-offset: 3px; }
.card-arrow {
  display: grid;
  place-items: center;
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 29px;
  height: 29px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  font: 400 1.1rem/1 var(--sans);
  transition: transform 180ms, background-color 180ms, color 180ms;
}
.card-prompt { display: none; margin-top: 9px; font: 400 .87rem/1.3 var(--sans); letter-spacing: normal; color: var(--muted); }
.is-practice .word:not(.is-revealed) .card-prompt { display: block; }
.word.is-revealed { background: var(--blush); border-color: var(--wine); }
.word.is-revealed dd { animation: entry-in 190ms ease-out both; }
.word:has(.card-control:active) { transform: translateY(1px); }
@media (hover: hover) {
  .word:hover { transform: translateY(-3px); border-color: var(--wine); box-shadow: 0 6px 14px #351e2a12; }
  .word:hover .card-arrow { transform: rotate(-8deg); background: var(--wine); color: var(--paper); }
}

.type-section { background: var(--blush); color: var(--wine-deep); }
.type-shell, .listening-shell { padding-block: clamp(24px, 4vw, 54px); }
.entry-dialog {
  width: min(800px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--wine);
  border-radius: 16px;
  background: var(--paper);
  color: var(--wine-deep);
  box-shadow: 0 22px 100px #1c101bb3;
}
.entry-dialog[open] { animation: entry-in 220ms ease-out both; }
.entry-dialog::backdrop { background: #271421aa; }
.entry-dialog[open]::backdrop { animation: backdrop-in 220ms ease-out both; }
body:has(.entry-dialog[open]) { overflow: hidden; }
.entry-inner { padding: clamp(16px, 4vw, 42px); }
.entry-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 10px; border-bottom: 1px solid var(--rule); }
.entry-header h2 { font: 700 clamp(1.55rem, 3vw, 2.1rem)/1.1 var(--display); letter-spacing: -.04em; }
.dialog-close { min-height: 44px; border: 0; padding: 0 8px; background: transparent; color: var(--wine); cursor: pointer; }
.dialog-close span { font-size: 1.2em; }
.dialog-close:hover { text-decoration: underline; text-underline-offset: 3px; }
.type-stage { display: grid; grid-template-columns: 1.55fr 1fr; padding-block: clamp(28px, 6vw, 58px); gap: 24px; }
.source-word { min-width: 0; }
.type-term, .type-meaning { font-family: var(--display); letter-spacing: -.074em; overflow-wrap: anywhere; }
.type-term { color: var(--wine); font-size: clamp(2.75rem, 6vw, 5.35rem); line-height: 1.1; margin-top: 9px; }
.translated-word { padding-inline-start: clamp(16px, 2.7vw, 40px); border-inline-start: 1px solid var(--rule); }
.type-meaning { font-size: clamp(2.1rem, 4vw, 3.25rem); line-height: 1.06; margin-top: 12px; }
.entry-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 14px; border-top: 1px solid var(--rule); }
.entry-nav button { min-height: 46px; padding: 0 12px; font-weight: 700; border: 1px solid var(--wine); border-radius: 8px; background: transparent; color: var(--wine); cursor: pointer; }
.entry-nav button:hover:not(:disabled) { color: var(--paper); background: var(--wine); }
.entry-nav button:disabled { opacity: .45; cursor: default; }
.entry-nav button:focus-visible { outline-color: var(--wine); }
.entry-count { font: 700 .9rem/1 var(--mono); }
.test-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 22px; }
.test-grid > div { border-inline-start: 1px solid var(--rule); padding: 0 clamp(7px, 2vw, 28px) 8px; }
.test-grid strong { display: block; color: var(--wine); font: 400 clamp(2.75rem, 6vw, 6rem)/1.08 var(--display); }
.test-grid dd { font: 400 clamp(.84rem, 2vw, 1.2rem)/1.4 var(--display); margin-top: 8px; }

.reading { display: grid; grid-template-columns: 1.45fr 1fr; align-items: start; gap: clamp(24px, 5vw, 76px); padding-block: clamp(24px, 4vw, 50px); }
.passage h3 { font: 700 .85rem/1.4 var(--mono); text-transform: uppercase; letter-spacing: .03em; color: var(--wine); }
.passage blockquote { margin-top: 14px; font: 400 clamp(1.8rem, 3.15vw, 3rem)/1.24 var(--display); letter-spacing: -.033em; overflow-wrap: anywhere; }
.credit { margin-top: 18px; color: var(--muted); line-height: 1.4; }
.audio-panel { border-top: 7px solid var(--copper); padding: clamp(16px, 3.2vw, 44px); color: var(--paper); background: var(--wine-deep); scroll-margin-top: 12px; }
.audio-panel h3 { color: var(--copper); font: 700 clamp(2.1rem, 4vw, 4rem)/1 var(--display); letter-spacing: -.055em; }
.track { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--rule); }
.track label { display: block; margin-bottom: 8px; font: 700 .95rem/1.4 var(--mono); }
.track-controls { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 10px; align-items: start; }
.track-toggle { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--copper); color: var(--wine-deep); cursor: pointer; transition: background-color 160ms, transform 160ms; }
.track-toggle:hover:not(:disabled) { background: var(--paper); }
.track-toggle:disabled { opacity: .6; cursor: progress; }
.track-toggle:active { transform: scale(.94); }
.track-toggle:focus-visible { outline-color: var(--paper); }
.track-icon { width: 0; height: 0; border: 8px solid transparent; border-right: 0; border-left: 12px solid currentColor; margin-left: 3px; }
.is-playing .track-icon { width: 12px; height: 15px; border: solid currentColor; border-width: 0 4px; margin-left: 0; }
.wave-seek { position: relative; height: 48px; padding: 5px 0; --position: 0%; }
.wave-seek:focus-within { outline: 2px solid var(--paper); outline-offset: 3px; }
.wave-seek input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.wave { display: flex; align-items: center; gap: clamp(1px, .15vw, 2px); height: 100%; }
.wave span { flex: 1 1 0; min-width: 0; height: var(--height); border-radius: 99px; background: #a77d86; transition: background-color 160ms; }
.wave span.played { background: var(--copper); }
.wave-playhead { position: absolute; top: 2px; bottom: 2px; left: var(--position); width: 2px; transform: translateX(-50%); border-radius: 2px; background: var(--paper); pointer-events: none; }
.wave-playhead::after { position: absolute; bottom: 0; left: 50%; width: 8px; height: 8px; transform: translateX(-50%); border-radius: 50%; background: inherit; content: ""; }
.wave-seek:has(input:disabled) .wave-playhead { opacity: .55; }
.track-times { display: flex; justify-content: space-between; color: var(--paper); font: .84rem/1.2 var(--mono); }
.track-status { margin-top: 8px; color: var(--paper); font-size: .88rem; }
audio { display: block; width: 100%; height: 52px; }
.audio-fallback { margin-top: 8px; }
.foot { min-height: 52px; flex-wrap: wrap; border-top: 1px solid var(--ink); padding-block: 10px; font-size: .88rem; }
.foot span { color: var(--muted); }

@media (max-width: 800px) {
  .cover h1 { font-size: clamp(3.5rem, 10.1vw, 6rem); }
  .word-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .mast { padding-top: 14px; }
  .mast nav { gap: 0 14px; }
  .mast nav a { font-size: .9rem; }
  .cover, .reading, .type-stage { grid-template-columns: minmax(0, 1fr); }
  .cover-copy { padding-right: 0; }
  .cover h1 { font-size: clamp(3.9rem, 14vw, 5.1rem); }
  .cover-art { min-height: 240px; }
  .cover-letter { font-size: clamp(12rem, 50vw, 16rem); }
  .cover-summary { max-width: 31ch; }
  .word { min-height: 124px; }
  .word dt { font-size: clamp(1.3rem, 6vw, 1.8rem); }
  .word dd { font-size: .94rem; }
  .word-tools { align-items: stretch; }
  .word-search, .word-search input { width: 100%; }
  .translated-word { border-inline-start: 0; border-top: 1px solid var(--rule); padding: 14px 0 0; }
  .type-meaning { margin-top: 6px; }
  .entry-nav button { padding-inline: 8px; }
}
@keyframes entry-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .entry-dialog[open], .entry-dialog[open]::backdrop, .word.is-revealed dd { animation: none; }
  .word, .card-arrow, .listen-link, .mode-switch button, .track-toggle, .wave span, .cover-letter, .art-arrow { transition: none; }
  .cover-art:is(:hover, :focus-visible) .cover-letter { transform: none; }
}
