:root {
  --red: #C0392B;
  --gold: #D4A017;
  --ink: #1a1a1a;
  --paper: #FAF6F0;
  --paper2: #F2EBE0;
  --border: #C8B89A;
  --success: #2E7D32;
  --error: #C0392B;
  --muted: #7a6a55;
  --accent-gradient: linear-gradient(135deg, #8f2d2d, #c7672d);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 6px 16px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 14px 32px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Be Vietnam Pro', sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  padding: 24px 16px 60px;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(200,184,154,0.2) 28px);
}

.app-shell {
  max-width: 1380px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 28px;
}

.side-menu {
  width: 250px;
  position: sticky;
  top: 20px;
  background: rgba(250, 246, 240, 0.96);
  border: 1px solid var(--border);
  box-shadow: 4px 6px 0 rgba(0,0,0,0.07);
  padding: 18px;
  backdrop-filter: blur(6px);
}

.side-menu-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 14px;
  letter-spacing: 0.12em;
  color: var(--red);
  margin-bottom: 6px;
}

.side-menu-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}

.side-menu-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.side-menu-links a {
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: white;
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.side-menu-links a:hover,
.side-menu-links a.active {
  color: white;
  background: var(--red);
  border-color: var(--red);
  transform: translateX(3px);
}

.page-main {
  flex: 1;
  min-width: 0;
}

.container { max-width: 960px; margin: 0 auto; }

header {
  text-align: center;
  padding: 32px 0 26px;
  margin-bottom: 32px;
  position: relative;
}

header::after {
  content: "";
  display: block;
  width: 64px;
  height: 4px;
  margin: 18px auto 0;
  border-radius: 999px;
  background: var(--accent-gradient);
}

.header-deco {
  font-family: 'Noto Serif SC', serif;
  font-size: 44px;
  color: var(--red);
  opacity: 0.12;
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  letter-spacing: 8px;
  pointer-events: none;
}

header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--ink);
  position: relative;
}

header p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  font-weight: 300;
}

nav.top-nav {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
}

nav.top-nav a {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-decoration: none;
  color: var(--muted);
  border: 1.5px solid var(--border);
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

nav.top-nav a.active,
nav.top-nav a:hover {
  color: white;
  background: var(--red);
  border-color: var(--red);
}

/* ── Compact page hero (title + stats trong 1 khối) ── */
header.page-hero {
  text-align: left;
  padding: 6px 0 20px;
  margin-bottom: 20px;
  border-bottom: 1px dashed var(--border);
}
header.page-hero::after { display: none; }

.page-hero-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

header.page-hero h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--ink);
}

.header-deco-inline {
  font-family: 'Noto Serif SC', serif;
  color: var(--red);
  opacity: 0.55;
  font-size: 16px;
  letter-spacing: 0.1em;
  margin-right: 8px;
}

header.page-hero p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 300;
}

