/* ═══════════════════════════════════════════════════════════════
   MatekÉrettségi – Notebook design system
   Warm paper aesthetic, Georgia headings, ruled-line pages
   ═══════════════════════════════════════════════════════════════ */

/* ─── Reset & tokens ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --paper:     #fffef6;
  --bg:        #ede8dc;
  --surface:   #fffef6;
  --ink:       #1c1917;
  --ink-2:     #3c3530;
  --muted:     #78716c;
  --muted-2:   #a8a29e;
  --border:    #ddd4c4;
  --border-2:  #ccc1ae;
  --navy:      #1e3758;
  --binding:   #14284a;
  --blue:      #2563eb;
  --blue-soft: #eef3ff;
  --blue-mid:  #c7d7ff;
  --green:     #16a34a;
  --green-soft:#f0fdf4;
  --gold:      #b45309;
  --gold-soft: #fff7ed;
  --red:       #dc2626;
  --red-soft:  #fef2f2;
  --ruled:     #dce4f5;
  --ruled-h:   28px;
  --margin-c:  #f87171;
  --ring-c:    #4d88c8;

  --r-sm:  5px;
  --r-md:  9px;
  --r-lg:  13px;
  --r-xl:  18px;

  --sh:    0 1px 4px rgba(60,40,20,.1), 0 1px 2px rgba(60,40,20,.07);
  --sh-md: 0 4px 14px rgba(60,40,20,.13);
  --sh-lg: 0 10px 32px rgba(60,40,20,.16);
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, h4 {
  font-family: Georgia, 'Times New Roman', serif;
}
h1 em, h2 em, h3 em, h4 em {
  font-style: italic;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }

/* ─── Utilities ─────────────────────────────────────────────── */
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }

/* ════════════════════════════════════════════════════════════════
   HEADER
   ════════════════════════════════════════════════════════════════ */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  font-family: Georgia, 'Times New Roman', serif;
}
.header-brand i { color: var(--gold); font-size: 1.05rem; }
.header-brand:hover { text-decoration: none; }

.header-nav { display: flex; align-items: center; gap: 4px; }
.nav-link {
  color: var(--ink-2);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: .875rem;
  font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  transition: background .12s;
  white-space: nowrap;
}
.nav-link:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.nav-link--primary {
  background: var(--blue);
  color: #fff;
}
.nav-link--primary:hover { background: #1d4ed8; color: #fff; }
.nav-link--ghost {
  color: var(--muted);
}
.nav-link--ghost:hover { color: var(--ink); background: var(--bg); }
.nav-user {
  display: flex; align-items: center; gap: 5px;
  font-size: .875rem; color: var(--muted); padding: 6px 8px;
}
.nav-user i { color: var(--gold); }
.nav-user-menu { display: flex; align-items: center; gap: 2px; }

/* ════════════════════════════════════════════════════════════════
   FOOTER
   ════════════════════════════════════════════════════════════════ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 16px;
  margin-top: auto;
  font-size: .8rem;
  color: var(--muted-2);
  background: var(--surface);
}
.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.footer-inner i { color: var(--gold); }

/* ════════════════════════════════════════════════════════════════
   HOME PAGE
   ════════════════════════════════════════════════════════════════ */
.page-home { background: var(--bg); }

/* ── Hero — two-column, ruled-paper background ──────────────── */
.home-hero {
  background-color: var(--surface);
  background-image: repeating-linear-gradient(
    transparent 0px,
    transparent 27px,
    rgba(180,200,235,.35) 27px,
    rgba(180,200,235,.35) 28px
  );
  border-bottom: 1px solid var(--border);
  padding: 40px 16px 36px;
}
.home-hero__inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 40px;
}

/* Left: text */
.home-hero__text {
  flex: 1;
  min-width: 0;
}

/* Eyebrow */
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .04em;
  margin-bottom: 14px;
}
.hero-eyebrow i { color: var(--gold); font-size: .8rem; }

/* Main heading */
.hero-heading {
  font-size: clamp(1.6rem, 3.2vw, 2.4rem);
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 22px;
  letter-spacing: -.3px;
}
.hero-heading em { color: var(--navy); font-style: italic; }

