:root {
  --bg: #f6f8f5;
  --panel: #ffffff;
  --ink: #1f2d24;
  --muted: #6f7b72;
  --line: #e3eadf;
  --green: #20c768;
  --green-dark: #16a653;
  --green-soft: #e7f8ee;
  --lime: #a7e55c;
  --orange: #ffb545;
  --red: #ef6b6b;
  --blue: #4a90e2;
  --purple: #8b66d9;
  --shadow: 0 16px 42px rgba(26, 64, 38, .10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(231, 248, 238, .95), rgba(246, 248, 245, .65) 360px),
    var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, var(--green), var(--lime));
  box-shadow: 0 10px 24px rgba(32, 199, 104, .26);
}

h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
  letter-spacing: 0;
}

.subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.segmented {
  display: flex;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .82);
  box-shadow: var(--shadow);
}

.segmented button {
  min-width: 98px;
  padding: 10px 16px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
  transition: .18s ease;
}

.segmented button.active {
  color: #fff;
  background: var(--green);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.account-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, .9);
  font-size: 13px;
  font-weight: 800;
}

.account-role {
  color: var(--green-dark);
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, .9);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.connection-pill[data-kind="ok"] {
  color: var(--green-dark);
  border-color: #9dde7c;
  background: var(--green-soft);
}

.connection-pill[data-kind="loading"],
.connection-pill[data-kind="warning"] {
  color: #8a5a00;
  border-color: #f1cb77;
  background: #fff8df;
}

.connection-pill[data-kind="offline"],
.connection-pill[data-kind="error"] {
  color: #a3244c;
  border-color: #f2afc4;
  background: #fff0f5;
}

.dictionary-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, .86);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.dictionary-pill.full {
  color: var(--green-dark);
  border-color: #9dde7c;
  background: var(--green-soft);
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  gap: 16px;
}

.teacher-grid {
  grid-template-columns: minmax(290px, .9fr) minmax(420px, 1.25fr);
  align-items: start;
}

.student-grid {
  grid-template-columns: minmax(300px, .82fr) minmax(420px, 1.18fr);
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-size: 17px;
}

.panel-body {
  padding: 18px;
}

.course-card {
  display: grid;
  gap: 14px;
}

.book-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.book-cover {
  display: grid;
  place-items: center;
  width: 58px;
  height: 76px;
  border-radius: 6px;
  color: #29442d;
  font-weight: 900;
  background: linear-gradient(160deg, #f6dc58, #70c581 62%, #2f8f7d);
  background-position: center;
  background-size: cover;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5);
  overflow: hidden;
}

.select-row,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.setting-stack {
  display: grid;
  gap: 8px;
}

.switch-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbf8;
}

.switch-copy {
  min-width: 0;
}

.switch-copy strong {
  display: block;
  font-size: 14px;
}

.switch-copy span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.switch-control {
  position: relative;
  width: 48px;
  height: 28px;
  flex: 0 0 auto;
}

.switch-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cfd8d1;
  cursor: pointer;
  transition: background .18s ease, box-shadow .18s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(31, 45, 36, .2);
  transition: transform .18s ease;
}

.switch-control input:checked + .switch-track {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(32, 199, 104, .13);
}

.switch-control input:checked + .switch-track::after {
  transform: translateX(20px);
}

.switch-control input:focus-visible + .switch-track {
  outline: 2px solid rgba(32, 199, 104, .48);
  outline-offset: 2px;
}

.field-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: 0;
}

select,
input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 160px;
  resize: vertical;
  padding: 12px;
  line-height: 1.65;
}

.import-review {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #ffc77f;
  border-radius: 10px;
  background: #fff8ec;
}

.import-review[hidden] {
  display: none;
}

.import-review-title {
  margin: 0 0 6px;
  color: #8a4f05;
  font-size: 14px;
  font-weight: 900;
}

.import-review-note {
  margin: 0 0 10px;
  color: #765d3d;
  font-size: 13px;
  line-height: 1.55;
}

