:root {
  --jade: #0F766E;
  --jade-soft: #CCFBF1;
  --jade-mid: #14B8A6;
  --amber: #F59E0B;
  --amber-soft: #FEF3C7;
  --error: #DC2626;
  --error-soft: #FEE2E2;
  --ok: #059669;
  --ok-soft: #D1FAE5;
  --bg: #F8FAF9;
  --surface: #FFFFFF;
  --text: #0F172A;
  --muted: #64748B;
  --border: #E2E8F0;
  --shadow: 0 4px 16px rgba(15, 118, 110, 0.08);
  --shadow-hover: 0 6px 20px rgba(15, 118, 110, 0.14);
  --radius: 16px;
  --radius-sm: 12px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--jade); text-decoration: none; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }

/* Splash */
#splash {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; transition: opacity 0.35s ease;
}
#splash.fade-out { opacity: 0; pointer-events: none; }
.splash-logo {
  width: 96px; height: 96px; border-radius: 22px;
  box-shadow: var(--shadow); object-fit: cover;
}
.splash-name { font-size: 28px; font-weight: 700; color: var(--jade); letter-spacing: 0.04em; }
.splash-spin {
  width: 28px; height: 28px; border: 2.5px solid var(--jade-soft);
  border-top-color: var(--jade); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Shell */
#app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
}
.brand {
  display: flex; align-items: center; gap: 10px; font-weight: 700;
  color: var(--jade); font-size: 18px;
}
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.version-chip {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  opacity: 0.75;
  letter-spacing: 0.02em;
  user-select: none;
  pointer-events: none;
  white-space: nowrap;
  padding: 2px 4px;
}

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; font-size: 13px;
  background: var(--jade-soft); color: var(--jade); font-weight: 600;
}
.lang-btn, .icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--jade); border: 1px solid transparent;
}
.lang-btn { font-size: 12px; font-weight: 700; width: auto; padding: 0 10px; }
.icon-btn:active { background: var(--jade-soft); }

.main {
  flex: 1; width: 100%; max-width: 720px; margin: 0 auto;
  padding: 20px 20px calc(var(--nav-h) + var(--safe-b) + 24px);
}
.main.wide { max-width: 960px; }
.main.no-nav { padding-bottom: 32px; }

/* Cards & layout */
.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.spread { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .grid-2 { grid-template-columns: 1fr; } }

h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
h2 { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.muted { color: var(--muted); font-size: 14px; }
.lead { color: var(--muted); margin-bottom: 20px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: var(--radius-sm); font-weight: 600;
  font-size: 15px; transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  border: 1.5px solid transparent;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--jade); color: #fff; }
.btn-primary:active { background: #0d5f59; }
.btn-secondary { background: var(--surface); color: var(--jade); border-color: var(--jade); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-amber { background: var(--amber); color: #fff; }
.btn-danger { background: var(--error-soft); color: var(--error); }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 20px; font-size: 16px; border-radius: 14px; }
.btn svg { flex-shrink: 0; }

/* Forms */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: 15px; color: var(--text); outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--jade); }
textarea { min-height: 100px; resize: vertical; }
.form-gap { display: flex; flex-direction: column; gap: 14px; }

/* Role gate */
.role-gate {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 40px 8px 20px; gap: 28px;
}
.role-gate .hero-logo { width: 88px; height: 88px; border-radius: 20px; box-shadow: var(--shadow); margin: 0 auto 12px; }
.role-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; max-width: 440px; }
.role-card {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 24px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px;
  box-shadow: var(--shadow); transition: border-color 0.15s, box-shadow 0.15s;
}
.role-card:active { border-color: var(--jade); box-shadow: var(--shadow-hover); }
.role-card .ico { color: var(--jade); }
.role-card strong { font-size: 16px; }
.role-card span { font-size: 12px; color: var(--muted); }

/* Bottom nav */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
  display: flex; justify-content: center;
}
.bottom-nav .nav-inner {
  display: flex; width: 100%; max-width: 720px; height: var(--nav-h);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: var(--muted); font-size: 11px; font-weight: 600;
  border-radius: 12px; margin: 6px 4px; transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.nav-item svg { stroke: currentColor; }
.nav-item.active {
  color: var(--jade); background: var(--jade-soft);
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.12);
}
.nav-item.active svg { fill: rgba(15, 118, 110, 0.12); }

