:root {
  --bg: #100a13;
  --glass: rgba(255, 255, 255, 0.055);
  --border: rgba(255, 255, 255, 0.09);
  --border-soft: rgba(255, 255, 255, 0.15);
  --text: #f3eef6;
  --text-muted: #9c92a8;
  --accent: #ff6a3d;
  --accent-2: #c084fc;
  --ok: #a3e635;
  --error: #fb7185;
  --radius: 20px;
  --radius-sm: 13px;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overscroll-behavior-y: none;
}

/* ---- energetic background ---- */
.aurora-bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; background: var(--bg); }
.aurora-blob { position: absolute; border-radius: 50%; filter: blur(85px); opacity: 0.32; will-change: transform; }
.blob-1 {
  width: 58vh; height: 58vh; top: -18%; left: -12%;
  background: radial-gradient(circle, #ff6a3d 0%, transparent 70%);
  animation: drift1 32s ease-in-out infinite alternate;
}
.blob-2 {
  width: 52vh; height: 52vh; top: 32%; right: -22%;
  background: radial-gradient(circle, #c084fc 0%, transparent 70%);
  opacity: 0.26;
  animation: drift2 38s ease-in-out infinite alternate;
}
.blob-3 {
  width: 48vh; height: 48vh; bottom: -22%; left: 8%;
  background: radial-gradient(circle, #a3e635 0%, transparent 70%);
  opacity: 0.2;
  animation: drift3 44s ease-in-out infinite alternate;
}
@keyframes drift1 { from { transform: translate(0,0); } to { transform: translate(8%,10%); } }
@keyframes drift2 { from { transform: translate(0,0); } to { transform: translate(-10%,8%); } }
@keyframes drift3 { from { transform: translate(0,0); } to { transform: translate(6%,-8%); } }

.grain {
  position: absolute; inset: -10%; opacity: 0.035; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

#app {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  height: 100dvh; height: 100vh;
  max-width: 560px; margin: 0 auto;
}

.view-container {
  flex: 1; overflow-y: auto;
  padding: 30px 18px calc(116px + env(safe-area-inset-bottom, 0px));
  -webkit-overflow-scrolling: touch;
}

.view-header { margin-bottom: 22px; }
.view-title { font-family: var(--font-display); font-size: 25px; font-weight: 700; letter-spacing: -0.01em; }
.view-subtitle { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; line-height: 1.4; }

.section-title {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); margin: 30px 0 14px; opacity: 0.85;
}

.glass, .packet-card, .flash-card, .summary-card, .global-stat-card, .stat-packet-row {
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 12px 30px -18px rgba(0,0,0,0.7);
}

@keyframes riseIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.packet-card, .flash-card, .summary-card { animation: riseIn 0.4s cubic-bezier(.2,.7,.3,1) both; }

.sub-chip, .btn-packet-all, .btn-packet-errors, .nav-btn, .assess-btn, .btn-primary, .packet-card, .quick-start-btn {
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.sub-chip:active, .btn-packet-all:active, .btn-packet-errors:active, .nav-btn:active, .assess-btn:active, .btn-primary:active, .quick-start-btn:active {
  transform: scale(0.96);
}

/* ---- quick start ---- */
.quick-start-card {
  display: flex; align-items: center; gap: 14px;
  border-radius: 24px;
  padding: 18px 18px 18px 20px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(255,106,61,0.16), rgba(192,132,252,0.12));
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 16px 36px -18px rgba(255,106,61,0.4);
  animation: riseIn 0.4s cubic-bezier(.2,.7,.3,1) both;
}
.quick-start-icon { font-size: 28px; }
.quick-start-info { flex: 1; min-width: 0; }
.quick-start-label { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.quick-start-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.quick-start-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #180a12; border: none; border-radius: var(--radius-sm);
  padding: 12px 18px; font-size: 13px; font-weight: 700; font-family: var(--font-body);
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
}

/* ---- error summary ---- */
.error-summary {
  font-size: 12.5px; color: var(--error); font-weight: 600;
  padding: 4px 4px 14px;
}
.error-summary.ok { color: var(--ok); }

/* ---- packets ---- */
.packet-list { display: flex; flex-direction: column; gap: 12px; }
.packet-card { border-radius: var(--radius); padding: 16px; }
.packet-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.packet-title { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.packet-count { font-size: 12px; color: var(--text-muted); }

.mini-bar { display: flex; height: 7px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,0.06); }
.mini-bar-seg { height: 100%; }
.seg-ok { background: var(--ok); }
.seg-error { background: var(--error); }
.seg-new { background: transparent; }

.packet-actions { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.btn-packet-all {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #180a12; border: none; border-radius: var(--radius-sm);
  padding: 11px; font-size: 13px; font-weight: 700; font-family: var(--font-body); cursor: pointer;
}
.sub-chip-row { display: flex; gap: 8px; }
.sub-chip {
  flex: 1; background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  color: var(--text-muted); border-radius: var(--radius-sm); padding: 9px 4px;
  font-size: 12px; font-weight: 700; cursor: pointer; font-family: var(--font-display);
}
.btn-packet-errors {
  background: rgba(251,113,133,0.14); border: 1px solid rgba(251,113,133,0.4);
  color: var(--error); border-radius: var(--radius-sm); padding: 10px;
  font-size: 12.5px; font-weight: 700; font-family: var(--font-body); cursor: pointer;
}

/* ---- session ---- */
.bottom-nav.hidden { display: none; }
.session-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 8px;
}
.session-exit, .hint-btn {
  background: var(--glass); border: 1px solid var(--border); color: var(--text);
  border-radius: 99px; padding: 8px 14px; font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: var(--font-body);
}
.session-progress-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }

.progress-bar-track { height: 5px; background: rgba(255,255,255,0.06); border-radius: 99px; margin-bottom: 22px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.3s ease; }

.flash-card {
  position: relative;
  border-radius: 26px;
  padding: 34px 22px 26px;
  text-align: center;
  min-height: 320px;
  display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start;
}
.flash-card.tappable { cursor: pointer; }
.fr-word { font-family: var(--font-display); font-size: 30px; font-weight: 700; margin-top: 10px; }
.hint-tag {
  align-self: center;
  font-size: 11px; font-weight: 700; padding: 4px 12px; border-radius: 99px;
  background: color-mix(in srgb, var(--tag-color) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--tag-color) 55%, transparent);
  color: var(--tag-color);
  margin-bottom: 14px;
}
.reveal-stack { width: 100%; margin-top: 22px; display: flex; flex-direction: column; gap: 14px; }
.reveal-row {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  animation: riseIn 0.3s ease both;
}
.reveal-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 4px; }
.reveal-value { font-family: var(--font-display); font-size: 19px; font-weight: 700; }

