:root {
  --qc-blue: #003399;
  --qc-blue-deep: #002266;
  --qc-blue-azure: #0047ab;
  --qc-blue-on-dark: #7eb6ff;
  --qc-white: #ffffff;
  --qc-gold: #e8a317;
  --qc-gold-soft: #f5c842;
  --qc-green: #34c759;
  --qc-purple: #af52de;
  --qc-red: #ff453a;
  --qc-orange: #ffb340;
  --qc-red-fill: #d32f2f;
  --qc-orange-fill: #c2410c;
  --qc-green-fill: #0e7a2e;
  --qc-easy-fill: #1a52d5;
  --gold-fill: #f5c842;

  --bg: #0a1020;
  --surface: #0f1830;
  --card: #141e38;
  --elevated: #1a2748;
  --input: #0d1529;
  --border: #3d4f7a;
  --text: #f5f7fa;
  --text-2: #c5cdd8;
  --text-3: #a8b4c8;
  --accent: #7eb6ff;
  --gold: #f5c842;
  --success: #34c759;
  --danger: #ff453a;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --touch: 44px;
  --space: 16px;
  --shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.4);
  --ease: cubic-bezier(0.2, 0, 0, 1);

  --font-h: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --nav-h: 64px;
  --sidebar-w: 248px;
}

html.light-mode,
body.light-mode {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --card: #ffffff;
  --elevated: #eef2f8;
  --input: #f5f7fb;
  --border: #9aa6ba;
  --text: #0b1220;
  --text-2: #3a4556;
  --text-3: #4a586e;
  --accent: #003399;
  --gold: #8a5f00;
  --success: #0e7a2e;
  --danger: #d32f2f;
  --qc-gold-soft: #8a5f00;
  --gold-fill: #e8a317;
  --qc-easy-fill: #003399;
  --shadow: 0 4px 16px -4px rgba(15, 23, 42, 0.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { overflow: hidden; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
img, svg { display: block; }

.app {
  display: flex;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

.sidebar {
  display: none;
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  padding: 22px 14px;
  flex-direction: column;
  gap: 20px;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-title { font-family: var(--font-h); font-weight: 800; font-size: 16px; letter-spacing: -0.02em; }
.brand-title span { color: var(--gold); }
.brand-sub { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }

.crest {
  width: 42px; height: 28px; border-radius: 5px;
  overflow: hidden;
  background: #003da5;
  box-shadow: 0 0 0 1px rgba(0, 51, 153, 0.35), 0 8px 20px rgba(0, 51, 153, 0.25);
  flex-shrink: 0;
}
.crest img { width: 100%; height: 100%; display: block; object-fit: cover; }
.crest-sm { width: 36px; height: 24px; border-radius: 4px; }
.crest-lg { width: 72px; height: 48px; border-radius: 8px; margin: 0 auto 12px; }

.flag {
  display: block;
  flex-shrink: 0;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
  object-fit: cover;
}
.flag-qc { width: 22px; height: 15px; }
.flag-ca { width: 22px; height: 11px; }

.dict-lang {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 12px;
}
.dict-lang-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.dict-lang-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  margin: 0;
  color: var(--accent);
}
.dict-lang.en .dict-lang-title { color: var(--success); }
.dict-lang .lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  margin: 10px 0 2px;
}
.dict-lang .meaning {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
  margin: 0;
}

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--touch); padding: 10px 12px;
  border-radius: var(--radius); color: var(--text-3); font-weight: 600;
  text-align: left;
}
.nav-item:hover { background: var(--elevated); color: var(--text); }
.nav-item.is-active { background: color-mix(in srgb, var(--qc-blue) 18%, transparent); color: var(--gold); }
.nav-ico { width: 18px; text-align: center; opacity: 0.9; }
.nav-badge {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--qc-red-fill); color: #fff;
  font-size: 11px; font-weight: 800; display: grid; place-items: center;
}

