:root {
  color-scheme: dark;
  --bg: #0e151f;
  --bg2: #131c28;
  --panel: #1a2535;
  --panel2: #222f43;
  --border: #2c3b53;
  --text: #e9e6dd;
  --muted: #93a0b5;
  --accent: #d8a85a;
  --accent2: #6bb8d4;
  --good: #74c47a;
  --bad: #e07a5f;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4ede0;
  --bg2: #efe6d3;
  --panel: #ffffff;
  --panel2: #f7f1e3;
  --border: #e2d6bd;
  --text: #2a2317;
  --muted: #6b6053;
  --accent: #a8761e;
  --accent2: #2a7da0;
  --shadow: 0 8px 24px rgba(80,60,20,.12);
}
@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f4ede0;
    --bg2: #efe6d3;
    --panel: #ffffff;
    --panel2: #f7f1e3;
    --border: #e2d6bd;
    --text: #2a2317;
    --muted: #6b6053;
    --accent: #a8761e;
    --accent2: #2a7da0;
    --shadow: 0 8px 24px rgba(80,60,20,.12);
  }
}
html, body { margin:0; padding:0; height:100%; }
body {
  background: radial-gradient(1200px 800px at 20% -10%, rgba(216,168,90,.08), transparent 60%),
              radial-gradient(900px 700px at 110% 110%, rgba(107,184,212,.07), transparent 55%),
              var(--bg);
  color: var(--text);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 1100px;
  margin: 0 auto;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg2), transparent);
  flex-wrap: wrap;
}
.brand { display:flex; align-items:center; gap:12px; }
.logo {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  font-family: 'Times New Roman', 'David', 'Noto Sans Hebrew', serif;
  font-size: 30px; font-weight: 700;
  color: var(--bg);
  background: linear-gradient(135deg, var(--accent), #c8924a);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.brand-text h1 { margin:0; font-size: 20px; letter-spacing: .5px; font-weight: 700; }
.brand-text p { margin:0; font-size: 12px; color: var(--muted); }

.tabs { display:flex; gap:6px; background: var(--panel); padding:5px; border-radius: 12px; border:1px solid var(--border); }
.tab {
  appearance: none; border:0; background: transparent; color: var(--muted);
  padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .18s ease;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); color: #1a1208; box-shadow: 0 2px 8px rgba(216,168,90,.35); }

/* Stage */
.stage { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.view { height: 100%; overflow: auto; padding: 20px; box-sizing: border-box; }
.view::-webkit-scrollbar { width: 10px; }
.view::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* ===== Niqqud definition banner ===== */
.niqqud-def {
  background: linear-gradient(180deg, var(--panel), var(--bg2));
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent2);
  border-radius: 12px;
  padding: 14px 18px;
}
.niqqud-def .nd-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 6px;
}
.nd-title { font-size: 14px; font-weight: 700; color: var(--accent); letter-spacing: .3px; }
.nd-toggle {
  appearance:none; border: 1px solid var(--border); background: var(--panel2);
  color: var(--text); width: 26px; height: 26px; border-radius: 7px;
  font-size: 16px; font-weight: 700; cursor: pointer; line-height: 1;
}
.nd-toggle:hover { border-color: var(--accent2); }
.niqqud-def p { margin: 0; color: var(--text); font-size: 13.5px; line-height: 1.6; }
.niqqud-def b { color: var(--accent); }
.nd-he { font-family: 'Times New Roman', 'David', 'Noto Sans Hebrew', serif; color: var(--accent2); font-size: 16px; }
.niqqud-def.collapsed p { display: none; }
.niqqud-def.collapsed { border-left: 3px solid var(--border); }

/* ===== Learn ===== */
.learn-single {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100%;
}
.learn-progress {
  display: flex; align-items: center; gap: 16px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 18px;
}
.counter { font-weight: 700; color: var(--accent); font-size: 15px; white-space: nowrap; }
.dots { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); transition: all .2s ease;
}
.dot.active { background: var(--accent); transform: scale(1.4); box-shadow: 0 0 8px rgba(216,168,90,.5); }
.learn-badge {
  font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel2);
}
.learn-badge.learned {
  color: var(--good); border-color: rgba(116,196,122,.3);
  background: rgba(116,196,122,.1);
}
.learn-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
  box-shadow: var(--shadow);
  flex: 1;
  display: flex; flex-direction: column; gap: 20px;
}
.learn-head {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  text-align: center;
}
.learn-glyphs {
  display: flex; align-items: center; justify-content: center; gap: 20px; flex-wrap: wrap;
}
.glyph-block {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 22px;
  min-width: 140px;
}
.glyph-label { font-size: 11px; color: var(--muted); line-height: 1.4; letter-spacing: .3px; }
.glyph-mark {
  font-family: 'Times New Roman', 'David', 'Noto Sans Hebrew', serif;
  font-size: 90px; line-height: 1; color: var(--accent);
  text-shadow: 0 4px 20px rgba(216,168,90,.25);
  min-height: 90px; display: grid; place-items: center;
}
.glyph-carrier {
  font-family: 'Times New Roman', 'David', 'Noto Sans Hebrew', serif;
  font-size: 90px; line-height: 1; color: var(--text);
  min-height: 90px; display: grid; place-items: center;
}
.glyph-arrow { font-size: 32px; color: var(--accent2); font-weight: 300; }
.learn-title h2 { margin: 0; font-size: 30px; font-weight: 700; }
.pron { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.pron b { color: var(--accent2); font-weight: 700; letter-spacing: .5px; }

/* How to say the name — English phonics */
.learn-say {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.say-label { font-size: 13px; font-weight: 700; color: var(--accent2); letter-spacing: .3px; }
.say-syllables {
  display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px;
  justify-content: center;
}
.syl-chip {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; min-width: 96px;
  text-align: center;
}
.syl {
  font-size: 22px; font-weight: 800; color: var(--accent);
  letter-spacing: .5px; line-height: 1.1;
}
.syl-like { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.syl-plus {
  align-self: center; font-size: 22px; font-weight: 300; color: var(--accent2);
  padding: 0 2px;
}
.say-full { font-size: 14px; color: var(--muted); text-align: center; }
.say-full b { color: var(--accent); font-weight: 700; letter-spacing: .5px; }

.learn-explain {
  background: var(--bg2); border-left: 3px solid var(--accent2);
  padding: 14px 18px; border-radius: 8px;
  color: var(--text); font-size: 14px; line-height: 1.65;
}
.learn-explain b { color: var(--accent); }
.learn-sound-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sound-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; text-align: center;
  display: flex; flex-direction: column; gap: 4px;
}
.sc-label { font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.sc-val { font-size: 22px; font-weight: 700; color: var(--accent); }
.learn-nav {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
}
.learn-nav .btn { flex: 1; min-width: 120px; }

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all .16s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--accent2); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #c8924a); color: #1a1208; border-color: transparent; }
.btn.primary:hover:not(:disabled) { box-shadow: 0 6px 18px rgba(216,168,90,.35); border-color: transparent; }
.btn.ghost { background: transparent; }

/* ===== Practice ===== */
.quiz-wrap { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; height: 100%; }
.quiz-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
#view-challenge .quiz-stats { grid-template-columns: repeat(3, 1fr); }
.stat {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; text-align: center;
}
.stat-label { display:block; font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.stat-val { display:block; font-size: 26px; font-weight: 700; color: var(--accent); margin-top: 2px; }

.practice-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; text-align: center; padding: 40px 20px;
  flex: 1;
}
.empty-icon { font-size: 64px; }
.practice-empty h2 { margin: 0; font-size: 22px; }
.practice-empty p { color: var(--muted); font-size: 15px; line-height: 1.5; }

/* Practice word card */
.practice-word-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 20px;
  box-shadow: var(--shadow);
  flex: 1; display: flex; flex-direction: column; gap: 16px;
  justify-content: center;
}
.pw-word-section { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.pw-vowel-mark-ref {
  font-family: 'Times New Roman', 'David', 'Noto Sans Hebrew', serif;
  font-size: 56px; color: var(--accent);
  text-shadow: 0 2px 12px rgba(216,168,90,.2);
  padding: 8px 20px; background: var(--bg2);
  border-radius: 12px; border: 1px solid var(--border);
}
.pw-word {
  font-family: 'Times New Roman', 'David', 'Noto Sans Hebrew', serif;
  font-size: 100px; line-height: 1.2; color: var(--text);
  text-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.pw-prompt {
  font-size: 16px; color: var(--muted); font-weight: 500;
}
.pw-prompt b { color: var(--accent2); }
.pw-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pw-opt {
  appearance: none; cursor: pointer;
  background: var(--panel2); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 14px 10px; color: var(--text);
  font-size: 15px; font-weight: 600; transition: all .16s ease;
  min-height: 52px; display: flex; align-items: center; justify-content: center;
}
.pw-opt:hover:not(:disabled) { border-color: var(--accent2); transform: translateY(-2px); }
.pw-opt.correct { border-color: var(--good); background: rgba(116,196,122,.15); color: var(--good); }
.pw-opt.correct-show { border-color: var(--good); background: rgba(116,196,122,.15); }
.pw-opt.wrong { border-color: var(--bad); background: rgba(224,122,95,.15); color: var(--bad); }
.pw-opt:disabled { cursor: default; }
.opt-pron { font-size: 12px; color: var(--muted); font-weight: 400; }

.pw-reveal-area { text-align: center; }
.pw-feedback { padding: 12px 16px; border-radius: 10px; font-size: 14px; text-align: center; }
.pw-feedback-good { background: rgba(116,196,122,.12); color: var(--good); border:1px solid rgba(116,196,122,.3); }
.pw-feedback-bad { background: rgba(224,122,95,.12); color: var(--bad); border:1px solid rgba(224,122,95,.3); }

/* Hidden word detail shown after reveal */
.pw-detail {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px; text-align: center;
  display: flex; flex-direction: column; gap: 8px;
  animation: detailIn .25s ease;
}
@keyframes detailIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.detail-hebrew {
  font-family: 'Times New Roman', 'David', 'Noto Sans Hebrew', serif;
  font-size: 60px; line-height: 1.2; color: var(--text);
}
.detail-translit { font-size: 18px; color: var(--accent2); font-weight: 600; }
.detail-meaning { font-size: 18px; color: var(--text); font-weight: 600; }
.detail-tip {
  background: var(--bg2); border-left: 3px solid var(--accent);
  padding: 14px 18px; border-radius: 8px;
  color: var(--text); font-size: 14px; line-height: 1.6; text-align: left;
}
.detail-tip b { color: var(--accent); }
.detail-tip em { color: var(--accent2); font-style: normal; font-weight: 600; }

.quiz-actions { display:flex; justify-content: space-between; gap: 10px; }

/* ===== Challenge ===== */
.quiz-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 24px;
  box-shadow: var(--shadow);
  flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px;
}
.qprompt { text-align: center; font-size: 17px; color: var(--muted); font-weight: 500; }
.qglyph {
  font-size: 90px; text-align: center; color: var(--accent);
  line-height: 1;
  text-shadow: 0 4px 18px rgba(216,168,90,.3);
}
.qoptions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qopt {
  appearance: none; cursor: pointer;
  background: var(--panel2); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 14px 10px; color: var(--text);
  font-size: 15px; font-weight: 600; transition: all .16s ease;
  min-height: 52px;
}
.qopt:hover:not(:disabled) { border-color: var(--accent2); transform: translateY(-2px); }
.qopt.correct { border-color: var(--good); background: rgba(116,196,122,.15); color: var(--good); }
.qopt.wrong { border-color: var(--bad); background: rgba(224,122,95,.15); color: var(--bad); }
.qopt.dim { opacity: .45; }

.challenge-intro { text-align: center; color: var(--muted); line-height: 1.7; font-size: 15px; padding: 16px; }
.challenge-intro b { color: var(--text); }
.result-card { text-align: center; padding: 20px; }
.result-big { font-size: 80px; font-weight: 800; color: var(--accent); line-height: 1; }
.result-label { color: var(--muted); letter-spacing: 2px; text-transform: uppercase; font-size: 13px; }
.result-sub { color: var(--text); margin-top: 14px; font-size: 14px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent); color: #1a1208;
  padding: 10px 18px; border-radius: 999px;
  font-weight: 700; font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0; transition: all .25s ease;
  pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Responsive */
@media (max-width: 720px) {
  .topbar { padding: 12px 14px; gap: 10px; }
  .brand-text h1 { font-size: 17px; }
  .brand-text p { font-size: 11px; }
  .learn-card { padding: 18px; }
  .glyph-mark, .glyph-carrier { font-size: 64px; min-height: 64px; }
  .glyph-block { min-width: 110px; padding: 12px 14px; }
  .learn-glyphs { gap: 12px; }
  .glyph-arrow { font-size: 24px; }
  .learn-title h2 { font-size: 24px; }
  .learn-sound-row { grid-template-columns: 1fr; }
  .qglyph { font-size: 76px; }
  .qoptions { grid-template-columns: 1fr; }
  .quiz-stats { grid-template-columns: repeat(2, 1fr); }
  #view-challenge .quiz-stats { grid-template-columns: repeat(3, 1fr); }
  .tab { padding: 7px 12px; font-size: 13px; }
  .learn-nav { flex-wrap: wrap; }
  .learn-nav .btn { min-width: calc(50% - 5px); }
  .pw-word { font-size: 72px; }
  .pw-vowel-mark-ref { font-size: 42px; }
  .detail-hebrew { font-size: 44px; }
  .syl { font-size: 18px; }
  .syl-chip { min-width: 84px; padding: 8px 10px; }
}
@media (max-width: 400px) {
  .glyph-mark, .glyph-carrier { font-size: 52px; min-height: 52px; }
  .learn-title h2 { font-size: 20px; }
  .pw-word { font-size: 60px; }
  .pw-vowel-mark-ref { font-size: 36px; }
  .detail-hebrew { font-size: 36px; }
  .stat-val { font-size: 22px; }
  .syl { font-size: 16px; }
  .syl-chip { min-width: 72px; }
}
