/* ─── DESIGN TOKENS ─────────────────────────────── */
:root {
  --bg:       #0a0a0b;
  --surface:  #131314;
  --s2:       #1c1c1e;
  --border:   #252528;
  --text:     #f0ece4;
  --muted:    #5a5a60;
  --muted2:   #7a7a88;
  --gold:     #d4a843;
  --gold-dim: rgba(212,168,67,.12);
  --blue:     #4a9eff;
  --blue-dim: rgba(74,158,255,.12);
  --green:    #34c97a;
  --green-dim:rgba(52,201,122,.12);
  --coral:    #ff6b5b;
  --coral-dim:rgba(255,107,91,.12);
  --purple:   #a78bfa;
  --purp-dim: rgba(167,139,250,.12);
  --teal:     #3dbfbf;
  --teal-dim: rgba(61,191,191,.12);
  --safe-t:   env(safe-area-inset-top, 0px);
  --safe-b:   env(safe-area-inset-bottom, 0px);
  --nav-h:    64px;
}

/* ─── MODULE COLORS ─────────────────────────────── */
.mod-chunks    { --mc: var(--gold);   --mc-dim: var(--gold-dim); }
.mod-phrasals  { --mc: var(--blue);   --mc-dim: var(--blue-dim); }
.mod-vocab     { --mc: var(--green);  --mc-dim: var(--green-dim); }
.mod-grammar   { --mc: var(--coral);  --mc-dim: var(--coral-dim); }
.mod-connectors{ --mc: var(--teal);   --mc-dim: var(--teal-dim); }
.mod-contrast  { --mc: var(--purple); --mc-dim: var(--purp-dim); }
.mod-quality   { --mc: var(--gold);   --mc-dim: var(--gold-dim); }

/* ─── RESET ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
}

/* ─── GRAIN ─────────────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 200px;
  pointer-events: none; z-index: 0; opacity: .5;
}

/* ─── LAYOUT ─────────────────────────────────────── */
.app {
  position: relative; z-index: 1;
  max-width: 430px; margin: 0 auto;
  padding: calc(var(--safe-t) + 16px) 20px calc(var(--safe-b) + var(--nav-h) + 20px);
  min-height: 100vh;
}
.app.no-nav {
  padding-bottom: calc(var(--safe-b) + 24px);
}

/* ─── BOTTOM NAV ─────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 430px;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(13,13,14,.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex; align-items: stretch;
  z-index: 100;
}
.nav-tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px; text-decoration: none;
  color: var(--muted); cursor: pointer;
  transition: color .18s; padding-top: 8px;
}
.nav-tab.active { color: var(--gold); }
.nav-tab svg { width: 22px; height: 22px; }
.nav-tab span { font-size: 10px; font-family: 'DM Mono', monospace; letter-spacing: .04em; }

/* ─── TOP BAR ─────────────────────────────────────── */
.top-bar {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 20px;
}
.back-btn {
  width: 36px; height: 36px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text); text-decoration: none; font-size: 18px;
  flex-shrink: 0; transition: border-color .2s;
}
.back-btn:active { border-color: var(--gold); }
.top-title {
  font-family: 'Fraunces', serif; font-size: 1.25rem; font-weight: 300; flex: 1;
}
.top-title em { font-style: italic; color: var(--gold); }
.icon-btn {
  width: 36px; height: 36px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--muted); font-size: 17px; flex-shrink: 0;
  transition: all .2s;
}
.icon-btn:active { border-color: var(--gold); color: var(--text); }

/* ─── SECTION LABEL ──────────────────────────────── */
.sec-label {
  font-family: 'DM Mono', monospace; font-size: 10px;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 12px;
  display: flex; align-items: center; gap: 10px;
}
.sec-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ─── CARDS ──────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 20px;
  position: relative; overflow: hidden;
}
.card::before {
  content: ''; position: absolute; top: 0; left: 0;
  width: 100%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent);
}
.card + .card { margin-top: 10px; }