/* CTA */
.hero-cta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.btn--hero-primary {
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  padding: 11px 22px;
  border-radius: var(--r-md);
  font-size: .95rem;
  display: inline-flex; align-items: center; gap: 7px;
  text-decoration: none;
  transition: background .12s, transform .12s;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
.btn--hero-primary:hover { background: #1d4ed8; text-decoration: none; transform: translateY(-1px); }
.btn--hero-ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--border-2);
  padding: 11px 20px;
  border-radius: var(--r-md);
  font-size: .95rem;
  display: inline-flex; align-items: center; gap: 7px;
  text-decoration: none;
  transition: background .12s;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
.btn--hero-ghost:hover { background: var(--bg); text-decoration: none; }

/* Right: stat counters */
.home-hero__counters {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.hero-counter {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--navy);
  border-radius: var(--r-lg);
  padding: 18px 20px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 5px;
  box-shadow: var(--sh);
  min-width: 84px;
}
.hc-num {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}
.hc-label {
  font-size: .68rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-family: -apple-system, system-ui, sans-serif;
}

/* ── Stats bar (logged-in user summary) ─────────────────────── */
.home-statsbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.home-statsbar__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 6px 16px;
  flex-wrap: wrap;
  font-size: .84rem;
}
.hsb-item { display: flex; align-items: center; gap: 5px; color: var(--muted); }
.hsb-item i { color: var(--gold); font-size: .8rem; }
.hsb-item strong { color: var(--ink); }
.hsb-divider { width: 1px; height: 14px; background: var(--border); flex-shrink: 0; }
.hsb-pct.great strong { color: var(--green); }
.hsb-pct.ok   strong { color: var(--gold); }
.hsb-pct.low  strong { color: var(--red); }
.hsb-link {
  margin-left: auto;
  font-size: .82rem; font-weight: 600;
  color: var(--blue);
  display: flex; align-items: center; gap: 4px;
}
.hsb-link:hover { text-decoration: underline; }

/* ── Exam list ───────────────────────────────────────────────── */
.home-main {
  flex: 1;
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
  padding: 20px 16px 52px;
}

/* Year group — horizontal card: year on left, exams on right */
.year-group {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh);
  overflow: hidden;
  margin-bottom: 6px;
  transition: box-shadow .13s;
}
.year-group:hover { box-shadow: var(--sh-md); }

.year-group__label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 70px;
  min-width: 70px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  gap: 0;
  margin-bottom: 0;
}
.year-group__label span {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1rem;
  font-weight: 700;
  font-style: italic;
  color: var(--navy);
  background: none;
  padding: 0;
  white-space: nowrap;
  letter-spacing: -.3px;
}
.year-group__line { display: none; }

/* Exam row — flex inside the year card */
.exam-row {
  flex: 1;
  display: flex;
  gap: 6px;
  padding: 6px;
  min-width: 0;
}

/* Exam tile — flat inside the card */
.exam-tile {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  text-decoration: none;
  color: var(--ink);
  transition: background .12s, border-color .12s;
  cursor: pointer;
  box-shadow: none;
}
.exam-tile--maj { border-left-color: var(--gold); }
.exam-tile--okt { border-left-color: var(--green); }
.exam-tile:hover {
  background: var(--bg);
  text-decoration: none;
  transform: none;
  box-shadow: none;
}
.exam-tile--maj:hover { border-left-color: var(--gold); border-color: var(--border-2); }
.exam-tile--okt:hover { border-left-color: var(--green); border-color: var(--border-2); }

.exam-tile__icon {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem;
}
.exam-tile--maj .exam-tile__icon { background: var(--gold-soft); color: var(--gold); }
.exam-tile--okt .exam-tile__icon { background: var(--green-soft); color: var(--green); }

.exam-tile__body { flex: 1; min-width: 0; }
.exam-tile__period { font-size: .83rem; font-weight: 700; color: var(--ink); }
.exam-tile__stats {
  display: flex; gap: 8px; margin-top: 2px;
  font-size: .71rem; color: var(--muted);
}
.exam-tile__stats i { margin-right: 2px; }
.exam-tile__arrow {
  color: var(--border-2); font-size: .7rem;
  transition: color .12s, transform .12s;
}
.exam-tile:hover .exam-tile__arrow { color: var(--blue); transform: translateX(2px); }

/* ════════════════════════════════════════════════════════════════
   AUTH PAGES
   ════════════════════════════════════════════════════════════════ */
