/* === Grade 6 Interactive Classroom — modern education theme === */
:root {
  --bg: #f6efde;
  --surface: #fdfaf1;
  --surface-2: #efe6cf;
  --ink: #2a1f1d;
  --ink-soft: #5a4a47;
  --muted: #9a8c87;
  --line: #e6dcc4;
  --brand: #8b1d2c;
  --brand-soft: #f4e3e6;
  --brand-ink: #5e1320;
  --accent: #c47840;
  --green: #2f8f5f;
  --green-soft: #e1f1e6;
  --red: #c8403d;
  --red-soft: #fbe2e1;
  --yellow: #d99a2b;
  --shadow-sm: 0 1px 2px rgba(94, 19, 32, .04), 0 2px 6px rgba(94, 19, 32, .05);
  --shadow-md: 0 6px 18px rgba(94, 19, 32, .10);
  --shadow-lg: 0 14px 40px rgba(94, 19, 32, .16);
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 22px;
  --space: 1rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }

/* Topbar */
#topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #8b1d2c 0%, #b54250 100%);
  color: #fff; font-weight: 700; display: grid; place-items: center;
  font-size: 14px; letter-spacing: .5px;
  box-shadow: var(--shadow-sm);
}
.brand-text strong { display: block; font-size: 15px; }
.brand-text small { color: var(--muted); font-size: 12px; }
#crumbs { flex: 1; color: var(--muted); font-size: 14px; }
#crumbs a { color: var(--ink-soft); }
#crumbs .sep { margin: 0 8px; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.back-btn { padding: 7px 12px; font-size: 13px; flex-shrink: 0; }
.back-btn[hidden] { display: none; }
.voice-picker {
  appearance: none; -webkit-appearance: none;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 28px 9px 12px; font-size: 13px; font-weight: 500;
  font-family: inherit; cursor: pointer; max-width: 200px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M3 5l3 3 3-3' stroke='%235e1320' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 8px center;
}
.voice-picker:hover { border-color: var(--brand); }
.voice-picker:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.stella-mark {
  display: inline-flex; align-items: center;
  margin-left: 18px;
  pointer-events: none;
  user-select: none;
  mix-blend-mode: multiply;
}
.stella-mark .stella-img {
  height: 56px; width: auto; display: inline-block;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(94,19,32,.12));
}
.stella-mark .stella-svg {
  height: 60px; width: auto;
  transform: rotate(-3deg) translateY(-2px);
  display: inline-block;
}
.stella-mark .stella-svg text {
  /* font may not load before SVG measures — let it scale naturally */
  letter-spacing: 0.5px;
}

#footer {
  text-align: center; color: var(--muted); font-size: 12px;
  padding: 24px; border-top: 1px solid var(--line); margin-top: 40px;
}
#footer .dot { margin: 0 8px; }