.side-user {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border-radius: var(--radius);
  background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.side-user-meta { flex: 1; display: flex; flex-direction: column; }
.side-user-meta span { color: var(--text-3); font-size: 12px; }

.shell {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  height: 100%;
}

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
  min-height: 56px;
}
.topbar-brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-h); font-weight: 800; min-width: 0; }
.topbar-brand strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-pills { display: flex; gap: 8px; flex: 1; min-width: 0; overflow: hidden; }
.pill {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
  background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  border-radius: 999px; padding: 6px 10px; font-size: 13px; white-space: nowrap;
}
.pill b { font-family: var(--font-h); }
.pill-lbl { color: var(--text-3); font-size: 12px; }

.topbar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
@media (max-width: 600px) {
  .topbar { gap: 6px; padding: 8px 10px; }
  .topbar-actions { gap: 4px; }
  .pill { padding: 5px 8px; gap: 4px; font-size: 12px; }
  .icon-btn { width: 36px; height: 36px; }
  .chip-btn { min-height: 34px; padding: 0 8px; }
  .topbar-actions .text-btn.hide-desktop { font-size: 12px; padding: 6px 8px; }
  .topbar-brand strong { display: none; }
}

.chip-btn {
  min-height: 36px; padding: 0 10px; border-radius: 999px;
  background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  font-weight: 800; font-size: 12px; letter-spacing: 0.02em;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
  display: grid; place-items: center; font-size: 16px;
}
.icon-btn:hover { background: var(--elevated); }

.main {
  flex: 1; overflow: auto;
  padding: 16px 16px calc(var(--nav-h) + 36px);
  -webkit-overflow-scrolling: touch;
}