.import-review-list {
  display: grid;
  gap: 8px;
}

.import-review-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .82);
}

.import-review-word {
  min-width: 0;
  color: #7b4500;
  font-size: 13px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.import-review-actions {
  display: flex;
  gap: 7px;
  flex: 0 0 auto;
}

.import-review-action {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid #efb867;
  border-radius: 999px;
  color: #8a4f05;
  background: #fff;
  font-size: 12px;
  font-weight: 900;
}

.word-edit-btn {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #9dde7c;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 900;
}

.word-data-warning {
  margin-top: 7px;
  color: #a35b00;
  font-size: 12px;
  font-weight: 850;
}

.word-edit-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 14px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 28px 80px rgba(27, 54, 36, .24);
}

.word-edit-dialog::backdrop {
  background: rgba(20, 39, 27, .42);
  backdrop-filter: blur(3px);
}

.word-edit-form {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.word-edit-form h2 {
  margin: 8px 0 4px;
}

.word-edit-form textarea {
  min-height: 96px;
}

.word-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 800;
  white-space: nowrap;
  transition: transform .14s ease, background .14s ease, box-shadow .14s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  color: #fff;
  background: var(--green);
  box-shadow: 0 10px 22px rgba(32, 199, 104, .24);
}

.btn-primary:hover {
  background: var(--green-dark);
}

.btn-soft {
  color: var(--green-dark);
  background: var(--green-soft);
}

.btn-outline {
  color: var(--green-dark);
  border: 1px solid #9dde7c;
  background: #fff;
}

.btn-muted {
  color: var(--muted);
  background: #edf1ec;
}

.btn-compact {
  min-height: 36px;
  padding: 0 13px;
  font-size: 13px;
}

.btn-danger-soft {
  color: #c43f5f;
  background: #fff0f3;
}

.btn-danger-soft:hover {
  background: #ffe3ea;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  min-height: 78px;
  padding: 13px;
  border-radius: 8px;
  background: #f1fae9;
}

.stat strong {
  display: block;
  color: var(--green-dark);
  font-size: 24px;
  line-height: 1.1;
}

.stat span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

.word-list {
  display: grid;
  gap: 10px;
  max-height: 610px;
  overflow: auto;
  padding-right: 4px;
}

.word-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.student-word-main {
  min-width: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.meaning-reveal {
  padding: 3px 8px;
  border: 1px dashed #9dde7c;
  border-radius: 7px;
  color: var(--green-dark);
  background: var(--green-soft);
  text-align: left;
  transition: background .16s ease, border-color .16s ease;
}

.meaning-reveal:hover,
.meaning-reveal:focus-visible {
  border-color: var(--green);
  outline: none;
}

.meaning-reveal.is-revealed {
  border-color: transparent;
  color: var(--muted);
  background: transparent;
}

.follow-read-btn {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 900;
}

.follow-read-btn.is-playing {
  color: #fff;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(32, 199, 104, .14);
}

.word-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #d73b74;
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.icon-btn:hover {
  border-color: #f0a4bd;
  background: #fff4f7;
}

.word-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 7px;
  font-weight: 900;
  font-size: 18px;
}

.phonetic {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.meaning {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 800;
}

.dot-progress {
  display: flex;
  gap: 7px;
  margin: 14px 0 24px;
  overflow: hidden;
}

.dot {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #dfe7dd;
}

.dot.done {
  background: var(--green);
}

.dot.current {
  outline: 5px solid #caeed9;
  background: var(--green);
}

.study-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-weight: 700;
}

.study-card {
  min-height: 575px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.word-stage {
  display: none;
  min-height: 330px;
  padding: 12px 0;
  text-align: center;
}

.word-stage.active {
  display: block;
}

.alignment-debug {
  display: none;
  max-width: 620px;
  margin: 8px auto 0;
  padding: 10px 12px;
  border: 1px solid #ffd7a5;
  border-radius: 8px;
  color: #805013;
  background: #fff8ed;
  text-align: left;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.5;
}

.alignment-debug.active {
  display: block;
}

.alignment-debug .debug-tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  margin-right: 8px;
  padding: 0 8px;
  border-radius: 999px;
  color: #fff;
  background: #d78318;
  font-size: 11px;
  font-weight: 900;
  vertical-align: middle;
}

