:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-muted: #f0f3f1;
  --text: #1f2925;
  --muted: #5e6964;
  --line: #d9e0dc;
  --primary: #246b53;
  --primary-dark: #1c5642;
  --primary-soft: #e7f1ec;
  --accent: #8a5412;
  --focus: #2563eb;
  --danger: #a93636;
  --warning-soft: #fff5e8;
  --danger-soft: #fff0f0;
  --shadow: 0 1px 3px rgba(31, 41, 37, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

body.access-locked .app-shell,
body.access-locked .modal-overlay {
  display: none;
}

.access-overlay {
  display: none;
}

body.access-locked .access-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: var(--bg);
}

.access-card {
  display: grid;
  width: min(100%, 360px);
  gap: 12px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.access-card h2 {
  margin-bottom: 4px;
}

.auth-card label,
.teacher-create-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.auth-card form,
.account-card {
  display: grid;
  gap: 14px;
}

.totp-qr {
  width: 240px;
  max-width: 100%;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.account-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 0;
}

.account-details dt { color: var(--muted); }
.account-details dd { margin: 0; font-weight: 700; }
.account-summary { color: var(--muted); font-size: 14px; }

.teacher-dashboard {
  width: min(1180px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 18px;
}

.teacher-header,
.teacher-create-form {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.teacher-create-form { flex-wrap: wrap; }
.teacher-create-form h2 { width: 100%; }
.teacher-create-form label { flex: 1 1 220px; }
.table-scroll { overflow-x: auto; }
.student-table { width: 100%; border-collapse: collapse; }
.student-table th, .student-table td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }

.submission-dashboard {
  width: min(1100px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  display: grid;
  gap: 16px;
  padding: 20px;
}

.submission-upload-form,
.submission-history,
.teacher-submissions,
.teacher-submission-detail {
  display: grid;
  gap: 14px;
}

.submission-drop-zone {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 28px 18px;
  border: 2px dashed #9dbbad;
  border-radius: 10px;
  background: var(--surface-muted);
  cursor: pointer;
  text-align: center;
}

.submission-drop-zone:hover,
.submission-drop-zone.dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.submission-drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.submission-drop-zone strong { color: var(--primary-dark); font-size: 18px; }
.submission-drop-zone span,
.submission-drop-zone small { color: var(--muted); }

.submission-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.submission-history-item > div { display: grid; gap: 4px; min-width: 0; }
.submission-history-item > div strong { overflow-wrap: anywhere; }
.submission-history-item > div span { color: var(--muted); font-size: 14px; }

.submission-status,
.pending-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.submission-status.pending,
.pending-badge { color: #84560b; background: #fff1cb; }
.submission-status.approved { color: #1b5c43; background: #dff0e7; }
.submission-status.rejected { color: #983c1d; background: #ffe5da; }
.submission-reason,
.submission-cleaned { grid-column: 1 / -1; margin: 0; }
.submission-cleaned { color: var(--muted); }
.submission-success { border-color: #9fcab8; background: #e8f5ee; }
.submission-page-error { min-height: auto; }
.submission-section-title { display: flex; justify-content: space-between; gap: 12px; }
.submission-section-title h2,
.submission-section-title p { margin-top: 0; }
.submission-table small { color: var(--muted); }

.submission-detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.submission-detail-meta p { flex-basis: 100%; margin: 0; }
.submission-pdf-preview { width: 100%; min-height: 55vh; border: 1px solid var(--line); border-radius: 8px; background: white; }
.submission-audio-preview { width: 100%; }
.submission-review-actions { display: flex; flex-wrap: wrap; gap: 10px; }

@media (max-width: 620px) {
  .submission-dashboard { width: calc(100vw - 16px); max-height: calc(100vh - 16px); padding: 14px; }
  .submission-history-item { grid-template-columns: minmax(0, 1fr); }
  .submission-status { justify-self: start; }
  .submission-pdf-preview { min-height: 48vh; }
}
.compact-input { min-width: 150px; min-height: 42px; font-size: 16px; }

@media (max-width: 700px) {
  .teacher-header { align-items: stretch; flex-direction: column; }
  .student-table { min-width: 820px; }
}

.access-input {
  width: 100%;
  min-height: 54px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  font-size: 20px;
}

.access-input:focus {
  border-color: var(--focus);
  outline: none;
}

.access-error {
  min-height: 22px;
  margin: 0;
  color: var(--danger);
  font-size: 15px;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 88px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  background: rgba(247, 245, 239, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.18;
}

h2 {
  margin: 0 0 14px;
  font-size: 22px;
  line-height: 1.25;
}

h3 {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.3;
}

.main-content {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 16px;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 22px rgba(32, 33, 36, 0.08);
}

.nav-button,
.primary-button,
.secondary-button,
.danger-button,
.option-button,
.tab-button,
.icon-text-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.nav-button {
  min-height: 52px;
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 16px;
}

.nav-button.active {
  color: #fff;
  background: var(--primary);
}

.primary-button {
  padding: 12px 18px;
  color: #fff;
  background: var(--primary);
  font-size: 17px;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.secondary-button {
  padding: 10px 14px;
  color: var(--primary-dark);
  background: #e6f1ec;
  border-color: #c7ded4;
  font-size: 15px;
}

.danger-button {
  padding: 12px 16px;
  color: #fff;
  background: var(--danger);
  font-size: 16px;
}

.icon-text-button {
  padding: 9px 12px;
  color: var(--text);
  background: var(--surface-muted);
  border-color: var(--line);
}

.panel,
.card,
.question-panel,
.result-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.result-scope {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.panel {
  padding: 16px;
}

.stack {
  display: grid;
  gap: 14px;
}

.hero-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.hero-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

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

.stat-box {
  padding: 12px;
  background: var(--surface-muted);
  border-radius: 8px;
}

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 800;
}

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

.question-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 15px;
}

.timer {
  color: var(--accent);
  font-weight: 800;
}

.prompt {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.45;
}

.prompt-sub {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.options {
  display: grid;
  gap: 12px;
}

.option-button {
  width: 100%;
  min-height: 58px;
  padding: 14px;
  color: var(--text);
  background: #fff;
  border-color: var(--line);
  font-size: 17px;
  line-height: 1.35;
  text-align: left;
}

.option-button.selected {
  border-color: var(--focus);
  background: #eaf3fb;
}

.option-button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.answer-input {
  width: 100%;
  min-height: 58px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 20px;
  line-height: 1.4;
}

.answer-input:focus {
  border-color: var(--focus);
  outline: none;
}

.test-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.test-actions .primary-button {
  grid-column: 1 / -1;
}

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

.result-actions button {
  min-height: 52px;
}

.progress-dots {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
}

.dot {
  height: 8px;
  border-radius: 999px;
  background: var(--line);
}

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

.dot.current {
  background: var(--accent);
}

.last-review-panel {
  margin-top: 14px;
}

.last-round-line {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
}

.review-words-grid .empty-state {
  grid-column: 1 / -1;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.source-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.word-source-tabs {
  margin-bottom: 10px;
}

.unit-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.unit-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.unit-picker-label {
  margin: 2px 0 -2px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.unit-option {
  min-height: 48px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px;
  font-weight: 700;
  text-align: left;
}

.unit-option.selected {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.scope-line,
.daily-last-time {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.unit-select-label {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.unit-select {
  min-height: 48px;
  padding: 8px 10px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px;
}

.listen-button {
  justify-self: start;
  min-height: 50px;
  padding: 10px 14px;
  color: var(--primary-dark);
  background: #e6f1ec;
  border: 1px solid #c7ded4;
  border-radius: 8px;
  font-size: 17px;
  font-weight: 800;
}

.test-mode-note,
.result-status {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.test-mode-note strong,
.result-status strong {
  font-size: 17px;
}

.test-mode-note span,
.result-status span {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.test-mode-note.needs-correction,
.test-mode-note.consolidation,
.test-mode-note.cautious,
.result-status.needs-work {
  border-color: #e5c68f;
  background: var(--warning-soft);
}

.result-status.passed {
  border-color: #b9d8ca;
  background: var(--primary-soft);
}

.test-task-summary {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px;
  line-height: 1.45;
}

.test-task-summary strong {
  color: var(--text);
}

.active-test-mode {
  margin-bottom: 12px;
  color: var(--primary-dark);
  font-size: 16px;
  font-weight: 800;
}

.daily-summary-panel {
  margin-top: 14px;
}

.daily-summary-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.daily-summary-head h2,
.daily-status,
.daily-source-list p {
  margin: 0;
}

.daily-summary-head span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.daily-status {
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  line-height: 1.55;
}

.daily-source-list {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface-muted);
  border-radius: 8px;
}

.daily-source-list p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.daily-round-list {
  border-top: 1px solid var(--line);
}

.daily-overview {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  background: var(--surface-muted);
  border-radius: 8px;
}

.daily-overview p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.daily-overview strong {
  color: var(--text);
  font-size: 18px;
}

.daily-round-item {
  display: grid;
  gap: 4px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.daily-round-item.compact {
  gap: 3px;
  padding: 9px 0;
}

.daily-record-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.daily-round-item strong {
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

.daily-round-item span {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}

.daily-round-item.incomplete strong {
  color: #9a5e14;
}

.daily-result-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 14px !important;
  font-weight: 800;
}

.daily-result-badge.qualified,
.daily-result-badge.excellent {
  color: var(--primary-dark);
  background: #e6f1ec;
}

.daily-result-badge.completed,
.daily-result-badge.needs_work {
  color: #8b3b18;
  background: #fff0e8;
}

.daily-result-badge.pending {
  color: var(--muted);
  background: var(--surface-muted);
}

.readaloud-round-complete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #bdd9cd;
  border-radius: 8px;
  background: #e6f1ec;
}

.readaloud-round-complete div {
  display: grid;
  gap: 3px;
}

.readaloud-round-complete strong {
  color: var(--primary-dark);
  font-size: 17px;
}

.readaloud-round-complete span {
  color: var(--muted);
  font-size: 15px;
}

.tab-button {
  padding: 10px 8px;
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 15px;
}

.tab-button.active {
  color: #fff;
  background: var(--primary);
}

.card-list {
  display: grid;
  gap: 12px;
}

.card-list.words {
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 8px;
}

.card {
  padding: 14px;
}

.card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.word-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.word-title button {
  flex: 1;
  min-width: 0;
  padding: 0;
  color: var(--primary-dark);
  background: transparent;
  border: 0;
  font-size: 20px;
  font-weight: 800;
  text-align: left;
}

.word-card {
  min-height: 52px;
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: 52px;
}

.word-card h3 {
  margin-bottom: 0;
  color: var(--primary-dark);
  font-size: 17px;
  line-height: 1.25;
}

.word-card.expanded {
  grid-column: 1 / -1;
  border-color: #bdd9cd;
}

.word-card.expanded h3 {
  font-size: 22px;
}

.word-card .icon-text-button {
  margin-top: 8px;
}

.load-more-row {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.forms-line {
  color: var(--accent) !important;
  font-size: 15px !important;
  font-weight: 800;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 8px;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.badge.weak {
  color: #8b3b18;
  background: #fff0e8;
  border-color: #f2c3a9;
}

.badge.mastered {
  color: var(--primary-dark);
  background: #e6f1ec;
  border-color: #bdd9cd;
}

.article-button {
  width: 100%;
  padding: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.35;
  text-align: left;
}

.local-calibration-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  color: var(--text);
  background: #fff8e8;
  border: 1px solid #efd39a;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.local-calibration-switch.active {
  background: #e6f1ec;
  border-color: #bdd9cd;
}

.local-calibration-switch div {
  display: grid;
  gap: 4px;
}

.local-calibration-switch strong {
  font-size: 17px;
}

.local-calibration-switch span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.article-detail-header {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.article-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.article-title-row h2 {
  margin: 0;
}

.compact-button {
  width: auto;
  min-height: 42px;
  padding: 10px 14px;
  white-space: nowrap;
}

audio {
  width: 100%;
}

.article-reader {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 18px;
  line-height: 1.95;
}

.article-sentence-wrap {
  display: inline;
}

.article-sentence {
  display: inline;
  min-height: 34px;
  margin: 0 2px 8px 0;
  padding: 2px 4px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 650;
  line-height: 1.7;
  text-align: left;
}

.article-sentence.active {
  color: var(--primary-dark);
  background: #dceee7;
}

.inline-structure {
  color: var(--accent);
  font-weight: 800;
}

.sentence-detail {
  display: block;
  margin: 8px 0 14px;
  padding: 12px;
  background: #fbfaf6;
  border-left: 4px solid var(--primary);
  border-radius: 0 8px 8px 0;
  font-size: 16px;
  line-height: 1.6;
}

.structure-slash {
  display: block;
  margin-bottom: 8px;
  color: var(--primary-dark);
  font-weight: 800;
}

.sentence-translation {
  display: block;
  color: var(--text);
}

.library-vocab-list {
  gap: 10px;
}

.library-vocab-card {
  display: block;
}

.library-vocab-main {
  display: grid;
  gap: 4px;
}

.library-vocab-word {
  width: fit-content;
  max-width: 100%;
  padding: 0;
  color: var(--primary-dark);
  background: transparent;
  border: 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.3;
  text-align: left;
}

.inline-alert {
  padding: 12px;
  color: #8b3b18;
  background: #fff0e8;
  border: 1px solid #f2c3a9;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1.5;
}

.readaloud-view {
  padding-bottom: 8px;
}

.readaloud-list {
  display: grid;
  gap: 12px;
}

.readaloud-card {
  display: grid;
  gap: 12px;
}

.readaloud-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.readaloud-status {
  justify-content: flex-end;
}

.readaloud-card .readaloud-en {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.55;
}

.readaloud-card .readaloud-zh,
.readaloud-card .readaloud-placeholder {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.readaloud-muted {
  color: var(--muted);
}

.readaloud-assessment {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #fbfaf6;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px;
  line-height: 1.5;
}

.readaloud-assessment.pending {
  color: var(--primary-dark);
  background: #e6f1ec;
  border-color: #bdd9cd;
  font-weight: 800;
}

.readaloud-assessment.unavailable {
  color: #8b3b18;
  background: #fff0e8;
  border-color: #f2c3a9;
}

.assessment-score-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.assessment-level {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #e6f1ec;
  border: 1px solid #bdd9cd;
  border-radius: 8px;
}

.assessment-level span {
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.assessment-level strong {
  color: var(--primary-dark);
  font-size: 18px;
}

.assessment-score {
  display: grid;
  gap: 2px;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.assessment-score span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.assessment-score strong {
  color: var(--primary-dark);
  font-size: 22px;
  line-height: 1.1;
}

.low-score-words {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.low-score-words strong {
  margin-right: 2px;
}

.low-score-word {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 3px 8px;
  color: #8b3b18;
  background: #fff0e8;
  border: 1px solid #f2c3a9;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
}

.article-readaloud-summary {
  display: grid;
  gap: 12px;
  border-color: #bdd9cd;
  background: #fbfffb;
}

.article-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.article-summary-head h3 {
  margin: 0;
}

.article-summary-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  color: var(--primary-dark);
  background: #e6f1ec;
  border: 1px solid #bdd9cd;
  border-radius: 8px;
}

.article-summary-hero span {
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
}

.article-summary-hero strong {
  font-size: 34px;
  line-height: 1;
}

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

.article-summary-metric strong {
  font-size: 20px;
}

.article-summary-note {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.assessment-attempts {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.assessment-feedback {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  background: #fff;
  border-left: 3px solid var(--primary);
}

.assessment-feedback p {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
}

.word-issue-list,
.weakest-sentences {
  display: grid;
  gap: 8px;
}

.word-issue {
  min-height: 40px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid #d5a153;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1.45;
}

.word-issue.critical {
  color: #8b3b18;
  background: #fff7f2;
  border-left-color: #c9673d;
}

.word-issue.system {
  color: var(--muted);
  border-left-color: var(--line-strong);
}

.weakest-sentence-button {
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 10px;
  width: 100%;
  min-height: 52px;
  padding: 9px 10px;
  color: var(--text);
  text-align: left;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.weakest-sentence-button > strong {
  justify-self: end;
  color: var(--primary-dark);
  font-size: 17px;
}

.weakest-sentence-button small {
  grid-column: 1 / -1;
  overflow: hidden;
  font-size: 16px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.readaloud-actions button {
  min-height: 48px;
  padding-right: 10px;
  padding-left: 10px;
}

.calibration-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #fbfaf6;
  border: 1px dashed var(--accent);
  border-radius: 8px;
}

.calibration-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.calibration-summary {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: #eef7f0;
  border: 1px solid #b9dac0;
  border-radius: 8px;
  color: var(--text);
}

.calibration-summary span {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.calibration-summary .continuity-ok {
  color: #276235;
  font-weight: 800;
}

.calibration-summary .continuity-warning {
  color: #9a4f07;
  font-weight: 800;
}

.calibration-summary button {
  justify-self: start;
  min-height: 42px;
}

.boundary-overview {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #f7fbff;
  border: 1px solid #c8d8eb;
  border-radius: 8px;
}

.boundary-overview-head {
  display: grid;
  gap: 4px;
}

.boundary-overview-head span {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

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

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

.boundary-row strong {
  color: var(--primary-dark);
}

.boundary-row em {
  color: var(--muted);
  font-size: 14px;
  font-style: normal;
}

.boundary-row.boundary-verified {
  border-color: #b9dac0;
}

.boundary-row button {
  min-height: 40px;
  padding: 7px 10px;
  font-size: 14px;
}

.file-input-label {
  display: inline-grid;
  place-items: center;
  min-height: 48px;
  text-align: center;
  cursor: pointer;
}

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

.calibration-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  background: #fbfaf6;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.calibration-time {
  grid-column: 1 / -1;
  color: var(--primary-dark);
  font-size: 15px;
  font-weight: 800;
}

.calibration-boundary {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.calibration-controls button {
  min-height: 42px;
  padding: 8px;
  font-size: 15px;
}

.calibration-controls button.fine-adjust {
  background: #ffffff;
  border-style: dotted;
  font-size: 14px;
}

.readaloud-card.verified-timing {
  border-color: #b9dac0;
  background: #fbfffb;
}

.waveform-placeholder {
  padding: 10px;
  color: var(--muted);
  background: #fbfaf6;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.4;
  text-align: center;
}

.sentence-waveform {
  position: relative;
  height: 74px;
  padding: 8px 6px;
  background: #fbfaf6;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.waveform-bars {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 1px;
}

.waveform-bar {
  flex: 1 1 1px;
  min-width: 1px;
  max-height: 100%;
  background: #c9c5bb;
  border-radius: 2px;
}

.waveform-bar.active {
  background: var(--primary);
}

.waveform-marker {
  position: absolute;
  top: 4px;
  bottom: 4px;
  z-index: 1;
  width: 2px;
  border-radius: 999px;
}

.waveform-marker.start {
  background: var(--focus);
}

.waveform-marker.end {
  background: var(--danger);
}

.sentence-list {
  display: grid;
  gap: 10px;
}

.sentence-card {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sentence-en {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.55;
}

.sentence-zh {
  display: none;
  margin-top: 10px;
  padding-top: 10px;
  color: var(--text);
  border-top: 1px dashed var(--line);
  font-size: 16px;
  line-height: 1.6;
}

.sentence-card.open .sentence-zh {
  display: block;
}

details {
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
}

summary {
  min-height: 36px;
  cursor: pointer;
  font-weight: 800;
}

.structure-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.structure-item {
  padding: 8px;
  background: var(--surface-muted);
  border-radius: 8px;
  line-height: 1.45;
}

.result-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.wrong-list {
  display: grid;
  gap: 10px;
}

.wrong-item {
  padding: 12px;
  background: #fff7f3;
  border: 1px solid #f0c7b4;
  border-radius: 8px;
}

.wrong-item p {
  margin: 4px 0 0;
  font-size: 15px;
}

.empty-state {
  padding: 22px 14px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 16px;
  line-height: 1.6;
  text-align: center;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(32, 33, 36, 0.52);
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: min(100%, 420px);
  padding: 18px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
}

.modal p {
  margin: 0 0 16px;
  font-size: 16px;
  line-height: 1.6;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 520px) {
  .daily-record-title {
    align-items: flex-start;
  }

  .daily-record-title strong {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .readaloud-round-complete {
    align-items: stretch;
    flex-direction: column;
  }

  .readaloud-round-complete .primary-button {
    width: 100%;
  }

  .article-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-button {
    width: 100%;
  }

  .readaloud-card-head {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (min-width: 720px) {
  .main-content {
    padding: 22px;
  }

  .hero-panel,
  .question-panel,
  .result-panel,
  .panel {
    padding: 22px;
  }

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

  .test-actions {
    grid-template-columns: 1fr 1fr 1.2fr;
  }

  .test-actions .primary-button {
    grid-column: auto;
  }

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

/* Unified student-facing interface */
body {
  line-height: 1.55;
}

button {
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 2px;
}

.main-content:focus {
  outline: none;
}

.app-shell {
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

.topbar {
  padding: 0;
  background: rgba(245, 247, 246, 0.96);
  backdrop-filter: none;
}

.topbar-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: min(100%, 960px);
  min-height: 72px;
  margin: 0 auto;
  padding: 10px 16px;
  gap: 12px;
}

.page-identity {
  min-width: 0;
}

.eyebrow {
  margin-bottom: 0;
  font-size: 13px;
  font-weight: 500;
}

h1 {
  font-size: 22px;
  line-height: 1.3;
}

h2 {
  margin-bottom: 12px;
  font-size: 20px;
  line-height: 1.4;
}

h3 {
  font-size: 18px;
  line-height: 1.45;
}

.main-content {
  width: min(100%, 960px);
  padding: 16px;
}

.bottom-nav {
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -1px 3px rgba(31, 41, 37, 0.08);
}

.nav-button,
.primary-button,
.secondary-button,
.danger-button,
.option-button,
.tab-button,
.icon-text-button {
  min-height: 48px;
  border-radius: 6px;
  font-weight: 650;
}

.nav-button {
  min-height: 52px;
  background: transparent;
  border-color: transparent;
}

.nav-button.active {
  background: var(--primary);
}

.primary-button {
  background: var(--primary);
  font-size: 16px;
}

.secondary-button {
  color: var(--primary-dark);
  background: var(--surface);
  border-color: var(--line);
  font-size: 16px;
}

.icon-text-button {
  color: var(--primary-dark);
  background: var(--surface-muted);
  border-color: var(--line);
  font-size: 16px;
}

.primary-button:disabled,
.secondary-button:disabled,
.option-button:disabled,
.icon-text-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.export-button {
  min-height: 44px;
  padding: 8px 12px;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  white-space: nowrap;
}

.panel,
.card,
.question-panel,
.result-panel {
  border-color: var(--line);
  box-shadow: none;
}

.panel,
.question-panel,
.result-panel {
  padding: 16px;
}

.stack {
  gap: 16px;
}

.section-heading,
.subsection-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h2,
.subsection-heading h3 {
  margin: 0;
}

.section-kicker {
  margin: 0 0 2px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 650;
}

.subsection-heading {
  padding-top: 4px;
}

.subsection-heading span,
.section-count,
.task-limit,
.control-label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.section-count,
.task-limit,
.mode-label {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  white-space: nowrap;
}

.hero-panel {
  gap: 16px;
  padding: 20px 16px;
}

.hero-panel p {
  max-width: 680px;
  line-height: 1.65;
}

.start-test-button {
  width: 100%;
  min-height: 54px;
}

.stats-grid {
  gap: 0;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.stat-box {
  padding: 12px 8px 4px;
  background: transparent;
  border-radius: 0;
}

.stat-box:nth-child(even) {
  border-left: 1px solid var(--line);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
}

.stat-label {
  font-size: 14px;
}

.last-review-panel {
  margin-top: 0;
}

.last-round-line {
  padding: 12px 14px;
  background: var(--surface-muted);
  border-radius: 6px;
}

.review-words-grid {
  grid-template-columns: 1fr !important;
}

.question-panel,
.result-panel {
  width: min(100%, 760px);
  margin: 0 auto;
}

.active-test-panel {
  gap: 16px;
}

.question-meta {
  font-size: 15px;
}

.question-position {
  color: var(--text);
  font-weight: 650;
}

.timer {
  min-width: 58px;
  color: var(--accent);
  text-align: right;
}

.progress-dots {
  gap: 4px;
}

.dot {
  height: 5px;
}

.prompt {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.5;
}

.option-button {
  min-height: 58px;
  border-color: var(--line);
  font-weight: 600;
}

.option-button.selected {
  color: #173e31;
  background: var(--primary-soft);
  border-color: var(--primary);
  box-shadow: inset 4px 0 0 var(--primary);
}

.question-progress-copy {
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.test-actions button {
  min-height: 50px;
}

.wrong-item {
  padding: 14px;
  background: var(--danger-soft);
  border-color: #efcaca;
}

.wrong-item strong {
  font-size: 18px;
}

.empty-state {
  background: transparent;
  border-color: var(--line);
}

.tabs {
  gap: 4px;
  padding: 4px;
  background: var(--surface-muted);
  border-radius: 8px;
}

.tab-button {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  font-size: 15px;
}

.tab-button.active {
  color: var(--primary-dark);
  background: var(--surface);
  border-color: var(--line);
}

.words-heading,
.library-heading {
  margin-bottom: 16px;
}

.card-list.words {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.card-list.words.phrase-grid {
  grid-template-columns: 1fr;
}

.word-card {
  display: grid;
  min-width: 0;
  min-height: 58px;
  align-content: center;
  padding: 12px;
  background: var(--surface);
}

.word-card h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.35;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.word-card.expanded {
  align-content: start;
  padding: 16px;
  background: #fbfdfc;
  border-color: #b9d2c8;
}

.word-card.expanded h3 {
  font-size: 21px;
}

.word-card p {
  overflow-wrap: break-word;
}

.forms-line {
  color: var(--accent) !important;
  font-weight: 650;
}

.badge {
  min-height: 26px;
  color: var(--muted);
  background: var(--surface-muted);
  border-color: transparent;
  font-weight: 600;
}

.badge.status-badge,
.badge.mastered {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.badge.weak,
.low-score-word {
  color: #75440b;
  background: var(--warning-soft);
  border-color: #efd6af;
}

.article-list {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.article-button {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  font-weight: 600;
}

.article-button:last-child {
  border-bottom: 0;
}

.article-order {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: 6px;
  font-size: 14px;
}

.article-name {
  min-width: 0;
}

.article-arrow {
  color: var(--muted);
  font-size: 24px;
  font-weight: 400;
}

.local-calibration-switch {
  padding: 12px 14px;
  background: var(--surface-muted);
  border-color: var(--line);
  box-shadow: none;
}

.article-detail-view {
  justify-items: center;
}

.article-detail-view > * {
  width: min(100%, 720px);
}

.article-detail-header {
  gap: 12px;
  margin-bottom: 0;
}

.back-button {
  justify-self: start;
  width: auto;
  min-height: 44px;
  padding: 8px 12px;
  color: var(--muted);
  background: transparent;
}

.article-title-row h2 {
  font-size: 22px;
  overflow-wrap: break-word;
}

.article-audio {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  background: var(--surface-muted);
  border-radius: 8px;
}

.article-reader {
  padding: 20px;
  border-color: var(--line);
  box-shadow: none;
  font-size: 18px;
  line-height: 1.9;
}

.article-sentence {
  margin-right: 1px;
  padding: 2px 3px;
  font-weight: 600;
  line-height: 1.85;
}

.article-sentence.active {
  background: var(--primary-soft);
}

.inline-structure,
.structure-slash {
  color: var(--accent);
  font-weight: 650;
}

.sentence-detail {
  background: var(--surface-muted);
  border-left-color: var(--primary);
}

.article-vocabulary {
  padding: 16px;
}

.library-vocab-list {
  gap: 0;
}

.library-vocab-card {
  padding: 12px 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.library-vocab-word {
  font-weight: 650;
}

.readaloud-view {
  width: min(100%, 760px);
  margin: 0 auto;
}

.mode-label {
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 14px;
  font-weight: 650;
}

.readaloud-progress {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.readaloud-progress div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.readaloud-progress span {
  color: var(--muted);
  font-size: 14px;
}

.readaloud-progress progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  accent-color: var(--primary);
}

.readaloud-progress progress::-webkit-progress-bar {
  background: var(--surface-muted);
  border-radius: 999px;
}

.readaloud-progress progress::-webkit-progress-value {
  background: var(--primary);
  border-radius: 999px;
}

.readaloud-card {
  gap: 10px;
  padding: 16px;
  border-left: 3px solid #c8d8d1;
}

.readaloud-card-head {
  align-items: center;
}

.readaloud-card-head .badge-row {
  margin-top: 0;
}

.sentence-number {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.readaloud-en {
  font-weight: 650;
  line-height: 1.6;
}

.readaloud-assessment {
  background: var(--surface-muted);
  border-color: transparent;
}

.readaloud-assessment.pending,
.article-summary-hero,
.assessment-level {
  background: var(--primary-soft);
  border-color: #c5dcd2;
}

.article-readaloud-summary {
  background: var(--surface);
  border-color: var(--line);
}

.assessment-score {
  border-color: var(--line);
}

.assessment-score strong,
.article-summary-hero strong {
  font-weight: 700;
}

.modal {
  border: 1px solid var(--line);
  box-shadow: 0 12px 36px rgba(31, 41, 37, 0.18);
}

@media (hover: hover) {
  .primary-button:not(:disabled):hover,
  .nav-button.active:hover {
    background: var(--primary-dark);
  }

  .secondary-button:not(:disabled):hover,
  .icon-text-button:not(:disabled):hover,
  .article-button:hover,
  .tab-button:not(.active):hover {
    background: var(--surface-muted);
  }

  .option-button:not(:disabled):hover {
    border-color: #aebbb5;
    background: #fbfdfc;
  }
}

@media (max-width: 520px) {
  .article-title-row {
    align-items: center;
    flex-direction: row;
    gap: 12px;
  }

  .article-title-row h2 {
    font-size: 20px;
  }

  .compact-button {
    flex: 0 0 auto;
    width: auto;
  }

  .back-button {
    min-height: 36px;
    padding: 5px 8px;
  }

  .readaloud-card-head {
    align-items: center;
    flex-direction: row;
  }

  .readaloud-status {
    justify-content: flex-end;
  }

  .subsection-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }
}

@media (min-width: 720px) {
  .main-content {
    padding: 24px 22px 32px;
  }

  .panel,
  .question-panel,
  .result-panel {
    padding: 24px;
  }

  .stat-box {
    padding: 12px 14px 4px;
    border-left: 1px solid var(--line);
  }

  .stat-box:first-child {
    border-left: 0;
  }

  .card-list.words.word-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .card-list.words.phrase-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .library-vocab-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 24px;
  }
}

@media (min-width: 900px) {
  .app-shell {
    padding-bottom: 0;
  }

  .topbar-inner {
    grid-template-columns: auto minmax(300px, 1fr) auto;
    min-height: 76px;
    padding: 10px 0;
  }

  .bottom-nav {
    position: static;
    justify-self: center;
    width: min(100%, 420px);
    padding: 4px;
    background: var(--surface-muted);
    border: 0;
    border-radius: 8px;
    box-shadow: none;
  }

  .nav-button {
    min-height: 40px;
    font-size: 15px;
  }

  .nav-button.active {
    color: var(--primary-dark);
    background: var(--surface);
    border-color: var(--line);
  }

  .export-button {
    min-height: 40px;
  }

  .card-list.words.word-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .hero-panel {
    padding: 28px;
  }
}

@media (min-width: 1100px) {
  .card-list.words.word-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* Learning progress */
.bottom-nav {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.progress-view {
  display: grid;
  gap: 16px;
  padding-bottom: 8px;
}

.progress-hero {
  display: grid;
  gap: 18px;
  padding: 20px 16px;
  overflow: hidden;
  background: #f4faf6;
  border: 1px solid #cfe0d6;
}

.progress-hero h2 {
  margin-bottom: 8px;
  font-size: 22px;
}

.progress-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.progress-hero-summary,
.progress-overview-main,
.progress-scope-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.progress-hero-summary > div:not(.progress-ring) {
  display: grid;
  gap: 3px;
}

.progress-hero-summary strong {
  font-size: 25px;
  line-height: 1.15;
}

.progress-hero-summary span,
.progress-hero-summary em {
  color: var(--muted);
  font-size: 16px;
  font-style: normal;
  line-height: 1.4;
}

.progress-ring {
  --progress-value: 0;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 92px;
  aspect-ratio: 1;
  padding: 8px;
  background: conic-gradient(var(--primary) calc(var(--progress-value) * 1%), #dbe5df 0);
  border-radius: 50%;
}

.progress-ring > div {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 6px;
  background: var(--surface);
  border-radius: 50%;
  text-align: center;
}

.progress-ring strong {
  color: var(--primary-dark);
  font-size: 20px;
  line-height: 1;
}

.progress-ring span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.progress-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.progress-overview-grid {
  display: grid;
  gap: 14px;
}

.progress-overview-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.progress-overview-card.outside {
  border-top: 4px solid #246b53;
}

.progress-overview-card.school {
  border-top: 4px solid #8a5412;
}

.progress-overview-main h3,
.progress-scope-main h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.progress-overview-main p,
.progress-scope-main p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}

.progress-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.progress-status-item {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px 6px;
  border-right: 1px solid var(--line);
  text-align: center;
}

.progress-status-item:last-child {
  border-right: 0;
}

.progress-status-item strong {
  font-size: 20px;
  line-height: 1;
}

.progress-status-item span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.progress-status-item.mastered strong { color: #246b53; }
.progress-status-item.learning strong { color: #9a650d; }
.progress-status-item.review strong { color: #b34a27; }
.progress-status-item.new strong { color: #68756f; }

.progress-milestones {
  display: grid;
  gap: 7px;
}

.milestone-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.milestone {
  min-height: 30px;
  padding: 5px;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.milestone.reached {
  color: #1d5f47;
  background: #e6f1ec;
  border-color: #a9cdbb;
}

.progress-milestones p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.progress-collection-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid #246b53;
  border-radius: 8px;
}

.progress-collection-header.school {
  border-top-color: #8a5412;
}

.progress-collection-header h2 {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.28;
}

.progress-collection-header p:not(.section-kicker) {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.progress-collection-summary {
  display: grid;
  gap: 3px;
  min-width: 68px;
  color: var(--primary-dark);
  text-align: right;
}

.progress-collection-header.school .progress-collection-summary {
  color: #8a5412;
}

.progress-collection-summary strong {
  font-size: 25px;
  line-height: 1;
}

.progress-collection-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.progress-scope-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.progress-scope-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid #246b53;
  border-radius: 8px;
  overflow: hidden;
}

.progress-scope-card.school {
  border-top-color: #8a5412;
}

.progress-scope-toggle {
  display: grid;
  align-content: start;
  gap: 11px;
  width: 100%;
  min-height: 212px;
  padding: 13px;
  color: var(--text);
  background: transparent;
  border: 0;
  text-align: left;
}

.progress-scope-toggle:hover {
  background: #f7faf8;
}

.progress-scope-card-topline,
.progress-scope-metrics,
.progress-scope-footer {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
}

.progress-scope-order {
  display: inline-grid;
  place-items: center;
  min-width: 25px;
  min-height: 25px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
}

.progress-scope-card.school .progress-scope-order {
  color: #8a5412;
  background: #fff1d8;
}

.progress-scope-percent {
  color: var(--primary-dark);
  font-size: 23px;
  font-weight: 800;
  line-height: 1;
}

.progress-scope-card.school .progress-scope-percent {
  color: #8a5412;
}

.progress-scope-main {
  min-width: 0;
}

.progress-scope-source {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.progress-scope-main h3 {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: normal;
  word-break: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.progress-scope-bar {
  height: 7px;
  overflow: hidden;
  background: #dce7e1;
  border-radius: 999px;
}

.progress-scope-bar span {
  display: block;
  min-width: 0;
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}

.progress-scope-card.school .progress-scope-bar {
  background: #f2e4cb;
}

.progress-scope-card.school .progress-scope-bar span {
  background: #a7671b;
}

.progress-scope-metrics {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.progress-scope-metrics span:last-child {
  text-align: right;
}

.progress-scope-footer {
  align-items: flex-start;
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.progress-scope-footer > span:first-child {
  flex: 1 1 auto;
}

.progress-scope-readaloud {
  flex: 0 0 auto;
  color: var(--primary-dark);
  font-weight: 800;
  white-space: nowrap;
}

.progress-details {
  display: grid;
  gap: 14px;
  padding: 18px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.progress-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.progress-filter {
  min-height: 38px;
  padding: 7px 10px;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.2;
}

.progress-filter:hover,
.progress-filter.active {
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-color: #a8cbbb;
}

.progress-detail-view {
  gap: 16px;
}

.progress-detail-hero {
  display: grid;
  gap: 16px;
  padding: 18px 16px;
  border-top: 4px solid #246b53;
}

.progress-detail-hero.school {
  border-top-color: #8a5412;
}

.progress-detail-title h2 {
  margin: 0 0 7px;
  font-size: 22px;
  line-height: 1.32;
}

.progress-detail-title > p:not(.section-kicker) {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.progress-detail-summary {
  display: flex;
  gap: 14px;
  align-items: center;
}

.progress-detail-summary > div:not(.progress-ring) {
  display: grid;
  gap: 3px;
}

.progress-detail-summary strong {
  font-size: 25px;
  line-height: 1.15;
}

.progress-detail-summary span,
.progress-detail-summary em {
  color: var(--muted);
  font-size: 15px;
  font-style: normal;
  line-height: 1.4;
}

.progress-detail-readaloud {
  display: grid;
  gap: 7px;
  padding: 12px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.article-readaloud-progress {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  margin-top: 0;
  color: var(--primary-dark);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.article-readaloud-progress span:first-child {
  color: var(--text);
}

.progress-detail-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px;
}

.progress-detail-actions .primary-button,
.progress-detail-actions .secondary-button {
  width: 100%;
}

.progress-word-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.progress-word-card {
  display: grid;
  align-content: start;
  gap: 5px;
  min-width: 0;
  min-height: 104px;
  padding: 11px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.progress-word-card:hover {
  border-color: #a7cabb;
}

.progress-word-card > strong {
  color: var(--primary-dark);
  font-size: 17px;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.progress-word-card > span:not(.progress-word-status) {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

.progress-word-status {
  justify-self: start;
  padding: 3px 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
}

.progress-word-card.mastered .progress-word-status { color: #1b5c43; background: #dff0e7; }
.progress-word-card.learning .progress-word-status { color: #84560b; background: #fff1cb; }
.progress-word-card.review .progress-word-status { color: #983c1d; background: #ffe5da; }
.progress-word-card.new .progress-word-status { color: #5f6c66; background: #e5e9e7; }

.progress-word-card.expanded {
  grid-column: 1 / -1;
  background: #fff;
  border-color: #aacbbb;
}

.progress-word-card.expanded > strong {
  font-size: 21px;
}

.progress-word-card .icon-text-button {
  justify-self: start;
  margin-top: 4px;
}

.progress-grade-select {
  margin-bottom: 0;
}

@media (min-width: 620px) {
  .progress-overview-grid,
  .progress-scope-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .progress-word-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 720px) {
  .progress-scope-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .bottom-nav {
    width: min(100%, 560px);
  }

  .progress-hero {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 26px;
  }

  .progress-hero > .progress-status-grid,
  .progress-hero > .progress-milestones {
    grid-column: 1 / -1;
  }

  .progress-scope-list { gap: 14px; }

  .progress-collection-header {
    padding: 22px;
  }

  .progress-detail-hero {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    padding: 24px;
  }

  .progress-detail-hero > .progress-status-grid,
  .progress-detail-hero > .progress-milestones,
  .progress-detail-hero > .progress-detail-readaloud,
  .progress-detail-hero > .progress-detail-actions {
    grid-column: 1 / -1;
  }

  .progress-word-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1120px) {
  .progress-scope-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 359px) {
  .progress-scope-list {
    grid-template-columns: minmax(0, 1fr);
  }
}