.screen { display: none; max-width: 920px; margin: 0 auto; }
.screen.is-active { display: block; animation: fade .22s var(--ease); }

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.hero {
  background: linear-gradient(135deg, var(--qc-blue), var(--qc-blue-deep));
  color: #fff; border-radius: var(--radius-xl); padding: 22px 20px;
  box-shadow: var(--shadow);
}
.hero-kicker {
  font-size: 12px; font-weight: 800; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--qc-gold-soft); margin-bottom: 6px;
}
html.light-mode .hero-kicker { color: #f5c842; }
.hero h1 { font-family: var(--font-h); font-size: 22px; line-height: 1.25; margin-bottom: 6px; color: #fff; }
.hero p { color: rgba(255,255,255,.88); font-size: 14px; margin-bottom: 16px; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.grid-2 { display: grid; gap: 12px; margin-top: 14px; }
.stats-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.card {
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h3 { font-family: var(--font-h); font-size: 16px; }
.card-note { color: var(--text-3); font-size: 13px; margin-top: 8px; }

.badge {
  display: inline-flex; align-items: center; min-height: 22px;
  padding: 0 8px; border-radius: 999px; font-size: 11px; font-weight: 800;
}
.badge-green { background: color-mix(in srgb, var(--qc-green) 18%, transparent); color: var(--success); }
.badge-purple { background: color-mix(in srgb, var(--qc-purple) 18%, transparent); color: #c77dff; }
html.light-mode .badge-purple { color: #7b1fa2; }
.badge-gold { background: color-mix(in srgb, var(--qc-gold) 18%, transparent); color: var(--gold); }
.badge-blue { background: color-mix(in srgb, var(--qc-blue) 18%, transparent); color: var(--accent); }

.progress {
  height: 10px; background: var(--input); border-radius: 999px; overflow: hidden;
}
.progress > span {
  display: block; height: 100%; background: var(--success);
  border-radius: inherit; width: 0; transition: width .3s var(--ease);
}

.srs-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.srs-cell {
  background: var(--elevated); border-radius: 12px; padding: 10px 4px;
  text-align: center; border: 1px solid transparent;
}
.srs-cell b { display: block; font-family: var(--font-h); font-size: 18px; }
.srs-cell small { color: var(--text-3); font-size: 10px; font-weight: 700; }

.stat-box { text-align: center; padding: 10px 4px; }
.stat-box .num { display: block; font-family: var(--font-h); font-size: 22px; font-weight: 800; }
.stat-box .lbl { color: var(--text-3); font-size: 12px; }

.week-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 10px; }
.week-day { text-align: center; }
.week-day span { display: block; font-size: 11px; font-weight: 700; color: var(--text-3); margin-bottom: 6px; }
.week-dot {
  height: 28px; border-radius: 8px;
  background: var(--input); border: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
}
.week-dot.on { background: var(--success); border-color: transparent; }
.week-dot.today { outline: 2px solid var(--gold); outline-offset: 1px; }

.btn {
  min-height: var(--touch); padding: 0 16px; border-radius: 14px;
  font-family: var(--font-h); font-weight: 700; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible,
.chip-btn:focus-visible, .rate:focus-visible, .btn-listen:focus-visible,
.nav-item:focus-visible, .bottom-item:focus-visible, .text-btn:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}
.btn-gold { background: var(--gold-fill); color: #111; font-weight: 800; }
.btn-gold:hover { filter: brightness(1.06); }
.btn-primary {
  background: color-mix(in srgb, var(--qc-blue) 88%, #000);
  color: #fff;
}
.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  font-weight: 600;
}
.btn-secondary:hover { background: var(--elevated); }
.hero .btn-secondary {
  color: #fff; border-color: rgba(255,255,255,.32); background: rgba(255,255,255,.1);
}
.hero .btn-secondary:hover { background: rgba(255,255,255,.18); }
.btn-danger { background: transparent; border: 1px solid color-mix(in srgb, var(--qc-red) 45%, transparent); color: var(--danger); }
.btn-wide { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }
.btn-link {
  min-height: 40px; padding: 0 8px; font-weight: 600; font-size: 13px;
  color: var(--accent); text-decoration: underline; text-underline-offset: 3px;
}
.text-btn {
  min-height: 36px; padding: 0 10px; border-radius: 999px;
  font-weight: 700; font-size: 12px; letter-spacing: 0.02em;
  color: var(--text-2);
  border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  background: var(--card);
}
.text-btn:hover { color: var(--text); background: var(--elevated); }

.listen-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 0 0 14px;
}
.btn-listen {
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  background: color-mix(in srgb, var(--qc-blue) 16%, transparent);
  color: var(--accent); font-weight: 700; font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--qc-blue) 28%, transparent);
}
.btn-listen:hover { background: color-mix(in srgb, var(--qc-blue) 26%, transparent); }
.btn-listen:active { transform: translateY(1px); }
.speed-row {
  display: inline-flex; align-items: center; gap: 4px; margin-left: auto;
  background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 999px; padding: 3px 6px;
}
.speed-tag {
  font-size: 11px; font-weight: 700; color: var(--text-3);
  padding: 0 4px;
}
.speed-btn {
  min-height: 30px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: var(--text-3);
  border: none; background: transparent; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.speed-btn:hover { color: var(--text); }
.speed-btn.is-on {
  background: var(--gold-fill);
  color: #111;
  font-weight: 800;
}

.study-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
}
.study-head .meta { flex: 1; min-width: 0; }
.study-head .meta strong { display: block; font-size: 14px; }
.study-head .meta small { color: var(--text-3); }
.study-head .count { font-weight: 800; font-size: 13px; }

.flash-wrap {
  perspective: 1800px;
  perspective-origin: 50% 42%;
  min-height: 360px;
  margin-bottom: 16px;
}
.flashcard {
  width: 100%; min-height: 360px; position: relative;
  transform-style: preserve-3d;
  transition: transform .56s cubic-bezier(0.22, 1, 0.36, 1);
  cursor: pointer;
  transform: rotateY(0deg) translateZ(0);
  will-change: transform;
}
.flashcard.is-flipped { transform: rotateY(180deg) translateZ(0); }
.flashcard.no-anim { transition: none; }
.flash-face {
  position: absolute; inset: 0;
  border: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  border-radius: var(--radius-xl);
  padding: 28px 20px 22px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  text-align: center;
  box-shadow: 0 18px 42px -18px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}
.flash-front {
  transform: rotateY(0deg) translateZ(1px);
  background:
    radial-gradient(120% 70% at 50% -10%, color-mix(in srgb, var(--qc-gold) 18%, transparent), transparent 58%),
    linear-gradient(180deg, color-mix(in srgb, var(--elevated) 70%, var(--card)), var(--card));
}
.flash-back {
  transform: rotateY(180deg) translateZ(1px);
  background:
    radial-gradient(120% 70% at 50% -10%, color-mix(in srgb, var(--success) 20%, transparent), transparent 58%),
    linear-gradient(180deg, color-mix(in srgb, var(--elevated) 70%, var(--card)), var(--card));
}
html.light-mode .flash-face {
  box-shadow: 0 14px 28px -16px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.7) inset;
}
.flash-word {
  font-family: var(--font-h); font-size: clamp(28px, 7vw, 42px);
  font-weight: 800; color: var(--text); letter-spacing: -0.03em; line-height: 1.15;
}
.flash-back .flash-word { color: var(--success); font-size: clamp(24px, 6vw, 34px); }
.flash-hint { color: var(--text-3); font-size: 13px; }
.flash-phon { color: var(--accent); font-weight: 700; }
.flash-flip-ico {
  width: 36px; height: 36px; border-radius: 999px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--qc-white) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
  color: var(--text-3); font-size: 16px;
  animation: flip-nudge 2.4s var(--ease) infinite;
}
.flashcard.is-flipped .flash-flip-ico { animation: none; }
@keyframes flip-nudge {
  0%, 70%, 100% { transform: rotateY(0deg); }
  80% { transform: rotateY(22deg); }
  90% { transform: rotateY(-8deg); }
}

#study-actions { min-height: 56px; }
#study-actions .rating-grid,
#study-actions .btn-wide {
  animation: rise-in .32s var(--ease);
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .flashcard, #study-actions .rating-grid, #study-actions .btn-wide { transition: none; animation: none; }
  .flash-flip-ico { animation: none; }
}