.alignment-debug .debug-line {
  margin-top: 5px;
  color: #6f5a3d;
  word-break: break-word;
}

.spell-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 40px auto 18px;
  font-family: Georgia, serif;
  font-size: clamp(32px, 7vw, 58px);
  font-weight: 900;
}

.word-syllable {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  min-width: 0;
  padding: 9px 14px 10px;
  border: 1px solid #e2ebe5;
  border-radius: 12px;
  color: var(--ink);
  background: linear-gradient(180deg, #fbfdfb, #f4f8f5);
  box-shadow: 0 3px 10px rgba(31, 68, 43, .06);
  font: inherit;
  line-height: 1;
  letter-spacing: -.035em;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.word-syllable:hover,
.word-syllable:focus-visible {
  transform: translateY(-2px);
  border-color: #a9dfb9;
  background: #f6fff8;
  box-shadow: 0 9px 22px rgba(32, 199, 104, .13);
  outline: 0;
}

.word-syllable.active-sound,
.word-syllable.is-playing {
  transform: translateY(-3px);
  border-color: var(--green);
  background: linear-gradient(180deg, #f2fff7, #e5f9ed);
  box-shadow:
    0 10px 26px rgba(32, 199, 104, .22),
    inset 0 0 0 2px rgba(32, 199, 104, .18);
}

.word-syllable.is-playing {
  animation: syllable-pulse 1.05s ease-in-out infinite;
}

.playing-bars {
  position: absolute;
  left: 50%;
  bottom: -10px;
  display: none;
  align-items: end;
  justify-content: center;
  gap: 2px;
  width: 20px;
  height: 9px;
  transform: translateX(-50%);
}

.word-syllable.is-playing .playing-bars {
  display: flex;
}

.playing-bars i {
  width: 3px;
  height: 4px;
  border-radius: 99px;
  background: var(--green);
  animation: sound-bar .7s ease-in-out infinite alternate;
}

.playing-bars i:nth-child(2) {
  height: 8px;
  animation-delay: -.24s;
}

.playing-bars i:nth-child(3) {
  height: 6px;
  animation-delay: -.43s;
}

@keyframes syllable-pulse {
  0%, 100% {
    box-shadow: 0 8px 22px rgba(32, 199, 104, .18), inset 0 0 0 2px rgba(32, 199, 104, .16);
  }
  50% {
    box-shadow: 0 12px 30px rgba(32, 199, 104, .3), inset 0 0 0 2px rgba(32, 199, 104, .26);
  }
}

@keyframes sound-bar {
  from { transform: scaleY(.55); }
  to { transform: scaleY(1.2); }
}

.word-chunk {
  color: #26342c;
}

.word-chunk.vowel {
  color: var(--green);
}

.word-chunk.silent {
  color: #9aa59e;
}

.word-chunk.unassigned {
  color: #b36a1e;
}

.phonetic-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  margin: 0 auto;
}

.phonetic-row .phonetic {
  font-size: 17px;
  line-height: 1.35;
}

.pronounce-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  cursor: pointer;
  transition: transform .14s ease, background .14s ease;
}

.pronounce-btn:hover {
  transform: scale(1.06);
  background: #d5f3e1;
}

.pronounce-btn.is-playing {
  color: #fff;
  background: var(--green);
  animation: speaker-pulse .9s ease-in-out infinite alternate;
}

@keyframes speaker-pulse {
  from { box-shadow: 0 0 0 0 rgba(32, 199, 104, .3); }
  to { box-shadow: 0 0 0 7px rgba(32, 199, 104, 0); }
}

.pronounce-btn svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.big-word {
  margin: 36px 0 8px;
  font-size: clamp(46px, 8vw, 76px);
  font-weight: 900;
  line-height: 1;
}

.definition {
  color: var(--ink);
  font-weight: 800;
  line-height: 1.7;
}

.phonics-definition {
  min-height: 28px;
  margin-top: 9px;
  font-size: 16px;
}

.phonics-definition.meaning-reveal {
  display: table;
  margin-right: auto;
  margin-left: auto;
  padding: 7px 14px;
  color: var(--green-dark);
  background: var(--green-soft);
}

.phonics-definition.meaning-reveal.is-revealed {
  color: var(--ink);
  background: transparent;
}

.phonics-definition:empty {
  display: none;
}

.sound-chips {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 30px;
}

.mapping-syllable {
  display: flex;
  align-items: stretch;
  gap: 5px;
  padding: 4px;
  border-radius: 18px;
  transition: background .18s ease, box-shadow .18s ease;
}

.mapping-syllable.is-playing,
.mapping-syllable.active-sound {
  background: rgba(231, 248, 238, .68);
  box-shadow: inset 0 0 0 1px rgba(32, 199, 104, .12);
}

.sound-chip {
  min-width: 44px;
  padding: 8px 8px 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #edf6fb;
  color: #226c91;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  transition: transform .16s ease, color .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.sound-chip span {
  display: block;
  margin-top: 2px;
  color: #d73b74;
  font-size: 12px;
  font-weight: 800;
}

.sound-chip:focus-visible {
  outline: 2px solid rgba(32, 199, 104, .48);
  outline-offset: 2px;
}

.sound-chip.silent {
  background: #eef3ef;
  color: #8b9992;
  cursor: default;
}

.sound-chip.silent span {
  color: #6f7b75;
}

.sound-chip.unassigned {
  background: #fff2dd;
  color: #9a5a16;
  box-shadow: inset 0 0 0 2px rgba(244, 156, 48, .22);
}

.sound-chip.unassigned span {
  color: #d17012;
}

.sound-chip.is-playing {
  z-index: 1;
  transform: translateY(-4px) scale(1.08);
  border-color: var(--green);
  color: var(--green-dark);
  background: #f2fff7;
  box-shadow:
    0 8px 20px rgba(32, 199, 104, .24),
    0 0 0 3px rgba(32, 199, 104, .12);
  animation: phoneme-pulse .72s ease-in-out infinite alternate;
}

.sound-chip.is-playing span {
  color: #d73b74;
}

@keyframes phoneme-pulse {
  from { transform: translateY(-3px) scale(1.05); }
  to { transform: translateY(-5px) scale(1.1); }
}

.video-job-status {
  min-height: 22px;
  margin-top: 8px;
  color: #526158;
  font-size: 13px;
  line-height: 1.5;
}

.video-job-status a {
  color: var(--green-dark);
  font-weight: 900;
}

body.video-rendering {
  overflow: hidden;
  min-height: 100vh;
  background: #fff;
}

body.video-rendering .app-shell {
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 0;
}

body.video-rendering .topbar,
body.video-rendering #teacherView {
  display: none !important;
}