.page-hero-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-badge {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  background: var(--paper2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  white-space: nowrap;
}

.stat-badge strong {
  color: var(--red);
  font-size: 15px;
  font-weight: 800;
  margin-right: 4px;
}

@media (max-width: 980px) {
  .app-shell {
    flex-direction: column;
  }

  .side-menu {
    width: 100%;
    position: static;
    padding: 14px;
  }

  .side-menu-links {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .side-menu-links a:hover,
  .side-menu-links a.active {
    transform: none;
  }
}

/* ── Section card (dùng chung) ── */
.section {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.section-header {
  background: var(--accent-gradient);
  color: white;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-header h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.section-header .pts {
  margin-left: auto;
  font-size: 12px;
  color: var(--gold);
  font-weight: 600;
}

.section-body { padding: 20px; }

.instruction {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}

/* ── Vocab table (trang từ vựng) ── */
.vocab-search {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: 'Be Vietnam Pro', sans-serif;
  margin-bottom: 18px;
  outline: none;
}
.vocab-search:focus { border-color: var(--red); }

.vocab-table {
  width: 100%;
  border-collapse: collapse;
}
.vocab-table th, .vocab-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--paper2);
  text-align: left;
  font-size: 13.5px;
}
.vocab-table tbody tr { transition: background 0.15s; }
.vocab-table tbody tr:hover { background: var(--paper2); }
.vocab-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.vocab-table .hanzi-cell {
  font-family: 'Noto Serif SC', serif;
  font-size: 18px;
  color: var(--red);
}
.vocab-table .py-cell { color: var(--muted); font-style: italic; }
.vocab-table .actions-cell { white-space: nowrap; text-align: right; }
.vocab-table .actions-cell button {
  padding: 5px 10px;
  font-size: 11px;
  letter-spacing: 0.03em;
  margin-left: 6px;
}
.vocab-edit-input {
  width: 100%;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}
.vocab-edit-input.hz {
  font-family: 'Noto Serif SC', serif;
  font-size: 16px;
}
.vocab-edit-input:focus { border-color: var(--red); }
.vocab-count {
  font-size: 11px;
  color: var(--gold);
  font-weight: 700;
}

#vocabContainer {
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 6px;
}

/* ── Tabs (trang luyện tập) ── */
.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.tab-btn {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 9px 16px;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.tab-btn.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.tab-btn:hover:not(.active) { border-color: var(--ink); color: var(--ink); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Word picker (checkbox list) ── */
.picker-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.picker-toolbar select,
.picker-toolbar input[type="text"] {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}
.picker-toolbar .spacer { flex: 1; }
.link-btn {
  font-size: 12px;
  color: var(--red);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  font-weight: 600;
}

.word-picker-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--paper2);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.word-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--paper2);
  font-size: 13px;
}
.word-picker-item:last-child { border-bottom: none; }
.word-picker-item:hover { background: var(--paper2); }
.word-picker-item .hanzi-cell {
  font-family: 'Noto Serif SC', serif;
  color: var(--red);
  font-size: 16px;
  min-width: 70px;
}
.word-picker-item .py-cell { color: var(--muted); font-style: italic; min-width: 90px; }
.word-picker-item .nghia-cell { color: var(--ink); }
.word-picker-item .cat-tag {
  margin-left: auto;
  font-size: 10px;
  color: var(--muted);
  background: var(--paper2);
  padding: 2px 8px;
  border-radius: 10px;
}

.selected-count {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
}
.selected-count strong { color: var(--red); }

/* ── Generated exercises ── */
.pinyin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.pinyin-item { display: flex; flex-direction: column; gap: 4px; }
.pinyin-item .hanzi {
  font-family: 'Noto Serif SC', serif;
  font-size: 22px;
  color: var(--red);
  line-height: 1;
  margin-bottom: 2px;
}
.pinyin-item .py { font-size: 12px; color: var(--muted); font-style: italic; }

.answer-input {
  width: 100%;
  border: none;
  border-bottom: 1.5px solid var(--border);
  background: transparent;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 13px;
  color: var(--ink);
  padding: 4px 2px;
  outline: none;
  transition: border-color 0.2s;
}
.answer-input:focus { border-bottom-color: var(--red); }
.answer-input.correct { border-bottom-color: var(--success); background: rgba(46,125,50,0.05); }
.answer-input.wrong { border-bottom-color: var(--error); background: rgba(192,57,43,0.05); }

.hanzi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.hanzi-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper);
}
.hanzi-item .big-char {
  font-family: 'Noto Serif SC', serif;
  font-size: 30px;
  color: var(--ink);
  line-height: 1;
}
.hanzi-item .listen-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--red);
  font-size: 15px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.hanzi-item .listen-btn:hover { border-color: var(--red); }
.hanzi-item .answer-input { text-align: center; font-size: 12px; width: 90%; }

.translate-list { display: flex; flex-direction: column; gap: 14px; }
.translate-item { display: flex; flex-direction: column; gap: 6px; }
.translate-item .q-num { font-size: 11px; font-weight: 700; color: var(--gold); letter-spacing: 0.08em; }
.translate-item .viet-sentence {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.5;
  padding: 8px 12px;
  background: var(--paper2);
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.translate-item textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: 'Noto Serif SC', serif;
  font-size: 16px;
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
  resize: vertical;
  min-height: 42px;
  transition: border-color 0.2s;
  line-height: 1.6;
}
.translate-item textarea:focus { border-color: var(--red); }
.translate-item textarea.correct { border-color: var(--success); background: rgba(46,125,50,0.04); }
.translate-item textarea.wrong { border-color: var(--error); background: rgba(192,57,43,0.04); }

