:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --text: #1f2328;
  --muted: #5d636b;
  --border: #dedad0;
  --accent: #c8102e;
  --accent-soft: #fbe8eb;
  --gold: #d4a017;
  --der: #1f5fbf;
  --die: #c42b3b;
  --das: #1d8a4a;
  --pl: #7a4bb3;
  --ok: #1d8a4a;
  --bad: #c42b3b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .04);
  --radius: 10px;
  --sidebar: 280px;
  font-size: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171a;
    --surface: #1d2024;
    --surface-2: #262a2f;
    --text: #e6e6e3;
    --muted: #a0a6ad;
    --border: #33383e;
    --accent: #ff5a6e;
    --accent-soft: #3a1f24;
    --der: #6ea8ff;
    --die: #ff7a86;
    --das: #5fd58f;
    --pl: #bb94ff;
    --ok: #5fd58f;
    --bad: #ff7a86;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  --bg: #15171a;
  --surface: #1d2024;
  --surface-2: #262a2f;
  --text: #e6e6e3;
  --muted: #a0a6ad;
  --border: #33383e;
  --accent: #ff5a6e;
  --accent-soft: #3a1f24;
  --der: #6ea8ff;
  --die: #ff7a86;
  --das: #5fd58f;
  --pl: #bb94ff;
  --ok: #5fd58f;
  --bad: #ff7a86;
  --shadow: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
}

a { color: var(--accent); }

/* ---------- Header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.flag {
  display: inline-flex;
  flex-direction: column;
  width: 26px;
  height: 18px;
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
.flag span { flex: 1; }
.flag span:nth-child(1) { background: #000; }
.flag span:nth-child(2) { background: #dd0000; }
.flag span:nth-child(3) { background: #ffce00; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.topbar .spacer { flex: 1; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  height: 36px;
  min-width: 36px;
  padding: 0 10px;
  cursor: pointer;
  font: inherit;
}
.icon-btn:hover { border-color: var(--accent); }

#menuBtn { display: none; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: calc(100vh - 56px);
}

.sidebar {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 16px 12px 40px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.search {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  margin-bottom: 12px;
}
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.nav-group {
  margin: 16px 8px 6px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

.nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--text);
  text-decoration: none;
  font-size: .94rem;
}
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.lvl {
  font-size: .68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  flex-shrink: 0;
}

.content {
  padding: 32px 40px 80px;
  max-width: 980px;
  width: 100%;
}

/* ---------- Topics ---------- */
.topic { display: none; }
.topic.active { display: block; animation: fade .2s ease; }
.no-js .topic { display: block; margin-bottom: 64px; }

