/* ── Page Header ── */
.page-header {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
  color: #fff;
  padding: 20px 20px 24px;
  flex-shrink: 0;
}
.page-header h1 { font-size: 1.35rem; font-weight: 800; line-height: 1.3; }
.page-header p { font-size: 0.88rem; opacity: .75; margin-top: 4px; }
.header-row { display: flex; align-items: center; justify-content: space-between; }

/* ── Card ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 0 16px 12px;
}
.card-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text3);
  margin-bottom: 10px;
}

/* ── Button ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); opacity: .85; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-secondary { background: var(--blue-light); color: var(--blue); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-danger { background: var(--rose-light); color: var(--rose); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Input ── */
.input-group { margin-bottom: 14px; }
.input-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.input {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
  font-family: inherit;
}
.input:focus { border-color: var(--blue); }

/* ── PIN dots ── */
.pin-wrap { display: flex; gap: 10px; justify-content: center; margin: 16px 0; }
.pin-dot {
  width: 44px;
  height: 52px;
  border: 2px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--blue);
  background: var(--surface2);
  transition: border-color .15s, background .15s;
}
.pin-dot.filled { border-color: var(--blue); background: var(--blue-light); }

/* ── Numpad ── */
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; }
.numpad-btn {
  height: 56px;
  border-radius: 14px;
  border: none;
  background: var(--surface2);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: background .1s, transform .1s;
  font-family: inherit;
}
.numpad-btn:active { background: var(--blue-light); transform: scale(.95); }
.numpad-btn.del { font-size: 1.1rem; color: var(--rose); }
.numpad-btn.empty { background: transparent; cursor: default; }

/* ── Avatar ── */
.avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
  line-height: 1;
}
.avatar-sm { width: 36px; height: 36px; font-size: 1.1rem; }

/* ── Child selection card ── */
.child-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 10px;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .15s, border-color .15s;
  font-family: inherit;
}
.child-card:active { transform: scale(.95); }
.child-card .child-name { font-size: 0.88rem; font-weight: 700; color: var(--text); }

/* ── Task item ── */
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  background: var(--surface);
  border-radius: 14px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  transition: opacity .2s;
}
.task-item.done { opacity: .55; }
.task-check {
  width: 26px; height: 26px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .15s;
  font-size: 14px;
  font-weight: 700;
}
.task-check.checked { background: var(--green); border-color: var(--green); color: #fff; }
.task-body { flex: 1; min-width: 0; }
.task-subject { font-size: 0.74rem; font-weight: 700; color: var(--blue); margin-bottom: 2px; }
.task-text { font-size: 0.9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-item.done .task-text { text-decoration: line-through; color: var(--text3); }

/* ── Progress bar ── */
.progress-wrap { height: 8px; background: rgba(255,255,255,.25); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: rgba(255,255,255,.9); border-radius: 999px; transition: width .5s ease; }

/* ── Stat row ── */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-val { font-size: 1.5rem; font-weight: 900; color: var(--blue); line-height: 1; }
.stat-label { font-size: 0.72rem; color: var(--text3); margin-top: 4px; }

/* ── Section ── */
.section { padding: 16px 16px 4px; }
.section-title {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text3);
  margin-bottom: 10px;
}

/* ── Quick grid ── */
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s;
  border: none;
  font-family: inherit;
}
.quick-item:active { transform: scale(.93); }
.quick-item .qi-icon { font-size: 1.6rem; line-height: 1; }
.quick-item .qi-label { font-size: 0.78rem; font-weight: 700; color: var(--text2); }

/* ── Empty state ── */
.empty { text-align: center; padding: 40px 20px; color: var(--text3); }
.empty-icon { font-size: 3rem; margin-bottom: 12px; line-height: 1; }
.empty-text { font-size: 0.9rem; }