.reveal-ans {
  display: none;
  font-size: 12px;
  color: var(--success);
  font-weight: 600;
  margin-top: 3px;
}
.reveal-ans.show { display: block; }

/* ── Flashcards ── */
.flashcard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.flashcard {
  perspective: 800px;
  height: 130px;
  cursor: pointer;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
  background: white;
  box-shadow: var(--shadow-sm);
}
.flashcard-front .hanzi {
  font-family: 'Noto Serif SC', serif;
  font-size: 30px;
  color: var(--red);
}
.flashcard-front .py { font-size: 11px; color: var(--muted); font-style: italic; margin-top: 4px; }
.flashcard-back {
  background: var(--ink);
  color: white;
  transform: rotateY(180deg);
  font-size: 13px;
  font-weight: 600;
}

.flashcard-single-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.flashcard-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 320px;
  gap: 12px;
  flex-wrap: wrap;
}
.remembered-count {
  font-size: 12px;
  color: var(--muted);
}
.mark-remembered {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.mark-remembered input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.flashcard-single {
  width: 100%;
  max-width: 320px;
  height: 220px;
}
.flashcard-single .flashcard-front .hanzi { font-size: 52px; word-break: keep-all; }
.flashcard-single .flashcard-front .py { font-size: 15px; margin-top: 10px; }
.flashcard-single .flashcard-back { font-size: 20px; padding: 20px; }

/* ── Thẻ lật (trang riêng): thẻ to, chữ to, co nhẹ theo độ dài từ ── */
.flashcard-single--lg {
  max-width: 440px;
  height: 340px;
}
.flashcard-single--lg .flashcard-front .hanzi,
.flashcard-single--lg .flashcard-back .hanzi {
  white-space: nowrap;
}
.flashcard-single--lg.len-1 .flashcard-front .hanzi { font-size: 96px; }
.flashcard-single--lg.len-2 .flashcard-front .hanzi { font-size: 76px; }
.flashcard-single--lg.len-3 .flashcard-front .hanzi { font-size: 58px; }
.flashcard-single--lg.len-4 .flashcard-front .hanzi { font-size: 46px; }
.flashcard-single--lg .flashcard-front .py {
  font-size: 19px;
  margin-top: 14px;
  color: var(--muted);
}
.flashcard-single--lg .flashcard-back .hanzi { font-size: 36px; }
.flashcard-single--lg .flashcard-back .py { font-size: 17px; }
.flashcard-single--lg .flashcard-back .nghia { font-size: 25px; }

.speak-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--red);
  font-size: 15px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  z-index: 3;
}
.speak-btn:hover { border-color: var(--red); }
.flashcard-back .speak-btn {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.35);
  color: white;
}
.flashcard-nav {
  display: flex;
  gap: 10px;
}