.rating-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rate {
  min-height: 56px; border-radius: 14px; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--font-h);
}
.rate b { font-size: 14px; }
.rate small { opacity: .9; font-size: 11px; font-weight: 600; }
.rate .mark { font-size: 12px; opacity: .85; margin-bottom: 1px; }
.rate-again { background: var(--qc-red-fill); }
.rate-hard { background: var(--qc-orange-fill); }
.rate-good { background: var(--qc-green-fill); }
.rate-easy { background: var(--qc-easy-fill); }
.rate:active { filter: brightness(0.92); }

.track-row, .chip-row {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px;
  scrollbar-width: none;
}
.track-row::-webkit-scrollbar, .chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: 38px; padding: 0 12px; border-radius: 12px;
  background: var(--elevated); border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  font-weight: 700; font-size: 13px; white-space: nowrap;
}
.chip.is-on { background: var(--gold-fill); color: #111; border-color: transparent; }

.sentence-box { text-align: center; }
.sentence-fr { font-size: 20px; font-weight: 700; line-height: 1.45; margin: 8px 0; }
.sentence-en { color: var(--text-2); font-size: 15px; }
.sentence-en.primary-en { color: var(--text); font-size: 20px; font-weight: 700; line-height: 1.45; margin: 8px 0; }
.word-chip {
  display: inline-block; margin: 3px 2px; padding: 4px 8px;
  background: var(--elevated); border-radius: 8px; cursor: pointer;
}
.word-chip:hover { background: color-mix(in srgb, var(--qc-blue) 22%, transparent); color: var(--accent); }
.punct { background: none; padding: 0; margin: 0; font-weight: 600; color: var(--text-3); }
.explain { margin-top: 10px; color: var(--accent); font-size: 13px; }

.search-input {
  width: 100%; min-height: var(--touch); padding: 0 14px;
  border-radius: 14px; border: 1px solid var(--border);
  background: var(--card); margin: 10px 0 12px;
}
.search-input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.dict-list { display: flex; flex-direction: column; gap: 8px; }
.dict-card {
  background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  border-radius: 14px; padding: 12px 14px; display: flex; gap: 10px; align-items: center;
}
.dict-card .fr { font-family: var(--font-h); font-weight: 800; font-size: 17px; }
.dict-card .en { color: var(--gold); font-weight: 700; }
.dict-card .ph { color: var(--accent); font-size: 12px; }
.dict-card .pos { color: var(--text-3); font-size: 12px; }
.dict-card .grow { flex: 1; min-width: 0; }
.dict-card .btn-listen { flex-shrink: 0; min-height: 36px; padding: 0 12px; }

.settings-block { margin-bottom: 18px; }
.settings-block h3 { font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); margin-bottom: 10px; }
.setting-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 35%, transparent);
}
.setting-row p { color: var(--text-3); font-size: 13px; }
.seg { display: flex; background: var(--elevated); border-radius: 12px; padding: 3px; }
.seg button { min-height: 36px; padding: 0 12px; border-radius: 10px; font-weight: 700; font-size: 13px; }
.seg button.is-on { background: var(--gold-fill); color: #111; }
.input-select {
  min-height: 40px; padding: 0 10px; border-radius: 10px;
  background: var(--input); border: 1px solid var(--border);
}
.info-link {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 46px; width: 100%; text-align: left; font-weight: 600;
}

.science h2 { font-family: var(--font-h); font-size: 22px; margin-bottom: 6px; }
.science .lede { color: var(--text-3); margin-bottom: 16px; }
.chart-wrap { width: 100%; height: 260px; }
.milestone { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 30%, transparent); }
.milestone p { color: var(--text-3); font-size: 13px; }