.session-footer { margin-top: 22px; }
.session-tap-hint { text-align: center; font-size: 12.5px; color: var(--text-muted); }
.assess-row { display: flex; gap: 10px; }
.assess-btn {
  flex: 1; border: none; border-radius: var(--radius-sm); padding: 15px 8px;
  font-size: 14px; font-weight: 700; font-family: var(--font-body); cursor: pointer;
}
.assess-wrong { background: rgba(251,113,133,0.16); color: var(--error); border: 1px solid rgba(251,113,133,0.4); }
.assess-correct { background: rgba(163,230,53,0.16); color: var(--ok); border: 1px solid rgba(163,230,53,0.4); }

.summary-card { border-radius: 26px; padding: 32px 22px; text-align: center; }
.summary-pct { font-family: var(--font-display); font-size: 46px; font-weight: 700; }
.summary-sub { font-size: 13px; color: var(--text-muted); margin: 8px 0 22px; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #180a12; border: none; border-radius: var(--radius-sm);
  padding: 13px; font-size: 14px; font-weight: 700; font-family: var(--font-body); cursor: pointer;
}
.btn-full { width: 100%; }

/* ---- stats ---- */
.global-stat-grid { display: flex; gap: 10px; }
.global-stat-card { flex: 1; border-radius: var(--radius); padding: 16px; text-align: center; }
.global-stat-num { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.global-stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.stat-packet-list { display: flex; flex-direction: column; gap: 10px; }
.stat-packet-row { border-radius: var(--radius-sm); padding: 14px; }
.stat-packet-label { font-family: var(--font-display); font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.stat-packet-nums { font-size: 11px; color: var(--text-muted); margin-top: 8px; }

.btn-reset {
  display: block; width: 100%; margin-top: 30px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); border-radius: var(--radius-sm);
  padding: 12px; font-size: 12.5px; font-weight: 600; font-family: var(--font-body);
  cursor: pointer; transition: border-color 0.15s ease, color 0.15s ease;
}
.btn-reset:active { border-color: var(--error); color: var(--error); }

/* ---- floating bottom nav ---- */
.bottom-nav {
  position: absolute; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); left: 16px; right: 16px;
  display: flex; background: rgba(24, 16, 26, 0.65); border: 1px solid var(--border-soft);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-radius: 22px; padding: 8px;
  box-shadow: 0 16px 40px -12px rgba(0,0,0,0.65);
}
.nav-btn {
  flex: 1; background: none; border: none; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px; cursor: pointer; border-radius: 16px; font-family: var(--font-body);
}
.nav-btn.active { color: var(--accent); background: linear-gradient(135deg, rgba(255,106,61,0.16), rgba(192,132,252,0.1)); }
.nav-icon { font-size: 19px; }
.nav-label { font-size: 9.5px; font-weight: 600; }