/* ── Manual sentence editor (dịch câu) ── */
.editor-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.editor-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: start;
}
.editor-row input {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}
.editor-row input.hz {
  font-family: 'Noto Serif SC', serif;
  font-size: 15px;
}
.editor-row input:focus { border-color: var(--red); }
.editor-row button.del-row {
  background: transparent;
  border: 1.5px solid var(--error);
  color: var(--error);
  font-size: 12px;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.editor-row button.del-row:hover { background: var(--error); color: white; }

/* ── Buttons ── */
.btn-row { display: flex; gap: 10px; justify-content: center; margin: 28px 0; flex-wrap: wrap; }
button {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 11px 24px;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.btn-check { background: var(--red); color: white; }
.btn-check:hover { background: #a93226; }
.btn-primary { background: var(--ink); color: white; }
.btn-primary:hover { background: #333; }
.btn-reset { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-reset:hover { border-color: var(--ink); color: var(--ink); }
.btn-answer { background: transparent; color: var(--gold); border: 1.5px solid var(--gold); }
.btn-answer:hover { background: var(--gold); color: white; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.score-panel {
  display: none;
  margin-top: 24px;
  padding: 18px 24px;
  border: 2px solid var(--gold);
  border-radius: var(--radius-sm);
  background: white;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.score-panel.show { display: block; }
.score-big { font-family: 'Noto Serif SC', serif; font-size: 48px; color: var(--red); line-height: 1; }
.score-label { font-size: 13px; color: var(--muted); margin-top: 6px; }

.empty-hint {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 30px 10px;
}

@media (max-width: 600px) {
  .pinyin-grid { grid-template-columns: 1fr; }
  .hanzi-grid { grid-template-columns: repeat(3, 1fr); }
  .editor-row { grid-template-columns: 1fr; }
}

/* Buổi học */
.lesson-form { display: flex; flex-direction: column; gap: 10px; max-width: 480px; margin-bottom: 10px; }
.lesson-form input,
.lesson-form select,
.lesson-form textarea {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  background: var(--paper);
  color: var(--ink);
}
.lesson-form textarea { min-height: 60px; resize: vertical; }
.lesson-item { cursor: pointer; }
.lesson-status-upcoming { background: rgba(212,160,23,0.15); color: var(--gold); }
.lesson-status-preview { background: rgba(192,57,43,0.12); color: var(--red); }
.lesson-status-completed { background: rgba(46,125,50,0.12); color: var(--success); }

/* ── Thẻ lật (trang riêng) ── */
.progress-track {
  width: 100%;
  max-width: 320px;
  height: 6px;
  background: var(--paper2);
  border-radius: 999px;
  overflow: hidden;
  margin: 0 auto 24px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--red));
  width: 0%;
  transition: width 0.25s ease;
}

.flashcard-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  position: relative;
}

.nav-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--red);
  font-size: 20px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.nav-circle:hover:not(:disabled) { border-color: var(--red); }

.flashcard-index {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.flashcard-single .flashcard-front .hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 14px;
  opacity: 0.7;
}
.flashcard-single .flashcard-back .hanzi {
  font-family: 'Noto Serif SC', serif;
  font-size: 26px;
  color: var(--gold);
}
.flashcard-single .flashcard-back .py {
  font-size: 13px;
  font-style: italic;
  opacity: 0.8;
  margin: 6px 0 10px;
}
.flashcard-single .flashcard-back .nghia {
  font-size: 19px;
  font-weight: 700;
}

.kbd-hint {
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 16px;
}

.the-lat-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.voice-settings {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 260px;
  flex: 0 0 260px;
  padding: 16px 18px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  animation: voiceSettingsIn 0.18s ease;
}
@keyframes voiceSettingsIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.voice-settings-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink);
  padding-bottom: 12px;
  border-bottom: 1.5px solid var(--border);
}
.voice-settings-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 2px 4px;
  cursor: pointer;
  letter-spacing: 0;
}
.voice-settings-close:hover { color: var(--red); }
.voice-settings-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.voice-settings-row label {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}
.voice-settings-row label span { color: var(--ink); font-weight: 600; }
.voice-settings-row select {
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  background: white;
  color: var(--ink);
}
.voice-settings-row input[type="range"] {
  width: 100%;
  accent-color: var(--red);
}
.btn-reset.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