body.video-rendering #studentView {
  display: block !important;
  width: 100%;
  height: 100vh;
}

body.video-rendering #studentView .student-grid {
  display: block;
  width: 100%;
  height: 100%;
}

body.video-rendering #studentView .student-grid > aside,
body.video-rendering .study-card > div > .panel-header,
body.video-rendering .study-header,
body.video-rendering .dot-progress,
body.video-rendering .alignment-debug,
body.video-rendering .stage-actions {
  display: none !important;
}

body.video-rendering .study-card {
  display: block;
  width: 100%;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

body.video-rendering .study-card > div,
body.video-rendering .study-card > div > .panel-body {
  width: 100%;
  height: 100vh;
  padding: 0;
}

body.video-rendering .word-stage.active {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: clamp(26px, 4vh, 48px) clamp(28px, 7vw, 110px) 36px;
}

.video-lesson-header {
  display: none;
}

body.video-rendering .video-lesson-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100%, 1080px);
  margin-bottom: clamp(28px, 4.5vh, 52px);
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

body.video-rendering .video-lesson-title {
  overflow: hidden;
  font-size: clamp(20px, 2.3vw, 30px);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.video-rendering .video-lesson-progress {
  flex: 0 0 auto;
  margin-left: 20px;
  padding: 7px 13px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: clamp(14px, 1.5vw, 18px);
  font-weight: 900;
}

body.video-rendering .spell-row {
  width: min(100%, 1120px);
  flex-wrap: nowrap;
  gap: clamp(5px, 1vw, 12px);
  margin: 0 auto clamp(34px, 6vh, 62px);
  font-size: clamp(64px, 10vw, 112px);
}

body.video-rendering .word-syllable {
  flex: 0 1 auto;
  white-space: nowrap;
  border-radius: 22px;
  padding: 18px 28px 20px;
}

body.video-rendering .spell-row[data-video-fit="compact"] {
  font-size: clamp(48px, 7vw, 78px);
}

body.video-rendering .spell-row[data-video-fit="compact"] .word-syllable {
  padding: 14px 20px 16px;
}

body.video-rendering .spell-row[data-video-fit="tight"] {
  gap: 4px;
  font-size: clamp(36px, 5.4vw, 60px);
}

body.video-rendering .spell-row[data-video-fit="tight"] .word-syllable {
  padding: 10px 12px 12px;
  border-radius: 14px;
}

body.video-rendering .phonetic-row .phonetic {
  font-size: clamp(25px, 3vw, 36px);
}

body.video-rendering .pronounce-btn {
  width: clamp(46px, 5vw, 60px);
  height: clamp(46px, 5vw, 60px);
}

body.video-rendering .pronounce-btn svg {
  width: clamp(24px, 3vw, 32px);
  height: clamp(24px, 3vw, 32px);
}

body.video-rendering .phonics-definition {
  margin-top: clamp(24px, 4vh, 42px);
  font-size: clamp(24px, 3vw, 34px);
}

body.video-rendering .sound-chips {
  width: min(100%, 1120px);
  flex-wrap: nowrap;
  margin-top: clamp(70px, 12vh, 150px);
  gap: clamp(14px, 2vw, 28px);
}

body.video-rendering .mapping-syllable {
  min-width: 0;
  flex: 0 1 auto;
  gap: clamp(3px, .7vw, 8px);
  padding: 2px;
}

body.video-rendering .sound-chip {
  min-width: clamp(64px, 7vw, 94px);
  padding: 18px 16px 15px;
  font-size: clamp(25px, 3vw, 36px);
}

body.video-rendering .sound-chip span {
  margin-top: 5px;
  font-size: clamp(19px, 2.2vw, 27px);
}

body.video-rendering .sound-chips[data-video-fit="compact"] {
  gap: clamp(4px, .8vw, 10px);
}

body.video-rendering .sound-chips[data-video-fit="compact"] .sound-chip {
  min-width: clamp(50px, 6vw, 72px);
  padding: 13px 8px 11px;
  font-size: clamp(20px, 2.4vw, 28px);
}

body.video-rendering .sound-chips[data-video-fit="compact"] .sound-chip span {
  font-size: clamp(15px, 1.8vw, 21px);
}

body.video-rendering .sound-chips[data-video-fit="tight"] {
  gap: 2px;
}

body.video-rendering .sound-chips[data-video-fit="tight"] .mapping-syllable {
  gap: 2px;
  padding: 1px;
}

body.video-rendering .sound-chips[data-video-fit="tight"] .sound-chip {
  min-width: 0;
  padding: 10px 6px 9px;
  font-size: clamp(16px, 1.9vw, 22px);
}

body.video-rendering .sound-chips[data-video-fit="tight"] .sound-chip span {
  font-size: clamp(12px, 1.45vw, 17px);
}

body.video-rendering[data-video-orientation="portrait"] .word-stage.active {
  padding-top: clamp(42px, 5vh, 72px);
}

body.video-rendering[data-video-orientation="portrait"] .video-lesson-header {
  align-items: flex-start;
  margin-bottom: clamp(70px, 8vh, 110px);
}

body.video-rendering[data-video-orientation="portrait"] .video-lesson-title {
  max-width: 540px;
  white-space: normal;
}

body.video-rendering[data-video-orientation="portrait"] .spell-row {
  margin-bottom: clamp(54px, 7vh, 88px);
  font-size: clamp(72px, 15vw, 108px);
}

body.video-rendering[data-video-orientation="portrait"] .spell-row[data-video-fit="compact"] {
  font-size: clamp(44px, 8.2vw, 59px);
}

body.video-rendering[data-video-orientation="portrait"] .spell-row[data-video-fit="compact"] .word-syllable {
  padding: 12px 14px 14px;
  border-radius: 16px;
}

body.video-rendering[data-video-orientation="portrait"] .spell-row[data-video-fit="tight"] {
  font-size: clamp(31px, 6vw, 43px);
}

body.video-rendering[data-video-orientation="portrait"] .spell-row[data-video-fit="tight"] .word-syllable {
  padding: 9px 8px 11px;
  border-radius: 12px;
}

body.video-rendering[data-video-orientation="portrait"] .sound-chips {
  margin-top: clamp(100px, 13vh, 170px);
}

body.video-rendering[data-video-orientation="portrait"] .sound-chips[data-video-fit="compact"] .sound-chip {
  min-width: 0;
  padding: 11px 7px 10px;
  font-size: clamp(18px, 3.1vw, 23px);
}

body.video-rendering[data-video-orientation="portrait"] .sound-chips[data-video-fit="compact"] .sound-chip span {
  font-size: clamp(13px, 2.3vw, 17px);
}

body.video-rendering button,
body.video-rendering input,
body.video-rendering select,
body.video-rendering label {
  pointer-events: none;
}

.sentence {
  margin: 46px auto 24px;
  max-width: 640px;
  font-size: clamp(20px, 3vw, 27px);
  line-height: 1.8;
  text-align: left;
}

.blank {
  display: inline-block;
  min-width: 126px;
  padding: 0 8px;
  border-bottom: 2px solid #b7d9c3;
  color: var(--green-dark);
  text-align: center;
  font-weight: 900;
}

.answer-box {
  display: grid;
  gap: 12px;
  max-width: 420px;
  margin: 0 auto;
}

.feedback {
  min-height: 26px;
  font-weight: 900;
}

.feedback.ok {
  color: var(--green-dark);
}

.feedback.bad {
  color: var(--red);
}

.stage-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.review-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 10px;
}