/* ---- grammar ---- */
.quiz-start-card {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  border-radius: 24px; padding: 18px 18px 18px 20px; margin-bottom: 10px;
  background: linear-gradient(135deg, rgba(56,189,248,0.16), rgba(163,230,53,0.1));
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 16px 36px -18px rgba(56,189,248,0.4);
  animation: riseIn 0.4s cubic-bezier(.2,.7,.3,1) both;
  cursor: pointer; font-family: var(--font-body);
  transition: transform 0.12s ease;
}
.quiz-start-card:active { transform: scale(0.97); }
.quiz-start-icon { font-size: 26px; }
.quiz-start-info { display: flex; flex-direction: column; }
.quiz-start-label { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--text); }
.quiz-start-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.rule-list { display: flex; flex-direction: column; gap: 12px; }
.rule-card {
  background: var(--glass); border: 1px solid var(--border);
  border-left: 3px solid var(--rule-color);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-radius: var(--radius); padding: 16px;
  animation: riseIn 0.4s cubic-bezier(.2,.7,.3,1) both;
}
.rule-title { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--rule-color); }
.rule-explanation { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; margin-top: 6px; }
.rule-endings {
  font-size: 11px; color: var(--text); background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 10px;
  font-family: var(--font-display);
}
.rule-example-label { font-size: 12px; font-weight: 700; margin-top: 14px; margin-bottom: 6px; }
.rule-extra { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; line-height: 1.5; }
.rule-extra strong { color: var(--text); }

.conj-table { display: flex; flex-direction: column; gap: 4px; }
.conj-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 6px 10px; background: rgba(255,255,255,0.035); border-radius: var(--radius-sm);
}
.conj-pronoun { font-size: 11.5px; color: var(--text-muted); }
.conj-form { font-family: var(--font-display); font-size: 13.5px; font-weight: 700; }

.quiz-anchor { font-size: 12px; color: var(--text-muted); margin-top: 14px; }
.quiz-anchor strong { color: var(--text); }
.quiz-ask { font-size: 14px; margin-top: 10px; }
.quiz-ask strong { color: var(--accent-2); }