.page-auth { background: var(--bg); }
.auth-main {
  flex: 1; display: flex;
  align-items: center; justify-content: center;
  padding: 32px 16px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-md);
  width: 100%; max-width: 420px;
  padding: 36px 28px;
}
.auth-icon { font-size: 1.8rem; color: var(--gold); margin-bottom: 10px; }
.auth-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 22px;
  font-family: Georgia, 'Times New Roman', serif;
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: .82rem; font-weight: 600; color: var(--ink-2);
  display: flex; align-items: center; gap: 5px;
}
.form-group label i { color: var(--gold); }
.form-group input {
  padding: 10px 12px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  font-size: .95rem;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  background: var(--paper);
  width: 100%;
  color: var(--ink);
}
.form-group input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.auth-switch { margin-top: 18px; text-align: center; font-size: .85rem; color: var(--muted); }
.auth-switch a { color: var(--blue); font-weight: 600; }

/* ════════════════════════════════════════════════════════════════
   BUTTONS  (sans-serif — not Georgia)
   ════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--r-md);
  font-size: .9rem; font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s, transform .1s, box-shadow .12s;
  text-decoration: none;
  white-space: nowrap;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn--primary { background: var(--blue); color: #fff; }
.btn--primary:hover { background: #1d4ed8; box-shadow: 0 3px 10px rgba(37,99,235,.3); }
.btn--ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--border-2);
}
.btn--ghost:hover { background: var(--bg); }
.btn--outline { background: transparent; color: var(--blue); border-color: var(--blue-mid); }
.btn--outline:hover { background: var(--blue-soft); }
.btn--reveal {
  background: var(--ink);
  color: #fff; font-size: .95rem; padding: 11px 24px;
  border-radius: var(--r-md);
}
.btn--reveal:hover { background: var(--ink-2); box-shadow: var(--sh-md); }
.btn--finish { background: var(--green); color: #fff; }
.btn--finish:hover { background: #15803d; }
.btn--danger { background: var(--red); color: #fff; }
.btn--danger:hover { background: #b91c1c; }
.btn--full { width: 100%; justify-content: center; padding: 11px; }
.btn--sm { padding: 6px 12px; font-size: .82rem; }

/* Icon button — used in practice header */
.btn-icon {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.12); color: #fff;
  border: none; cursor: pointer; font-size: .95rem;
  transition: background .12s; text-decoration: none;
}
.btn-icon:hover { background: rgba(255,255,255,.22); }

.btn-icon-sm {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; color: var(--muted);
  transition: color .12s, background .12s, border-color .12s;
}
.btn-delete:hover { color: var(--red); border-color: var(--red); background: var(--red-soft); }