/* ── Danh sách bộ bài (trang Luyện tập) ── */
.set-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.set-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
}
.set-item:hover { border-color: var(--red); box-shadow: var(--shadow-sm); }
.set-title { font-weight: 700; font-size: 14px; color: var(--ink); }
.set-meta { margin-left: auto; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.set-badge { background: var(--paper2); color: var(--gold); padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.set-delete {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  padding: 4px 6px;
  cursor: pointer;
}
.set-delete:hover { color: var(--error); }

.subview-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.subview-header h2 { font-size: 16px; color: var(--ink); }
.btn-back-list {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
  padding: 7px 14px;
  font-size: 12px;
}
.btn-back-list:hover { border-color: var(--ink); color: var(--ink); }

/* ── Sắp xếp câu & Điền từ ── */
.score-bar {
  text-align: center;
  background: var(--ink);
  color: white;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 13px;
  max-width: 260px;
  margin: 0 auto 20px auto;
}
.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 28px 0 14px 0;
  padding: 9px 16px;
  color: white;
  background: var(--ink);
  border-radius: var(--radius-sm);
}
.section-title.st-order { background: var(--red); }
.section-title.st-fill { background: var(--gold); }

.exercise {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.ex-head { display: flex; align-items: center; margin-bottom: 10px; }
.ex-number {
  display: inline-block;
  width: 26px;
  height: 26px;
  line-height: 26px;
  text-align: center;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-weight: 700;
  margin-right: 10px;
  font-size: 12px;
}
.ex-label { font-size: 12.5px; color: var(--muted); font-style: italic; }

.tiles-pool { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; min-height: 40px; }
.tile {
  font-family: 'Noto Serif SC', serif;
  font-size: 18px;
  padding: 7px 13px;
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.tile:hover { transform: translateY(-2px); border-color: var(--red); }
.tile.used { opacity: 0.25; cursor: default; pointer-events: none; }

.answer-slot {
  min-height: 46px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
}
.answer-slot .tile { background: white; border-color: var(--gold); }
.placeholder-text { color: var(--muted); font-size: 13px; font-style: italic; }

.fill-sentence { font-family: 'Noto Serif SC', serif; font-size: 19px; line-height: 1.9; margin-bottom: 12px; }
.fill-input {
  font-family: 'Noto Serif SC', serif;
  font-size: 17px;
  width: 86px;
  text-align: center;
  border: none;
  border-bottom: 2px solid var(--border);
  background: var(--paper2);
  padding: 3px 6px;
  outline: none;
}
.fill-input:focus { border-bottom-color: var(--red); }

.word-bank { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.bank-chip {
  font-family: 'Noto Serif SC', serif;
  font-size: 15px;
  padding: 5px 12px;
  background: var(--paper2);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.bank-chip:hover { border-color: var(--gold); background: var(--paper); }

.feedback { margin-top: 8px; font-size: 13px; font-weight: 700; min-height: 20px; }
.feedback.ok { color: var(--success); }
.feedback.no { color: var(--error); }
.feedback .detail {
  font-weight: 400;
  font-style: italic;
  color: var(--muted);
  display: block;
  margin-top: 4px;
  font-size: 12.5px;
}

/* ── Form tạo bài mới (trang Luyện tập) ── */
.set-form-title {
  width: 100%;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  margin-bottom: 16px;
}
.set-form-title:focus { border-color: var(--red); }

.editor-row--order,
.editor-row--fill {
  display: grid;
  gap: 8px;
  align-items: start;
  margin-bottom: 10px;
}
.editor-row--order { grid-template-columns: 2fr 1fr 1fr auto; }
.editor-row--fill { grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr auto; }
.editor-row--order input,
.editor-row--fill input {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 12.5px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}
.editor-row--order input.hz,
.editor-row--fill input.hz { font-family: 'Noto Serif SC', serif; font-size: 14px; }
.editor-row--order input:focus,
.editor-row--fill input:focus { border-color: var(--red); }

@media (max-width: 700px) {
  .editor-row--order,
  .editor-row--fill { grid-template-columns: 1fr; }
}

/* ── Nút "Tạo bài mới" dùng chung, cùng hàng với tabs ── */
.tabs-action {
  margin-left: auto;
}

/* ── Chọn loại câu (Sắp xếp / Điền từ) khi soạn thẻ ── */
.kind-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}
.kind-btn {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 8px 16px;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.kind-btn.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.kind-btn:hover:not(.active) { border-color: var(--ink); color: var(--ink); }

/* ── Thẻ soạn từng câu (kiểu lật thẻ: 1 câu tại 1 thời điểm) ── */
.editor-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.editor-card input {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}
.editor-card input.hz {
  font-family: 'Noto Serif SC', serif;
  font-size: 16px;
}
.editor-card input:focus { border-color: var(--red); }

.card-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.card-nav button { flex: 1; }