@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.topic h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin: 0 0 6px;
}
.topic .subtitle { color: var(--muted); margin: 0 0 24px; font-size: 1.05rem; }
.topic h2 { margin-top: 36px; font-size: 1.3rem; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.topic h3 { margin-top: 24px; font-size: 1.08rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin: 16px 0;
}

.tip, .warn {
  border-left: 4px solid var(--gold);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 12px 16px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}
.warn { border-left-color: var(--accent); }
.tip strong:first-child, .warn strong:first-child { display: block; margin-bottom: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 16px 0; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: .95rem;
}
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td:first-child { font-weight: 600; }
tbody tr:hover td { background: var(--surface-2); }

.m, .der { color: var(--der); font-weight: 600; }
.f, .die { color: var(--die); font-weight: 600; }
.n, .das { color: var(--das); font-weight: 600; }
.p { color: var(--pl); font-weight: 600; }
.hl { color: var(--accent); font-weight: 700; }
.end { color: var(--accent); font-weight: 700; }

/* ---------- Examples ---------- */
.ex { list-style: none; padding: 0; margin: 12px 0; }
.ex li {
  padding: 8px 14px;
  margin: 6px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.ex .de { font-weight: 500; }
.ex .en { display: block; color: var(--muted); font-size: .9rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.grid .card { margin: 0; }
.grid .card h4 { margin: 0 0 6px; }
.grid .card p { margin: 0; color: var(--muted); font-size: .92rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: .9rem;
}

/* ---------- Home ---------- */
.hero {
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 24px;
}
.hero h1 { font-size: 2.3rem; margin: 0 0 8px; }
.hero p { margin: 0; color: var(--muted); font-size: 1.1rem; max-width: 60ch; }

.topic-cards a.card {
  display: block;
  text-decoration: none;
  color: var(--text);
  transition: transform .12s ease, border-color .12s ease;
}
.topic-cards a.card:hover { transform: translateY(-2px); border-color: var(--accent); }

/* ---------- Quiz ---------- */
.quiz {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 32px 0 16px;
  box-shadow: var(--shadow);
}
.quiz h3 { margin: 0 0 10px; }
.quiz ol { padding-left: 22px; margin: 0; }
.quiz li { margin: 10px 0; }
.quiz input {
  width: 8.5em;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--muted);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.quiz input.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.quiz input.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.quiz .sol { display: none; color: var(--bad); font-size: .88rem; margin-left: 6px; }
.quiz .sol.show { display: inline; }
.quiz .hint { color: var(--muted); font-size: .88rem; }
.quiz-actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.btn {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.score { font-weight: 600; }

/* ---------- Pager ---------- */
.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.pager a {
  flex: 1;
  max-width: 48%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.pager a:hover { border-color: var(--accent); }
.pager a small { display: block; color: var(--muted); }
.pager .next { text-align: right; margin-left: auto; }

footer.site-footer {
  margin-top: 40px;
  color: var(--muted);
  font-size: .85rem;
}

kbd {
  font-family: ui-monospace, monospace;
  font-size: .85em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  background: var(--surface-2);
}

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  #menuBtn { display: inline-block; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    left: 0;
    top: 56px;
    width: min(85vw, 320px);
    z-index: 15;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, .15);
  }
  body.nav-open .sidebar { transform: none; }
  .content { padding: 24px 16px 64px; }
  .hero { padding: 22px; }
  .hero h1 { font-size: 1.8rem; }
  .topic h1 { font-size: 1.6rem; }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
}

@media print {
  .topbar, .sidebar, .pager, .quiz-actions { display: none !important; }
  .layout { display: block; }
  .topic { display: block !important; page-break-after: always; }
}

.hint { color: var(--muted); font-size: .88rem; }
.topic-cards .card h4 { display: flex; justify-content: space-between; gap: 8px; }
[id] { scroll-margin-top: 72px; }
.lvl { align-self: flex-start; }

/* ---------- Dictionary ---------- */
.toplink { display: inline-flex; align-items: center; text-decoration: none; font-weight: 600; font-size: .92rem; }
.dict-controls { display: flex; gap: 8px; align-items: flex-start; }
.dict-controls .search { margin: 0; flex: 1; }
.dict-controls .btn { height: 40px; white-space: nowrap; }
.chip.filter { cursor: pointer; font: inherit; font-size: .88rem; color: var(--text); }
.chip.filter:hover { border-color: var(--accent); }
.chip.filter.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.dict-table td { font-weight: 400; }
.dict-table td:first-child { font-weight: 600; white-space: nowrap; }
.dict-table td.forms { color: var(--muted); font-size: .9rem; }
.theme-tag { display: inline-block; margin-left: 8px; font-size: .72rem; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; vertical-align: middle; }
.speak { border: none; background: none; cursor: pointer; font-size: .85rem; padding: 0 4px; margin-left: 4px; opacity: .55; }
.speak:hover { opacity: 1; }
.flashcard { text-align: center; padding: 28px 20px; }
.fc-front { font-size: 2rem; font-weight: 700; }
.fc-back { font-size: 1.1rem; color: var(--muted); margin-top: 8px; }
.flashcard .quiz-actions { justify-content: center; }
@media (max-width: 860px) {
  .toplink { display: none; }
  .dict-table td:first-child { white-space: normal; }
}
[hidden] { display: none !important; }
.forms-inline { display: none; }
@media (max-width: 600px) {
  .dict-table th:nth-child(2), .dict-table td.forms, .theme-tag { display: none; }
  .forms-inline { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; }
  .dict-table td { padding: 8px 10px; }
}

/* ---------- Quiz input sizes ---------- */
.quiz input.short { width: 4em; }
.quiz input.wide { width: min(100%, 26em); display: block; margin-top: 6px; }

/* ---------- Practice trainer ---------- */
.trainer { text-align: center; padding: 28px 20px; }
.tr-prompt { font-size: 1.9rem; font-weight: 700; line-height: 1.25; }
.tr-hint { margin-top: 4px; min-height: 1.4em; }
.tr-answer { margin: 18px 0 8px; }
.tr-input {
  width: min(100%, 22em);
  padding: 10px 14px;
  font: inherit;
  font-size: 1.1rem;
  text-align: center;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--muted);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
}
.tr-input.correct, .tr-sentence input.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.tr-input.wrong, .tr-sentence input.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.tr-sentence { font-size: 1.15rem; line-height: 2.2; }
.tr-sentence input {
  width: 8em;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--muted);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.tr-sentence input.short { width: 4em; }
.tr-sentence input.wide { width: min(100%, 24em); display: block; margin: 6px auto 0; }
.tr-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.gender-btn { min-width: 90px; font-size: 1.1rem; background: var(--surface-2); border: 2px solid currentColor; }
.gender-btn:hover { background: var(--surface); }
.tr-feedback { min-height: 1.6em; font-weight: 600; }
.tr-feedback.good { color: var(--ok); }
.tr-feedback.bad { color: var(--bad); }
.trainer .quiz-actions { justify-content: center; }
.gender-btn.m { color: var(--der); }
.gender-btn.f { color: var(--die); }
.gender-btn.n { color: var(--das); }
.tr-prompt:empty { display: none; }
.tr-instruction { font-size: 1rem; font-weight: 500; color: var(--text); }

/* ---------- Explanations ---------- */
.steps ol { margin: 0; padding-left: 22px; }
.steps li { margin: 8px 0; }
.mistakes { display: grid; gap: 8px; margin: 16px 0; }
.mistake {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.mistake .wrong { color: var(--bad); }
.mistake .right { color: var(--ok); font-weight: 600; }
.mistake .mk { font-weight: 700; margin-right: 2px; }
.mistake .why { grid-column: 1 / -1; color: var(--muted); font-size: .9rem; }
@media (max-width: 600px) {
  .mistake { grid-template-columns: 1fr; }
}

/* ---------- Notes ---------- */
.notes-link { display: inline-flex; align-items: center; gap: 2px; text-decoration: none; font-weight: 600; font-size: .92rem; }
.notes-badge:not(:empty) {
  margin-left: 4px;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: .72rem;
  line-height: 18px;
  text-align: center;
}
.nav a.has-note > span:first-child::after { content: " ✎"; color: var(--accent); font-size: .85em; }

.notes-panel {
  margin: 40px 0 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.notes-panel > summary {
  cursor: pointer;
  padding: 12px 16px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
}
.notes-panel > summary::-webkit-details-marker { display: none; }
.notes-panel > summary::after { content: "▾"; color: var(--muted); margin-left: auto; }
.notes-panel[open] > summary::after { content: "▴"; }
.notes-count { color: var(--muted); font-weight: 400; font-size: .88rem; }
.notes-panel .note-editor { padding: 0 16px 14px; }
.note-text {
  display: block;
  width: 100%;
  min-height: 110px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}
.note-text:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.note-meta { margin-top: 6px; color: var(--muted); font-size: .82rem; }
.warn-text { color: var(--bad); }

.add-note-btn {
  position: absolute;
  z-index: 30;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 40;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: .92rem;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.notes-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.notes-toolbar .search { margin: 0; flex: 1; min-width: 200px; }
.notes-list { display: grid; gap: 12px; margin: 14px 0; }
.note-card { margin: 0; }
.note-card-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.note-card-title { font-weight: 700; text-decoration: none; }
.note-card-title:hover { text-decoration: underline; }
.note-card-text { white-space: pre-wrap; margin: 8px 0; overflow-wrap: anywhere; }
.note-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.btn.small { padding: 4px 12px; font-size: .85rem; }
.btn.danger { color: var(--bad); }
.notes-actions { margin-top: 8px; }
@media (max-width: 860px) {
  .notes-link-label { display: none; }
}
@media print {
  .notes-panel:not([open]), .add-note-btn, .toast, .notes-link { display: none !important; }
}
@media (max-width: 440px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand { font-size: 1rem; gap: 8px; }
  .icon-btn { padding: 0 8px; }
}
@media (max-width: 370px) {
  .brand .flag { display: none; }
}
.brand { min-width: 0; }
.brand-text { overflow: hidden; text-overflow: ellipsis; }
.topbar > .icon-btn, .topbar > .notes-link { flex-shrink: 0; }

/* ---------- Comments ---------- */
.sec-comment-btn {
  margin-left: 8px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .8em;
  vertical-align: middle;
  opacity: .35;
  padding: 2px 4px;
  border-radius: 6px;
}
.topic h2:hover .sec-comment-btn, .sec-comment-btn:focus-visible { opacity: .8; }
.sec-comment-btn.has-comment { opacity: 1; }
.sec-comment-btn:hover { background: var(--surface-2); opacity: 1; }
@media (hover: none) { .sec-comment-btn { opacity: .6; } }
.sec-comment {
  margin: 10px 0 16px;
  padding: 10px 14px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
}
.sec-comment-label { font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.note-text.compact { min-height: 64px; }
.word-comment-btn { opacity: .35; }
.word-comment-btn.has-comment { opacity: 1; }
.word-comment-preview { margin-top: 4px; font-size: .85rem; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-row td { background: var(--surface-2); }
.comment-row td:first-child { font-weight: 400; white-space: normal; }
.comment-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.comment-actions .note-meta { margin: 0; }
.notes-group-title { margin: 18px 0 2px; font-size: 1rem; color: var(--muted); }
.chip.filter.commented-chip:not(.on) { border-style: dashed; }
@media print {
  .sec-comment-btn, .word-comment-btn { display: none !important; }
  .sec-comment[hidden] { display: none !important; }
}

/* ---------- Sentence builder ---------- */
.builder-line {
  min-height: 52px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
  padding: 10px;
  margin: 0 auto 12px;
  max-width: 640px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}
.builder-line.correct { border-color: var(--ok); border-style: solid; }
.builder-line.wrong { border-color: var(--bad); border-style: solid; }
.builder-end { color: var(--muted); font-weight: 700; }
.builder-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 640px; margin: 0 auto; }
.word-chip { cursor: pointer; font: inherit; font-size: 1.02rem; padding: 6px 12px; color: var(--text); }
.word-chip:hover { border-color: var(--accent); }
.word-chip.placed { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- Progress & study ---------- */
.study-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: -8px 0 20px; }
.study-bar-bottom { margin: 36px 0 0; padding: 12px 16px; border: 1px dashed var(--border); border-radius: var(--radius); }
.study-bar-bottom.suggest { border-color: var(--ok); border-style: solid; background: color-mix(in srgb, var(--ok) 8%, transparent); }
.study-bar-bottom.suggest .study-q::after { content: " All exercises perfect — nice!"; color: var(--ok); font-weight: 600; }
.study-q { font-weight: 600; }
.learn-btn { padding: 6px 14px; font-size: .9rem; }
.learn-btn.is-learned { background: var(--ok); border-color: var(--ok); color: #fff; }
.nav a.learned > span:first-child::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.mistake-hint { text-decoration: none; }
.mistake-hint:hover { text-decoration: underline; }

.home-progress { margin: 0 0 8px; }
.home-progress-line { margin-bottom: 8px; }
.home-progress-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.home-progress-actions .btn { text-decoration: none; }

.pg-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.pg-tile { margin: 0; text-decoration: none; color: var(--text); text-align: center; padding: 16px 12px; }
a.pg-tile:hover { border-color: var(--accent); }
.pg-value { font-size: 1.6rem; font-weight: 800; }
.pg-label { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.pg-next { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.pg-bar { flex: 1; height: 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.pg-fill { height: 100%; width: 0; background: var(--ok); border-radius: 999px; transition: width .3s ease; }
.pg-levels { display: grid; gap: 10px; margin: 12px 0; }
.pg-level { display: flex; align-items: center; gap: 12px; }
.pg-level-name { width: 2.4em; font-weight: 700; }
.pg-level-count { width: 4.5em; text-align: right; color: var(--muted); font-size: .9rem; }
.pg-group { margin: 20px 0 6px; font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.pg-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.pg-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.pg-item:last-child { border-bottom: none; }
.pg-item.done .pg-title { color: var(--ok); }
.pg-check input { width: 18px; height: 18px; accent-color: var(--ok); cursor: pointer; }
.pg-title { font-weight: 600; text-decoration: none; color: var(--text); }
.pg-title:hover { text-decoration: underline; }
.pg-scores { margin-left: auto; }

.review-tag { display: inline-block; margin-right: 8px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip.filter.review-chip:not(.on) { border-style: dashed; }

.fc-status { margin-bottom: 10px; }
.fc-tag { font-size: .8rem; font-weight: 600; color: var(--muted); margin-top: 4px; }
.fc-good { background: var(--ok); }
.fc-again { color: var(--bad); }
.fc-help { margin: 14px 0 0; }

/* ---------- Reading texts ---------- */
.reading-card { text-decoration: none; color: var(--text); }
.reading-card:hover { border-color: var(--accent); }
.reading-card.done { border-left: 4px solid var(--ok); }
.reading-card h4 { display: flex; justify-content: space-between; gap: 8px; margin: 0 0 6px; }
.reading-card p { margin: 0 0 6px; color: var(--muted); font-size: .92rem; }
.reader-back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 600; }
.reader-head { display: flex; align-items: center; gap: 10px; }
.reader-title { margin: 0; border: none; padding: 0; font-size: 1.5rem; }
.reader-tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 4px; }
.reader-tools .chip { cursor: pointer; font: inherit; font-size: .9rem; color: var(--text); }
.reader-help { margin: 4px 0 12px; }
.reading-text {
  font-size: 1.12rem;
  line-height: 1.85;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
}
.reading-text p { margin: 0 0 12px; }
.reading-text p:last-child { margin-bottom: 0; }
.reading-text .w { cursor: pointer; border-radius: 3px; }
.reading-text .w:hover { background: var(--surface-2); text-decoration: underline dotted; }
.reading-text .w.active { background: var(--accent-soft); color: var(--accent); }
.reading-text.show-grammar .gr { background: color-mix(in srgb, var(--gold) 22%, transparent); border-bottom: 2px solid var(--gold); border-radius: 3px; }
.reading-translation { margin: 12px 0; padding: 14px 18px; border-left: 4px solid var(--border); color: var(--muted); }
.reading-translation p { margin: 0 0 10px; }
.reader-grammar { margin: 16px 0; font-size: .95rem; }
.quiz input.tf { width: 6.5em; }
.word-pop {
  position: absolute;
  z-index: 35;
  max-width: min(320px, calc(100vw - 16px));
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  font-size: .95rem;
}
.word-pop-head { display: flex; align-items: center; gap: 6px; font-size: 1.05rem; }
.word-pop-en { margin: 4px 0; }
.word-pop-gr, .word-pop-dict { display: block; font-size: .88rem; margin-top: 4px; text-decoration: none; }

/* ---------- Level test ---------- */
.leveltest { padding: 22px; }
.lt-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.lt-sentence { font-size: 1.35rem; font-weight: 600; margin: 22px 0 16px; line-height: 1.5; }
.lt-gap { color: var(--accent); letter-spacing: .1em; }
.lt-options { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.lt-option { min-width: 120px; font-size: 1.02rem; color: var(--text); }
.lt-option:hover { border-color: var(--accent); }
.lt-skip { color: var(--muted); font-weight: 400; }
.lt-result { text-align: center; margin: 6px 0 16px; }
.lt-level { font-size: 2.2rem; font-weight: 800; color: var(--accent); }
.pg-fill.low { background: var(--gold); }

/* ---------- Today's plan ---------- */
.plan { margin: 0 0 12px; border-left: 4px solid var(--accent); }
.plan.complete { border-left-color: var(--ok); }
.plan-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.plan-list { list-style: none; margin: 0; padding: 0; }
.plan-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.plan-check {
  width: 20px; height: 20px; flex-shrink: 0;
  border: 2px solid var(--border); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 800; color: #fff;
}
.plan-item.done .plan-check { background: var(--ok); border-color: var(--ok); }
.plan-item.done .plan-link { color: var(--muted); text-decoration: line-through; }
.plan-link { font-weight: 600; text-decoration: none; }
.plan-link:hover { text-decoration: underline; }
.plan-progress { margin-left: auto; }
.plan-complete { margin: 10px 0 0; font-weight: 600; color: var(--ok); }
.topic .reader-title { margin: 0; border: none; padding: 0; }

/* ---------- Everyday situations ---------- */
.sit-card { text-decoration: none; color: var(--text); }
.sit-card:hover { border-color: var(--accent); }
.sit-card h4 { display: flex; justify-content: space-between; gap: 8px; margin: 4px 0; }
.sit-card p { margin: 0; color: var(--muted); font-style: italic; }
.sit-icon { font-size: 1.8rem; }
.sit-sub { margin: 4px 0 8px; }
.sit-de { font-weight: 600; }
.sit-dialogue-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 24px; }
.sit-dialogue-head h3 { margin: 0 auto 0 0; }
.sit-dialogue-head .chip { cursor: pointer; font: inherit; font-size: .88rem; color: var(--text); }
.sit-dialogue { margin: 12px 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); }
.sit-line { padding: 6px 0; border-bottom: 1px solid var(--border); line-height: 1.55; }
.sit-line:last-child { border-bottom: none; }
.sit-line.playing { background: var(--accent-soft); border-radius: 6px; }
.sit-speaker { font-weight: 700; margin-right: 6px; color: var(--accent); }
.sit-en { display: block; color: var(--muted); font-size: .9rem; }
.sit-en[hidden] { display: none; }
.is-letter .sit-line { border-bottom: none; padding: 4px 0; }

/* ---------- Trainer extras & install ---------- */
.conj-grid { display: grid; gap: 8px; max-width: 420px; margin: 0 auto; }
.conj-row { display: grid; grid-template-columns: 6.5em 1fr; align-items: center; gap: 10px; text-align: left; }
.conj-person { font-weight: 600; color: var(--muted); text-align: right; }
.conj-input { width: 100%; text-align: left; font-size: 1rem; padding: 8px 12px; }
.tr-input.tr-wide { width: min(100%, 32em); margin-top: 12px; }
.install-btn { margin-right: 8px; }

/* ---------- Dictionary levels & examples ---------- */
.level-chips { margin-top: -4px; }
.level-chips .chip { font-size: .8rem; padding: 3px 10px; }
.word-lvl { margin: 0 6px 0 0; vertical-align: 1px; }
.word-example { margin-top: 4px; font-size: .88rem; overflow-wrap: anywhere; }
.word-example span[lang] { font-style: italic; }
.word-example small { display: block; color: var(--muted); }
.word-example .speak { font-size: .8rem; }
.fc-example { margin-top: 10px; font-size: .95rem; font-style: italic; }

/* ---------- Writing practice ---------- */
.write-status { margin-top: 6px; min-height: 1em; }
.write-task p { margin: 4px 0; }
.write-task-de { font-weight: 600; }
.write-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
@media (max-width: 760px) { .write-grid { grid-template-columns: 1fr; } }
.write-checklist, .write-phrases { list-style: none; padding: 0; margin: 0 0 12px; }
.write-checklist li { display: flex; gap: 8px; padding: 4px 0; overflow-wrap: anywhere; }
.write-mark { flex: none; width: 1.2em; text-align: center; color: var(--muted); font-weight: 700; }
.write-checklist li.ok .write-mark { color: var(--ok); }
.write-checklist li.ok > span:last-child > span:first-child, .write-checklist li.ok > span:last-child { color: var(--ok); }
.write-phrases li { padding: 5px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.write-phrases small { display: block; }
.write-text { width: 100%; min-height: 220px; font-size: 1rem; line-height: 1.6; box-sizing: border-box; }
.write-bar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 6px 0; font-size: .9rem; }
.write-count { color: var(--muted); }
.write-count.ok { color: var(--ok); font-weight: 600; }
.write-count.off { color: var(--bad); }
.write-model { margin-top: 16px; }
.write-model-text { white-space: pre-wrap; line-height: 1.7; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; overflow-wrap: anywhere; }
.write-model-en { margin-top: 8px; color: var(--muted); }

/* ---------- Speaking practice ---------- */
.sp-target { font-size: 1.35rem; line-height: 1.6; margin: 4px 0 12px; overflow-wrap: anywhere; }
.sp-word { border-radius: 4px; padding: 0 2px; }
.sp-word.hit { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.sp-word.miss { color: var(--bad); text-decoration: underline wavy; text-underline-offset: 4px; }
.sp-mic.on { animation: sp-pulse 1.2s ease-in-out infinite; }
@keyframes sp-pulse { 50% { opacity: .65; } }
.sp-heard { margin-top: 10px; min-height: 1.2em; }

/* ---------- Word statistics ---------- */
.wstat { display: inline-block; margin-right: 6px; font-size: .72rem; font-family: ui-monospace, monospace; letter-spacing: -1px; padding: 0 5px; border-radius: 6px; border: 1px solid var(--border); vertical-align: 1px; white-space: nowrap; }
.wstat.known { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.wstat.hard { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.wstat.learning { color: var(--muted); }

/* ---------- My Vocabulary ---------- */
button.pg-tile { font: inherit; cursor: pointer; border: 1px solid var(--border); }
button.pg-tile:hover { border-color: var(--accent); }
.vc-chart { display: flex; align-items: stretch; gap: 4px; height: 150px; padding: 8px 0; }
.vc-day { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.vc-num { font-size: .7rem; color: var(--muted); height: 1.1em; }
.vc-bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.vc-bar { width: 70%; max-width: 28px; background: var(--ok); border-radius: 4px 4px 0 0; display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.vc-wrong { background: var(--bad); width: 100%; }
.vc-date { font-size: .7rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.vc-legend { display: flex; align-items: center; gap: 6px; }
.vc-key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.vc-key.right { background: var(--ok); }
.vc-key.wrong { background: var(--bad); margin-left: 10px; }
.vc-boxes { display: grid; gap: 6px; max-width: 560px; }
.vc-box-row { display: grid; grid-template-columns: 9em 1fr 3em; align-items: center; gap: 10px; font-size: .9rem; }
.vc-box-count { text-align: right; font-weight: 600; }
.vc-fill-known { background: var(--ok) !important; }
.vc-fill-learning { background: var(--accent) !important; }
.vc-fill-hard { background: var(--bad) !important; }
#vcSort { flex: none; max-width: 45%; height: 40px; font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--card, transparent); color: var(--text); }
.vc-table td { vertical-align: top; }
.vc-en { display: block; color: var(--muted); }
.vc-lvl { margin: 0 0 0 6px; }
.vc-box { font-family: ui-monospace, monospace; letter-spacing: -1px; white-space: nowrap; color: var(--muted); }
.vc-rw { white-space: nowrap; }
.vc-acc { min-width: 90px; }
.vc-acc-bar { height: 6px; margin: 6px 0 2px; }
.vc-pct { font-size: .85rem; }
.vc-pct.hard { color: var(--bad); font-weight: 600; }
.vc-col-date { white-space: nowrap; font-size: .88rem; color: var(--muted); }
.vc-due { color: var(--accent); font-weight: 600; }
@media (max-width: 640px) {
  .vc-col-date { display: none; }
  .vc-box-row { grid-template-columns: 7.5em 1fr 2.5em; }
}