/* Alert */
.alert {
  padding: 10px 13px; border-radius: var(--r-md);
  font-size: .85rem; display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px;
}
.alert--error { background: var(--red-soft); color: var(--red); border: 1px solid #fecaca; }

/* ════════════════════════════════════════════════════════════════
   PRACTICE PAGE
   ════════════════════════════════════════════════════════════════ */
.page-practice { background: var(--bg); }

/* ── Practice header — dark notebook cover ───────────────────── */
.practice-header {
  background: var(--navy);
  border-bottom: 2px solid var(--binding);
  padding: 0 12px;
  height: 52px;
  display: flex; align-items: center;
  justify-content: space-between; gap: 8px;
  position: sticky; top: 0; z-index: 200;
}
.practice-header__left  { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.practice-header__center { display: flex; align-items: center; justify-content: center; }
.practice-header__right  { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Override btn-icon for dark practice header */
.practice-header .btn-icon {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  color: rgba(255,255,255,.85);
}
.practice-header .btn-icon:hover {
  background: rgba(255,255,255,.22);
  color: #fff;
}

.exam-label {
  display: flex; align-items: center; gap: 6px;
  font-size: .88rem; font-weight: 600;
  color: rgba(255,255,255,.9);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.exam-label i { color: rgba(255,255,255,.6); flex-shrink: 0; }

.timer-block {
  display: flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  padding: 5px 12px; border-radius: 99px;
  font-size: .85rem; font-variant-numeric: tabular-nums;
  color: rgba(255,255,255,.9);
}
.timer-block i { color: rgba(255,255,255,.55); font-size: .8rem; }
.timer-sep { color: rgba(255,255,255,.3); }
#problem-timer { color: rgba(255,255,255,.65); }

.score-block {
  display: flex; align-items: center; gap: 5px;
  font-size: .88rem; font-weight: 700;
  color: rgba(255,255,255,.9);
}
.score-block i { color: #fbbf24; }

/* Practice header user display */
.practice-header .nav-user {
  color: rgba(255,255,255,.7);
  font-size: .82rem;
}
.practice-header .nav-user i { color: rgba(255,255,255,.5); }
.practice-header .nav-link {
  color: rgba(255,255,255,.8);
  font-size: .82rem;
}
.practice-header .nav-link:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

/* ── Progress bar ────────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 7px 16px;
  display: flex; align-items: center; gap: 10px;
}
.progress-bar-track {
  flex: 1; height: 4px;
  background: var(--border);
  border-radius: 99px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--blue);
  border-radius: 99px; transition: width .4s ease;
}
.progress-label { color: var(--muted); font-size: .78rem; white-space: nowrap; }

/* ── Practice main ───────────────────────────────────────────── */
.practice-main {
  flex: 1; max-width: 860px; margin: 0 auto; width: 100%;
  padding: 20px 12px 48px;
}

.problem-slide { display: none; }
.problem-slide.is-active { display: block; animation: fadeUp .2s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Notebook page ───────────────────────────────────────────── */
.notebook-page {
  background: var(--paper);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--sh-md);
  display: flex; overflow: hidden;
}

/* Binding — dark spine of the notebook */
.notebook-binding {
  width: 40px; min-width: 40px;
  background: var(--binding);
  background-image: linear-gradient(
    to right,
    rgba(0,0,0,.15) 0%,
    transparent 30%,
    transparent 70%,
    rgba(0,0,0,.1) 100%
  );
  display: flex; flex-direction: column;
  align-items: center; justify-content: space-evenly;
  padding: 16px 0;
}

/* Rings — metallic binder rings */
.ring {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--ring-c);
  background: #0e1e36;
  box-shadow: inset 0 2px 3px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.1);
  flex-shrink: 0;
}

/* Paper area with ruled lines + red margin */
.notebook-content {
  flex: 1;
  padding: 24px 24px 28px 20px;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    transparent 0px,
    transparent 27px,
    var(--ruled) 27px,
    var(--ruled) 28px
  );
  background-position: 0 48px;
  border-left: 3px solid var(--margin-c);
  min-width: 0;
}

/* ── Problem badge ───────────────────────────────────────────── */
.problem-badge {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.problem-num {
  font-size: 1rem; font-weight: 800; color: var(--ink);
  font-family: Georgia, 'Times New Roman', serif;
}
.problem-pts {
  font-size: .76rem; font-weight: 600;
  background: var(--blue-soft); color: var(--blue);
  padding: 2px 8px; border-radius: 99px;
}

/* ── Problem image ───────────────────────────────────────────── */
.problem-img-wrap {
  margin: 0 -4px 18px;
  display: flex; justify-content: center;
}
.problem-img { max-width: 100%; border-radius: 4px; }
.img-missing {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; color: var(--muted); padding: 32px;
  background: var(--bg); border-radius: var(--r-md);
  border: 1px dashed var(--border-2); font-size: .88rem; width: 100%;
}
.img-missing i { font-size: 1.8rem; color: var(--border-2); }

/* ── Solution ────────────────────────────────────────────────── */
.solution-wrap {
  margin: 14px 0;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid #86efac;
  animation: revealIn .25s ease;
}
@keyframes revealIn {
  from { opacity:0; transform: scaleY(.97); }
  to   { opacity:1; transform: scaleY(1); }
}
.solution-header {
  background: var(--green-soft);
  color: var(--green);
  padding: 8px 14px;
  font-weight: 700; font-size: .84rem;
  display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid #86efac;
}
.solution-img { max-width: 100%; background: #fff; }
.img-missing--sol { background: var(--green-soft); border-color: #86efac; }

/* ── Problem controls ────────────────────────────────────────── */
.problem-controls {
  margin-top: 20px;
  display: flex; flex-direction: column; gap: 14px;
  align-items: flex-start;
}

/* Points input */
.points-input-wrap { display: flex; flex-direction: column; gap: 7px; }
.points-input-wrap label {
  font-size: .84rem; font-weight: 600; color: var(--ink-2);
  display: flex; align-items: center; gap: 5px;
}
.points-input-wrap label i { color: var(--blue); }
.points-row { display: flex; align-items: center; gap: 7px; }
.pts-btn {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  border: 1px solid var(--border-2); background: var(--surface);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--ink); transition: background .1s, border-color .1s;
  font-size: .85rem;
}
.pts-btn:hover { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.points-input {
  width: 64px; text-align: center;
  font-size: 1.1rem; font-weight: 700;
  padding: 6px; border: 1px solid var(--border-2); border-radius: var(--r-sm);
  outline: none; transition: border-color .12s;
  font-family: inherit;
  background: var(--paper);
  color: var(--ink);
}
.points-input:focus { border-color: var(--blue); }
.points-max { color: var(--muted); font-size: .88rem; }
.nav-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

/* Report button */
.btn-report {
  margin-left: auto;
  background: none; border: 1px solid transparent;
  border-radius: var(--r-sm); cursor: pointer;
  color: var(--border-2); font-size: .78rem;
  padding: 3px 7px;
  display: flex; align-items: center; gap: 4px;
  transition: color .12s, border-color .12s, background .12s;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
.btn-report:hover { color: var(--red); border-color: #fca5a5; background: var(--red-soft); }

/* ── Summary screen ──────────────────────────────────────────── */
.notebook-page--summary .notebook-content {
  text-align: center;
  background-image: none;
  border-left-color: var(--border);
}
.summary-icon { font-size: 2.5rem; color: var(--gold); margin-bottom: 10px; }
.summary-title {
  font-size: 1.6rem; font-weight: 800; color: var(--ink); margin-bottom: 4px;
}
.summary-exam { font-size: .9rem; color: var(--muted); margin-bottom: 24px; }

.summary-stats {
  display: flex; gap: 12px; justify-content: center;
  flex-wrap: wrap; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 22px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 100px;
}
.stat-card i { font-size: 1.2rem; color: var(--blue); }
.stat-card--pct i { color: var(--green); }
.stat-value { font-size: 1.5rem; font-weight: 800; color: var(--ink); }
.stat-label { font-size: .75rem; color: var(--muted); }

.summary-table-wrap { overflow-x: auto; margin-bottom: 20px; text-align: left; }
.summary-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.summary-table th, .summary-table td {
  padding: 7px 10px; border-bottom: 1px solid var(--border);
}
.summary-table th { font-weight: 700; color: var(--ink-2); background: var(--bg); }

.summary-actions {
  display: flex; gap: 8px; justify-content: center;
  flex-wrap: wrap; align-items: center;
}
.save-note {
  font-size: .82rem; color: var(--green); font-weight: 600;
  display: flex; align-items: center; gap: 4px;
}

/* ════════════════════════════════════════════════════════════════
   HISTORY PAGE
   ════════════════════════════════════════════════════════════════ */
.page-history { background: var(--bg); }
.history-main {
  flex: 1; max-width: 860px; margin: 0 auto;
  width: 100%; padding: 0 12px 48px;
}

.page-title-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.page-title-bar__inner {
  max-width: 860px; margin: 0 auto;
  padding: 20px 12px;
  display: flex; align-items: center;
  justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.page-title-bar h1 {
  font-size: 1.3rem; font-weight: 800; color: var(--ink);
  display: flex; align-items: center; gap: 8px; margin-bottom: 2px;
}
.page-title-bar h1 i { color: var(--gold); }
.page-title-bar p { font-size: .85rem; color: var(--muted); }

/* Stats overview */
.stats-overview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px; margin-bottom: 20px;
}
.stat-overview-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--sh);
}
.soc-icon {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  background: var(--blue-soft); color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.soc-icon--gold  { background: var(--gold-soft); color: var(--gold); }
.soc-icon--green { background: var(--green-soft); color: var(--green); }
.soc-icon--red   { background: var(--red-soft);   color: var(--red); }
.soc-body { display: flex; flex-direction: column; gap: 1px; }
.soc-body strong { font-size: 1.1rem; font-weight: 800; color: var(--ink); }
.soc-body span   { font-size: .74rem; color: var(--muted); }

/* History list */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-card {
  display: flex; background: var(--surface);
  border-radius: var(--r-lg); border: 1px solid var(--border);
  overflow: hidden; box-shadow: var(--sh);
}
.history-card__accent {
  width: 4px; flex-shrink: 0; background: var(--blue);
}
.history-card__accent.pct--great { background: var(--green); }
.history-card__accent.pct--ok    { background: var(--gold); }
.history-card__accent.pct--low   { background: var(--red); }
.history-card__body { flex: 1; padding: 12px 14px; min-width: 0; }
.history-card__top {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 8px;
  margin-bottom: 8px; flex-wrap: wrap;
}
.hcard-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.history-exam-name {
  font-weight: 700; font-size: .92rem;
  display: flex; align-items: center; gap: 6px; min-width: 0;
}
.history-exam-name i { color: var(--gold); flex-shrink: 0; }
.history-date { font-size: .75rem; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.history-card__stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.hstat {
  font-size: .8rem; display: flex; align-items: center; gap: 4px; color: var(--muted);
}
.hstat i { color: var(--muted-2); width: 13px; text-align: center; }
.hstat--pct--great, .hstat--pct--great i { color: var(--green) !important; }
.hstat--pct--ok,    .hstat--pct--ok i    { color: var(--gold) !important; }
.hstat--pct--low,   .hstat--pct--low i   { color: var(--red) !important; }

.history-bar { height: 4px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.history-bar__fill { height:100%; border-radius:99px; background: var(--blue); }
.history-bar__fill.pct--great { background: var(--green); }
.history-bar__fill.pct--ok    { background: var(--gold); }
.history-bar__fill.pct--low   { background: var(--red); }

.history-card__retry {
  display: flex; align-items: center; justify-content: center;
  padding: 0 16px;
  color: var(--border-2); font-size: .88rem;
  border-left: 1px solid var(--border);
  transition: color .12s, background .12s;
}
.history-card__retry:hover { color: var(--blue); background: var(--blue-soft); }

/* ════════════════════════════════════════════════════════════════
   MODALS
   ════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20,10,5,.5);
  backdrop-filter: blur(3px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 28px 24px 22px;
  max-width: 420px; width: 100%;
  box-shadow: var(--sh-lg);
  animation: modalIn .18s ease;
}
@keyframes modalIn {
  from { opacity:0; transform: scale(.96) translateY(8px); }
  to   { opacity:1; transform: scale(1)  translateY(0); }
}
.modal__icon {
  width: 46px; height: 46px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; margin-bottom: 12px;
}
.modal__icon--danger { background: var(--red-soft); color: var(--red); }
.modal__icon--warn   { background: var(--gold-soft); color: var(--gold); }
.modal h3 {
  font-size: 1.05rem; font-weight: 800; color: var(--ink); margin-bottom: 5px;
}
.modal p  { font-size: .875rem; color: var(--muted); margin-bottom: 18px; line-height: 1.5; }
.modal__sub { color: var(--muted); font-size: .85rem; margin-bottom: 14px; }
.modal__actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* Report modal */
.report-types { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.report-type-btn {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer; font-size: .875rem; color: var(--ink);
  transition: border-color .12s, background .12s;
}
.report-type-btn:has(input:checked) {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}
.report-type-btn input { accent-color: var(--blue); flex-shrink: 0; }
.report-type-btn i { color: var(--blue); width: 14px; text-align: center; }
.report-comment {
  width: 100%; border: 1px solid var(--border-2);
  border-radius: var(--r-md); padding: 9px 11px;
  font-size: .875rem; font-family: inherit;
  resize: vertical; min-height: 64px; outline: none;
  transition: border-color .12s;
  background: var(--paper);
  color: var(--ink);
}
.report-comment:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ════════════════════════════════════════════════════════════════
   EMPTY STATE
   ════════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center; padding: 56px 20px;
  color: var(--muted);
  display: flex; flex-direction: column;
  align-items: center; gap: 12px;
}
.empty-state i { font-size: 2.5rem; color: var(--border-2); }
.empty-state p { font-size: .9rem; }

/* ════════════════════════════════════════════════════════════════
   FORMULA LEFT-SIDE BOOKMARK TAB
   ════════════════════════════════════════════════════════════════ */
.formula-tab {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 850;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  background: var(--navy);
  width: 46px;
  padding: 20px 0 16px;
  border-radius: 0 12px 12px 0;
  border-left: 4px solid var(--gold);
  box-shadow: 4px 0 18px rgba(0,0,0,.22);
  transition: transform .2s ease, background .15s, box-shadow .15s;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  user-select: none;
}
.formula-tab:hover {
  transform: translateY(-50%) translateX(4px);
  background: #1a4d80;
  box-shadow: 6px 0 22px rgba(0,0,0,.3);
  text-decoration: none;
  color: #fff;
}
.formula-tab__icon { font-size: 1.15rem; opacity: .9; }
.formula-tab__label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: .6rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  opacity: .75;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
.formula-tab__arrow {
  font-size: .65rem;
  opacity: .5;
  transition: opacity .15s;
}
.formula-tab:hover .formula-tab__arrow { opacity: 1; }

/* Pulse on first load to draw attention */
@keyframes tabPulse {
  0%, 100% { box-shadow: 4px 0 18px rgba(0,0,0,.22); }
  50%       { box-shadow: 6px 0 28px rgba(180,83,9,.4), 4px 0 18px rgba(0,0,0,.22); }
}
.formula-tab.is-pulsing { animation: tabPulse 2s ease 1s 2; }

/* ════════════════════════════════════════════════════════════════
   FORMULA FULLSCREEN MODAL
   ════════════════════════════════════════════════════════════════ */
.formula-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.formula-modal.is-open {
  opacity: 1;
  pointer-events: all;
}

.formula-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10,8,5,.78);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.formula-modal__box {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 72px rgba(40,20,5,.5), 0 4px 12px rgba(40,20,5,.25);
  width: min(88vw, 820px);
  height: min(90vh, 940px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(.94) translateY(16px);
  transition: transform .24s cubic-bezier(.34,1.3,.64,1);
}
.formula-modal.is-open .formula-modal__box {
  transform: scale(1) translateY(0);
}

/* ── Modal header ── */
.formula-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--navy);
  color: #fff;
  flex-shrink: 0;
  gap: 12px;
}
.fmh-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: .95rem;
  min-width: 0;
}
.fmh-left i { font-size: 1rem; opacity: .85; flex-shrink: 0; }
.fmh-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .68rem;
  font-weight: 500;
  opacity: .65;
  background: rgba(255,255,255,.12);
  border-radius: 99px;
  padding: 2px 9px;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,.15);
}
.fmh-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.fmh-pagenum {
  font-size: .82rem;
  font-weight: 700;
  color: rgba(255,255,255,.7);
  font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,.1);
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid rgba(255,255,255,.15);
  white-space: nowrap;
}
.formula-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: background .13s, border-color .13s;
  flex-shrink: 0;
}
.formula-close-btn:hover {
  background: rgba(255,255,255,.22);
  border-color: rgba(255,255,255,.4);
}

/* ── Viewer ── */
.formula-viewer {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #c8ccd4;
}

.formula-slide {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: auto;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  scroll-behavior: smooth;
}

.formula-page-img {
  display: block;
  background: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,.2);
  border-radius: 4px;
  width: 75%;
  flex-shrink: 0;
  transition: width .12s ease;
}