/* ── Modal (bottom sheet) ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end;
  z-index: 1000;
  animation: fade-in .15s ease;
}
.modal {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 24px 20px 40px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slide-up .2s ease;
}
.modal-title { font-size: 1.1rem; font-weight: 800; text-align: center; margin-bottom: 20px; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(40px); } }

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: 16px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  border: none;
  font-size: 1.5rem;
  box-shadow: 0 4px 16px rgba(37,99,235,.4);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  transition: transform .15s;
}
.fab:active { transform: scale(.92); }

/* ── Segmented control ── */
.seg-ctrl { display: flex; background: var(--surface2); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.seg-btn {
  flex: 1; padding: 7px;
  border: none; background: transparent;
  border-radius: 8px;
  font-size: 0.85rem; font-weight: 700; color: var(--text3);
  cursor: pointer; transition: all .15s;
  font-family: inherit;
}
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* ── Subject colors ── */
.subject-math    { background: #eff6ff; color: #2563eb; }
.subject-chinese { background: #fdf4ff; color: #7c3aed; }
.subject-english { background: #f0fdf4; color: #16a34a; }
.subject-science { background: #fff7ed; color: #ea580c; }
.subject-other   { background: #f8fafc; color: #475569; }

/* ── Subject badge ── */
.subj-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: outline .1s;
  font-family: inherit;
}
.subj-badge.selected { outline: 2px solid var(--blue); }

/* ── Icon button (camera / mic) ── */
.icon-btn {
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
  font-family: inherit;
}
.icon-btn:active { background: var(--blue-light); transform: scale(.93); }

/* ── Dot loading animation ── */
.dot-loading {
  display: inline-block;
  letter-spacing: .2em;
  animation: dot-blink 1.2s infinite;
  font-size: .9rem;
  color: var(--text3);
}
@keyframes dot-blink {
  0%, 100% { opacity: .2; }
  50%       { opacity: 1;  }
}

/* ── Voice recording pulse ── */
@keyframes pulse-rec {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.6); }
}

/* ── Amber colour (used in English warning banner) ── */
:root { --amber-light: #fef3c7; }

/* ── Knowledge cards module ─────────────────────────────── */

/* Sub-category filter bar */
.k-filter-bar {
  padding: 10px 0 4px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.k-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 16px;
  scrollbar-width: none;
}
.k-filter-row::-webkit-scrollbar { display: none; }
.k-filter-name {
  flex-shrink: 0;
  font-size: .74rem;
  font-weight: 700;
  color: var(--text3);
  padding-right: 2px;
}
.k-chip {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: all .15s;
}
.k-chip:active { transform: scale(.95); }
.k-chip.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.k-chip .k-chip-count {
  opacity: .6;
  font-weight: 600;
  margin-left: 3px;
  font-size: .7rem;
}

/* Card */
.k-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin: 0 0 12px;
  cursor: pointer;
}
.k-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.k-card-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.35;
}
.k-card-title.idiom { font-size: 1.1rem; font-weight: 900; letter-spacing: .05em; }
.k-card-sub {
  font-size: .78rem;
  color: var(--text3);
  margin-top: 3px;
}
.k-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.k-act-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.05rem;
  padding: 4px;
  line-height: 1;
}
.k-caret { color: var(--text3); font-size: .8rem; }

.k-tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.k-tag {
  display: inline-block;
  background: var(--blue-light);
  color: var(--blue);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: .7rem;
  font-weight: 700;
}

.k-body {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.k-body .k-content {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: .92rem;
  line-height: 2;
  color: var(--text);
  margin: 0;
}
.k-body .k-para {
  font-size: .86rem;
  color: var(--text2);
  line-height: 1.75;
  margin-top: 10px;
}
.k-body .k-para strong { color: var(--text); }
.k-body .k-figures {
  font-size: .8rem;
  color: var(--text3);
  margin-top: 8px;
}

.k-ai-btn-wrap { text-align: center; margin-top: 14px; }
.k-ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: 1.5px solid var(--blue);
  border-radius: 999px;
  background: var(--blue-light);
  color: var(--blue);
  font-size: .84rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

/* ── Account bar ── */
#account-bar {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 6px 12px;
  display: flex;
  align-items: center;
}
.acct-bar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 20px;
  border: none;
  background: var(--surface2);
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.acct-bar-btn:active { background: var(--blue-light); }
.acct-bar-name {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
}
.acct-bar-arrow {
  font-size: .7rem;
  color: var(--text3);
}

/* ── Account switcher (bottom sheet) ── */
.as-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
  margin-bottom: 6px;
}
.as-item:active { background: var(--surface2); }
.as-item.active { background: var(--blue-light); }
.as-name {
  flex: 1;
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
}
.as-badge {
  font-size: .75rem;
  font-weight: 700;
  color: var(--blue);
  background: var(--surface);
  padding: 3px 10px;
  border-radius: 999px;
}
.as-logout {
  padding: 6px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--rose);
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.as-logout:active { background: var(--rose-light); }

/* ── Logged-in child card badge ── */
.child-card.logged-in {
  border-color: var(--green);
}
.child-loggedin-badge {
  display: inline-block;
  background: var(--green);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

/* ── Quiz status row ── */
.quiz-status {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 16px; font-size: .75rem; color: var(--text3);
  background: var(--surface2); border-top: 1px solid var(--border);
  flex-shrink: 0; min-height: 28px;
}
.quiz-status-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); flex-shrink: 0;
}
.quiz-status-dot.busy { background: #FDCB6E; animation: pulse-rec 1s infinite; }

/* ── Wave bars (sound visualization) ── */
.quiz-wave {
  display: none; align-items: center; justify-content: center;
  gap: 3px; height: 22px; margin: 0 2px; flex-shrink: 0;
}
.quiz-wave.active { display: flex; }
.quiz-wave .wave-bar {
  width: 3px; height: 6px; border-radius: 2px;
  background: var(--blue);
  animation: waveAnim 0.8s ease-in-out infinite;
}
.quiz-wave .wave-bar:nth-child(1) { animation-delay: 0s; }
.quiz-wave .wave-bar:nth-child(2) { animation-delay: 0.1s; }
.quiz-wave .wave-bar:nth-child(3) { animation-delay: 0.2s; }
.quiz-wave .wave-bar:nth-child(4) { animation-delay: 0.3s; }
.quiz-wave .wave-bar:nth-child(5) { animation-delay: 0.4s; }
@keyframes waveAnim {
  0%, 100% { height: 6px; }
  50% { height: 20px; background: var(--rose); }
}

/* ── Mic button recording state ── */
.icon-btn.recording {
  background: linear-gradient(135deg, #FF6B6B, #EE5A24) !important;
  color: #fff; border-color: #EE5A24;
  animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(255,107,107,0.4); }
  50% { box-shadow: 0 4px 20px rgba(255,107,107,0.75); }
}

