/* ============================================================
   styles.css — mobile-first, dark/light theme
   ============================================================ */
:root {
  --bg: #0f1216; --bg2: #171c22; --card: #1c232b; --card2: #232b34;
  --txt: #eef2f6; --muted: #93a1b0; --line: #2a333d;
  --pri: #ff7a59; --pri-d: #e8623f;        /* warm Spanish accent */
  --ok: #3ecf8e; --warn: #f2c14e; --bad: #ff5d6c;
  --m: #5aa9ff; --f: #ff7eb6;               /* masc / fem */
  --r0: #ff5d6c; --r1: #f2a13e; --r2: #3ecf8e; --r3: #5aa9ff;
  --radius: 16px; --shadow: 0 6px 24px rgba(0,0,0,.35);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
:root[data-theme="light"] {
  --bg: #f4f6f9; --bg2: #ffffff; --card: #ffffff; --card2: #f0f3f7;
  --txt: #16202b; --muted: #5d6b7a; --line: #e2e8f0;
  --shadow: 0 6px 20px rgba(20,40,70,.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--txt);
  -webkit-font-smoothing: antialiased; line-height: 1.45;
  overscroll-behavior-y: none;
}
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 700; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; margin-top: 1rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
code { background: var(--card2); padding: .05rem .35rem; border-radius: 6px; font-size: .85em; }
button { font-family: inherit; cursor: pointer; }
hr { border: none; border-top: 1px solid var(--line); margin: 1rem 0; }

/* ---------- App shell ---------- */
#app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.appbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1rem; background: var(--bg); border-bottom: 1px solid var(--line);
}
.appbar .brand { font-weight: 800; letter-spacing: .2px; display: flex; gap: .4rem; align-items: center; }
.appbar .brand .flag { font-size: 1.1rem; }
#gear { background: none; border: none; font-size: 1.3rem; color: var(--txt); padding: .2rem .4rem; }
#view { flex: 1; padding: 1rem 1rem 6rem; }

/* ---------- Bottom nav ---------- */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--bg2); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); max-width: 560px; margin: 0 auto;
}
.nav-btn {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: .55rem 0 .5rem; font-size: .68rem; display: flex; flex-direction: column; align-items: center; gap: .15rem;
}
.nav-btn .ic { font-size: 1.25rem; line-height: 1; }
.nav-btn.active { color: var(--pri); }