/* ── Page turn animations ── */
@keyframes fp-slide-in-right {
  from { opacity: .15; transform: translateX(80px) scale(.97); }
  to   { opacity: 1;   transform: translateX(0)    scale(1); }
}
@keyframes fp-slide-out-left {
  from { opacity: 1;   transform: translateX(0)     scale(1); }
  to   { opacity: .15; transform: translateX(-80px) scale(.97); }
}
@keyframes fp-slide-in-left {
  from { opacity: .15; transform: translateX(-80px) scale(.97); }
  to   { opacity: 1;   transform: translateX(0)     scale(1); }
}
@keyframes fp-slide-out-right {
  from { opacity: 1;   transform: translateX(0)    scale(1); }
  to   { opacity: .15; transform: translateX(80px) scale(.97); }
}

.formula-slide.fp-in-right  { animation: fp-slide-in-right  .3s cubic-bezier(.4,0,.2,1) both; }
.formula-slide.fp-out-left  { animation: fp-slide-out-left  .3s cubic-bezier(.4,0,.2,1) both; pointer-events: none; }
.formula-slide.fp-in-left   { animation: fp-slide-in-left   .3s cubic-bezier(.4,0,.2,1) both; }
.formula-slide.fp-out-right { animation: fp-slide-out-right .3s cubic-bezier(.4,0,.2,1) both; pointer-events: none; }