.connect-grid { display: grid; gap: 10px; }
.connective { background: var(--elevated); border-radius: 12px; padding: 12px; }
.connective ul { margin-left: 16px; color: var(--text-2); font-size: 13px; }
.connective .t { font-weight: 800; margin-bottom: 6px; color: var(--gold); }

.analog-clock { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 8px 0 4px; }
.clock-face {
  width: 128px; height: 128px; border-radius: 50%;
  background: var(--elevated); border: 3px solid var(--qc-blue);
  position: relative;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--qc-blue) 25%, transparent);
}
.clock-mark {
  position: absolute; background: var(--text-3); border-radius: 1px;
  left: 50%; top: 50%; width: 3px; height: 10px;
  transform-origin: center 64px;
}
.clock-mark.m12 { transform: translate(-50%, -64px); }
.clock-mark.m3 { transform: translate(-50%, -64px) rotate(90deg); }
.clock-mark.m6 { transform: translate(-50%, -64px) rotate(180deg); }
.clock-mark.m9 { transform: translate(-50%, -64px) rotate(270deg); }
.clock-hand {
  position: absolute; left: 50%; bottom: 50%; transform-origin: bottom center;
  background: var(--text); border-radius: 2px;
}
.clock-hand.hour { width: 4px; height: 32px; margin-left: -2px; background: var(--gold); }
.clock-hand.minute { width: 2px; height: 44px; margin-left: -1px; }
.clock-center {
  position: absolute; width: 8px; height: 8px; border-radius: 50%;
  background: var(--qc-red); left: 50%; top: 50%; margin: -4px 0 0 -4px;
}
.clock-digital { font-weight: 800; color: var(--gold); }

.empty {
  text-align: center; padding: 48px 16px; color: var(--text-3);
}
.empty h3 { color: var(--text); margin: 8px 0; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
  display: grid; grid-template-columns: repeat(5, 1fr);
  z-index: 20;
}
.nav-svg {
  width: 20px; height: 20px;
  stroke: currentColor; fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#theme-toggle .ico-moon { display: none; fill: currentColor; stroke: none; }
html.light-mode #theme-toggle .ico-sun { display: none; }
html.light-mode #theme-toggle .ico-moon { display: block; }

.bottom-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-3); font-weight: 600; position: relative;
}
.bottom-item::before {
  content: ""; width: 16px; height: 3px; border-radius: 99px;
  background: transparent;
}
.bottom-item small { font-size: 12px; font-weight: 700; letter-spacing: 0.01em; }
.bottom-item.is-active { color: var(--gold); }
.bottom-item.is-active::before { background: var(--gold); }
.bottom-nav.is-hidden { display: none; }
.bottom-nav.is-hidden ~ .shell .main,
body:has(.bottom-nav.is-hidden) .main { padding-bottom: 24px; }
.dot-badge {
  position: absolute; top: 6px; right: calc(50% - 22px);
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--qc-red-fill); color: #fff; border-radius: 999px;
  font-size: 10px; font-style: normal; font-weight: 800;
  display: grid; place-items: center;
}

