:root {
  --bg: #faf7f1;
  --bg-grid: rgba(180, 168, 148, 0.22);
  --surface: #ffffff;
  --surface-warm: #fffdf8;
  --surface-tint: #f3f6ff;
  --ink: #18181b;
  --muted: #52525b;
  --border: #e5e0d5;
  --border-blue: #dbe6fe;

  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #dbeafe;
  --orange: #f97316;
  --orange-dark: #ea580c;
  --orange-soft: #ffedd5;
  --orange-ink: #9a3412;
  --green: #059669;
  --green-soft: #d1fae5;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --yellow: #fde047;
  --purple: #673ab7;
  --purple-soft: #ede7f6;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(24, 24, 27, 0.06);
  --shadow-hard: 4px 5px 0 rgba(24, 24, 27, 0.1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(to right, var(--bg-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--bg-grid) 1px, transparent 1px);
  background-size: 36px 36px;
  line-height: 1.5;
  min-height: 100dvh;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }

.boot-loader {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-weight: 700;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(250, 247, 241, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1.5px solid var(--border);
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}
.brand-mark, .brand-mark-lg {
  background: var(--orange);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  box-shadow: 2px 3px 0 var(--ink);
}
.brand-mark { width: 36px; height: 36px; border-radius: 10px; font-size: 1.15rem; }
.brand-mark-lg { width: 52px; height: 52px; border-radius: 14px; font-size: 1.6rem; }
.brand-name { font-size: 1.15rem; letter-spacing: -0.02em; }
.brand-tag { font-size: 0.72rem; color: var(--muted); font-weight: 600; display: block; line-height: 1.1; }

.header-actions { display: flex; align-items: center; gap: 8px; }

/* Containers */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 18px 16px 64px;
}
.container-narrow { max-width: 680px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 0.96rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
  text-align: center;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 0.84rem; border-radius: 10px; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--ink);
  box-shadow: 3px 4px 0 var(--ink);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-orange {
  background: var(--orange);
  color: #fff;
  border-color: var(--ink);
  box-shadow: 3px 4px 0 var(--ink);
}
.btn-orange:hover { background: var(--orange-dark); }
.btn-green {
  background: var(--green);
  color: #fff;
  border-color: var(--ink);
  box-shadow: 3px 4px 0 var(--ink);
}
.btn-outline {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--ink);
  box-shadow: 2px 3px 0 rgba(24, 24, 27, 0.14);
}
.btn-outline:hover { background: var(--surface-tint); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:hover { background: rgba(24, 24, 27, 0.05); color: var(--ink); }

/* Badges & Stabilo highlight */
.eyebrow-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: #fffdf8;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 6px 12px;
  border-left: 5px solid var(--orange);
  letter-spacing: 0.04em;
}
.stabilo {
  background: linear-gradient(180deg, transparent 42%, var(--yellow) 42%, var(--yellow) 92%, transparent 92%);
  padding: 0 4px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 999px;
}
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-orange { background: var(--orange-soft); color: var(--orange-ink); }
.pill-blue { background: var(--primary-soft); color: var(--primary-dark); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-purple { background: var(--purple-soft); color: var(--purple); }

/* Hero Editorial Card */
.hero-card {
  background: var(--surface-warm);
  border: 2.5px solid var(--ink);
  border-radius: 22px;
  padding: 24px 20px;
  box-shadow: 6px 7px 0 rgba(24, 24, 27, 0.14);
  position: relative;
  overflow: hidden;
}
.hero-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.75rem, 5.5vw, 2.5rem);
  line-height: 1.12;
  margin: 14px 0 10px;
  letter-spacing: -0.02em;
}
.hero-sub {
  color: var(--muted);
  font-size: 0.96rem;
  margin: 0 0 18px;
}