/* ── Controls bar ── */
.formula-modal__controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  gap: 10px;
}

.formula-nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r-md);
  background: var(--navy);
  color: #fff;
  border: none;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .13s, opacity .13s, transform .1s;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  white-space: nowrap;
  flex-shrink: 0;
}
.formula-nav-btn:hover:not(:disabled) {
  background: var(--blue);
  transform: translateY(-1px);
}
.formula-nav-btn:disabled { opacity: .28; cursor: default; transform: none !important; }
.fnb-label { font-size: .82rem; }

/* Zoom bar */
.formula-zoom-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 420px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 7px 12px;
}
.formula-zoom-step {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: .9rem;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color .12s, background .12s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.formula-zoom-step:hover { color: var(--blue); background: var(--blue-soft); }

.formula-zoom-track { flex: 1; }
.formula-zoom-slider {
  width: 100%;
  cursor: pointer;
  accent-color: var(--blue);
  height: 4px;
}
.formula-zoom-reset {
  background: none;
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 700;
  padding: 2px 7px;
  cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
  min-width: 42px;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  flex-shrink: 0;
}
.formula-zoom-reset:hover {
  color: var(--blue);
  border-color: var(--blue);
  background: var(--blue-soft);
}

/* ════════════════════════════════════════════════════════════════
   MOBILE  (max-width: 600px)
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  /* Header */
  .header-inner { padding: 0 12px; }
  .nav-link span { display: none; }
  .nav-link { padding: 6px 8px; }
  .nav-user span { display: none; }

  /* Home hero — stack on mobile */
  .home-hero { padding: 28px 16px 24px; }
  .home-hero__inner { flex-direction: column; gap: 20px; align-items: flex-start; }
  .home-hero__counters { width: 100%; justify-content: space-between; }
  .hero-counter { flex: 1; padding: 12px 10px 10px; min-width: 0; }
  .hc-num { font-size: 1.7rem; }
  .hc-label { font-size: .62rem; }

  .home-statsbar__inner { gap: 8px; font-size: .8rem; }
  .hsb-divider { display: none; }
  .hsb-link { font-size: .78rem; }

  /* Exam list — year card compresses */
  .year-group__label { width: 52px; min-width: 52px; }
  .year-group__label span { font-size: .88rem; }
  .exam-row { gap: 4px; padding: 4px; }
  .exam-tile { padding: 9px 10px; gap: 7px; }
  .exam-tile__icon { width: 28px; height: 28px; font-size: .85rem; }
  .exam-tile__period { font-size: .78rem; }
  .exam-tile__stats { font-size: .67rem; gap: 5px; }
  .exam-tile__arrow { display: none; }

  /* Practice */
  .practice-header { height: 48px; padding: 0 8px; }
  .practice-header__center { display: flex; } /* visible on mobile with dark bg */
  .practice-header__right .score-block span { font-size: .8rem; }
  .exam-label span { display: none; }

  .practice-main { padding: 12px 8px 40px; }
  .notebook-content { padding: 16px 12px 20px 14px; }
  .notebook-binding { width: 28px; min-width: 28px; }
  .ring { width: 13px; height: 13px; }

  .problem-badge { gap: 6px; }
  .problem-num { font-size: .92rem; }
  .btn--reveal { width: 100%; justify-content: center; }
  .nav-buttons { width: 100%; }
  .nav-buttons .btn { flex: 1; justify-content: center; }

  /* Summary */
  .notebook-page--summary .notebook-content { padding: 20px 14px; }
  .summary-stats { flex-direction: column; align-items: center; }
  .stat-card { min-width: 160px; }

  /* History */
  .history-card__stats { gap: 6px; }
  .hstat { font-size: .74rem; }
  .history-card__retry { padding: 0 10px; }
  .stats-overview { grid-template-columns: 1fr; }

  /* Auth */
  .auth-card { padding: 26px 18px; }

  /* Modals */
  .modal { padding: 22px 18px 18px; }

  /* Formula tab — smaller on mobile */
  .formula-tab {
    width: 36px;
    padding: 14px 0 10px;
    gap: 8px;
  }
  .formula-tab__icon { font-size: 1rem; }
  .formula-tab__label { font-size: .55rem; letter-spacing: .1em; }

  /* Formula modal */
  .formula-modal { padding: 8px; }
  .formula-modal__box { width: 98vw; height: 96vh; border-radius: 14px; }
  .formula-modal__header { padding: 11px 14px; }
  .fmh-badge { display: none; }
  .fmh-left strong { font-size: .88rem; }
  .formula-modal__controls { padding: 8px 10px; gap: 6px; }
  .formula-nav-btn { padding: 8px 12px; }
  .fnb-label { display: none; }
  .formula-zoom-bar { padding: 6px 8px; gap: 5px; }
  .formula-zoom-reset { min-width: 36px; font-size: .7rem; }
}

@media (max-width: 480px) {
  /* On very small screens, stack exam tiles vertically within the card */
  .exam-row { flex-direction: column; }
  .exam-tile { flex: none; }
}

@media (max-width: 380px) {
  .year-group__label { width: 44px; min-width: 44px; }
  .year-group__label span { font-size: .8rem; }
  .formula-tab__label { display: none; }
}