.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  display: grid; place-items: center; padding: 20px;
  backdrop-filter: blur(10px);
}
.overlay[hidden], .modal-overlay[hidden] { display: none !important; }
.welcome-card {
  max-width: 440px; background: var(--card); border-radius: 28px;
  padding: 28px 22px; text-align: center;
  border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.welcome-card h1 { font-family: var(--font-h); font-size: 28px; margin-bottom: 8px; }
.welcome-card p { color: var(--text-2); }
.welcome-points { text-align: left; margin: 16px 0 20px; color: var(--text-2); padding-left: 18px; }
.welcome-points li { margin: 6px 0; }
.fine { margin-top: 10px; font-size: 12px; color: var(--text-3); }

.modal-overlay {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(4, 8, 18, 0.55);
  display: grid; place-items: end center;
  padding: 12px;
  cursor: pointer;
}
.modal-overlay .modal { cursor: default; }
.modal {
  width: min(640px, 100%);
  max-height: min(88dvh, 760px);
  overflow: auto;
  background: var(--card); border-radius: 22px 22px 16px 16px;
  border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  box-shadow: var(--shadow);
}
.modal-sm { width: min(440px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 8px; position: sticky; top: 0; background: var(--card);
}
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 8px 16px 18px; }
.tense-tabs { display: flex; gap: 6px; padding: 0 14px 10px; overflow-x: auto; }
.tense-tabs button {
  flex: 0 0 auto; min-height: 34px; padding: 0 10px; border-radius: 10px;
  background: var(--elevated); font-size: 12px; font-weight: 700; color: var(--text-3);
}
.tense-tabs button.is-on { background: var(--qc-blue); color: #fff; }
.conj-table { width: 100%; border-collapse: collapse; }
.conj-table td { padding: 8px 4px; border-bottom: 1px solid color-mix(in srgb, var(--border) 30%, transparent); }
.conj-table td:first-child { color: var(--text-3); width: 34%; }

.goal-modal { text-align: center; padding: 24px 18px; place-self: center; }
.talk-group {
  font-size: 13px; font-weight: 800; color: var(--gold);
  margin: 22px 0 10px; letter-spacing: 0.04em; text-transform: uppercase;
}
.talk-card {
  width: 100%; display: flex; flex-direction: column; gap: 12px;
  text-align: left; background: var(--card);
  border: 1px solid color-mix(in srgb, var(--border) 65%, transparent);
  border-radius: 18px; padding: 16px; margin-bottom: 14px;
}
.talk-card-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.talk-scene {
  font-size: 11px; font-weight: 800; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-radius: 999px; padding: 4px 10px;
}
.talk-lines { font-size: 11px; font-weight: 700; color: var(--text-3); }
.talk-card-main { display: flex; align-items: center; gap: 10px; }
.talk-card .grow { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.talk-card strong { font-size: 17px; line-height: 1.25; }
.talk-roles { color: var(--gold); font-size: 12px; font-weight: 700; }
.talk-why { margin: 0; color: var(--text-3); font-size: 13px; line-height: 1.4; }
.punk {
  width: 40px; height: 40px; border-radius: 8px;
  image-rendering: pixelated;
  background: var(--elevated);
  border: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
  flex-shrink: 0;
}
.punk-lg { width: 52px; height: 52px; border-radius: 10px; }
.talk-turn {
  display: flex; align-items: flex-end; gap: 8px; margin-bottom: 10px;
}
.talk-turn.is-you { justify-content: flex-end; }
.talk-turn.is-playing .talk-bubble {
  border-color: var(--gold-fill);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold-fill) 45%, transparent);
}
.talk-plain { font-weight: 700; font-size: 16px; line-height: 1.4; }
.talk-word {
  display: inline-block;
  font-weight: 700; font-size: 16px; line-height: 1.6;
  padding: 2px 6px; margin: 0 1px;
  border-radius: 6px;
  transition: background-color 0.14s ease, color 0.14s ease, transform 0.14s ease;
}
.talk-word.is-active {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--text);
  transform: scale(1.05);
}
.talk-bubble {
  max-width: 82%;
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
  border-radius: 14px; padding: 10px 12px;
}
.talk-turn.is-you .talk-bubble { background: var(--elevated); }
.talk-bubble-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 6px;
}
.talk-bubble-head b { font-size: 11px; color: var(--accent); }
.talk-turn.is-you .talk-bubble-head b { color: var(--gold); }
.btn-turn-audio {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--text); border: none; font-size: 12px; cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}
.talk-turn.is-you .btn-turn-audio {
  background: color-mix(in srgb, var(--gold-fill) 20%, transparent);
}
.btn-turn-audio:hover { transform: scale(1.1); }
.btn-turn-audio:active { transform: scale(0.95); }