/* ---------- Cards / boxes ---------- */
.card-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.section-intro { margin: 0 0 1rem; }
.lvl-head { margin: 1.2rem 0 .6rem; font-size: .8rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.lvl-head:first-child { margin-top: 0; }

/* ---------- Hero stats ---------- */
.hero { margin-bottom: 1rem; }
.hero-row { display: flex; gap: .7rem; }
.stat { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem .5rem; text-align: center; }
.stat-num { font-size: 1.5rem; font-weight: 800; }
.stat-lbl { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary, .btn-danger { border: none; border-radius: 12px; font-weight: 700; padding: .85rem 1rem; font-size: .95rem; width: 100%; }
.btn-primary { background: var(--pri); color: #fff; }
.btn-primary:active { background: var(--pri-d); }
.btn-primary:disabled { opacity: .5; }
.btn-secondary { background: var(--card2); color: var(--txt); border: 1px solid var(--line); }
.btn-danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); width: auto; padding: .6rem 1rem; }
.big { margin-top: .8rem; }
.row-btns { display: flex; gap: .5rem; }
.row-btns .btn-secondary { width: auto; padding: .6rem .9rem; }

/* ---------- Segmented control ---------- */
.field-lbl { display: block; font-size: .78rem; color: var(--muted); margin: .8rem 0 .35rem; font-weight: 600; }
.seg { display: flex; gap: .4rem; }
.seg button { flex: 1; padding: .65rem .3rem; border: 1px solid var(--line); background: var(--card2); color: var(--txt); border-radius: 10px; font-size: .85rem; font-weight: 600; }
.seg button.on { background: var(--pri); color: #fff; border-color: var(--pri); }

/* ---------- Inputs ---------- */
.inp { width: 100%; padding: .75rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); color: var(--txt); font-size: 1rem; }
.inp:focus { outline: none; border-color: var(--pri); }
.inp.num { width: 80px; text-align: center; }
textarea.inp { resize: vertical; font-family: inherit; }
.row2 { display: flex; gap: .7rem; }
.row2 > div { flex: 1; }
select.inp { appearance: none; }

/* ---------- Decks ---------- */
.deck { display: flex; align-items: center; gap: .7rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; margin-bottom: .7rem; }
.deck.off { opacity: .62; }
.deck-main { display: flex; gap: .7rem; align-items: center; flex: 1; min-width: 0; }
.deck-icon { font-size: 1.6rem; width: 2.2rem; text-align: center; }
.deck-info { min-width: 0; flex: 1; }
.deck-name { font-weight: 700; }
.deck-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 6px; background: var(--card2); border-radius: 4px; margin-top: .4rem; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.bar.big { height: 12px; display: flex; }
.bar.big span { border-radius: 0; }
.seg-mastered { background: var(--ok); } .seg-learning { background: var(--warn); }

/* toggle switch */
.toggle { width: 46px; height: 28px; border-radius: 16px; border: none; background: var(--line); position: relative; flex: 0 0 auto; transition: background .15s; }
.toggle span { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on { background: var(--pri); }
.toggle.on span { left: 21px; }

/* ---------- Grammar ---------- */
.g-row { display: flex; align-items: center; gap: .7rem; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .8rem; margin-bottom: .55rem; }
.g-check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-size: .8rem; color: var(--ok); }
.g-check.on { border-color: var(--ok); background: rgba(62,207,142,.12); }
.g-text { flex: 1; min-width: 0; cursor: pointer; }
.g-title { font-weight: 700; }
.g-arrow { color: var(--muted); font-size: 1.4rem; cursor: pointer; }
.g-practice-mini { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; line-height: 1; background: var(--card2); border: 1px solid var(--line); color: var(--txt); border-radius: 10px; padding: .35rem .5rem; font-size: 1rem; }
.g-practice-mini small { font-size: .58rem; color: var(--muted); font-weight: 700; }
.g-practice-mini:active { background: var(--pri); color: #fff; border-color: var(--pri); }
.g-leveltest { width: 100%; text-align: left; background: var(--card2); border: 1px solid var(--line); color: var(--txt); border-radius: 12px; padding: .75rem .85rem; margin-bottom: .55rem; font-weight: 700; font-size: .95rem; }
.g-leveltest:active { border-color: var(--pri); }
.g-practice-box { display: flex; flex-direction: column; gap: .5rem; margin: 1rem 0 .6rem; }

.grammar-body table { width: 100%; border-collapse: collapse; margin: .6rem 0; font-size: .9rem; }
.grammar-body th, .grammar-body td { border: 1px solid var(--line); padding: .4rem .5rem; text-align: left; }
.grammar-body th { background: var(--card2); }
.grammar-body ul { padding-left: 1.1rem; }
.grammar-body li { margin: .25rem 0; }
.grammar-body em { color: var(--pri); font-style: normal; font-weight: 600; }
.pill { display: inline-block; background: var(--card2); border: 1px solid var(--line); border-radius: 20px; padding: .15rem .7rem; font-size: .75rem; margin-bottom: .6rem; }
.pill.tiny { padding: .05rem .5rem; font-size: .68rem; }
.tip { background: rgba(242,193,78,.12); border: 1px solid rgba(242,193,78,.4); border-radius: 10px; padding: .7rem .8rem; margin-top: 1rem; font-size: .9rem; }
.ex { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.ex:last-child { border-bottom: none; }
.ex-es { font-weight: 600; }
.ex-en { font-size: .85rem; }

/* ---------- Custom list ---------- */
.mini-row { display: flex; justify-content: space-between; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.mini-row:last-child { border-bottom: none; }
.del { background: none; border: none; color: var(--bad); font-size: 1rem; padding: .2rem .5rem; }

/* ---------- Speaker ---------- */
.spk { background: none; border: none; font-size: 1rem; padding: .1rem .3rem; }
.spk.inline { font-size: .95rem; opacity: .85; }

/* ============================================================
   OVERLAY (session / grammar / settings)
   ============================================================ */
.overlay { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: none; }
.overlay.open { display: block; overflow-y: auto; }
.ov-inner { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; padding: 0 1rem 2rem; }
.ov-head { position: sticky; top: 0; background: var(--bg); display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .9rem 0; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.ov-title { font-weight: 800; flex: 1; text-align: center; }
.ov-close { background: none; border: none; color: var(--pri); font-size: 1rem; font-weight: 700; padding: .3rem; }
.ov-done { background: var(--card2); border: 1px solid var(--line); color: var(--txt); border-radius: 20px; padding: .4rem .8rem; font-size: .8rem; font-weight: 700; }
.ov-done.on { background: rgba(62,207,142,.15); border-color: var(--ok); color: var(--ok); }
.ov-body { padding-bottom: 2rem; }

/* settings rows */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.set-row.danger b { color: var(--bad); }
.linkbtn { background: none; border: none; color: var(--pri); font: inherit; padding: 0; text-decoration: underline; cursor: pointer; }

/* bookmark / saved */
.iconbtn { background: none; border: none; font-size: 1.2rem; padding: .2rem .4rem; opacity: .4; filter: grayscale(1); }
.iconbtn.on { opacity: 1; filter: none; }
.row-add { display: flex; gap: .5rem; margin-top: .6rem; }
.row-add .inp { flex: 1; }
.row-add .btn-secondary { width: auto; padding: .6rem .9rem; }
.bm-row { display: flex; align-items: center; gap: .4rem; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .6rem .7rem; margin-bottom: .5rem; }
.bm-main { flex: 1; min-width: 0; cursor: pointer; }
.bm-title { font-weight: 700; word-break: break-word; }
.bm-copy, .bm-del { background: none; border: none; font-size: 1rem; padding: .35rem .45rem; flex: 0 0 auto; }
.bm-del { color: var(--bad); }

/* verb tables */
.vt-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .65rem .8rem; margin-bottom: .45rem; cursor: pointer; }
.vt-info { min-width: 0; }
.conj-table .vt-form { cursor: pointer; }

/* ============================================================
   SESSION
   ============================================================ */
.overlay.full .ov-inner { padding-bottom: 1rem; }
.sess-top { display: flex; align-items: center; gap: .7rem; padding: .9rem 0; }
.sess-top .ov-close { color: var(--muted); font-size: 1.2rem; }
.progress { flex: 1; height: 8px; background: var(--card2); border-radius: 4px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--pri); transition: width .2s; }
.sess-count { font-size: .8rem; color: var(--muted); min-width: 42px; text-align: right; }
.sess-tag { text-align: center; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: .6rem; }
.sess-stage { flex: 1; display: flex; flex-direction: column; }

/* flash card */
.flash { background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow);
  flex: 1; min-height: 230px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; padding: 1.5rem; text-align: center; }
.flash.small-flash { flex: 0 0 auto; min-height: 130px; margin-bottom: 1rem; }
.flash-lang { font-size: .72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.flash-word { font-size: 2.1rem; font-weight: 800; }
.flash-hint { font-size: .8rem; }

/* answer */
.answer { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 1.4rem; text-align: center; box-shadow: var(--shadow); margin-bottom: 1rem; }
.ans-es { font-size: 1.9rem; font-weight: 800; }
.ans-en { font-size: 1.2rem; color: var(--muted); margin-top: .3rem; }
.ans-es.g-m { color: var(--m); } .ans-es.g-f { color: var(--f); }
.flash-word.g-m { color: var(--m); } .flash-word.g-f { color: var(--f); }
.gtag { font-size: .7rem; vertical-align: super; opacity: .7; margin-left: .2rem; }
.ans-ex { margin-top: .9rem; padding-top: .8rem; border-top: 1px solid var(--line); font-size: .95rem; }
.ans-ex span { font-weight: 600; }

/* rating bar */
.rate-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-top: auto; padding-top: .5rem; }
.rate { position: relative; border: none; border-radius: 12px; padding: .75rem .2rem; color: #fff; display: flex; flex-direction: column; gap: .15rem; font-size: .9rem; }
.rate small { font-size: .68rem; opacity: .9; font-weight: 600; }
.rate .rk { position: absolute; top: 4px; right: 5px; font: inherit; font-size: .62rem; font-weight: 700; line-height: 1; padding: 2px 4px; border-radius: 5px; background: rgba(0,0,0,.22); opacity: .8; }
.rate.r0 { background: var(--r0); } .rate.r1 { background: var(--r1); }
.rate.r2 { background: var(--r2); } .rate.r3 { background: var(--r3); }

/* write mode */
.big-inp { font-size: 1.3rem; text-align: center; padding: .9rem; }
.accent-bar { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.acc { width: 2.6rem; height: 2.6rem; border: 1px solid var(--line); background: var(--card2); color: var(--txt); border-radius: 10px; font-size: 1.1rem; }
.result { text-align: center; font-weight: 800; font-size: 1.1rem; padding: .6rem; border-radius: 12px; margin-bottom: .6rem; }
.result.ok { background: rgba(62,207,142,.15); color: var(--ok); }
.result.warn { background: rgba(242,193,78,.15); color: var(--warn); }
.result.bad { background: rgba(255,93,108,.15); color: var(--bad); }

/* done screen */
.done { text-align: center; padding: 2rem 1rem; display: flex; flex-direction: column; gap: .6rem; align-items: center; }
.done-emoji { font-size: 3rem; }
.done-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: .6rem; width: 100%; margin: 1rem 0; }
.done-grid > div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .2rem; }
.done-grid b { font-size: 1.3rem; display: block; } .done-grid small { color: var(--muted); font-size: .7rem; }

/* 6-way practice-type selector */
.seg.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.seg.type-grid button { padding: .6rem .2rem; font-size: .8rem; }

/* gender drill */
.gender-btns { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: 1.2rem; }
.gbtn { padding: 1.5rem .5rem; border-radius: 16px; border: 2px solid var(--line); background: var(--card2); color: var(--txt); font-size: 1.7rem; font-weight: 800; }
.gbtn.gm { color: var(--m); border-color: var(--m); }
.gbtn.gf { color: var(--f); border-color: var(--f); }
.gbtn:active { transform: scale(.97); }

/* numbers / time prompt */
.drill-q { font-size: 2.4rem; font-weight: 800; margin-top: .3rem; word-break: break-word; }

/* 20-day program */
.prog-cta { border-color: var(--pri); }
.prog-head { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; }
.prog-head h2 { margin: 0; }
.prog-title { font-weight: 800; font-size: 1.05rem; margin: .3rem 0 .1rem; }
.task-list { margin: .8rem 0; }
.task-row { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.task-row:last-child { border-bottom: none; }
.task-check { width: 26px; height: 26px; flex: 0 0 auto; border-radius: 50%; border: 2px solid var(--line); background: var(--card2); color: var(--ok); font-weight: 800; font-size: .85rem; }
.task-check.on { border-color: var(--ok); background: rgba(62,207,142,.15); }
.task-label { flex: 1; min-width: 0; font-size: .92rem; }
.task-go { flex: 0 0 auto; background: var(--card2); border: 1px solid var(--line); color: var(--pri); border-radius: 10px; padding: .4rem .7rem; font-weight: 700; font-size: .82rem; }
.prog-nav { display: flex; align-items: center; justify-content: space-between; margin-top: .8rem; }
.free-head { margin-top: 1.4rem; }
.quiz-prompt { font-size: 1.4rem; font-weight: 700; line-height: 1.4; }

/* clearer English meaning under the verb prompt */
.conj-en { font-size: 1.15rem; color: var(--txt); opacity: .82; margin-top: .15rem; }
.flash-hint { font-size: .95rem; }

/* pause button + resume banner */
#sess-pause { color: var(--muted); font-size: 1.05rem; }
.resume-box { border-color: var(--pri); }
.resume-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.resume-row .btn-primary { width: auto; padding: .6rem 1rem; margin: 0; }

/* chips (tense / level selectors) */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { border: 1px solid var(--line); background: var(--card2); color: var(--txt); border-radius: 20px; padding: .45rem .8rem; font-size: .82rem; font-weight: 600; display: flex; align-items: center; gap: .35rem; }
.chip small { font-size: .6rem; opacity: .6; background: var(--bg); padding: .05rem .3rem; border-radius: 8px; }
.chip.on { background: var(--pri); color: #fff; border-color: var(--pri); }
.chip.on small { background: rgba(255,255,255,.25); opacity: .95; }

/* leech */
.leech-box { border-color: var(--warn); }
.leech-badge { display: inline-block; background: rgba(242,193,78,.18); color: var(--warn); border-radius: 8px; padding: .05rem .4rem; font-size: .7rem; font-weight: 700; }

/* listen / dictation */
.listen-flash { gap: 1rem; }
.spk.huge { font-size: 3.2rem; background: none; border: none; line-height: 1; }

/* conjugation */
.conj-flash { gap: .4rem; }
.conj-person { font-size: 1.2rem; font-weight: 700; color: var(--pri); margin-top: .2rem; }
.conj-person-en { color: var(--muted); font-weight: 600; font-size: .8em; }
.conj-help { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .85rem; margin: .2rem 0 .9rem; text-align: left; }
.conj-goal { font-size: 1.05rem; font-weight: 700; line-height: 1.35; margin-bottom: .35rem; }
.conj-goal b { color: var(--pri); }
.conj-goal-hint { color: var(--muted); font-weight: 600; font-size: .82em; }
.ex-mini.conj-ex { margin-top: .5rem; }
.ex-mini.conj-ex b { color: var(--txt); }
.conj-table { width: 100%; border-collapse: collapse; margin-top: .9rem; font-size: .92rem; }
.conj-table td { border: 1px solid var(--line); padding: .35rem .6rem; text-align: left; }
.conj-table td:first-child { color: var(--muted); width: 42%; }
.conj-table tr.hl td { background: rgba(255,122,89,.15); font-weight: 800; color: var(--txt); }
.tense-note { margin-top: .9rem; padding-top: .7rem; border-top: 1px solid var(--line); text-align: left; }
.ex-mini { font-size: .92rem; margin-top: .3rem; line-height: 1.4; }
.ex-mini .muted { color: var(--muted); }

/* cloze */
.cloze-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 1.5rem 1.2rem; text-align: center; margin-bottom: 1rem; }
.cloze-text { font-size: 1.3rem; font-weight: 600; line-height: 1.5; }
.cloze-text.filled { font-size: 1.15rem; }
.cloze-text .fill { color: var(--ok); }

/* stats */
.legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .6rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .3rem; }
.dot.mastered { background: var(--ok); } .dot.learning { background: var(--warn); } .dot.fresh { background: var(--line); }
.heat { display: flex; gap: 4px; align-items: flex-end; height: 80px; }
.hb { flex: 1; background: var(--card2); border-radius: 3px; height: 100%; display: flex; align-items: flex-end; overflow: hidden; }
.hb span { display: block; width: 100%; background: var(--pri); border-radius: 3px; min-height: 2px; }
