:root {
  --bg: #f4efe6;
  --bg-2: #ebe3d4;
  --paper: #fffdf8;
  --ink: #1c1915;
  --muted: #6a6258;
  --line: #ddd3c3;
  --accent: #0f5c4c;
  --accent-2: #c45c26;
  --accent-soft: #dceee8;
  --warn: #8a4b12;
  --ok: #1f7a45;
  --bad: #a12828;
  --shadow: 0 10px 30px rgba(40, 30, 10, 0.08);
  --radius: 14px;
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #f8e7c8 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #d9ebe4 0%, transparent 50%),
    var(--bg);
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; }
a { color: var(--accent); }
.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: #fff; padding: 0.5rem 1rem; z-index: 100;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

.shell { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.65rem 1rem;
  background: rgba(244, 239, 230, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 0.65rem;
  text-decoration: none; color: inherit; min-width: 10rem;
}
.brand-mark {
  width: 2.3rem; height: 2.3rem; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 700;
}
.brand strong { display: block; font-size: 0.95rem; }
.brand small { color: var(--muted); font-size: 0.75rem; }
.nav { display: flex; flex-wrap: wrap; gap: 0.25rem; flex: 1; }
.nav a {
  text-decoration: none; color: var(--muted);
  padding: 0.4rem 0.7rem; border-radius: 999px; font-size: 0.92rem;
}
.nav a:hover, .nav a[aria-current="page"] {
  background: var(--accent-soft); color: var(--accent);
}
.en-toggle {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.25rem 0.65rem; cursor: pointer;
  font-size: 0.85rem; font-weight: 600;
}

.main { flex: 1; padding: 1.25rem 1.25rem 5rem; max-width: 1200px; width: 100%; margin: 0 auto; }
.panel {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem;
}
.hero {
  display: grid; gap: 1rem;
  grid-template-columns: 1.4fr 1fr;
}
.nav-toggle { display: none; border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 0.35rem 0.55rem; cursor: pointer; }
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .nav-toggle { display: inline-flex; }
  .nav { display: none; }
  .nav.open {
    display: flex; position: absolute; top: 100%; left: 0; right: 0;
    background: rgba(244,239,230,0.98); padding: 0.5rem; flex-direction: column;
    border-bottom: 1px solid var(--line);
  }
}
.hero h1 { font-family: var(--font); font-size: clamp(1.8rem, 3vw, 2.5rem); margin: 0 0 0.4rem; }
.hero p { color: var(--muted); margin: 0 0 1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.stat {
  background: var(--bg-2); border-radius: 12px; padding: 0.85rem 1rem;
}
.stat b { display: block; font-size: 1.4rem; }
.stat span { color: var(--muted); font-size: 0.85rem; }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--paper);
  color: var(--ink); border-radius: 999px; padding: 0.55rem 1rem;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 0.35rem;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, .icon-btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, button:focus-visible, textarea:focus-visible {
  outline: 3px solid #7bc4b0; outline-offset: 2px;
}
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { background: #f8e4e4; border-color: #e5b6b6; color: var(--bad); }

.tip {
  margin-top: 1rem; padding: 0.85rem 1rem; border-radius: 12px;
  background: #fff6e8; border: 1px solid #efd7ad; color: var(--warn); font-size: 0.92rem;
}
.tip code { background: #fff; padding: 0.1rem 0.35rem; border-radius: 4px; }

.course-layout { display: grid; grid-template-columns: 280px 1fr; gap: 1rem; }
@media (max-width: 900px) { .course-layout { grid-template-columns: 1fr; } }
.course-nav { max-height: calc(100vh - 7rem); overflow: auto; position: sticky; top: 4.5rem; }
.course-nav h2 { margin: 0 0 0.75rem; font-size: 1rem; }
.section-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.section-list a {
  display: grid; grid-template-columns: 1fr auto; gap: 0.35rem;
  text-decoration: none; color: inherit; padding: 0.55rem 0.65rem;
  border-radius: 10px; border: 1px solid transparent;
}
.section-list a:hover, .section-list a[aria-current="page"] {
  background: var(--accent-soft); border-color: #b7d8cd;
}
.section-list small { color: var(--muted); }
.pct { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 600; font-size: 0.85rem; }

.lesson-head { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; justify-content: space-between; margin-bottom: 1rem; }
.lesson-head h1 { margin: 0; font-family: var(--font); font-size: 1.7rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 1rem; }
.tabs button {
  border: 1px solid var(--line); background: var(--bg-2); border-radius: 999px;
  padding: 0.4rem 0.85rem; cursor: pointer; color: var(--muted);
}
.tabs button[aria-selected="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

.spread { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.page {
  background: #fffef9; border: 1px solid var(--line); border-radius: 12px; padding: 1rem;
}
.page .meta { color: var(--muted); font-size: 0.8rem; margin: 0 0 0.5rem; }
.page h2, .page h3 { font-family: var(--font); margin: 0.2rem 0 0.6rem; }
.page p { margin: 0.4rem 0; white-space: pre-wrap; }
.block { margin: 0.75rem 0; }
.unit { position: relative; }
.unit .en-line { color: var(--muted); font-size: 0.92rem; margin: 0.15rem 0 0.4rem; }
.unit.en-off .en-line { display: none; }
.en-btn {
  position: absolute; right: 0; top: 0;
  font-size: 0.68rem; border: 1px solid var(--line); background: #fff;
  border-radius: 4px; padding: 0.05rem 0.3rem; cursor: pointer; color: var(--muted);
}
.blank {
  display: inline-block; min-width: 3.5rem; border-bottom: 2px solid var(--accent-2);
  margin: 0 0.15rem; height: 1em; vertical-align: baseline;
}
.table-wrap { overflow: auto; margin: 0.5rem 0; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { border: 1px solid var(--line); padding: 0.35rem 0.5rem; vertical-align: top; }
th { background: var(--bg-2); }
.callout {
  background: #f7f1e4; border-left: 4px solid var(--accent-2);
  padding: 0.65rem 0.85rem; border-radius: 0 10px 10px 0; margin: 0.5rem 0;
}
.entry { display: grid; grid-template-columns: 1fr 1.2fr; gap: 0.5rem; padding: 0.35rem 0; border-bottom: 1px dashed var(--line); }
.entry .term { font-weight: 600; font-family: var(--font); }
.example { color: var(--muted); font-size: 0.9rem; }
.items, .bank { padding-left: 1.2rem; }
.bank { display: flex; flex-wrap: wrap; gap: 0.35rem; list-style: none; padding: 0; }
.bank li { background: var(--accent-soft); padding: 0.2rem 0.55rem; border-radius: 999px; }
.instruction { font-weight: 600; }
.fig-ph {
  background: var(--bg-2); border: 1px dashed var(--line); border-radius: 10px;
  padding: 0.85rem; color: var(--muted); font-size: 0.9rem; margin: 0.5rem 0;
}
.fig-ph strong { color: var(--ink); display: block; margin-bottom: 0.25rem; }
.desc { color: var(--muted); font-size: 0.88rem; }
.photo summary { cursor: pointer; color: var(--accent); margin-bottom: 0.5rem; }
.photo img { max-width: 100%; border-radius: 8px; }
.banner { background: #fff1df; color: var(--warn); padding: 0.6rem 0.8rem; border-radius: 8px; margin-bottom: 0.75rem; }

.vocab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.65rem; }
.vocab-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 0.85rem;
  background: #fff; cursor: pointer; min-height: 5.5rem;
}
.vocab-card.known { outline: 2px solid var(--ok); }
.vocab-card .term { font-family: var(--font); font-size: 1.15rem; font-weight: 700; }
.vocab-card .en { color: var(--muted); margin-top: 0.35rem; }
.vocab-card .meta { font-size: 0.75rem; color: var(--muted); margin-top: 0.5rem; }

.games-hub { display: grid; gap: 1rem; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.65rem; }
.game-tile {
  border: 1px solid var(--line); border-radius: 14px; padding: 1rem; background: #fff;
  text-align: left; cursor: pointer; min-height: 7rem;
}
.game-tile:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.game-tile b { display: block; font-size: 1.05rem; margin-bottom: 0.35rem; }
.game-tile span { color: var(--muted); font-size: 0.88rem; }

.game-stage { display: grid; gap: 1rem; }
.prompt-card {
  background: linear-gradient(160deg, #fff, #f3efe4);
  border: 1px solid var(--line); border-radius: 16px; padding: 1.5rem; text-align: center;
  min-height: 10rem; display: grid; place-content: center; gap: 0.5rem;
}
.prompt-card .big { font-family: var(--font); font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 700; }
.prompt-card .sub { color: var(--muted); }
.answer-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.answer-row input[type="text"] {
  flex: 1; min-width: 12rem; padding: 0.7rem 0.9rem; border-radius: 10px;
  border: 1px solid var(--line); background: #fff;
}
.feedback.ok { color: var(--ok); font-weight: 600; }
.feedback.bad { color: var(--bad); font-weight: 600; }
.match-board { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.match-col { display: grid; gap: 0.4rem; }
.match-item {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 0.7rem; cursor: pointer; text-align: left;
}
.match-item.selected { outline: 2px solid var(--accent); }
.match-item.matched { opacity: 0.45; outline: 2px solid var(--ok); pointer-events: none; }
.quiz-options { display: grid; gap: 0.5rem; }
.quiz-options button { text-align: left; padding: 0.75rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.quiz-options button.correct { background: #e5f6ea; border-color: var(--ok); }
.quiz-options button.wrong { background: #fdecec; border-color: var(--bad); }
.scorebar { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.9rem; }

.book-layout { display: grid; grid-template-columns: 300px 1fr; gap: 1rem; min-height: 70vh; }
@media (max-width: 900px) { .book-layout { grid-template-columns: 1fr; } }
.book-aside { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem; max-height: calc(100vh - 6rem); overflow: auto; position: sticky; top: 4.5rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.5rem 0; }
.filters button { border: 1px solid var(--line); background: var(--bg-2); border-radius: 999px; padding: 0.25rem 0.55rem; cursor: pointer; font-size: 0.8rem; }
.filters button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-list { list-style: none; margin: 0; padding: 0; }
.page-list button {
  width: 100%; text-align: left; border: 0; background: transparent; padding: 0.55rem 0.4rem;
  border-radius: 8px; cursor: pointer;
}
.page-list button[aria-current="true"], .page-list button:hover { background: var(--accent-soft); }
.page-list .num { display: block; color: var(--muted); font-size: 0.75rem; }
.page-list .name { font-size: 0.9rem; }
.count { color: var(--muted); font-size: 0.85rem; }
.reader-nav { display: flex; gap: 0.5rem; margin-top: 1rem; }
.search-label { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; }
#book-search, #dict-search { width: 100%; padding: 0.55rem 0.7rem; border-radius: 8px; border: 1px solid var(--line); }


.dict-letters { display: flex; flex-wrap: wrap; gap: 0.28rem; margin: 0.75rem 0 0.25rem; }
.dict-letter {
  border: 1px solid var(--line); background: var(--bg-2); border-radius: 8px;
  min-width: 2rem; padding: 0.28rem 0.45rem; cursor: pointer; font-size: 0.82rem;
  font-family: var(--font);
}
.dict-letter[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.dict-more { margin: 0.75rem 0 0; }

.dict-results {
  display: grid; gap: 0.4rem; margin-top: 1rem;
  max-width: 42rem; /* readable column — avoid full-bleed empty rows */
}
.dict-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) auto minmax(0, 1.3fr) auto;
  gap: 0.45rem;
  align-items: start;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
}
.dict-row .src { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.dict-row strong { min-width: 0; overflow-wrap: anywhere; }
.dict-row > span:not(.src) { min-width: 0; overflow-wrap: anywhere; }

.kb-lab { display: grid; gap: 1rem; }
.kb-grid {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.5rem;
}
.kb-key {
  aspect-ratio: 1.2; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; font-size: 1.6rem; font-family: var(--font); cursor: pointer;
}
.kb-key:active, .kb-key.flash { background: var(--accent-soft); }
.kb-help { color: var(--muted); font-size: 0.92rem; }
.kb-help table { margin-top: 0.5rem; }

.ee-keys {
  position: sticky; bottom: 0; z-index: 30;
  display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center;
  padding: 0.55rem 1rem; background: rgba(28, 25, 21, 0.92); color: #fff;
}
.ee-keys[hidden] { display: none !important; }
.ee-keys-label { opacity: 0.7; font-size: 0.8rem; margin-right: 0.35rem; }
.ee-keys button {
  min-width: 2.2rem; border: 0; border-radius: 8px; padding: 0.4rem 0.55rem;
  background: #3a342c; color: #fff; cursor: pointer; font-family: var(--font); font-size: 1.05rem;
}
.ee-keys button:hover { background: var(--accent); }

.modal {
  position: fixed; inset: 0; background: rgba(20, 16, 10, 0.45);
  display: grid; place-items: center; z-index: 60; padding: 1rem;
}
.modal[hidden] { display: none !important; }
.modal-card {
  background: var(--paper); border-radius: 16px; width: min(560px, 100%);
  max-height: 80vh; overflow: auto; box-shadow: var(--shadow);
}
.modal-card header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.85rem 1rem; border-bottom: 1px solid var(--line);
}
.modal-card header h2 { margin: 0; font-size: 1.1rem; }
.modal-card #modal-body { padding: 1rem; }
.icon-btn { border: 0; background: transparent; font-size: 1.4rem; cursor: pointer; line-height: 1; }

.empty { color: var(--muted); padding: 2rem; text-align: center; }
.progress-ring { height: 0.45rem; background: var(--bg-2); border-radius: 999px; overflow: hidden; margin-top: 0.35rem; }
.progress-ring > span { display: block; height: 100%; background: var(--accent); }

.exercise-interactive { border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin: 0.75rem 0; background: #fff; }
.exercise-interactive .blank-input {
  display: inline-block; min-width: 5rem; margin: 0 0.2rem;
  border: 0; border-bottom: 2px solid var(--accent-2); background: transparent; padding: 0.15rem;
}
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

.book-figure {
  margin: 0.85rem 0 1.1rem;
  padding: 0;
  background: #fffaf3;
  border: 1px solid #eadecb;
  border-radius: 14px;
  overflow: hidden;
  max-width: 420px;
}
.book-figure img {
  display: block;
  width: 100%;
  height: auto;
  background: #f7f1e6;
}
.book-figure figcaption {
  padding: 0.55rem 0.75rem 0.7rem;
  font-size: 0.95rem;
  color: #3a342c;
}
.fig-ph {
  padding: 1rem 0.9rem;
  color: #5c5348;
  background: repeating-linear-gradient(-45deg, #f7f1e6, #f7f1e6 8px, #f1e8da 8px, #f1e8da 16px);
}
.fig-ph-desc {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  opacity: 0.85;
}


/* —— Navigation aids: search + contents —— */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}
.tool-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.tool-btn:hover { border-color: var(--accent); color: var(--accent); }
.search-btn { min-width: 7.5rem; }
.tool-kbd {
  font: 0.7rem/1 var(--sans);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.12rem 0.3rem;
  background: var(--bg-2);
}
body.overlay-open { overflow: hidden; }

.search-palette {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: start center;
  padding: 8vh 1rem 1rem;
}
.search-palette[hidden] { display: none !important; }
.search-palette-backdrop {
  position: absolute; inset: 0;
  background: rgba(28, 25, 21, 0.45);
}
.search-palette-panel {
  position: relative;
  width: min(640px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.search-palette-bar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}
.search-palette-icon { color: var(--muted); font-size: 1.2rem; }
.search-palette-bar input {
  flex: 1; border: 0; background: transparent; outline: none;
  font-size: 1.05rem; color: var(--ink);
}
.search-kbd {
  font: 0.75rem/1 var(--sans);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.2rem 0.4rem;
}
.search-palette-results {
  max-height: min(52vh, 420px);
  overflow: auto;
  padding: 0.35rem;
}
.search-hit {
  width: 100%;
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.65rem;
  align-items: center;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  color: inherit;
}
.search-hit:hover,
.search-hit.active { background: var(--accent-soft); }
.search-hit-type {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: #fff;
  border: 1px solid #b7d8cd;
  border-radius: 999px;
  padding: 0.2rem 0.45rem;
  text-align: center;
}
.search-hit-main { display: grid; gap: 0.1rem; min-width: 0; }
.search-hit-main strong { font-size: 0.95rem; }
.search-hit-main small {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-empty,
.search-palette-hint {
  margin: 0;
  padding: 0.75rem 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.search-palette-hint { border-top: 1px solid var(--line); }

.contents-drawer { position: fixed; inset: 0; z-index: 75; }
.contents-drawer[hidden] { display: none !important; }
.contents-backdrop {
  position: absolute; inset: 0;
  background: rgba(28, 25, 21, 0.4);
}
.contents-panel {
  position: absolute; top: 0; right: 0;
  height: 100%;
  width: min(380px, 94vw);
  background: var(--paper);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.contents-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}
.contents-head h2 {
  margin: 0;
  font-family: var(--font);
  font-size: 1.25rem;
}
.contents-body {
  overflow: auto;
  padding: 0.75rem 1rem 2rem;
  flex: 1;
}
.contents-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.contents-tools a {
  text-decoration: none;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  background: var(--bg-2);
}
.contents-group { margin-bottom: 1rem; }
.contents-group h3 {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.contents-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
}
.contents-group a {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem;
  align-items: start;
  text-decoration: none;
  color: inherit;
  padding: 0.45rem 0.5rem;
  border-radius: 10px;
}
.contents-group a:hover { background: var(--accent-soft); }
.contents-group strong { display: block; font-size: 0.92rem; }
.contents-group small { color: var(--muted); font-size: 0.78rem; }
.contents-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  margin-top: 0.35rem;
  border: 2px solid var(--line);
  background: transparent;
}
.contents-dot.done {
  background: var(--accent);
  border-color: var(--accent);
}

.lesson-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.lesson-nav a { max-width: 48%; }
.lesson-nav .dir {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}
.lesson-nav .name { font-weight: 600; }

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; }
  .topbar-actions {
    order: 3;
    width: 100%;
    justify-content: flex-end;
    margin-left: 0;
  }
  .search-btn-label { display: none; }
  .search-btn { min-width: 0; }
  .tool-kbd { display: none; }
  .nav.open { z-index: 50; }
}

/* mobile nav-aids polish */
@media (max-width: 860px) {
  .topbar-actions {
    order: 3;
    width: 100%;
    justify-content: flex-end;
    margin-left: 0;
    padding-top: 0.25rem;
  }
  .search-btn-label { display: none; }
  .tool-kbd { display: none; }
  .search-btn { min-width: 0; }
  .nav.open { z-index: 50; }
  .contents-panel { width: min(100vw, 100%); }
  .search-palette { padding: 12vh 0.5rem 0.5rem; align-items: start; }
}


/* Tutor notes */
.tutor-btn {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  margin: 0;
  vertical-align: middle;
  width: 1.55rem; height: 1.55rem; padding: 0;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-2, #f6f1e8); color: var(--accent);
  font-size: 0.75rem; line-height: 1; cursor: pointer;
}
.tutor-btn:hover, .tutor-btn:focus-visible {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
/* Keep ✦ on the same line as the Estonian text (h3/p are normally block) */
.unit .et,
.entry .term {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.4rem;
}
.unit .et .et-body,
.entry .term .et-body {
  min-width: 0;
  flex: 0 1 auto;
}
.unit .et .et-body > h1,
.unit .et .et-body > h2,
.unit .et .et-body > h3,
.unit .et .et-body > p,
.unit .et .et-body > .instruction {
  display: inline;
  margin: 0;
}
.unit .tutor-btn,
.entry .term .tutor-btn {
  position: relative;
  top: -0.05rem;
  align-self: baseline;
}
.dict-row .tutor-btn { grid-column: 2; margin-top: 0.1rem; }
.dict-row.tutor-row {
  width: 100%; max-width: 42rem; text-align: left; cursor: pointer;
  font: inherit; color: inherit;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto;
}
.dict-row.tutor-row:hover { border-color: var(--accent); }
.tutor-note h3 { margin: 1rem 0 0.35rem; font-size: 1rem; }
.tutor-note ul { margin: 0.25rem 0 0; padding-left: 1.2rem; }
.tutor-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.tutor-table th, .tutor-table td { border-bottom: 1px solid var(--line); padding: 0.35rem 0.4rem; text-align: left; vertical-align: top; }
.tutor-en { font-size: 1.05rem; margin: 0 0 0.5rem; }
.modal-card { max-width: min(720px, 96vw); max-height: 90vh; overflow: auto; }