.talk-controls {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
  border-radius: 14px; padding: 10px 12px; margin-bottom: 12px;
}
.talk-controls .speed-row { margin-left: 0; }
.talk-words { display: flex; flex-wrap: wrap; gap: 4px; }
.talk-bubble .btn-listen { min-height: 28px; padding: 0 8px; font-size: 11px; }

.goal-mark {
  width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center;
  margin: 0 auto 8px;
  background: color-mix(in srgb, var(--gold-fill) 22%, transparent);
  color: var(--gold); font-size: 28px; font-weight: 800;
}

.toasts {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px;
  z-index: 50; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--elevated); color: var(--text); border-radius: 12px;
  padding: 10px 14px; box-shadow: var(--shadow); font-weight: 600; font-size: 13px;
  border: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
}
.toast.ok { border-color: color-mix(in srgb, var(--qc-green) 50%, transparent); }
.toast.err { border-color: color-mix(in srgb, var(--qc-red) 50%, transparent); }

.hide-desktop { display: flex; }
.hide-mobile { display: none; }

@media (min-width: 900px) {
  .sidebar { display: flex; }
  .bottom-nav { display: none; }
  .main { padding: 24px 28px 32px; }
  .hide-desktop { display: none !important; }
  .hide-mobile { display: flex; }
  .hero h1 { font-size: 26px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .connect-grid { grid-template-columns: 1fr 1fr; }
  .rating-grid { grid-template-columns: repeat(4, 1fr); }
  .modal-overlay { place-items: center; }
  .modal { border-radius: 22px; }
}

@media (max-width: 420px) {
  .pill-lbl { display: none; }
  .flash-wrap, .flashcard { min-height: 300px; }
}

/* Matching pairs drill */
.match-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.match-card {
  min-width: 0;
  min-height: 68px;
  border-radius: var(--radius-lg);
  border: 2px solid color-mix(in srgb, var(--border) 55%, transparent);
  background: var(--card);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
  -webkit-tap-highlight-color: transparent;
}
.match-card:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
.match-card:active {
  transform: scale(0.985);
}
.match-card.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}
.match-card.is-matched {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
  pointer-events: none;
  transition: background 0.3s ease, border-color 0.3s ease;
  animation: match-pop 0.28s var(--ease);
}
.match-card.is-error {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger);
  animation: match-shake 0.3s var(--ease);
}
@keyframes match-pop {
  0% { transform: scale(0.96); }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
@keyframes match-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
.match-promo {
  margin-top: 12px;
  border-radius: var(--radius-xl);
  padding: 20px;
  color: var(--qc-white);
  background:
    radial-gradient(120% 70% at 90% -20%, rgba(255, 255, 255, 0.16), transparent 55%),
    linear-gradient(135deg, var(--qc-blue-azure), var(--qc-blue-deep));
}
.match-promo-head { display: flex; align-items: center; gap: 8px; }
.match-promo-ico { font-size: 24px; line-height: 1; }
.match-promo h3 {
  font-family: var(--font-h);
  font-size: 19px;
  font-weight: 800;
  margin: 8px 0 2px;
  color: var(--qc-white);
}
.match-promo p {
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  line-height: 1.45;
  margin: 0 0 12px;
}
.match-promo-tiles {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.match-promo-tile {
  flex: 1;
  text-align: center;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius);
  padding: 9px 6px;
  font-weight: 800;
  font-size: 14px;
}
.match-promo-arrow { color: var(--qc-gold-soft); font-weight: 800; }
.match-promo .btn { margin-top: 2px; }
.match-roundbar {
  height: 4px;
  border-radius: 99px;
  background: var(--border);
  margin: 0 0 12px;
  overflow: hidden;
}
.match-roundbar span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.25s var(--ease);
}
.match-hint {
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  margin-top: 14px;
}
.match-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
}
.match-foot .match-hint { margin-top: 0; }
.match-review-note {
  color: var(--text-3);
  font-size: 12px;
  margin: 6px 2px 14px;
}
.match-review-head {
  font-family: var(--font-h);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 16px 2px 8px;
}
.match-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
}
.match-row:active { transform: scale(0.995); }
.match-row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.match-row-text b { font-size: 14px; color: var(--text); }
.match-row-text span { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-row .btn-listen { font-size: 11px; }
.match-done {
  background:
    radial-gradient(120% 70% at 50% -10%, color-mix(in srgb, var(--success) 18%, transparent), transparent 58%),
    linear-gradient(180deg, color-mix(in srgb, var(--elevated) 70%, var(--card)), var(--card));
  border: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  border-radius: var(--radius-xl);
  padding: 32px 22px;
  text-align: center;
  animation: rise-in 0.32s var(--ease);
}
.match-done-emoji { font-size: 44px; margin-bottom: 8px; }
.match-done h2 { font-family: var(--font-h); font-size: 22px; font-weight: 800; }
.match-done p { color: var(--text-2); margin: 6px 0 20px; }
.match-done .btn-row { justify-content: center; }
@media (prefers-reduced-motion: reduce) {
  .match-card, .match-done { transition: none; animation: none; }
}
html.light-mode .match-card { box-shadow: 0 2px 6px -2px rgba(15, 23, 42, 0.12); }

/* ===== GUEST QUOTA CARD ===== */
.guest-card {
  background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 8%, var(--card)), var(--card));
  border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.guest-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.guest-card-head strong {
  font-family: var(--font-h);
  font-size: 14px;
  color: var(--gold);
}
.guest-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.guest-card-foot small {
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.4;
  flex: 1;
  min-width: 180px;
}