/* ─── MODULE CARD ─────────────────────────────────── */
.mod-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px 18px;
  display: flex; align-items: center; gap: 14px;
  text-decoration: none; color: inherit; cursor: pointer;
  transition: border-color .2s; position: relative; overflow: hidden;
}
.mod-card::before {
  content: ''; position: absolute; top: 0; left: 0;
  width: 100%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent);
}
.mod-card:active { border-color: var(--mc, var(--gold)); }
.mod-icon {
  width: 46px; height: 46px; border-radius: 13px;
  background: var(--mc-dim, var(--gold-dim));
  border: 1px solid color-mix(in srgb, var(--mc, var(--gold)) 30%, transparent);
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; flex-shrink: 0;
}
.mod-info { flex: 1; min-width: 0; }
.mod-name { font-size: 14px; font-weight: 500; margin-bottom: 3px; }
.mod-desc { font-size: 11px; color: var(--muted2, var(--muted)); line-height: 1.4; }
.mod-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.mod-count { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--mc, var(--gold)); }
.mod-arr { color: var(--muted); font-size: 16px; }

/* ─── PROGRESS RING ──────────────────────────────── */
.ring-wrap { position: relative; width: 48px; height: 48px; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--border); stroke-width: 3; }
.ring-fill { fill: none; stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Mono', monospace; font-size: 10px; font-weight: 500;
}

/* ─── STAGE PILL ─────────────────────────────────── */
.stage-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  font-family: 'DM Mono', monospace; font-size: 9px;
  letter-spacing: .08em; text-transform: uppercase; flex-shrink: 0;
}
.stage-0 { background: rgba(90,90,96,.12); color: var(--muted); border: 1px solid var(--border); }
.stage-1 { background: rgba(255,107,91,.1); color: var(--coral); border: 1px solid rgba(255,107,91,.2); }
.stage-2 { background: rgba(74,158,255,.1); color: var(--blue); border: 1px solid rgba(74,158,255,.2); }
.stage-3 { background: rgba(52,201,122,.1); color: var(--green); border: 1px solid rgba(52,201,122,.2); }

/* ─── BUTTONS ────────────────────────────────────── */
.btn {
  width: 100%; padding: 14px;
  border: none; border-radius: 14px;
  font-family: 'DM Sans', sans-serif; font-size: 15px; font-weight: 500;
  cursor: pointer; transition: opacity .15s, transform .1s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { opacity: .85; transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--gold); color: #0a0a0b; }
.btn-secondary {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:active { border-color: var(--gold); }
.btn-green { background: var(--green); color: #0a0a0b; }
.btn-sm {
  padding: 9px 16px; font-size: 13px; width: auto; border-radius: 10px;
}

/* ─── EXERCISE CARD ──────────────────────────────── */
.ex-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 22px; margin-bottom: 16px;
}
.ex-type-badge {
  font-family: 'DM Mono', monospace; font-size: 9px;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--mc, var(--gold)); margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}
.ex-type-badge::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--mc, var(--gold)); flex-shrink: 0;
}
.ex-context {
  font-size: 12px; color: var(--mc, var(--gold)); margin-bottom: 12px;
  padding: 6px 10px;
  background: var(--mc-dim, var(--gold-dim));
  border-radius: 7px; font-family: 'DM Mono', monospace;
  line-height: 1.5;
}
.ex-question {
  font-family: 'Fraunces', serif; font-size: 1.15rem;
  font-weight: 300; line-height: 1.6; color: var(--text);
}
.ex-note {
  font-size: 12px; color: var(--muted2, var(--muted));
  margin-top: 8px; font-style: italic; line-height: 1.5;
}

/* ─── MULTIPLE CHOICE ────────────────────────────── */
.opts { display: grid; gap: 8px; margin-bottom: 14px; }
.opt {
  padding: 12px 16px; border: 1.5px solid var(--border);
  border-radius: 12px; cursor: pointer; font-size: 13px;
  background: var(--s2); color: var(--text); text-align: left;
  font-family: 'DM Sans', sans-serif; transition: all .15s; line-height: 1.5;
}
.opt:active:not(.disabled) { border-color: var(--gold); }
.opt.selected { border-color: var(--gold); background: var(--gold-dim); }
.opt.correct { background: var(--green-dim); border-color: var(--green); color: var(--green); }
.opt.wrong { background: var(--coral-dim); border-color: var(--coral); color: var(--coral); }
.opt.disabled { cursor: default; }