.review-cell {
  min-height: 86px;
  padding: 12px 8px;
  border-radius: 8px;
  color: #fff;
  text-align: center;
  font-weight: 900;
  background: var(--green);
}

.review-cell strong {
  display: block;
  font-size: 24px;
}

.review-cell span {
  display: block;
  margin-top: 6px;
  font-size: 12px;
}

.review-cell.red {
  background: #f03b73;
}

.review-cell.orange {
  background: var(--orange);
}

.review-cell.lime {
  background: #85e42c;
}

.toast {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  width: min(430px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 14px 16px;
  border-radius: 8px;
  color: #fff;
  background: rgba(31, 45, 36, .94);
  box-shadow: var(--shadow);
  font-weight: 800;
  text-align: center;
  line-height: 1.45;
  overflow: hidden;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.toast.show {
  display: -webkit-box;
}

select.is-loading {
  cursor: wait;
  opacity: .7;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(133, 228, 44, .16), transparent 35%),
    linear-gradient(180deg, #e7f8ee, #f6f8f5);
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  width: min(430px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(26, 64, 38, .16);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.auth-card h2 {
  margin: 0;
  font-size: 26px;
}

.auth-card .setting-stack {
  margin-top: 16px;
}

.auth-error {
  min-height: 22px;
  margin: 12px 0 0;
  color: #c73852;
  font-size: 13px;
  font-weight: 800;
}

.admin-grid {
  grid-template-columns: minmax(290px, .78fr) minmax(430px, 1.22fr);
  align-items: start;
}

.soundwhy-free-settings-panel {
  grid-column: 1 / -1;
}

.free-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.soundwhy-settings-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}

.teacher-account-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.teacher-account {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.teacher-account.active {
  border-color: var(--green);
  background: var(--green-soft);
}

.teacher-account strong,
.teacher-account span {
  display: block;
}

.teacher-account span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.permission-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.catalog-editor-grid {
  grid-template-columns: minmax(260px, .72fr) minmax(560px, 1.28fr);
  align-items: start;
}

.catalog-book-list {
  display: grid;
  gap: 10px;
  max-height: 680px;
  overflow: auto;
  margin-top: 14px;
}

.catalog-book-card {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.catalog-book-card.active {
  border-color: var(--green);
  background: var(--green-soft);
}

.catalog-book-thumb,
.catalog-cover-preview {
  overflow: hidden;
  color: var(--green-dark);
  background: linear-gradient(145deg, #e4f7ec, #f6fbf4);
  background-position: center;
  background-size: cover;
  font-weight: 900;
}

.catalog-book-thumb {
  display: grid;
  place-items: center;
  width: 48px;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  font-size: 12px;
}

.catalog-book-card strong,
.catalog-book-card span {
  display: block;
}

.catalog-book-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.catalog-meta-grid {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 22px;
}

.catalog-cover-preview {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 20px;
}

.catalog-editor-section {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.catalog-word-list {
  max-height: 360px;
  margin-top: 14px;
}

.permission-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfb;
}

.permission-row strong,
.permission-row span {
  display: block;
}

.permission-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

[data-auth-hidden="true"],
[data-feature-hidden="true"],
[data-scope-hidden="true"] {
  display: none !important;
}

.success-screen {
  display: none;
  place-items: center;
  min-height: 520px;
  text-align: center;
}

.success-screen.active {
  display: grid;
}

.success-check {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  margin: 0 auto 22px;
  border-radius: 999px;
  color: #fff;
  background: var(--green);
  font-size: 48px;
  font-weight: 900;
}

.mobile-frame {
  width: min(430px, 100%);
  margin: 0 auto;
  border-radius: 8px;
}

.mini-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.unit-word-limit-notice {
  padding: 11px 13px;
  border: 1px solid #9dde7c;
  border-radius: 10px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.55;
}

.unit-word-limit-notice[data-kind="full"] {
  border-color: #efb867;
  color: #8a4f05;
  background: #fff7e9;
}

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
  }

  .header-actions {
    justify-content: stretch;
  }

  .header-actions .segmented,
  .header-actions .btn,
  .connection-pill,
  .dictionary-pill {
    flex: 1 1 auto;
  }

  .teacher-grid,
  .student-grid,
  .admin-grid,
  .catalog-editor-grid {
    grid-template-columns: 1fr;
  }

  .free-settings-grid {
    grid-template-columns: 1fr;
  }

  .catalog-meta-grid {
    grid-template-columns: 150px 1fr;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100vw - 18px, 1180px);
    padding-top: 14px;
  }

  .panel-body {
    padding: 14px;
  }

  .panel-header {
    padding: 14px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .catalog-meta-grid {
    grid-template-columns: 1fr;
  }

  .catalog-cover-preview {
    width: min(190px, 100%);
  }

  .stat strong {
    font-size: 21px;
  }

  .review-map {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .spell-row {
    gap: 10px;
    margin-top: 30px;
  }

  .word-syllable {
    padding: 8px 10px 9px;
  }

  .sound-chips {
    gap: 12px;
  }
}