/* ===== OAUTH BUTTONS & AUTH MODAL ===== */
.auth-modal {
  text-align: center;
  padding: 24px 20px 20px;
  max-width: 440px;
  width: 100%;
}
.auth-modal .crest {
  margin: 0 auto 12px;
}
.auth-modal h2 {
  font-family: var(--font-h);
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 6px;
  color: var(--text);
}
.auth-modal .auth-desc {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.45;
  margin: 0 0 18px;
}
.auth-alert {
  background: color-mix(in srgb, var(--gold) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--gold);
  margin-bottom: 16px;
  text-align: left;
  line-height: 1.4;
}
.oauth-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.btn-oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.btn-oauth:hover {
  background: var(--elevated);
  transform: translateY(-1px);
}
.btn-oauth:active {
  transform: translateY(0);
}
.btn-oauth svg, .btn-oauth img {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.btn-google {
  background: #ffffff;
  color: #1f1f1f;
  border-color: #dadce0;
}
.btn-google:hover {
  background: #f8f9fa;
  border-color: #c6c8cc;
}
.btn-microsoft {
  background: #2f2f2f;
  color: #ffffff;
  border-color: #4a4a4a;
}
html.light-mode .btn-microsoft {
  background: #1e1e1e;
  color: #ffffff;
}
.btn-microsoft:hover {
  background: #3f3f3f;
}
.btn-apple {
  background: #000000;
  color: #ffffff;
  border-color: #222222;
}
.btn-apple:hover {
  background: #181818;
}
.auth-privacy-note {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.45;
  margin: 12px 0 0;
}

/* ===== ACCOUNT PROFILE IN SETTINGS & SIDEBAR ===== */
.account-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}
.account-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--qc-blue), var(--accent));
  color: #ffffff;
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 18px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid var(--gold);
}
.account-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.account-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.account-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-email {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  margin-top: 2px;
}