/* ─── FILL INPUT ─────────────────────────────────── */
.fill-wrap { font-family: 'Fraunces', serif; font-size: 1.05rem; font-weight: 300; line-height: 2.8; }
.fill-inp {
  display: inline-block; background: transparent; border: none;
  border-bottom: 2px solid var(--gold); color: var(--gold);
  font-family: 'DM Mono', monospace; font-size: .9rem;
  min-width: 120px; padding: 2px 6px; outline: none; text-align: center;
  transition: border-color .2s;
}
.fill-inp:focus { border-bottom-color: var(--blue); }
.fill-inp.ok { border-bottom-color: var(--green); color: var(--green); }
.fill-inp.no { border-bottom-color: var(--coral); color: var(--coral); }

/* ─── TEXTAREA ───────────────────────────────────── */
.ex-ta {
  width: 100%; background: var(--s2);
  border: 1.5px solid var(--border);
  border-radius: 12px; padding: 14px 16px;
  font-size: 14px; color: var(--text);
  font-family: 'DM Sans', sans-serif;
  resize: none; outline: none;
  transition: border-color .2s; min-height: 100px; line-height: 1.6;
}
.ex-ta:focus { border-color: var(--gold); }
.ex-ta.ok { border-color: var(--green); background: var(--green-dim); }
.ex-ta.no { border-color: var(--coral); background: var(--coral-dim); }

/* ─── FEEDBACK ───────────────────────────────────── */
.fb-box {
  border-radius: 13px; padding: 14px 16px;
  font-size: 13px; line-height: 1.7;
  display: none; margin-bottom: 14px;
}
.fb-box.show { display: block; animation: fadeUp .25s ease both; }
.fb-box.ok { background: var(--green-dim); border: 1px solid rgba(52,201,122,.25); }
.fb-box.no { background: var(--coral-dim); border: 1px solid rgba(255,107,91,.25); }
.fb-res { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.fb-res.ok { color: var(--green); }
.fb-res.no { color: var(--coral); }
.fb-correct { color: var(--text); margin-top: 6px; }
.fb-correct strong { color: var(--green); }

/* ─── PROGRESS BAR ───────────────────────────────── */
.prog-track {
  height: 3px; background: var(--border);
  border-radius: 2px; overflow: hidden; margin-bottom: 22px;
}
.prog-fill {
  height: 100%; background: linear-gradient(90deg, var(--gold), var(--green));
  border-radius: 2px; transition: width .4s ease;
}

/* ─── SPINNER ────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.15);
  border-top-color: var(--gold);
  animation: spin .7s linear infinite; display: none;
}
.spinner.show { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── STREAK PILL ────────────────────────────────── */
.streak-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--gold-dim); border: 1px solid rgba(212,168,67,.2);
  border-radius: 20px; padding: 6px 14px;
  font-family: 'DM Mono', monospace; font-size: 11px;
  color: var(--gold); letter-spacing: .06em;
}

/* ─── HERO ───────────────────────────────────────── */
.hero { padding: 8px 0 28px; }
.hero-label {
  font-family: 'DM Mono', monospace; font-size: 10px;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}
.hero-title {
  font-family: 'Fraunces', serif;
  font-size: clamp(2rem, 8vw, 2.6rem);
  font-weight: 300; line-height: 1.1; margin-bottom: 6px;
}
.hero-title em { font-style: italic; color: var(--gold); }
.hero-sub { font-size: 13px; color: var(--muted); line-height: 1.6; margin-top: 8px; }

/* ─── TODAY CARD ─────────────────────────────────── */
.today-card {
  background: linear-gradient(135deg, #1a1508, #100e06);
  border: 1px solid rgba(212,168,67,.2);
  border-radius: 20px; padding: 22px; margin-bottom: 28px;
}
.today-nums {
  display: flex; gap: 20px; margin-bottom: 18px;
}
.today-num-item { flex: 1; }
.today-num {
  font-family: 'Fraunces', serif; font-size: 2.2rem;
  font-weight: 300; color: var(--gold); line-height: 1;
}
.today-num-label {
  font-family: 'DM Mono', monospace; font-size: 9px;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); margin-top: 4px;
}

