/* ===========================================================================
   Spanish Streak — stylesheet
   Warm, sunlit Spanish palette. Mobile-first, works offline from file://.
   =========================================================================== */
:root {
  --ink: #2a1f1a;
  --ink-soft: #6b5d54;
  --paper: #fff8f0;
  --card: #ffffff;
  --line: #f0e3d4;
  --rojo: #e63946;
  --rojo-dark: #c52d3a;
  --amarillo: #ffb703;
  --naranja: #fb8500;
  --verde: #2a9d8f;
  --verde-soft: #e3f4f1;
  --azul: #4895ef;
  --bad: #e5484d;
  --bad-soft: #fdecec;
  --good: #2a9d8f;
  --good-soft: #e3f4f1;
  --shadow: 0 6px 24px rgba(120, 70, 30, 0.10);
  --shadow-sm: 0 2px 8px rgba(120, 70, 30, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --maxw: 760px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 100% -10%, #ffe9cf 0%, rgba(255,233,207,0) 60%),
    radial-gradient(1000px 500px at -10% 0%, #ffe0e0 0%, rgba(255,224,224,0) 55%),
    var(--paper);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { margin: 0 0 .3em; line-height: 1.2; }
p { margin: 0 0 .6em; }
.muted { color: var(--ink-soft); }
.small { font-size: .82rem; }
.center { text-align: center; }
button { font-family: inherit; cursor: pointer; }

/* ---- top bar ------------------------------------------------------------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 248, 240, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.brand-flag { font-size: 1.4rem; }
.brand-name { font-weight: 800; letter-spacing: -.02em; }
.bar-stats { display: flex; gap: 6px; }
.pill {
  font-size: .78rem; font-weight: 700; padding: 5px 10px; border-radius: 999px;
  white-space: nowrap;
}
.pill-lvl { background: #fff0d6; color: var(--naranja); }
.pill-xp { background: #e9f0ff; color: var(--azul); }
.pill-streak { background: #ffe1e1; color: var(--rojo); }

/* ---- layout -------------------------------------------------------------- */
.view {
  max-width: var(--maxw); margin: 0 auto;
  padding: 18px 16px calc(96px + env(safe-area-inset-bottom));
  min-height: 60vh;
}
.page { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 18px; margin-bottom: 16px;
}
.section-h { margin: 22px 4px 10px; font-size: 1rem; color: var(--ink-soft); font-weight: 800; letter-spacing: .02em; text-transform: uppercase; }
.section-h.flush { margin: 0 0 12px; }

/* ---- buttons ------------------------------------------------------------- */
.primary-btn {
  background: linear-gradient(135deg, var(--rojo), var(--naranja));
  color: #fff; border: none; border-radius: 999px;
  padding: 13px 22px; font-size: 1rem; font-weight: 800;
  box-shadow: 0 6px 16px rgba(230, 57, 70, 0.28);
  transition: transform .08s ease, box-shadow .15s ease;
}
.primary-btn:hover { transform: translateY(-1px); }
.primary-btn:active { transform: translateY(1px) scale(.99); }
.primary-btn:disabled { opacity: .6; }
.primary-btn.big { width: 100%; padding: 16px; font-size: 1.08rem; margin-top: 10px; }
.secondary-btn {
  background: #fff; color: var(--ink); border: 1.5px solid var(--line);
  border-radius: 999px; padding: 12px 20px; font-weight: 700;
}
.secondary-btn:hover { border-color: var(--naranja); }
.danger-btn {
  background: var(--bad-soft); color: var(--bad); border: 1.5px solid #f6c9c9;
  border-radius: 999px; padding: 11px 18px; font-weight: 700;
}
.ghost-btn { background: none; border: none; font-size: 1.2rem; color: var(--ink-soft); padding: 6px 10px; border-radius: 10px; }
.ghost-btn:hover { background: var(--line); }
.link-btn { background: none; border: none; color: var(--ink-soft); text-decoration: underline; font-size: .9rem; padding: 6px; }
.link-btn:hover { color: var(--rojo); }
.back-link { background: none; border: none; color: var(--naranja); font-weight: 700; padding: 4px 0; font-size: .92rem; }

/* ---- hero / home --------------------------------------------------------- */
.hero { padding: 6px 4px 14px; }
.hero-greet { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }
.hero-date { color: var(--ink-soft); text-transform: capitalize; }

.today-card {
  background: linear-gradient(135deg, #fff, #fff6ea);
  border: 1px solid #ffe6c7;
}
.today-card h2 { font-size: 1.25rem; }

.level-card .level-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.level-num { font-size: 1.2rem; font-weight: 800; }
.level-acc { text-align: right; }
.level-acc-num { font-size: 1.2rem; font-weight: 800; color: var(--verde); }

.pbar { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 6px 0 8px; }
.pbar-fill { height: 100%; background: linear-gradient(90deg, var(--amarillo), var(--naranja)); border-radius: 999px; transition: width .5s ease; }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quick-card { text-align: left; display: block; }
.quick-ico { font-size: 1.6rem; }
.quick-title { font-weight: 800; margin: 6px 0 2px; }

.badge-preview { background: linear-gradient(135deg, #fff, #f3fbf9); }
.badge-row { display: flex; flex-wrap: wrap; gap: 8px; }
.badge-chip { background: var(--good-soft); color: var(--good); font-weight: 700; font-size: .85rem; padding: 6px 11px; border-radius: 999px; }

/* ---- nav ----------------------------------------------------------------- */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: center; gap: 2px;
  background: rgba(255,248,240,.92); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.nav-btn {
  flex: 1; max-width: 130px; background: none; border: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; border-radius: 12px; color: var(--ink-soft); font-size: .68rem; font-weight: 700;
}
.nav-ico { font-size: 1.25rem; filter: grayscale(.3); }
.nav-btn.active { color: var(--rojo); }
.nav-btn.active .nav-ico { filter: none; transform: translateY(-1px); }

/* ---- session ------------------------------------------------------------- */
.sess-card { padding: 16px; }
.sess-top { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.sess-progress { flex: 1; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.sess-progress-fill { height: 100%; background: linear-gradient(90deg, var(--verde), var(--azul)); transition: width .3s ease; }
.sess-count { font-size: .8rem; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }

.prompt { text-align: center; padding: 18px 10px 22px; }
.prompt-sub { color: var(--ink-soft); font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.prompt-main { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; margin: 8px 0; word-break: break-word; }
.prompt-en { color: var(--ink-soft); font-style: italic; }
.prompt-person { margin-top: 14px; font-size: 1.2rem; font-weight: 700; }
.chip { background: #fff0d6; color: var(--naranja); padding: 4px 12px; border-radius: 999px; font-weight: 800; }

.choices { display: grid; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 16px; font-size: 1.05rem; font-weight: 600; color: var(--ink);
  transition: border-color .12s ease, background .12s ease, transform .06s ease;
}
.choice:hover:not(:disabled) { border-color: var(--naranja); transform: translateY(-1px); }
.choice-key { width: 26px; height: 26px; flex: none; display: grid; place-items: center; background: var(--line); border-radius: 8px; font-size: .82rem; font-weight: 800; color: var(--ink-soft); }
.choice.correct { border-color: var(--good); background: var(--good-soft); }
.choice.correct .choice-key { background: var(--good); color: #fff; }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); }
.choice.wrong .choice-key { background: var(--bad); color: #fff; }
.choice:disabled { cursor: default; }

.type-form { display: flex; gap: 10px; }
.type-form input {
  flex: 1; min-width: 0; font-size: 1.15rem; padding: 13px 16px;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); outline: none;
  background: #fff; color: var(--ink);
}
.type-form input:focus { border-color: var(--naranja); box-shadow: 0 0 0 3px #ffe6c7; }
.type-form.ok input { border-color: var(--good); background: var(--good-soft); }
.type-form.bad input { border-color: var(--bad); background: var(--bad-soft); }
.skip-row { text-align: center; margin-top: 12px; }

.feedback { margin-top: 16px; padding: 16px; border-radius: var(--radius-sm); animation: pop .2s ease; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.feedback.good { background: var(--good-soft); }
.feedback.miss { background: var(--bad-soft); }
.fb-head { font-size: 1.15rem; font-weight: 800; margin-bottom: 6px; }
.feedback.good .fb-head { color: var(--good); }
.feedback.miss .fb-head { color: var(--bad); }
.fb-answer { font-size: 1.05rem; }
.fb-correct { font-weight: 800; }
.fb-note { color: var(--ink-soft); font-size: .9rem; margin-top: 4px; }
.cont-btn { margin-top: 14px; width: 100%; }

/* ---- result -------------------------------------------------------------- */
.result-card { text-align: center; }
.result-title { font-size: 1.5rem; margin-bottom: 18px; }
.result-ring {
  --pct: 0;
  width: 160px; height: 160px; border-radius: 50%; margin: 0 auto 18px;
  background: conic-gradient(var(--verde) calc(var(--pct) * 1%), var(--line) 0);
  display: grid; place-items: center;
}
.result-ring-inner { width: 124px; height: 124px; border-radius: 50%; background: #fff; display: grid; place-items: center; box-shadow: inset 0 2px 6px rgba(0,0,0,.04); }
.result-pct { font-size: 2.1rem; font-weight: 800; }
.result-pct-sub { color: var(--ink-soft); font-size: .8rem; }
.result-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-box { background: var(--paper); border-radius: var(--radius-sm); padding: 12px 6px; }
.stat-big { font-size: 1.15rem; font-weight: 800; }
.stat-small { font-size: .72rem; color: var(--ink-soft); }
.result-streak { font-weight: 700; color: var(--rojo); margin-bottom: 14px; }
.result-review { text-align: left; background: var(--paper); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 16px; }
.result-review h3 { font-size: .95rem; }
.result-review ul { margin: 6px 0 0; padding-left: 18px; }
.result-review li { margin: 4px 0; font-size: .92rem; }
.result-actions { display: flex; gap: 10px; }
.result-actions .primary-btn { flex: 1; }
.result-actions .secondary-btn { flex: 1; }

/* ---- setup screens ------------------------------------------------------- */
.setup-head { margin-bottom: 14px; }
.setup-head h1 { font-size: 1.5rem; margin-top: 4px; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle-chip {
  background: #fff; border: 1.5px solid var(--line); border-radius: 999px;
  padding: 9px 14px; font-weight: 700; color: var(--ink-soft); font-size: .9rem;
  display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.15;
}
.toggle-chip .chip-sub { font-size: .68rem; font-weight: 600; opacity: .8; }
.toggle-chip.on { background: #fff0d6; border-color: var(--naranja); color: var(--naranja); }
.toggle-chip.locked { opacity: .55; cursor: not-allowed; background: var(--paper); }
.length-row { display: flex; align-items: center; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.len-btn { background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 14px; font-weight: 800; color: var(--ink-soft); }
.len-btn.on { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.setup-actions { margin-top: 20px; }
.setup-actions .primary-btn { width: 100%; }

/* ---- progress view ------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 4px; }
.big-stat { text-align: center; padding: 16px 10px; margin: 0; }
.big-stat-num { font-size: 1.5rem; font-weight: 800; }
.tense-list { display: grid; gap: 10px; }
.tense-row { display: grid; grid-template-columns: 1fr 2fr auto; align-items: center; gap: 10px; }
.tense-name { font-size: .9rem; font-weight: 700; }
.tense-bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.tense-bar-fill { height: 100%; background: linear-gradient(90deg, var(--azul), var(--verde)); }
.tense-n { font-size: .82rem; font-weight: 800; color: var(--ink-soft); min-width: 24px; text-align: right; }
.badge-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.badge-card { background: var(--paper); border-radius: var(--radius-sm); padding: 14px; text-align: center; }
.badge-card.locked { opacity: .55; }
.badge-card.got { background: var(--good-soft); }
.badge-ico { font-size: 1.8rem; }
.badge-name { font-weight: 800; margin: 4px 0 2px; }
.danger-card { background: #fff9f5; }

/* ---- reference ----------------------------------------------------------- */
.ref-header h2 { font-size: 1.45rem; }
.ref-tense-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 16px; }
.ref-tab { background: #fff; border: 1.5px solid var(--line); border-radius: 999px; padding: 7px 13px; font-weight: 700; font-size: .82rem; color: var(--ink-soft); }
.ref-tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.ref-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ref-card { margin-bottom: 0; }
.ref-verb-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ref-verb-select { flex: 1; padding: 10px; border-radius: 10px; border: 1.5px solid var(--line); font-size: .95rem; background: #fff; color: var(--ink); }

/* searchable verb picker */
.ref-verb-picker { margin-bottom: 14px; }
.ref-verb-current { margin-bottom: 8px; font-size: 1.05rem; }
.ref-verb-current b { font-size: 1.1rem; }
.ref-verb-search {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--line);
  border-radius: 10px; font-size: .95rem; outline: none; background: #fff; color: var(--ink);
}
.ref-verb-search:focus { border-color: var(--naranja); box-shadow: 0 0 0 3px #ffe6c7; }
.ref-verb-list {
  margin-top: 8px; max-height: 240px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper);
}
.ref-verb-item {
  display: flex; align-items: baseline; gap: 8px; width: 100%; text-align: left;
  background: none; border: none; border-bottom: 1px solid var(--line);
  padding: 9px 12px; font-size: .92rem; color: var(--ink);
}
.ref-verb-item:last-child { border-bottom: none; }
.ref-verb-item:hover { background: #fff0d6; }
.ref-verb-item.active { background: #fff0d6; }
.rvi-inf { font-weight: 800; }
.ref-verb-item.active .rvi-inf { color: var(--naranja); }
.rvi-en { color: var(--ink-soft); font-size: .82rem; }
.ref-verb-empty { padding: 12px; color: var(--ink-soft); text-align: center; }
.conj-table { width: 100%; border-collapse: collapse; }
.conj-table td { padding: 9px 6px; border-bottom: 1px solid var(--line); }
.ct-person { color: var(--ink-soft); font-size: .85rem; }
.ct-form { text-align: right; font-weight: 800; font-size: 1.05rem; }
.ref-notes h3 { font-size: .95rem; margin-top: 12px; }
.ref-notes h3:first-child { margin-top: 0; }
.ref-notes ul { padding-left: 18px; margin: 6px 0; }
.ref-notes li { margin: 5px 0; font-size: .9rem; }
.ref-cheat { margin-top: 0; }
.table-scroll { overflow-x: auto; }
.cheat-table { width: 100%; border-collapse: collapse; font-size: .82rem; white-space: nowrap; }
.cheat-table th, .cheat-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: right; }
.cheat-table th { color: var(--ink-soft); font-weight: 700; }
.cheat-table td:first-child, .cheat-table th:first-child { text-align: left; font-weight: 800; }

/* ---- toasts + confetti --------------------------------------------------- */
.toast-host { position: fixed; top: 70px; left: 0; right: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-weight: 700; font-size: .9rem; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-10px); transition: opacity .3s ease, transform .3s ease;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: none; }
.toast-level { background: linear-gradient(135deg, var(--naranja), var(--rojo)); }
.toast-badge { background: linear-gradient(135deg, var(--verde), var(--azul)); }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti span {
  position: absolute; top: -10px; width: 10px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(540deg); opacity: .9; }
}

/* ---- desktop tweaks ------------------------------------------------------ */
@media (min-width: 680px) {
  .nav {
    position: sticky; top: 0; max-width: var(--maxw); margin: 0 auto; bottom: auto;
    background: transparent; backdrop-filter: none; border-top: none; border-bottom: 1px solid var(--line);
    padding: 6px 16px; justify-content: flex-start; gap: 4px;
  }
  .nav-btn { flex-direction: row; gap: 6px; max-width: none; padding: 8px 14px; font-size: .85rem; }
  .nav-ico { font-size: 1rem; }
  .view { padding-bottom: 40px; }
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 480px) {
  .ref-grid { grid-template-columns: 1fr; }
  .prompt-main { font-size: 1.9rem; }
  .result-stats { grid-template-columns: repeat(2, 1fr); }
}