@media (hover: hover) and (pointer: fine) {
  .nav-item:hover {
    color: var(--jade); background: rgba(15, 118, 110, 0.06);
    box-shadow: 0 2px 10px rgba(15, 118, 110, 0.1);
  }
  .role-card:hover { border-color: var(--jade); box-shadow: var(--shadow-hover); }
  .btn-primary:hover { box-shadow: var(--shadow-hover); }
  .icon-btn:hover { background: var(--jade-soft); }
  .list-item:hover { background: rgba(15, 118, 110, 0.04); }
}

/* Stats / pills */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 10px; text-align: center;
}
.stat .n { font-size: 22px; font-weight: 700; color: var(--jade); }
.stat .l { font-size: 11px; color: var(--muted); margin-top: 2px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.pill-amber { background: var(--amber-soft); color: #B45309; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-err { background: var(--error-soft); color: var(--error); }
.pill-jade { background: var(--jade-soft); color: var(--jade); }

/* Lists */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); transition: background 0.15s;
}
.list-item .meta { flex: 1; min-width: 0; }
.list-item .meta strong { display: block; font-size: 15px; }
.list-item .meta small { color: var(--muted); font-size: 12px; }
.avatar {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--jade-soft); color: var(--jade);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}

/* Practice — blind-box simplified (SpeakUp jade) */
.practice-main { max-width: 560px; }
.practice-hero { margin-bottom: 16px; }
.practice-title { font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.practice-sub { font-size: 13px; margin-top: 4px; }
.practice-meta { margin-top: 14px; font-size: 13px; align-items: center; }
.practice-student { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.avatar.tiny { width: 28px; height: 28px; border-radius: 999px; font-size: 12px; }
.practice-card { text-align: center; padding: 22px 18px 18px; }
.practice-card.blind-practice { padding-top: 18px; }
.word-en { font-size: 30px; font-weight: 700; letter-spacing: 0.02em; margin: 4px 0 6px; color: var(--text); }
.word-zh { font-size: 15px; color: var(--muted); margin-bottom: 4px; }
.phonetic { font-size: 14px; color: var(--jade); margin-bottom: 8px; }
.practice-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }

.blind-box {
  width: 100%;
  min-height: 108px;
  border: 1.5px dashed #CBD5E1;
  border-radius: 16px;
  background: #F8FAFC;
  color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 18px 14px; margin-bottom: 18px;
  transition: border-color 0.15s, background 0.15s;
}
.blind-box:active { background: #F1F5F9; }
.blind-box.open {
  border-style: solid; border-color: rgba(15, 118, 110, 0.25);
  background: linear-gradient(180deg, rgba(15,118,110,0.06) 0%, #fff 70%);
  color: var(--text);
}
.blind-lock { color: var(--amber); display: inline-flex; }
.blind-hint { font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }

.speed-row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.speed-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.speed-pills { display: inline-flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.speed-pill {
  min-width: 52px; padding: 8px 12px; border-radius: 999px;
  background: #F1F5F9; color: var(--muted); font-size: 13px; font-weight: 700;
  border: 1px solid transparent;
}
.speed-pill.active {
  background: var(--jade); color: #fff;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.28);
}

.btn-speak {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 16px 18px; border-radius: 16px;
  background: var(--jade); color: #fff; font-size: 16px; font-weight: 700;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.28);
  margin-top: 16px;
  margin-bottom: 8px;
}
.btn-speak:active { transform: translateY(1px); }
.btn-speak.listening {
  background: var(--error);
  animation: pulse 1.2s ease infinite;
}

.practice-nav-row {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px;
  align-items: center; margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.btn-nav {
  padding: 12px 14px; border-radius: 14px; background: #F1F5F9;
  color: var(--text); font-weight: 600; font-size: 14px;
}
.btn-nav:active { background: #E2E8F0; }
.listen-fab {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--jade); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.35);
}
.listen-fab:active { transform: scale(0.96); }
.listen-fab svg { width: 26px; height: 26px; }

.feedback {
  margin-top: 14px; padding: 14px; border-radius: var(--radius-sm); text-align: left;
}
.feedback.ok { background: var(--ok-soft); color: #065F46; }
.feedback.bad { background: var(--error-soft); color: #991B1B; }
.feedback.mid { background: var(--amber-soft); color: #92400E; }

.practice-mic-note { margin-top: 12px; font-size: 12px; text-align: center; }
.practice-type { margin-top: 12px; text-align: left; }
.practice-type-mini {
  margin-top: 12px; display: flex; gap: 8px; align-items: center;
}
.said-mini {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: #fff; font-size: 14px;
}
.btn-sm { padding: 8px 12px; font-size: 13px; }
.btn-mark-done {
  margin-top: 14px; width: 100%; padding: 10px;
  color: var(--amber); font-weight: 700; font-size: 13px;
  background: transparent; border-radius: 12px;
}
.btn-mark-done:active { background: var(--amber-soft); }

.mic-pulse {
  width: 72px; height: 72px; border-radius: 50%; background: var(--jade);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.4);
}
.mic-pulse.listening { animation: pulse 1.2s ease infinite; background: var(--error); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
  70% { box-shadow: 0 0 0 18px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

@media (min-width: 720px) {
  .practice-title { font-size: 30px; }
  .practice-card.blind-practice { padding: 28px 28px 22px; }
  .listen-fab { width: 72px; height: 72px; }
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4);
  z-index: 200; display: flex; align-items: flex-end; justify-content: center;
  padding: 16px;
}
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
}
.modal {
  background: var(--surface); border-radius: 20px; width: 100%; max-width: 440px;
  padding: 24px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}
.modal h2 { margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 300; max-width: 90%;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty {
  text-align: center; padding: 32px 16px; color: var(--muted);
}
.empty svg { margin: 0 auto 12px; color: var(--jade); opacity: 0.5; }

.code-big {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 28px; letter-spacing: 0.2em; font-weight: 700; color: var(--jade);
  text-align: center; padding: 16px; background: var(--jade-soft); border-radius: 12px;
}

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  color: var(--muted); background: transparent; border: 1px solid var(--border);
}
.tab.active { background: var(--jade); color: #fff; border-color: var(--jade); }

@media (hover: hover) and (pointer: fine) {
  .tab:hover { color: var(--jade); border-color: var(--jade); box-shadow: 0 2px 8px rgba(15,118,110,0.1); }
}

.divider { height: 1px; background: var(--border); margin: 16px 0; }
.badge-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--amber); display: inline-block;
}

/* Teacher submissions / in-app notifications */
.notif-panel { border-color: #F59E0B55; background: linear-gradient(180deg, #FFFBEB 0%, #FFFFFF 48%); }
.notif-item:hover, .list-item.is-new { background: rgba(245, 158, 11, 0.08); }
.list-item.is-new { border-color: #F59E0B55; }
.card .pill { flex-shrink: 0; }


/* v1.1 British TTS / sync notes */
.voice-note {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.4;
  border: 1px solid var(--border, #E2E8F0);
  background: #fff;
}
.voice-note.ok {
  border-color: rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.06);
  color: var(--jade, #0F766E);
}
.voice-note.warn {
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.1);
  color: #92400E;
}
.notif-item:hover, .list-item.is-new {
  background: rgba(245, 158, 11, 0.08);
}


/* v1.2.5 recognition + wrong book */
.recog-card {
  margin-top: 14px; padding: 14px; border-radius: 14px; text-align: left;
  background: #F8FAFC; border: 1px solid var(--border);
}
.recog-card.ok { background: var(--ok-soft); border-color: rgba(5,150,105,0.25); }
.recog-card.bad { background: #FFF1F2; border-color: rgba(220,38,38,0.2); }
.recog-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 10px;
}
.recog-line {
  font-size: 15px; font-weight: 600; line-height: 1.45; margin-bottom: 4px;
}
.recog-line.ok { color: var(--ok); }
.recog-line.bad { color: var(--error); text-decoration: underline; text-decoration-style: wavy; text-underline-offset: 3px; }
.recog-line.heard { font-weight: 500; opacity: 0.95; }
.recog-legend {
  display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 10px;
  font-size: 12px; color: var(--muted); align-items: center;
}
.recog-legend .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}
.recog-legend .dot.ok { background: var(--ok); }
.recog-legend .dot.bad { background: var(--error); }
.btn-save-wrong {
  margin-top: 12px; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 14px; border-radius: 14px;
  background: #FEF3C7; color: #92400E; font-weight: 700; font-size: 14px;
  border: 1px solid rgba(245,158,11,0.35);
}
.btn-save-wrong:active { background: #FDE68A; }
.wrong-card { flex-wrap: wrap; align-items: flex-start; }
.wrong-card .wrong-note { display: block; color: var(--error); margin-top: 4px; }
.wrong-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
@media (min-width: 640px) {
  .wrong-actions { flex-direction: row; align-items: center; }
}

/* Topics preview — compact teacher courses + topic filters */
.compact-list .list-item, .course-row {
  padding: 10px 12px;
  gap: 8px;
  flex-wrap: wrap;
}
.compact-list .list-item .btn-sm, .course-row .btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}
.tabs-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.tabs-scroll .tab {
  flex: 0 0 auto;
  white-space: nowrap;
}
.topic-filter .tabs-scroll { max-width: 100%; }
label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.question-card textarea { width: 100%; }
.oral-box { border-top: 1px dashed rgba(15,118,110,.25); padding-top: 8px; }
@media (min-width: 900px) {
  .compact-list .list-item { align-items: center; }
}
@media (max-width: 520px) {
  .course-row .btn-sm { flex: 1 1 auto; }
}

.demo-banner {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #92400e;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 12px;
  line-height: 1.35;
}
.answer-text { margin-top: 4px; font-size: 13px; color: var(--text, #134e4a); }
.answer-row { align-items: flex-start; }

.oral-privacy {
  background: rgba(15, 118, 110, 0.06);
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(15, 118, 110, 0.15);
}

/* ===== v1.5 preview: responsive text + new compact components ===== */
.list-item { flex-wrap: wrap; }
.list-item .meta { flex: 1 1 12rem; min-width: 0; }
.list-item .meta strong, .list-item .meta small, .course-title, .course-meta, .hist-text, .import-pair { overflow-wrap: break-word; word-break: normal; }
.btn { white-space: normal; text-align: center; line-height: 1.25; min-height: 40px; }
.btn-sm { min-height: 36px; }
.row.spread { flex-wrap: wrap; }
.topbar-actions { min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
h1, h2, .lead { overflow-wrap: break-word; }
.modal { max-width: min(560px, calc(100vw - 24px)); overflow-x: hidden; }
.modal select, .modal input, .field select, .field input { max-width: 100%; min-width: 0; }

.course-row { flex-direction: column; align-items: stretch; gap: 10px; }
.course-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.course-title { font-size: 15px; display: block; }
.course-meta { color: var(--muted); font-size: 12px; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.course-actions, .item-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.item-actions { margin-left: auto; }
.danger-text { color: #b42318; }
.link-btn { background: none; border: 0; color: var(--jade); font-weight: 600; text-decoration: underline; padding: 0 2px; font-size: inherit; }

.chip-warn { background: #fef3c7; color: #92400e; border: 1px solid #f59e0b; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.chip-muted { background: var(--surface); color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-size: 12px; }

.asg-strip { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 10px; border-radius: var(--radius-sm); background: var(--jade-soft); flex-wrap: wrap; }
.asg-strip.done { background: #ecfdf3; }
.asg-text { flex: 1 1 10rem; min-width: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: center; }
.asg-bar { grid-column: 1 / -1; height: 6px; background: rgba(0,0,0,0.08); border-radius: 999px; overflow: hidden; }
.asg-bar i { display: block; height: 100%; background: var(--jade); }
.asg-picks { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; max-height: 40vh; overflow-y: auto; }
.asg-pick { display: flex; gap: 8px; align-items: flex-start; overflow-wrap: break-word; }

.retry-flow { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.retry-answer { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--jade-soft); overflow-wrap: break-word; }
.retry-steps { display: flex; gap: 8px; flex-wrap: wrap; }

.srs-bar { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.srs-counts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; }
.srs-upcoming { margin-top: 12px; }
.srs-upcoming summary { cursor: pointer; color: var(--jade); font-weight: 600; padding: 8px 0; }

.toggle-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; }
.toggle-row input { margin-top: 3px; width: 20px; height: 20px; flex: none; }
.toggle-row span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toggle-row small { font-size: 12px; }

.conflict-card { border: 1px solid #f59e0b; border-radius: var(--radius-sm); padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-wrap: break-word; }
.conflict-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 13px; }
@media (max-width: 400px) { .conflict-sides { grid-template-columns: 1fr; } }

.qr-box { display: flex; justify-content: center; padding: 12px; background: #fff; border-radius: var(--radius-sm); }
.qr-box svg { width: min(220px, 70vw); height: auto; }
.class-code { text-align: center; font: 700 28px ui-monospace, monospace; letter-spacing: 0.2em; margin: 8px 0; }

.import-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; max-height: 45vh; overflow-y: auto; }
.import-row { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; font-size: 14px; }
.import-row .pill { flex: none; }
.import-pair { flex: 1 1 10rem; min-width: 0; }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) { .grid-3 { grid-template-columns: 1fr; } }
.hist-list { display: flex; flex-direction: column; margin-top: 8px; max-height: 50vh; overflow-y: auto; }
.hist-row { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.hist-row .hist-text { grid-column: 2; }
@media (max-width: 400px) { .hist-row { grid-template-columns: 1fr; } .hist-row .hist-text { grid-column: 1; } }
.join-row .item-actions select { max-width: 12rem; }

/* ===== v1.5 viewport / nav stability (mobile) =====
   Root cause candidates in v1.4.3: html/body height:100% + body overflow-x:hidden made BODY the scroll
   container on iOS/Android (fixed nav jitters with rubber-band + toolbar resize); inputs <16px trigger
   iOS focus zoom (whole page incl. nav shifts sideways); wide rows created horizontal overflow. */
html { height: auto; min-height: 100%; overflow-x: hidden; overscroll-behavior-y: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { height: auto; min-height: 100vh; min-height: 100dvh; overflow-x: visible; overflow-x: clip; width: 100%; max-width: 100%; }
#app { width: 100%; max-width: 100%; min-width: 0; }
.main { width: 100%; min-width: 0; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.main > * { min-width: 0; max-width: 100%; }
.card { min-width: 0; max-width: 100%; }
input, select, textarea { font-size: 16px; } /* prevents iOS zoom-on-focus shifting the page */
.topbar { width: 100%; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
.bottom-nav { width: 100%; max-width: 100%; transform: translateZ(0); will-change: transform; touch-action: manipulation;
  padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); overscroll-behavior: contain; }
.bottom-nav .nav-inner { min-width: 0; }
.nav-item { min-width: 0; }
.nav-item span { max-width: 100%; overflow-wrap: break-word; text-align: center; line-height: 1.15; }
.tabs-scroll { max-width: 100%; min-width: 0; overscroll-behavior-x: contain; touch-action: pan-x pan-y; }
.modal-backdrop { padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.modal { max-height: 90vh; max-height: 90dvh; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
#toast { bottom: calc(var(--nav-h) + var(--safe-b) + 16px); max-width: calc(100vw - 32px); }
.practice-nav-row, .speed-row, .speed-pills { min-width: 0; flex-wrap: wrap; }
@media (max-width: 360px) {
  .main { padding-left: 12px; padding-right: 12px; }
  .card { padding: 14px; }
  .nav-item { margin: 6px 2px; font-size: 10.5px; }
}

/* ===== v1.5 overflow root-cause fixes (teacher dashboard sway video) =====
   `1fr` tracks = minmax(auto,1fr): a grid item's min-content (long label / nowrap pill / long sync line)
   forced the grid wider than the phone → document scrollWidth > viewport → page sways, nav shifts. */
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 520px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.role-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.practice-nav-row { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.grid-2 > *, .stat-grid > *, .role-cards > *, .grid-3 > * { min-width: 0; }
button.card { width: 100%; display: block; overflow-wrap: break-word; }
button.card .row { flex-wrap: wrap; min-width: 0; }
.stat .l, .stat .n { overflow-wrap: break-word; }
.notif-item .meta small { overflow-wrap: break-word; }
.main p, .main small, .main strong { overflow-wrap: break-word; }
.bottom-nav { transform: none; will-change: auto; } /* nav anchored to viewport; no transformed ancestors */

/* ===== v1.5 QA round 2 ===== */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.topbar { flex-wrap: nowrap; gap: 8px; }
.topbar .brand { min-width: 0; flex: 0 1 auto; }
.topbar-actions { flex-wrap: nowrap; gap: 6px; flex: 0 0 auto; }
.gear-btn { position: relative; }
.gear-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; border-radius: 999px; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; padding: 0 4px; }
.gear-badge.warn { background: #f59e0b; color: #fff; }
.gear-badge.dot { min-width: 8px; width: 8px; height: 8px; padding: 0; background: var(--muted); top: 6px; right: 6px; }
.sync-pill { border: 1px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 600; min-height: 28px; }
.sync-pill.warn { border-color: #f59e0b; background: #fef3c7; color: #92400e; }
@media (max-width: 480px) { .version-chip { display: none; } }
.settings-sheet { gap: 10px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.settings-sheet .divider { margin: 6px 0; }
.warn-btn { border-color: #f59e0b; color: #92400e; }
.search-field input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); min-height: 40px; }
.search-field input:focus { border-color: var(--jade); outline: none; }
.empty p { margin: 0 0 14px; }
.empty .btn { margin-top: 4px; }
/* IELTS chips: still scrollable (touch/trackpad/keyboard), scrollbar hidden, edge fade hints more */
.tabs-scroll { mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 24px), transparent); -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 24px), transparent); padding-right: 24px; }
.modal:focus { outline: none; }


/* ===== t1046u: sliding pill thumb only (no full-height track) =====
   Thin overlay scrollbar: transparent track + short rounded thumb.
   Scrolling unchanged (touch / wheel / keyboard). Preview only. */
html {
  scrollbar-width: thin; /* Firefox: thin thumb, no thick gutter */
  scrollbar-color: rgba(15, 23, 42, 0.28) transparent; /* thumb | track */
}
html::-webkit-scrollbar {
  width: 5px;
  height: 5px;
  background: transparent;
}
html::-webkit-scrollbar-track,
html::-webkit-scrollbar-track-piece {
  background: transparent;
  border: none;
  box-shadow: none;
}
html::-webkit-scrollbar-corner { background: transparent; }
html::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.28);
  border-radius: 999px;
  border: 1px solid transparent; /* keeps the pill short / inset look */
  background-clip: padding-box;
  min-height: 28px;
}
html::-webkit-scrollbar-thumb:active {
  background: rgba(15, 23, 42, 0.42);
  background-clip: padding-box;
}

/* Same pill on main content + chip/filter rows + sheets that scroll */
body,
#app,
.main,
.modal,
.import-rows,
.hist-list,
.asg-picks,
.tabs-scroll,
.srs-upcoming,
.list {
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 23, 42, 0.28) transparent;
}
body::-webkit-scrollbar,
#app::-webkit-scrollbar,
.main::-webkit-scrollbar,
.modal::-webkit-scrollbar,
.import-rows::-webkit-scrollbar,
.hist-list::-webkit-scrollbar,
.asg-picks::-webkit-scrollbar,
.tabs-scroll::-webkit-scrollbar,
.srs-upcoming::-webkit-scrollbar,
.list::-webkit-scrollbar {
  width: 5px;
  height: 5px;
  background: transparent;
}
body::-webkit-scrollbar-track,
#app::-webkit-scrollbar-track,
.main::-webkit-scrollbar-track,
.modal::-webkit-scrollbar-track,
.import-rows::-webkit-scrollbar-track,
.hist-list::-webkit-scrollbar-track,
.asg-picks::-webkit-scrollbar-track,
.tabs-scroll::-webkit-scrollbar-track,
.srs-upcoming::-webkit-scrollbar-track,
.list::-webkit-scrollbar-track,
body::-webkit-scrollbar-track-piece,
#app::-webkit-scrollbar-track-piece,
.main::-webkit-scrollbar-track-piece,
.modal::-webkit-scrollbar-track-piece,
.import-rows::-webkit-scrollbar-track-piece,
.hist-list::-webkit-scrollbar-track-piece,
.asg-picks::-webkit-scrollbar-track-piece,
.tabs-scroll::-webkit-scrollbar-track-piece,
.srs-upcoming::-webkit-scrollbar-track-piece,
.list::-webkit-scrollbar-track-piece {
  background: transparent;
  border: none;
  box-shadow: none;
}
body::-webkit-scrollbar-thumb,
#app::-webkit-scrollbar-thumb,
.main::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb,
.import-rows::-webkit-scrollbar-thumb,
.hist-list::-webkit-scrollbar-thumb,
.asg-picks::-webkit-scrollbar-thumb,
.tabs-scroll::-webkit-scrollbar-thumb,
.srs-upcoming::-webkit-scrollbar-thumb,
.list::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.28);
  border-radius: 999px;
  border: 1px solid transparent;
  background-clip: padding-box;
  min-height: 28px;
  min-width: 28px;
}
/* Chip rows already hide the bar via earlier rules; force the pill there too */
.tabs-scroll {
  scrollbar-width: thin !important;
  -ms-overflow-style: auto;
  /* keep edge fade; do not fully hide the thumb */
}
.tabs-scroll::-webkit-scrollbar {
  width: 5px !important;
  height: 5px !important;
  display: block !important;
  background: transparent;
}