/* ─── LIBRARY ITEM ───────────────────────────────── */
.lib-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.lib-item:last-child { border-bottom: none; }
.lib-en { font-size: 14px; color: var(--text); line-height: 1.45; flex: 1; }
.lib-pt { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ─── STAT CARD ──────────────────────────────────── */
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px; text-align: center;
}
.stat-num {
  font-family: 'Fraunces', serif; font-size: 2rem;
  font-weight: 300; color: var(--text); line-height: 1;
}
.stat-label {
  font-family: 'DM Mono', monospace; font-size: 9px;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); margin-top: 6px;
}

/* ─── MODAL ──────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none; align-items: flex-end; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px 24px 0 0; padding: 28px 24px;
  padding-bottom: calc(28px + var(--safe-b));
  width: 100%; max-width: 430px;
  animation: slideUp .3s ease both;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-title {
  font-family: 'Fraunces', serif; font-size: 1.3rem;
  font-weight: 300; margin-bottom: 16px;
}
.modal-label {
  font-family: 'DM Mono', monospace; font-size: 10px;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); margin-bottom: 6px;
}
.modal-input {
  width: 100%; background: var(--s2); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 12px 14px; color: var(--text);
  font-size: 13px; font-family: 'DM Mono', monospace;
  outline: none; margin-bottom: 16px; transition: border-color .2s;
}
.modal-input:focus { border-color: var(--gold); }
.modal-note { font-size: 11px; color: var(--muted); line-height: 1.6; margin-bottom: 20px; }

/* ─── SESSION SUMMARY ─────────────────────────────── */
.summary-card {
  background: linear-gradient(135deg, #0f1a0c, #0a1008);
  border: 1px solid rgba(52,201,122,.2);
  border-radius: 20px; padding: 28px; text-align: center;
}
.summary-emoji { font-size: 3rem; margin-bottom: 16px; }
.summary-title {
  font-family: 'Fraunces', serif; font-size: 1.6rem;
  font-weight: 300; margin-bottom: 6px;
}
.summary-title em { font-style: italic; color: var(--green); }
.summary-sub { font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.summary-nums { display: flex; gap: 16px; justify-content: center; margin-bottom: 24px; }
.summary-num {
  font-family: 'Fraunces', serif; font-size: 2.5rem;
  font-weight: 300; color: var(--text); line-height: 1;
}
.summary-num-label {
  font-family: 'DM Mono', monospace; font-size: 9px;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); margin-top: 4px;
}

/* ─── SEARCH ─────────────────────────────────────── */
.search-wrap {
  position: relative; margin-bottom: 18px;
}
.search-icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); color: var(--muted); font-size: 14px;
}
.search-inp {
  width: 100%; background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 11px 14px 11px 36px;
  color: var(--text); font-size: 14px; font-family: 'DM Sans', sans-serif;
  outline: none; transition: border-color .2s;
}
.search-inp:focus { border-color: var(--gold); }

/* ─── FILTER PILLS ───────────────────────────────── */
.filter-row {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 4px; margin-bottom: 18px;
  -ms-overflow-style: none; scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }
.filter-pill {
  flex-shrink: 0; padding: 6px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; font-family: 'DM Mono', monospace;
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); cursor: pointer; transition: all .18s;
  white-space: nowrap;
}
.filter-pill.active {
  background: var(--gold-dim); border-color: rgba(212,168,67,.3);
  color: var(--gold);
}

/* ─── EMPTY STATE ─────────────────────────────────── */
.empty {
  text-align: center; padding: 48px 24px;
  color: var(--muted); font-size: 13px; line-height: 1.7;
}
.empty-icon { font-size: 2.5rem; margin-bottom: 14px; }

/* ─── ANIMATIONS ─────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .6; transform: scale(.85); }
}
.fade-up { animation: fadeUp .35s ease both; }
.pulse { animation: pulse 2s ease-in-out infinite; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