/* Buttons */
.btn {
  appearance: none; border: 1px solid transparent; border-radius: 10px;
  padding: 9px 16px; font-weight: 600; font-size: 14px;
  cursor: pointer; transition: transform .05s ease, box-shadow .15s ease, background .15s ease;
  background: var(--brand); color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn:hover { box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.success { background: var(--green); }
.btn.warn { background: var(--accent); }
.btn.danger { background: var(--red); }
.btn.lg { padding: 14px 22px; font-size: 16px; border-radius: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Generic card / panel */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 20px;
}

main#app {
  max-width: 1180px; margin: 0 auto;
  padding: 28px 24px;
}

/* === Dashboard === */
.dash-hero { margin-bottom: 28px; }
.dash-hero .hero-card {
  background: linear-gradient(135deg, #6b1521 0%, #8b1d2c 55%, #b54250 100%);
  color: #fff; border-radius: var(--radius-lg);
  padding: 28px 32px; box-shadow: var(--shadow-md);
  position: relative; overflow: hidden;
}
.dash-hero .hero-card h1 { margin: 0 0 8px; font-size: 28px; }
.dash-hero .hero-card p { margin: 0 0 20px; opacity: .92; }
.dash-hero .hero-card .meta { display: flex; gap: 18px; flex-wrap: wrap; opacity: .92; font-size: 14px; }
.dash-hero .hero-card .meta span::before { content: "● "; color: rgba(255,255,255,.6); }
.dash-hero .stat-card { display: grid; grid-template-rows: repeat(3, 1fr); gap: 12px; }
.stat-tile {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-sm);
}
.stat-tile .v { font-size: 24px; font-weight: 700; color: var(--ink); }
.stat-tile .l { color: var(--muted); font-size: 13px; }
.stat-tile .badge { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.stat-tile .badge.warn { background: #fff4e3; color: #b86b00; }
.stat-tile .badge.ok { background: var(--green-soft); color: var(--green); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 14px; }
.section-head h2 { font-size: 20px; margin: 0; }
.section-head .hint { color: var(--muted); font-size: 13px; }

.unit-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
}
.unit-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
  cursor: pointer;
}
.unit-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.unit-card .cover {
  height: 150px; display: grid; place-items: center;
  position: relative; overflow: hidden;
}
.unit-card .cover .glyph {
  font-size: 64px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,.08));
}
.unit-card .cover .pill {
  position: absolute; top: 12px; left: 12px;
  background: rgba(255,255,255,.85); color: var(--brand-ink);
  font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px; letter-spacing: .5px;
  backdrop-filter: blur(4px);
}
.unit-card .cover.u1 { background: linear-gradient(135deg, #b54250 0%, #f4dadd 100%); }
.unit-card .cover.u2 { background: linear-gradient(135deg, #c47840 0%, #f5e3d2 100%); }
.unit-card .cover.u3 { background: linear-gradient(135deg, #6b8a4f 0%, #e8eed8 100%); }
.unit-card .cover.u4 { background: linear-gradient(135deg, #d99a2b 0%, #faedd0 100%); }
.unit-card .cover.u5 { background: linear-gradient(135deg, #a04a3a 0%, #f0d9d0 100%); }
.unit-card .cover.u6 { background: linear-gradient(135deg, #5e1320 0%, #d4a8b0 100%); }
.unit-card .body { padding: 16px 18px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.unit-card h3 { margin: 0; font-size: 16px; }
.unit-card .desc { color: var(--ink-soft); font-size: 13px; min-height: 36px; }
.unit-card .meta-row { display: flex; gap: 12px; color: var(--muted); font-size: 12px; margin-top: auto; }
.unit-card .meta-row .chip {
  background: var(--surface-2); padding: 3px 8px; border-radius: 999px;
}
.unit-card .needs-review {
  background: #fff4e3; color: #b86b00;
  padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
}

/* === Unit Detail === */
.unit-header {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 26px; margin-bottom: 22px;
  display: flex; align-items: center; gap: 22px;
  box-shadow: var(--shadow-sm);
}
.unit-header .num {
  width: 64px; height: 64px; border-radius: 18px;
  background: linear-gradient(135deg, #6b1521, #b54250);
  color: #fff; font-weight: 700; font-size: 24px;
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
.unit-header h1 { margin: 0; font-size: 22px; }
.unit-header p { margin: 4px 0 0; color: var(--ink-soft); }
.unit-header .actions { margin-left: auto; display: flex; gap: 10px; }

.unit-tabs {
  display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
}
.unit-tabs .tab {
  background: var(--surface); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--ink-soft); cursor: pointer;
}
.unit-tabs .tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.unit-tabs .tab .dot { display: inline-block; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; margin-left: 6px; vertical-align: middle; }

.section-block { margin-bottom: 22px; }
.section-block h2 {
  font-size: 18px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px;
}
.section-block h2 .icon {
  width: 26px; height: 26px; border-radius: 8px; background: var(--brand-soft);
  display: grid; place-items: center; color: var(--brand-ink); font-size: 14px;
}

.placeholder {
  background: #fff7ec; border: 1px dashed #f1b500;
  color: #8a6300; padding: 14px 16px; border-radius: var(--radius-sm);
  font-size: 14px;
}
.placeholder strong { color: #6b4d00; }

/* Vocabulary list */
.vocab-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.vocab-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; text-align: center;
  box-shadow: var(--shadow-sm);
}
.vocab-card .img-slot {
  width: 100%; aspect-ratio: 4/3; background: var(--surface-2);
  border-radius: 10px; display: grid; place-items: center; color: var(--muted);
  font-size: 12px; margin-bottom: 10px; overflow: hidden;
}
.vocab-card .img-slot img { width: 100%; height: 100%; object-fit: cover; }
.vocab-card .word { font-weight: 700; font-size: 16px; }
.vocab-card .meaning { color: var(--ink-soft); font-size: 13px; margin-top: 4px; }

/* Sentence + grammar lists */
.bullet-list { list-style: none; margin: 0; padding: 0; }
.bullet-list li {
  background: var(--surface-2); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 8px; font-size: 15px;
}
.bullet-list li::before { content: "→ "; color: var(--brand); font-weight: 700; }

/* Activity launcher cards on Unit page */
.activity-launcher { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.act-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; background: var(--surface); cursor: pointer;
  display: flex; gap: 14px; align-items: center;
  transition: transform .12s ease, box-shadow .12s ease;
}
.act-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.act-card .ic {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-size: 22px; color: #fff;
}
.act-card.t1 .ic { background: linear-gradient(135deg, #8b1d2c, #b54250); }
.act-card.t2 .ic { background: linear-gradient(135deg, #2f8f5f, #6dbf91); }
.act-card.t3 .ic { background: linear-gradient(135deg, #c47840, #e3a86d); }
.act-card.t4 .ic { background: linear-gradient(135deg, #5e1320, #8b1d2c); }
.act-card .meta strong { display: block; font-size: 15px; }
.act-card .meta small { color: var(--muted); font-size: 12px; }
.act-card.disabled { opacity: .55; cursor: not-allowed; }

/* === Teacher Review === */
.editor-grid {
  display: grid; grid-template-columns: 260px 1fr; gap: 24px;
}
.editor-side { position: sticky; top: 80px; align-self: start; }
.editor-side .nav-list {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px;
}
.editor-side .nav-list a {
  display: block; padding: 10px 12px; border-radius: 8px;
  color: var(--ink-soft); font-size: 14px;
}
.editor-side .nav-list a:hover { background: var(--surface-2); text-decoration: none; }
.editor-side .nav-list a.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-family: inherit; font-size: 14px; background: var(--surface);
  color: var(--ink);
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }

.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.row .icon-btn { flex: 0 0 auto; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-soft); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

.mini-list { display: flex; flex-direction: column; gap: 8px; }
.toolbar-right { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.save-banner {
  position: sticky; bottom: 12px;
  background: var(--ink); color: #fff;
  border-radius: 999px; padding: 10px 18px;
  display: flex; align-items: center; gap: 10px;
  width: max-content; margin: 12px auto 0;
  box-shadow: var(--shadow-md); font-size: 13px;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: all .2s ease;
}
.save-banner.show { opacity: 1; transform: translateY(0); }

/* Page-thumb gallery in editor */
.page-thumbs {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px;
}
.page-thumbs .thumb {
  border: 1px solid var(--line); border-radius: 8px; aspect-ratio: 3/4;
  background: var(--surface-2); display: grid; place-items: center;
  color: var(--muted); font-size: 11px; overflow: hidden;
  cursor: pointer; position: relative;
}
.page-thumbs .thumb img { width: 100%; height: 100%; object-fit: cover; }
.page-thumbs .thumb.assigned { outline: 2px solid var(--brand); }
.page-thumbs .thumb .num {
  position: absolute; top: 4px; left: 4px;
  background: rgba(0,0,0,.6); color: #fff; font-size: 10px;
  padding: 2px 6px; border-radius: 6px;
}

/* === Classroom Mode (light, matches dashboard palette) === */
.classroom-shell {
  max-width: 1100px; margin: 0 auto; padding: 8px 24px 24px;
}
.classroom-shell .stage {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 28px;
  box-shadow: var(--shadow-sm);
}
.stage-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 12px; margin-bottom: 18px;
}
.classroom-shell .stage h1 { font-size: 24px; margin: 0 0 4px; color: var(--ink); }
.classroom-shell .stage .sub { color: var(--ink-soft); margin: 0; font-size: 14px; }
.play-area { margin-top: 18px; min-height: 320px; }

.classroom-controls {
  display: flex; justify-content: center; gap: 10px; margin-top: 20px; flex-wrap: wrap;
}

.activity-tabs {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.activity-tabs .at {
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); padding: 7px 14px; border-radius: 999px; cursor: pointer;
  font-size: 13px; font-weight: 600;
}
.activity-tabs .at:hover:not(.disabled):not(.active) { background: var(--surface-2); }
.activity-tabs .at.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.activity-tabs .at.disabled { opacity: .45; cursor: not-allowed; }

.score-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-soft); padding: 6px 14px; border-radius: 999px;
  font-size: 13px; color: var(--brand-ink); font-weight: 600;
}
.score-pill b { color: var(--brand); font-size: 15px; }

/* Drag pieces — common */
.drag-piece {
  background: var(--surface); color: var(--ink); border-radius: 12px;
  padding: 12px 18px; font-size: 18px; font-weight: 600;
  box-shadow: var(--shadow-sm); cursor: grab; user-select: none;
  display: inline-flex; align-items: center; gap: 10px;
  border: 1px solid var(--line);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.drag-piece:hover { border-color: var(--brand); box-shadow: var(--shadow-md); }
.drag-piece:active { cursor: grabbing; transform: scale(1.02); }
.drag-piece.dragging { opacity: .35; }
.drag-piece.correct { border-color: var(--green); background: var(--green-soft); }
.drag-piece.wrong { border-color: var(--red); background: var(--red-soft); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* Word-to-picture */
.match-board {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  max-width: 100%;
}
.match-col { min-width: 0; }
.match-col h3 { color: var(--ink-soft); font-weight: 600; margin: 0 0 12px; font-size: 13px; letter-spacing: .5px; text-transform: uppercase; }
.match-col .pool { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.match-target {
  background: var(--surface-2); border: 2px dashed var(--line);
  border-radius: 14px; padding: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 6px;
  max-width: 200px; width: 100%;
  margin: 0 auto;
}
.match-target.over { border-color: var(--brand); background: rgba(139,29,44,.08); }
.match-target .pic {
  width: 100%; aspect-ratio: 4/3;
  background: linear-gradient(110deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 200% 100%;
  animation: pic-skel 1.6s ease-in-out infinite;
  border-radius: 10px;
  display: grid; place-items: center; overflow: hidden;
  color: var(--muted); font-size: 13px;
}
.match-target .pic img {
  width: 100%; height: 100%; object-fit: contain;
  background: #fff;
  animation: none; /* image present — stop skeleton */
}
.match-target .pic .pic-fallback {
  font-size: 36px; line-height: 1; opacity: .4;
  animation: none;
}
@keyframes pic-skel {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.match-target .label { color: var(--ink-soft); font-size: 12px; text-align: center; }
.match-target.solved { border-style: solid; border-color: var(--green); background: var(--green-soft); }
.match-target.solved .label { color: var(--green); font-weight: 700; font-size: 14px; }

/* Word-to-meaning two-column */
.pair-board { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.pair-col { display: flex; flex-direction: column; gap: 10px; }
.pair-col-head {
  margin: 0 0 4px;
  font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--brand-ink); font-weight: 700; opacity: .75;
}
.pair-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; font-size: 17px; cursor: pointer;
  color: var(--ink); transition: all .15s ease;
}
.pair-card:hover { border-color: var(--brand); background: var(--surface-2); }
.pair-card.selected { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.pair-card.matched-1 { background: var(--green-soft); border-color: var(--green); cursor: default; color: var(--ink); }
.pair-card.matched-2 { background: #fbe9d2; border-color: var(--accent); cursor: default; color: var(--ink); }
.pair-card.matched-3 { background: #f4dadd; border-color: #b54250; cursor: default; color: var(--ink); }
.pair-card.matched-4 { background: #faedd0; border-color: var(--yellow); cursor: default; color: var(--ink); }
.pair-card.matched-5 { background: #ead7c4; border-color: #5e1320; cursor: default; color: var(--ink); }

/* Sentence ordering */
.sentence-source, .sentence-target {
  display: flex; flex-wrap: wrap; gap: 10px; padding: 14px;
  border-radius: 12px; min-height: 72px;
}
.sentence-source { background: var(--surface-2); border: 1px dashed var(--line); }
.sentence-target { background: var(--brand-soft); border: 2px dashed var(--brand); margin-bottom: 14px; }
.sentence-target.correct { border-color: var(--green); background: var(--green-soft); }
.sentence-target.wrong { border-color: var(--red); background: var(--red-soft); }
.sentence-meta { color: var(--ink-soft); font-size: 13px; margin: 12px 0 6px; }

/* Grammar sorting bins */
.bins { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.bin {
  background: var(--surface-2); border: 2px dashed var(--line);
  border-radius: 14px; padding: 14px; min-height: 180px;
}
.bin.over { border-color: var(--brand); background: rgba(139,29,44,.06); }
.bin h4 { margin: 0 0 12px; color: var(--brand-ink); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.bin .items { display: flex; flex-direction: column; gap: 8px; }
.bin .item { background: var(--surface); color: var(--ink); border-radius: 10px; padding: 8px 12px; font-size: 15px; font-weight: 600; border: 1px solid var(--line); }
.bin .item.correct { background: var(--green-soft); border-color: var(--green); }
.bin .item.wrong { background: var(--red-soft); border-color: var(--red); }
.grammar-pool { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }

/* Loading */
.loading { color: var(--muted); padding: 40px; text-align: center; }

/* === Fill in the Blank === */
.fb-sentence {
  font-size: 26px; line-height: 1.6;
  color: var(--ink); font-weight: 500;
  padding: 22px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; margin-bottom: 18px;
  min-height: 70px;
}
.fb-blank {
  display: inline-block;
  min-width: 110px; text-align: center;
  padding: 4px 14px; margin: 0 4px;
  border-bottom: 3px dashed var(--brand);
  color: var(--brand-ink); font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.fb-blank.over { background: var(--brand-soft); border-style: solid; }
.fb-blank.filled { border-style: solid; background: var(--brand-soft); }
.fb-blank.correct { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.fb-blank.wrong { background: var(--red-soft); border-color: var(--red); color: var(--red); animation: shake .3s; }
.fb-pool { display: flex; flex-wrap: wrap; gap: 12px; }
.fb-tile { font-size: 18px; padding: 10px 18px; }

/* === Dialogue Reading (bilingual + clickable words) + Ordering === */
.dlg-list { display: flex; flex-direction: column; gap: 10px; }
.dlg-title {
  margin: 14px 0 4px; font-size: 13px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--brand-ink); font-weight: 700; opacity: .8;
}
.dlg-bilingual {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 18px;
}
.dlg-row-en {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  font-size: 16px; line-height: 1.55; color: var(--ink);
}
.dlg-row-zh {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  font-size: 14px; line-height: 1.55; color: var(--ink-soft);
  margin-top: 6px; padding-top: 6px;
  border-top: 1px dashed var(--line);
}
.dlg-row-missing { color: var(--muted); font-style: italic; }
.dlg-speaker, .dlg-speaker-zh {
  color: var(--brand-ink); font-weight: 700; font-size: 13px;
  white-space: nowrap;
}
.dlg-text, .dlg-text-zh { flex: 1; }

/* Clickable English word (open dictionary) */
.dlg-word {
  cursor: pointer;
  border-bottom: 1px dashed transparent;
  transition: background .12s ease, border-color .12s ease;
  padding: 1px 2px; border-radius: 3px;
}
.dlg-word:hover {
  background: var(--brand-soft);
  border-bottom-color: var(--brand);
  color: var(--brand-ink);
}

/* Dictionary modal */
.dict-modal {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(42, 31, 29, 0.45);
  display: none; align-items: flex-end; justify-content: center;
  padding: 16px;
}
.dict-modal.open { display: flex; }
.dict-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  width: 100%; max-width: 480px;
  max-height: 75vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 18px 20px;
  animation: dict-slide .22s ease-out;
}
@keyframes dict-slide {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.dict-head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.dict-head .dict-word {
  font-size: 24px; font-weight: 700; color: var(--brand-ink);
}
.dict-head .dict-phon {
  color: var(--ink-soft); font-size: 15px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.dict-head .dict-audio {
  border: 1px solid var(--line); background: var(--surface);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; font-size: 14px;
  color: var(--brand-ink);
}
.dict-head .dict-audio:hover { background: var(--brand-soft); }
.dict-head .dict-close {
  margin-left: auto; border: none; background: transparent;
  font-size: 26px; cursor: pointer; color: var(--ink-soft);
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center; line-height: 1;
}
.dict-head .dict-close:hover { background: var(--surface-2); color: var(--ink); }
.dict-zh-line {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
  background: var(--brand-soft);
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 16px;
  color: var(--brand-ink);
}
.dict-zh-line strong { font-weight: 700; }
.dict-zh-line .dict-zh-text { color: var(--ink); font-weight: 600; }
.dict-zh-line .dict-zh-source {
  margin-left: auto;
  font-size: 11px; color: var(--muted); font-weight: 500;
}
.dict-body { display: flex; flex-direction: column; gap: 12px; }
.dict-block {
  background: var(--surface);
  padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line);
}
.dict-syn-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.dict-syn-chip {
  background: var(--brand-soft); color: var(--brand-ink);
  padding: 5px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 500;
}
.dict-pos {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--brand); font-weight: 700; margin-top: 8px;
  padding-bottom: 4px; border-bottom: 1px solid var(--line);
}
.dict-pos-zh {
  text-transform: none; letter-spacing: 0;
  color: var(--brand-ink); font-size: 13px; font-weight: 600;
}
.dict-def-block {
  background: var(--surface);
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line);
}
.dict-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); font-weight: 600;
  margin: 6px 0 4px;
}
.dict-section-label:first-child { margin-top: 0; }
.dict-section-label .zh {
  text-transform: none; letter-spacing: 0;
  color: var(--brand-ink); font-weight: 600;
}
.dict-def { font-size: 15px; line-height: 1.5; color: var(--ink); }
.dict-def-zh {
  font-size: 14px; line-height: 1.5; color: var(--brand-ink);
  margin-top: 4px;
  padding: 6px 10px; background: var(--brand-soft); border-radius: 6px;
}
.dict-ex {
  font-size: 14px; line-height: 1.5; color: var(--ink-soft);
  font-style: italic; padding-left: 12px;
  border-left: 2px solid var(--brand-soft);
  margin-top: 4px;
}
.dict-ex-zh {
  font-size: 13px; line-height: 1.5; color: var(--brand-ink);
  padding-left: 12px; border-left: 2px solid var(--brand);
  margin-top: 4px;
  font-style: normal;
}
.dict-syn {
  font-size: 13px; color: var(--ink-soft);
  background: var(--surface-2); padding: 8px 12px; border-radius: 8px;
  margin-top: 4px;
}
.dict-loading, .dict-fail {
  padding: 24px 0; text-align: center; color: var(--muted);
}

.dlg-order-source, .dlg-order-target {
  display: flex; flex-direction: column; gap: 8px; padding: 12px;
  border-radius: 12px; min-height: 80px; margin-bottom: 12px;
}
.dlg-order-source { background: var(--surface-2); border: 1px dashed var(--line); }
.dlg-order-target { background: var(--brand-soft); border: 2px dashed var(--brand); }
.dlg-order-target.correct { border-color: var(--green); background: var(--green-soft); }
.dlg-order-target.wrong { border-color: var(--red); background: var(--red-soft); }
.dlg-order-source.over, .dlg-order-target.over { border-color: var(--brand); background: rgba(139,29,44,.08); }
.dlg-tile {
  display: flex; gap: 10px; align-items: baseline;
  padding: 10px 14px; font-size: 15px; font-weight: 500;
}
.dlg-tile .dlg-speaker {
  font-size: 13px; min-width: 80px; text-align: right;
}

/* === Bilingual toggle === */
/* .zh — Chinese fragments. Hidden when body has zh-hidden class. */
body.zh-hidden .zh { display: none !important; }
.unit-card h3 .zh,
.dash-hero .hero-card h1 .zh {
  display: block;
  font-weight: 500;
  font-size: .72em;
  margin-top: 4px;
  opacity: .85;
}
.unit-card .desc .zh {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.classroom-shell h1 .zh {
  display: inline;
  font-size: .68em;
  color: var(--brand-ink);
  font-weight: 600;
  margin-left: 6px;
}
.activity-tabs .at .zh { font-weight: 500; opacity: .85; }
#crumbs .zh { font-size: .92em; opacity: .85; }

/* === Reward checkmark (correct-answer feedback) === */
.reward-check {
  position: fixed;
  font-size: 64px;
  font-weight: 800;
  color: var(--green);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  text-shadow: 0 4px 16px rgba(47, 143, 95, 0.4);
  animation: reward-pop 1.1s cubic-bezier(.2,.7,.4,1.2) forwards;
}
@keyframes reward-pop {
  0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  20%  { transform: translate(-50%, -90%) scale(1.3); opacity: 1; }
  60%  { transform: translate(-50%, -130%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -200%) scale(0.9); opacity: 0; }
}

/* === Darker text inside Classroom shell for legibility on cream === */
.classroom-shell .pair-card { color: var(--brand-ink); font-weight: 600; }
.classroom-shell .drag-piece { color: var(--brand-ink); }
.classroom-shell .stage h1 { color: var(--brand-ink); }
.classroom-shell .stage .sub { color: var(--ink); }
.classroom-shell .sentence-meta,
.classroom-shell .match-col h3,
.classroom-shell .bin h4,
.classroom-shell .match-target .label { color: var(--brand-ink); }
.classroom-shell .activity-tabs .at:not(.active):not(.disabled) { color: var(--brand-ink); }
.classroom-shell .bin .item { color: var(--brand-ink); }

/* Responsive trims */
@media (max-width: 980px) {
  .dash-hero { grid-template-columns: 1fr; }
  .unit-grid { grid-template-columns: repeat(2, 1fr); }
  .editor-grid { grid-template-columns: 1fr; }
  .vocab-grid { grid-template-columns: repeat(2, 1fr); }
  .activity-launcher { grid-template-columns: 1fr; }
}
/* match-board (word-to-picture) and pair-board (word-to-meaning) — always two columns on desktop/tablet */
.match-board, .pair-board { grid-template-columns: 1fr 1fr !important; }
/* Mobile: stack word-to-picture vertically — words first, pictures below.
   word-to-meaning stays 2-col since cards are short. */
@media (max-width: 760px) {
  .match-board { grid-template-columns: 1fr !important; }
  /* Dialogue bilingual rows on mobile: speaker as label above text */
  .dlg-bilingual { padding: 12px 14px; }
  .dlg-row-en, .dlg-row-zh { flex-direction: column; gap: 4px; }
  .dlg-speaker, .dlg-speaker-zh {
    font-size: 11px !important;
    letter-spacing: .5px;
    text-transform: uppercase;
    opacity: .8;
  }
  .dlg-text { font-size: 15px; line-height: 1.5; }
  .dlg-text-zh { font-size: 13px; line-height: 1.5; }
  /* Dialogue Ordering tiles */
  .dlg-tile {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .dlg-tile .dlg-speaker {
    text-align: left !important;
    font-size: 11px !important;
  }
  /* Dictionary modal — full-width sheet on mobile */
  .dict-card { max-width: 100%; max-height: 85vh; border-radius: 18px 18px 0 0; }
  .dict-modal { padding: 0; }
}
.pair-col:first-child { text-align: left; }
.pair-col:last-child .pair-card { font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; }
@media (max-width: 600px) {
  .unit-grid { grid-template-columns: 1fr; }
  .page-thumbs { grid-template-columns: repeat(4, 1fr); }
}

/* ===== Mobile / narrow viewport — collapse topbar ===== */
@media (max-width: 760px) {
  #topbar {
    padding: 10px 14px; gap: 10px;
    flex-wrap: nowrap;
  }
  /* Brand: keep logo + short title only */
  .brand { gap: 8px; flex-shrink: 0; }
  .brand-text strong { font-size: 13px; line-height: 1.15; }
  .brand-text small { display: none; }
  .brand-text strong .zh { display: none !important; }
  /* Crumbs: hide on mobile (chapter shown inside main view) */
  #crumbs { display: none; }
  /* Voice picker: hide — reachable on desktop, default voice covers mobile */
  .voice-picker { display: none; }
  /* Actions: shrink */
  .topbar-actions { gap: 6px; margin-left: auto; }
  .topbar-actions .btn { padding: 7px 10px; font-size: 12px; border-radius: 8px; }
  #toggle-zh { padding: 7px 10px; }
  /* Stella mark: smaller */
  .stella-mark { margin-left: 8px; }
  .stella-mark .stella-img { height: 36px; }
  .stella-mark .stella-svg { height: 36px; }
  /* Main content padding */
  main#app { padding: 16px 14px; }
  /* Hero card lighter */
  .dash-hero .hero-card { padding: 22px 20px; border-radius: 18px; }
  .dash-hero .hero-card h1 { font-size: 22px; }
  .dash-hero .hero-card p { font-size: 13px; }
  .dash-hero .hero-card .meta { font-size: 12px; gap: 12px; }
  /* Classroom shell & stage trim */
  .classroom-shell { padding: 6px 14px 16px; }
  .classroom-shell .stage { padding: 18px; border-radius: 16px; }
  .classroom-shell .stage h1 { font-size: 18px; }
  .activity-tabs { gap: 6px; }
  .activity-tabs .at { padding: 6px 11px; font-size: 12px; }
  .score-pill { font-size: 12px; padding: 5px 10px; }
  /* Footer */
  #footer { font-size: 11px; padding: 16px 14px; }
}

@media (max-width: 420px) {
  .brand-text { display: none; } /* logo only */
  .topbar-actions .btn { padding: 7px 10px; font-size: 11px; }
  .stella-mark .stella-img { height: 30px; }
  .stella-mark .stella-svg { height: 30px; }
}