/* Countdown Grid */
.countdown-wrap {
  background: var(--ink);
  color: #fffdf8;
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.countdown-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.74rem;
  color: #fde047;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}
.countdown-boxes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.cd-box {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
}
.cd-num {
  font-family: "JetBrains Mono", monospace;
  font-size: clamp(1.3rem, 4.5vw, 1.85rem);
  font-weight: 700;
  line-height: 1;
}
.cd-unit {
  font-size: 0.7rem;
  color: #d4d4d8;
  margin-top: 4px;
  font-weight: 600;
}

/* Schedule Strip */
.schedule-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.sched-box {
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: var(--surface);
}
.sched-box.highlight-red { border-color: #fca5a5; background: #fff5f5; }
.sched-box.highlight-green { border-color: #86efac; background: #f0fdf4; }
.sched-k {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}
.sched-v {
  font-size: 0.98rem;
  font-weight: 800;
  margin-top: 3px;
}
.sched-s { font-size: 0.78rem; color: var(--muted); }

/* Cards & Sections */
.section-stack { display: flex; flex-direction: column; gap: 18px; }
.card {
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-hard);
}
.card-soft {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-yellow {
  background: #fff9db;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-hard);
}
.card-title {
  font-size: 1.12rem;
  font-weight: 800;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.card-desc { color: var(--muted); font-size: 0.9rem; margin: 0 0 14px; }

/* 3-Step Checklist */
.step-list { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.step-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
}
.step-num {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  display: grid;
  place-items: center;
}
.step-text strong { display: block; font-size: 0.93rem; }
.step-text span { font-size: 0.82rem; color: var(--muted); }

/* Feature Chips */
.feat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0 18px;
}
.feat-chip {
  background: var(--surface-tint);
  border: 1.5px solid var(--border-blue);
  border-radius: 12px;
  padding: 11px 10px;
  text-align: center;
}
.feat-chip strong { display: block; font-size: 0.95rem; color: var(--primary-dark); }
.feat-chip span { font-size: 0.76rem; color: var(--muted); }

/* Forms */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-row label { font-size: 0.82rem; font-weight: 700; color: var(--ink); }
.input, .textarea, .select {
  width: 100%;
  padding: 12px 14px;
  border: 1.8px solid #d4cfc4;
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form .input { flex: 1 1 220px; }

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-top: 10px;
  border: 1.5px solid transparent;
}
.alert-green { background: var(--green-soft); color: #065f46; border-color: #6ee7b7; }
.alert-orange { background: var(--orange-soft); color: var(--orange-ink); border-color: #fdba74; }
.alert-red { background: var(--red-soft); color: #991b1b; border-color: #fca5a5; }
.alert-blue { background: var(--primary-soft); color: #1e40af; border-color: #93c5fd; }

/* Pricing Grid */
.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}
.price-card {
  border: 1.8px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}
.price-card.featured {
  border-color: var(--primary);
  background: #f5f8ff;
}
.price-amt { font-size: 1.45rem; font-weight: 800; color: var(--primary-dark); }
.price-list { margin: 0; padding-left: 18px; font-size: 0.83rem; color: var(--muted); }
.price-list li { margin-bottom: 4px; }

/* ============================================================================
   LIVE CAT EXAM UI (MOBILE-FIRST, THUMB-FRIENDLY, ANTI-ACCIDENT)
   ============================================================================ */
.cat-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #f3f6ff;
}
.cat-topbar {
  position: sticky;
  top: 0;
  z-index: 45;
  background: #ffffff;
  border-bottom: 2px solid var(--border-blue);
  padding: 10px 14px;
}
.cat-topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.cat-timer {
  font-family: "JetBrains Mono", monospace;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--orange-soft);
  color: var(--orange-ink);
  border: 1.5px solid var(--orange);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.cat-timer.danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: var(--red);
  animation: pulse 1.1s infinite;
}
.timer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.cat-progress-strip {
  height: 5px;
  background: #e2e8f0;
}
.cat-progress-fill {
  height: 100%;
  background: var(--orange);
  transition: width 0.2s ease;
}

.cat-main {
  flex: 1;
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 14px 104px;
}
.q-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.q-card {
  background: #ffffff;
  border: 1.5px solid var(--border-blue);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.q-stem {
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.62;
  white-space: pre-line;
  margin: 0 0 16px;
}
.q-fig-box {
  margin: 0 0 16px;
  padding: 10px;
  background: #fafbff;
  border: 1.5px solid var(--border-blue);
  border-radius: 14px;
  text-align: center;
  cursor: zoom-in;
}
.q-fig-box img { margin: 0 auto; max-height: 360px; border-radius: 8px; }
.q-fig-hint { font-size: 0.74rem; color: var(--muted); margin-top: 6px; }

.opt-list { display: flex; flex-direction: column; gap: 10px; }
.opt-btn {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  padding: 13px 14px;
  border-radius: 14px;
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.opt-btn:hover { border-color: #93c5fd; background: #eff6ff; }
.opt-btn.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}
.opt-key {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #ffffff;
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 0.88rem;
  display: grid;
  place-items: center;
  border: 1.5px solid #cbd5e1;
}
.opt-btn.selected .opt-key {
  background: var(--orange);
  color: #ffffff;
  border-color: var(--orange);
}
.opt-text { font-size: 0.94rem; font-weight: 500; line-height: 1.48; padding-top: 3px; }

.cat-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 45;
  background: #ffffff;
  border-top: 2px solid var(--border-blue);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.cat-bottom-inner {
  max-width: 820px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 8px;
}
.btn-flag.active {
  background: #fef3c7;
  border-color: #d97706;
  color: #92400e;
}

/* Question Navigator Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.drawer-sheet {
  width: 100%;
  max-width: 720px;
  max-height: 82dvh;
  background: #ffffff;
  border-radius: 22px 22px 0 0;
  padding: 18px 16px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}
.nav-filter-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.filter-tab {
  border: 1.5px solid var(--border);
  background: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.filter-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.num-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 7px;
  overflow-y: auto;
  padding: 4px 2px;
}
.num-cell {
  height: 42px;
  border-radius: 10px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
}
.num-cell.answered { background: var(--green); border-color: var(--green); color: #fff; }
.num-cell.flagged { background: #f59e0b; border-color: #d97706; color: #fff; }
.num-cell.current { outline: 3px solid var(--primary); outline-offset: 1px; }

/* Result Screen */
.result-hero {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 52%, #f97316 100%);
  color: #ffffff;
  border-radius: 22px;
  padding: 24px 20px;
  border: 2.5px solid var(--ink);
  box-shadow: 6px 7px 0 rgba(24, 24, 27, 0.16);
}
.score-big {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(3rem, 11vw, 4.4rem);
  font-weight: 800;
  line-height: 1;
}
.subtest-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 18px;
}
.sub-card {
  background: #ffffff;
  color: var(--ink);
  border-radius: 14px;
  padding: 12px;
}
.sub-code { font-size: 0.76rem; font-weight: 800; color: var(--muted); }
.sub-val { font-size: 1.55rem; font-weight: 800; line-height: 1.15; margin: 2px 0; }
.sub-pg { font-size: 0.72rem; font-weight: 800; }
.sub-pg.ok { color: var(--green); }
.sub-pg.fail { color: var(--red); }

.lock-upsell {
  background: #fffbeb;
  border: 2px dashed var(--orange);
  border-radius: 18px;
  padding: 20px;
}
.review-item {
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: #ffffff;
  margin-bottom: 12px;
}
.review-exp {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-tint);
  font-size: 0.87rem;
}

/* Admin Tables */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
}
.kpi-box {
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.kpi-k { font-size: 0.76rem; font-weight: 700; color: var(--muted); }
.kpi-v { font-size: 1.6rem; font-weight: 800; margin-top: 2px; }
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
table.data-table th, table.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
table.data-table th { font-size: 0.74rem; text-transform: uppercase; color: var(--muted); background: #faf8f4; }

/* Modal & Toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 460px;
  background: #ffffff;
  border: 2.5px solid var(--ink);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.lightbox-img {
  max-width: 94vw;
  max-height: 86dvh;
  background: #fff;
  padding: 10px;
  border-radius: 14px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 99;
  max-width: 92vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.site-footer {
  text-align: center;
  padding: 24px 16px 40px;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 560px) {
  .schedule-grid { grid-template-columns: 1fr; }
  .feat-grid { grid-template-columns: 1fr; }
  .subtest-grid { grid-template-columns: 1fr; }
  .hero-card { padding: 18px 16px; }
}
