/* ── Reset & Variables ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
button, a, [onclick] { touch-action: manipulation; }

:root {
  /* Tema Nautico — Acqua Chiara + Legno */
  --bg: #a8d8ec;
  --surface: rgba(245, 233, 210, 0.93);
  --surface2: rgba(234, 219, 188, 0.88);
  --border: rgba(0,100,140,0.13);
  --border-bright: rgba(0,100,140,0.24);
  --primary: #006994;
  --primary-soft: rgba(0,105,148,0.12);
  --success: #2a9d8f;
  --success-soft: rgba(42,157,143,0.12);
  --error: #dc3545;
  --error-soft: rgba(220,53,69,0.12);
  --warning: #e07b00;
  --warning-soft: rgba(224,123,0,0.13);
  --text: #081c28;
  --text-muted: #1a4a5e;
  --text-dim: #2d6070;
  --radius: 18px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --shadow-card: 0 1px 3px rgba(0,80,110,0.1), 0 4px 12px rgba(0,80,110,0.08);
  --shadow: 0 4px 24px rgba(0,80,110,0.18);
  --nav-h: 72px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.5; overscroll-behavior: none; }

@keyframes pn-water {
  0%   { background-position: 0px 0px, 0px 0px, 0% 50%; }
  100% { background-position: 80px 40px, -60px 80px, 100% 50%; }
}
@keyframes pn-deepsea {
  0%   { background-position: 0px 0px, 0px 0px, 0% 0%; }
  25%  { background-position: 50px 25px, -30px 60px, 40% 30%; }
  50%  { background-position: 100px 50px, -80px 100px, 100% 80%; }
  75%  { background-position: 50px 75px, -50px 140px, 60% 100%; }
  100% { background-position: 0px 0px, 0px 0px, 0% 0%; }
}
body {
  background-image: url('../img/sea-bg.jpg');
  background-size: cover;
  background-position: center top;
  background-attachment: fixed;
}
[data-theme="dark"] body,
body.dark-bg {
  background-image: url('../img/sea-bg-dark.jpg');
  background-size: cover;
  background-position: center top;
  background-attachment: fixed;
  animation: none;
}
@media (min-width: 1024px) {
  body {
    background-image: url('../img/sea-bg-desktop.jpg');
    background-position: center center;
  }
  [data-theme="dark"] body,
  body.dark-bg {
    background-image: url('../img/sea-bg-dark-desktop.jpg');
    background-position: center center;
  }
}

@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(40px); } to { transform: translateY(0); } }

/* ── Typography ── */
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.03em; color: var(--text); }
h2 { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
h3 { font-size: 1.05rem; font-weight: 600; color: var(--text); }
p { color: var(--text-dim); line-height: 1.7; }

/* ── Layout ── */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
.screen { display: none; flex: 1; overflow-y: auto; overflow-x: hidden; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); }
.screen.active { display: block; }

/* ── Lucide SVG Icons ── */
svg.lucide { display: block; stroke: currentColor; fill: none; flex-shrink: 0; }
.nav-icon { display: flex; align-items: center; justify-content: center; }
.nav-icon svg { width: 22px; height: 22px; stroke-width: 1.75; }
.topic-icon svg { width: 22px; height: 22px; stroke-width: 1.75; }
.topic-chevron { display: flex; align-items: center; }
.topic-chevron svg { width: 16px; height: 16px; stroke-width: 2.5; color: var(--text-muted); }
.mode-icon { display: flex; align-items: center; justify-content: center; }
.mode-icon svg { width: 26px; height: 26px; stroke-width: 1.75; }
.mode-chevron { display: flex; align-items: center; }
.mode-chevron svg { width: 18px; height: 18px; stroke-width: 2.5; }
.qb-icon { display: flex; align-items: center; justify-content: center; }
.qb-icon svg { width: 28px; height: 28px; stroke-width: 1.75; }
.back-btn svg { width: 20px; height: 20px; stroke-width: 2; }
.accordion-arrow { display: flex; align-items: center; }
.accordion-arrow svg { width: 18px; height: 18px; stroke-width: 2; transition: transform 0.3s; }
.accordion-item.open .accordion-arrow svg { transform: rotate(180deg); }
.app-logo svg { width: 52px; height: 52px; stroke-width: 1.5; color: var(--primary); }
.info-card-title svg { width: 14px; height: 14px; stroke-width: 2; vertical-align: -2px; color: var(--primary); }
#teoria-detail-icon svg { width: 22px; height: 22px; stroke-width: 1.75; }

/* ── Bottom Nav ── */
.bottom-nav {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}
.home-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  padding: 16px 20px 8px;
}
.home-footer a {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
}
.home-footer a:hover { color: var(--primary); }
.footer-dot { font-size: 0.75rem; color: var(--border-bright); }
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
  height: var(--nav-h);
  padding: 0;
}
.nav-btn.active { color: var(--primary); }
.nav-btn .nav-icon { font-size: 22px; line-height: 1; }
.nav-btn .nav-label { font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }

/* ── Page Header ── */
.page-header { padding: calc(52px + env(safe-area-inset-top)) 20px 20px; }
.page-header h1 { margin-bottom: 4px; }
.page-header p { font-size: 0.9rem; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 0 16px 12px;
  box-shadow: var(--shadow-card);
}
.card-sm { padding: 14px 16px; }

/* ── HOME ── */
.home-hero {
  padding: 12px 16px 8px;
}
.hero-banner {
  width: 100%;
  display: block;
  border-radius: var(--radius);
  box-shadow: 0 4px 24px rgba(0,60,100,0.22);
  object-fit: cover;
}
.info-card { background: var(--surface) !important; border-color: rgba(0,105,148,0.25) !important; border-left: 3px solid var(--primary) !important; }
.info-card-title { font-size: 0.82rem; color: var(--primary); font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 5px; }
.info-card-body { font-size: 0.8rem; color: var(--text-dim); line-height: 1.6; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.stat-value { font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.stat-streak { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; text-align: left; }
.streak-fire { font-size: 1.8rem; line-height: 1; flex-shrink: 0; }
.streak-msg { flex: 1; font-size: 0.78rem; color: var(--text-muted); text-align: right; line-height: 1.4; }

/* ── Section Title (Omnineo style: dot + uppercase) ── */
.section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  padding: 0 20px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

/* ── EXAM PLAN CARD ── */
.exam-plan-card {
  margin: 0 16px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.notif-btn {
  display: block;
  width: calc(100% - 32px);
  margin: 0 16px 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1.5px dashed var(--border-bright);
  background: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  text-align: center;
  transition: background 0.2s, color 0.2s;
}
.notif-btn:active { background: var(--surface2); }

.plan-empty {
  padding: 24px 20px;
  text-align: center;
}
.plan-empty-icon { color: var(--primary); display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.plan-empty-icon svg { width: 32px; height: 32px; stroke-width: 1.5; }
.plan-empty-title { font-weight: 700; font-size: 1rem; color: var(--text); margin-bottom: 6px; }
.plan-empty-sub { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 16px; line-height: 1.55; }
.plan-date-wrap { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.plan-date-sel-wrap { position: relative; }
.plan-date-overlay-input {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
  border: none;
  background: transparent;
}
.plan-date-sel-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 14px;
  background: var(--surface2);
  border: 1.5px dashed var(--border-bright);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--font);
  text-align: left;
  transition: all 0.2s;
}
.plan-date-sel-btn:active { background: var(--primary-soft); border-color: var(--primary); }
.plan-date-sel-btn.has-date { border-style: solid; border-color: var(--primary); color: var(--text); }
.plan-date-sel-icon { display: flex; align-items: center; color: var(--primary); flex-shrink: 0; }
.plan-date-sel-icon svg { width: 20px; height: 20px; stroke-width: 2; }
.plan-date-sel-label { flex: 1; }
.plan-date-sel-arr { display: flex; align-items: center; color: var(--text-muted); flex-shrink: 0; }
.plan-date-sel-arr svg { width: 16px; height: 16px; stroke-width: 2.5; }
.plan-date-confirm {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.plan-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 18px 10px;
}
.plan-days-row { display: flex; align-items: baseline; gap: 7px; margin-bottom: 4px; }
.plan-days-num { font-size: 2.4rem; font-weight: 900; line-height: 1; }
.plan-days-label { font-size: 0.85rem; color: var(--text-muted); font-weight: 500; }
.plan-exam-date { font-size: 0.78rem; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.plan-exam-date svg { width: 13px; height: 13px; stroke-width: 2; }
.plan-edit-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; display: flex; align-items: center; }
.plan-edit-btn svg { width: 16px; height: 16px; stroke-width: 2; }

.plan-prob-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 18px 6px;
  font-size: 0.82rem;
}
.plan-prob-label { color: var(--text-muted); }
.plan-prob-pct { font-weight: 800; font-size: 1.1rem; }
.plan-prob-bar {
  height: 6px;
  background: var(--surface2);
  margin: 0 18px 14px;
  border-radius: 99px;
  overflow: hidden;
}
.plan-prob-fill { height: 100%; border-radius: 99px; transition: width 0.6s ease; }
.plan-prob-hint { font-size: 0.75rem; color: var(--text-muted); padding: 0 18px 12px; }

.plan-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 18px 14px;
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 700;
}
.plan-status-badge svg { width: 13px; height: 13px; stroke-width: 2.5; }

.plan-today {
  border-top: 1px solid var(--border);
  padding: 14px 18px;
  background: var(--surface2);
}
.plan-today-label {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--primary);
  margin-bottom: 6px;
}
.plan-today-content { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.plan-today-text { font-weight: 600; font-size: 0.9rem; color: var(--text); flex: 1; }
.plan-today-btn {
  padding: 8px 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}
.plan-today-btn:active { transform: scale(0.97); }

.plan-past {
  padding: 18px 20px;
  font-size: 0.88rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.plan-past svg { width: 16px; height: 16px; stroke-width: 2; color: var(--success); flex-shrink: 0; }
.plan-reset-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  font-family: var(--font);
  cursor: pointer;
  padding: 0;
}

/* ── Quick Buttons ── */
.quick-btns { display: flex; gap: 10px; padding: 0 16px 16px; }
.quick-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
  box-shadow: var(--shadow-card);
}
.quick-btn:active { transform: scale(0.97); }
.quick-btn .qb-icon { font-size: 28px; }
.quick-btn.secondary { border-top-color: var(--warning); }

/* ── Topic List ── */
.topic-list { padding: 0 16px; }
.topic-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid #ccc;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.18s;
  color: var(--text);
  box-shadow: var(--shadow-card);
}
.topic-card:active { transform: scale(0.98); }
.topic-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  background: var(--surface2);
}
.topic-info { flex: 1; min-width: 0; }
.topic-name { font-weight: 600; font-size: 0.95rem; margin-bottom: 2px; color: var(--text); }
.topic-meta { font-size: 0.78rem; color: var(--text-muted); }
.topic-progress { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.topic-pbar { flex: 1; height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; }
.topic-pfill { height: 100%; border-radius: 99px; transition: width 0.5s ease; }
.topic-pct { font-size: 0.7rem; color: var(--text-muted); }
.topic-chevron { color: var(--text-muted); font-size: 18px; }

/* ── TEORIA DETAIL ── */
#screen-teoria-detail { display: none; }
#screen-teoria-detail.active { display: block; }
.teoria-header {
  padding: 16px 16px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.back-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: var(--shadow-card);
}
.teoria-title { font-weight: 800; font-size: 1.15rem; color: var(--text); letter-spacing: -0.02em; }

.accordion { padding: 12px 16px; }
.accordion-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  gap: 12px;
  color: var(--text);
  border-left: 3px solid transparent;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.accordion-header:active { background: var(--surface2); }
.accordion-item.open > .accordion-header {
  border-left-color: var(--primary);
  color: var(--primary);
  background: linear-gradient(90deg, var(--primary-soft) 0%, transparent 60%);
}
.accordion-item.open > .accordion-header .accordion-arrow { color: var(--primary); }
.accordion-arrow { flex-shrink: 0; color: var(--text-muted); transition: color 0.2s; }
.acc-inner { display: flex; align-items: center; gap: 10px; min-width: 0; }
.acc-num {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 5px;
  padding: 2px 6px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  transition: background 0.2s, color 0.2s;
}
.accordion-item.open .acc-num {
  background: var(--primary);
  color: #fff;
}
.accordion-body {
  display: none;
  padding: 20px 20px 24px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.85;
  color: var(--text-dim);
}
.accordion-item.open .accordion-body { display: block; }
.accordion-body p { margin-bottom: 18px; }
.accordion-body p:last-child { margin-bottom: 0; }
.accordion-body ul { padding-left: 20px; margin-bottom: 18px; }
.accordion-body ol { padding-left: 20px; margin-bottom: 18px; }
.accordion-body li { margin-bottom: 10px; }
.accordion-body li:last-child { margin-bottom: 0; }
.accordion-body strong { color: var(--text); font-weight: 600; }
.accordion-body ul ul, .accordion-body ol ol { margin-top: 8px; margin-bottom: 0; }

/* Theory tables */
.th-table-wrap {
  overflow-x: auto;
  margin: 0 0 18px;
  border-radius: 10px;
}
.th-table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 0.85rem;
  border-radius: 10px;
  overflow: hidden;
}
.th-table th {
  background: var(--surface2);
  color: var(--text);
  font-weight: 700;
  padding: 9px 12px;
  text-align: left;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}
.th-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text-dim);
}
.th-table tr:last-child td { border-bottom: none; }
.th-table tr:nth-child(even) td { background: var(--surface2); }
.th-table td strong { color: var(--text); }

/* Theory illustrations */
.th-img {
  width: 100%;
  max-width: 480px;
  display: block;
  margin: 0 auto 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

/* Theory callout boxes */
.th-note {
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
  margin: 0 0 18px;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.th-note strong { color: var(--primary); }
.th-warn {
  background: var(--warning-soft);
  border-left: 3px solid var(--warning);
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
  margin: 0 0 18px;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.th-warn strong { color: var(--warning); }

/* Theory quick recap box */
.th-recap {
  background: var(--surface2);
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 0 20px;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.th-recap-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.th-recap ul { padding-left: 16px; margin: 0; }
.th-recap li { margin-bottom: 5px; line-height: 1.5; }
.th-recap li:last-child { margin-bottom: 0; }
.th-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
  opacity: 0.75;
}
.th-divider::before, .th-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, rgba(0,105,148,0.35), rgba(0,105,148,0.08));
}
.th-divider::after {
  background: linear-gradient(to left, rgba(0,105,148,0.35), rgba(0,105,148,0.08));
}

.quiz-this-topic {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 32px);
  margin: 8px 16px 16px;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.quiz-this-topic:active { transform: scale(0.98); }

/* ── QUIZ ── */
.quiz-modes { padding: 0 16px; }
.mode-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.18s;
  box-shadow: var(--shadow-card);
}
.mode-card:nth-child(1) { border-top: 3px solid var(--primary); }
.mode-card:nth-child(2) { border-top: 3px solid #a855f7; }
.mode-card:nth-child(3) { border-top: 3px solid var(--error); }
.mode-card:nth-child(4) { border-top: 3px solid var(--success); }
.mode-card:nth-child(5) { border-top: 3px solid #06b6d4; }
.mode-card:active { transform: scale(0.98); }
.sr-due-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #06b6d4;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1;
}
.mode-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  background: var(--surface2);
}
.mode-info { flex: 1; }
.mode-title { font-weight: 700; font-size: 1rem; margin-bottom: 4px; color: var(--text); }
.mode-desc { font-size: 0.82rem; color: var(--text-muted); }
.mode-chevron { color: var(--text-muted); font-size: 20px; }

.topic-filter { padding: 0 16px 12px; }
.topic-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }

/* ── EXAM SCREEN ── */
#screen-esame { display: none; position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: var(--bg); z-index: 200; overflow-y: auto; }
#screen-esame.active { display: block; }

.exam-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.exam-info { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.exam-progress-text { font-size: 0.75rem; color: var(--text-muted); }
.exam-qnum { font-weight: 800; font-size: 1.1rem; color: var(--text); }

.exam-timer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.exam-timer.warning { color: var(--warning); }
.exam-timer.danger { color: var(--error); animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.exam-stop-btn {
  padding: 7px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.progress-bar { height: 4px; background: var(--border); position: sticky; top: 57px; z-index: 9; }
.progress-fill { height: 100%; background: var(--primary); transition: width 0.4s ease; }

.question-container { padding: 24px 20px 16px; }
.question-topic-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.73rem;
  font-weight: 600;
  margin-bottom: 14px;
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.question-img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
  margin: 0 auto 16px;
  border-radius: 8px;
  background: var(--surface);
}
.question-text {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 24px;
}

.answers-list { display: flex; flex-direction: column; gap: 10px; padding: 0 20px 20px; }
.answer-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.45;
  width: 100%;
  box-shadow: var(--shadow-card);
}
.answer-btn:active:not(:disabled) { transform: scale(0.99); }
.answer-btn:disabled { cursor: default; }
.answer-letter {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
  color: var(--text-dim);
  margin-top: 1px;
}
.answer-btn.correct { background: var(--success-soft); border-color: var(--success); }
.answer-btn.correct .answer-letter { background: var(--success); color: #fff; }
.answer-btn.wrong { background: var(--error-soft); border-color: var(--error); }
.answer-btn.wrong .answer-letter { background: var(--error); color: #fff; }
.answer-btn.neutral { opacity: 0.5; }

.feedback-box {
  margin: 0 20px 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  line-height: 1.5;
  display: none;
}
.feedback-box.correct { background: var(--success-soft); border: 1px solid var(--success); color: var(--success); }
.feedback-box.wrong { background: var(--error-soft); border: 1px solid var(--error); color: var(--error); }
.feedback-box.show { display: block; }

.next-btn {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 40px);
  margin: 0 20px 24px;
  padding: 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.next-btn.show { display: flex; }
.next-btn:active { transform: scale(0.98); }

/* ── RESULT ── */
.result-container { padding: 32px 20px 100px; text-align: center; }
.result-emoji { font-size: 72px; margin-bottom: 16px; }
.result-title { font-size: 1.8rem; font-weight: 800; margin-bottom: 8px; color: var(--text); }
.result-subtitle { font-size: 1rem; color: var(--text-dim); margin-bottom: 28px; }
.result-score { font-size: 4rem; font-weight: 900; color: var(--primary); line-height: 1; margin-bottom: 4px; }
.result-score-label { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 28px; }
.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 28px;
}
.result-badge.passed { background: var(--success-soft); color: var(--success); border: 1.5px solid var(--success); }
.result-badge.failed { background: var(--error-soft); color: var(--error); border: 1.5px solid var(--error); }

.result-breakdown {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}
.breakdown-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; color: var(--text); }
.breakdown-row:last-child { border-bottom: none; }
.breakdown-val { font-weight: 700; color: var(--text); }
.breakdown-val.green { color: var(--success); }
.breakdown-val.red { color: var(--error); }

.result-actions { display: flex; flex-direction: column; gap: 10px; }
.btn-primary {
  padding: 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  padding: 14px;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  box-shadow: var(--shadow-card);
}
.btn-secondary:active { transform: scale(0.98); }

/* ── REVIEW ── */
.review-list { padding: 0 16px 20px; }
.review-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-card);
}
.review-item.wrong-item { border-left: 3px solid var(--error); }
.review-item.right-item { border-left: 3px solid var(--success); }
.review-q { font-size: 0.9rem; font-weight: 600; margin-bottom: 10px; color: var(--text); }
.review-answers { display: flex; flex-direction: column; gap: 6px; }
.review-ans {
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}
.review-ans.correct-ans { background: var(--success-soft); color: var(--success); }
.review-ans.wrong-ans { background: var(--error-soft); color: var(--error); }
.review-ans.neutral-ans { color: var(--text-dim); }

/* ── PROGRESSI ── */
.big-stat { text-align: center; padding: 32px 20px 24px; }
.big-stat .circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--pct) * 1%), var(--surface2) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  position: relative;
}
.big-stat .circle::after {
  content: '';
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: var(--bg);
  position: absolute;
}
.big-stat .circle-text { position: relative; z-index: 1; text-align: center; }
.big-stat .circle-pct { font-size: 1.8rem; font-weight: 900; color: var(--primary); display: block; }
.big-stat .circle-label { font-size: 0.7rem; color: var(--text-muted); }

.history-list { padding: 0 16px; }
.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-card);
}
.history-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.history-info { flex: 1; }
.history-score { font-weight: 700; font-size: 1rem; color: var(--text); }
.history-date { font-size: 0.78rem; color: var(--text-muted); }
.history-badge { padding: 4px 10px; border-radius: 99px; font-size: 0.72rem; font-weight: 700; }

.cat-progress-list { padding: 0 16px; }
.cat-row { margin-bottom: 14px; }
.cat-row-header { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 0.85rem; }
.cat-name { font-weight: 600; color: var(--text); }
.cat-pct { color: var(--text-muted); }
.cat-bar { height: 8px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.cat-fill { height: 100%; border-radius: 99px; transition: width 0.8s ease; }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-text { font-size: 1rem; font-weight: 600; margin-bottom: 6px; color: var(--text-dim); }
.empty-sub { font-size: 0.85rem; }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--surface);
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 0.88rem;
  font-weight: 600;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 300;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── AUTH SCREEN ── */
#screen-auth {
  display: flex;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background-image:
    linear-gradient(160deg, rgba(0,15,30,0.36) 0%, rgba(0,8,20,0.68) 100%),
    url('../img/auth-bg.jpg');
  background-size: cover;
  background-position: center top;
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
#screen-auth.hidden { display: none; }

.auth-card {
  background: rgba(6,22,42,0.52);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-lg);
  padding: 36px 28px 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 4px 20px rgba(0,0,0,0.3);
}
.auth-logo {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  color: #fff;
}
.auth-logo svg { width: 32px; height: 32px; stroke-width: 1.5; }
.auth-title { font-size: 1.5rem; text-align: center; margin-bottom: 4px; color: #fff; }
.auth-subtitle { font-size: 0.88rem; color: rgba(255,255,255,0.72); margin-bottom: 28px; text-align: center; }

.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255,255,255,0.62);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 0.95rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  -webkit-appearance: none;
}
.form-input:focus { border-color: rgba(125,211,252,0.65); background: rgba(255,255,255,0.15); }
.form-input::placeholder { color: rgba(255,255,255,0.4); }

.auth-error {
  display: none;
  font-size: 0.82rem;
  color: var(--error);
  background: var(--error-soft);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.auth-error.show { display: block; }
.auth-error { background: rgba(220,53,69,0.25); border-color: rgba(220,53,69,0.35); color: #fca5a5; }
.auth-error.success { color: #6ee7b7; background: rgba(16,185,129,0.2); border-color: rgba(16,185,129,0.3); }

.auth-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.62);
}
.auth-toggle-btn {
  background: none;
  border: none;
  color: #7dd3fc;
  font-weight: 700;
  font-size: 0.85rem;
  font-family: var(--font);
  cursor: pointer;
  padding: 0;
}

/* ── USER BAR ── */
.user-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 20px 12px;
}
.user-bar-info {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  min-width: 0;
}
.user-bar-info svg { width: 15px; height: 15px; stroke-width: 2; flex-shrink: 0; color: var(--text-muted); }
#user-bar-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-version { font-size: 0.65rem; color: var(--text-dim); opacity: 0.6; flex-shrink: 0; }
.user-bar-logout {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s;
}
.user-bar-logout svg { width: 12px; height: 12px; stroke-width: 2.5; }
.user-bar-logout:active { background: var(--surface2); }
.user-bar-update {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--primary);
  background: rgba(37,99,235,0.08);
  color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}
.user-bar-update svg { width: 14px; height: 14px; stroke-width: 2.5; }
.user-bar-update:active { background: rgba(37,99,235,0.18); }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }

/* ── INFINITE QUIZ SCREEN ── */
#screen-infinito { display: none; position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: var(--bg); z-index: 200; overflow-y: auto; }
#screen-infinito.active { display: block; }

.inf-streak {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: color 0.3s;
}
.inf-streak.hot { color: var(--warning); }
.inf-streak-icon { display: flex; align-items: center; }
.inf-streak-icon svg { width: 18px; height: 18px; stroke-width: 2.5; }

/* ── EXPLANATION BOX ── */
.infinito-explanation {
  display: none;
  margin: 0 20px 16px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1.5px solid rgba(239,68,68,0.35);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.infinito-explanation.show { display: block; }

.expl-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  background: var(--error-soft);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--error);
  border-bottom: 1px solid rgba(239,68,68,0.15);
}

.expl-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.expl-row-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.expl-row-text {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
}
.expl-row-text.wrong { color: var(--error); }
.expl-row-text.correct { color: var(--success); }

.expl-why {
  padding: 14px 16px 16px;
  background: var(--surface2);
}
.expl-why-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--primary);
  margin-bottom: 10px;
}
.expl-theory-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.expl-sec-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  display: block;
}
.expl-sec-text {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.72;
  display: block;
}
.expl-study-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}
.expl-study-btn:active { transform: scale(0.97); }

/* ── LEGAL OVERLAY ── */
#screen-legal {
  display: none;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background: var(--bg);
  z-index: 250;
  overflow-y: auto;
}
.legal-ov-hdr {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 12px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
}
.legal-ov-title { font-weight: 700; font-size: 1rem; color: var(--text); }
.legal-pg { max-width: 680px; margin: 0 auto; padding: 20px 20px 56px; }
.legal-pg-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.legal-pg-logo-icon { width: 36px; height: 36px; background: var(--primary); border-radius: 9px; display: flex; align-items: center; justify-content: center; color: white; font-size: 18px; }
.legal-pg-logo-name { font-weight: 800; font-size: 1rem; color: var(--text); }
.legal-pg h1 { font-size: 1.55rem; font-weight: 800; color: var(--text); margin-bottom: 8px; line-height: 1.2; }
.legal-pg .legal-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 32px; }
.legal-section { margin-bottom: 28px; }
.legal-section-h { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.legal-section p { font-size: 0.88rem; color: var(--text-muted); line-height: 1.7; margin-bottom: 10px; }
.legal-section ul { font-size: 0.88rem; color: var(--text-muted); line-height: 1.7; padding-left: 20px; margin-bottom: 10px; }
.legal-section li { margin-bottom: 4px; }
.legal-date { font-size: 0.8rem; color: var(--text-muted); margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); }
/* Contatti */
.contact-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.contact-card-title { font-weight: 700; font-size: 0.95rem; color: var(--text); margin-bottom: 4px; }
.contact-card-val { color: var(--primary); font-size: 0.9rem; text-decoration: none; word-break: break-all; display: block; }
.contact-card-val:hover { text-decoration: underline; }
.contact-card-desc { color: var(--text-muted); font-size: 0.82rem; margin-top: 6px; }
/* Privacy table */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin: 12px 0; }
.data-table th { text-align: left; padding: 8px 10px; background: var(--surface2); color: var(--text); font-weight: 600; }
.data-table td { padding: 8px 10px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
/* Esame */
.e-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 8px; }
.e-update { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 28px; }
.alert-box { background: rgba(37,99,235,0.08); border: 1px solid rgba(37,99,235,0.25); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 28px; font-size: 0.85rem; color: var(--text-muted); line-height: 1.6; }
.alert-box strong { color: var(--primary); }
.e-h2 { font-size: 1.1rem; font-weight: 700; color: var(--text); margin: 32px 0 14px; display: flex; align-items: center; gap: 8px; }
.h2-num { width: 28px; height: 28px; background: var(--primary); color: white; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 700; flex-shrink: 0; }
.req-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 4px; }
.req-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.req-card-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 4px; }
.req-card-value { font-size: 0.92rem; font-weight: 700; color: var(--text); }
.req-card-note { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.doc-list { list-style: none; padding: 0; margin: 0; }
.doc-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.doc-item:last-child { border-bottom: none; }
.doc-num { width: 26px; height: 26px; border-radius: 50%; background: var(--surface2); border: 1.5px solid var(--border-bright); display: flex; align-items: center; justify-content: center; font-size: 0.78rem; font-weight: 700; color: var(--primary); flex-shrink: 0; margin-top: 1px; }
.doc-body { flex: 1; }
.doc-name { font-weight: 700; font-size: 0.92rem; color: var(--text); margin-bottom: 3px; }
.doc-desc { font-size: 0.82rem; color: var(--text-muted); line-height: 1.55; }
.doc-tag { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 2px 8px; border-radius: 20px; margin-top: 4px; }
.tag-imp { background: rgba(239,71,111,0.1); color: var(--error); }
.tag-note { background: rgba(37,99,235,0.08); color: var(--primary); }
.steps { position: relative; }
.step { display: flex; gap: 16px; margin-bottom: 4px; padding-bottom: 24px; position: relative; }
.step:not(:last-child)::before { content: ''; position: absolute; left: 16px; top: 36px; bottom: 0; width: 2px; background: var(--border); }
.step-circle { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem; flex-shrink: 0; z-index: 1; }
.step-body { flex: 1; padding-top: 5px; }
.step-title { font-weight: 700; font-size: 0.95rem; color: var(--text); margin-bottom: 4px; }
.step-desc { font-size: 0.84rem; color: var(--text-muted); line-height: 1.6; }
.step-desc a { color: var(--primary); }
.cost-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; font-size: 0.87rem; }
.cost-table th { background: var(--surface2); padding: 10px 14px; text-align: left; font-weight: 600; color: var(--text); font-size: 0.8rem; }
.cost-table td { padding: 10px 14px; color: var(--text-muted); border-top: 1px solid var(--border); }
.cost-table td:last-child { font-weight: 600; color: var(--text); text-align: right; white-space: nowrap; }
.cost-total td { background: var(--surface2); font-weight: 700; color: var(--text); }
.cost-total td:last-child { color: var(--primary); font-size: 1rem; }
.esame-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.esame-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; }
.esame-card-icon { font-size: 1.4rem; margin-bottom: 8px; }
.esame-card-title { font-weight: 700; font-size: 0.9rem; color: var(--text); margin-bottom: 6px; }
.esame-card-body { font-size: 0.82rem; color: var(--text-muted); line-height: 1.55; }
.ext-link-list { display: flex; flex-direction: column; gap: 10px; }
.ext-link { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; text-decoration: none; transition: border-color 0.15s; }
.ext-link:active { border-color: var(--primary); }
.ext-link-icon { font-size: 1.2rem; flex-shrink: 0; }
.ext-link-body { flex: 1; }
.ext-link-title { font-weight: 700; font-size: 0.9rem; color: var(--text); margin-bottom: 2px; }
.ext-link-url { font-size: 0.78rem; color: var(--text-muted); }
.ext-link-arr { color: var(--text-muted); font-size: 1.2rem; flex-shrink: 0; }
.esame-disclaimer { background: var(--surface2); border-radius: var(--radius-sm); padding: 14px 16px; margin-top: 32px; font-size: 0.8rem; color: var(--text-muted); line-height: 1.65; }
.esame-disclaimer strong { color: var(--text); }
@media (max-width: 420px) { .req-grid, .esame-grid { grid-template-columns: 1fr; } }

/* ── Responsive ── */
/* Full-width on all devices — no max-width centering */

/* ── Offline Banner ── */
#offline-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 400;
  background: #f59e0b;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  text-align: center;
}
#offline-banner svg { width: 14px; height: 14px; stroke-width: 2.5; flex-shrink: 0; }
body.offline #offline-banner { display: flex; }

/* ── Onboarding ── */
#screen-onboarding {
  display: none;
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background: var(--bg);
  z-index: 500;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 32px) 32px calc(env(safe-area-inset-bottom) + 32px);
  text-align: center;
}
#screen-onboarding.visible { display: flex; }
.ob-slides { flex: 1; display: flex; align-items: center; width: 100%; max-width: 360px; }
.ob-slide { display: none; flex-direction: column; align-items: center; gap: 20px; width: 100%; }
.ob-slide.active { display: flex; }
.ob-icon {
  width: 88px; height: 88px;
  border-radius: 28px;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
}
.ob-icon svg { width: 44px; height: 44px; stroke-width: 1.5; }
.ob-title { font-size: 1.6rem; font-weight: 800; color: var(--text); line-height: 1.2; }
.ob-desc { font-size: 1rem; color: var(--text-muted); line-height: 1.6; max-width: 300px; }
.ob-dots { display: flex; gap: 8px; margin: 24px 0 32px; }
.ob-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border-bright);
  transition: all 0.3s;
}
.ob-dot.active { width: 24px; border-radius: 4px; background: var(--primary); }
.ob-actions { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 360px; }
.ob-btn-skip {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
}
.ob-btn-next {
  flex: 2;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
  transition: opacity 0.2s;
}
.ob-btn-next:active { opacity: 0.85; }

/* ── Dark Mode — Abisso Notturno ── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #020d18;
    --surface: rgba(5, 22, 38, 0.95);
    --surface2: rgba(8, 28, 48, 0.92);
    --border: rgba(60,160,200,0.12);
    --border-bright: rgba(80,180,220,0.22);
    --primary: #22c8f0;
    --primary-soft: rgba(34,200,240,0.13);
    --text: #e8f6fd;
    --text-muted: #9ecfe8;
    --text-dim: #6ab8d8;
    --shadow-card: 0 1px 4px rgba(0,0,0,0.6), 0 6px 18px rgba(0,0,0,0.45);
    --shadow: 0 4px 28px rgba(0,0,0,0.7);
  }
}
[data-theme="dark"] {
  --bg: #020d18;
  --surface: rgba(5, 22, 38, 0.95);
  --surface2: rgba(8, 28, 48, 0.92);
  --border: rgba(60,160,200,0.12);
  --border-bright: rgba(80,180,220,0.22);
  --primary: #22c8f0;
  --primary-soft: rgba(34,200,240,0.13);
  --text: #e8f6fd;
  --text-muted: #9ecfe8;
  --text-dim: #6ab8d8;
  --shadow-card: 0 1px 4px rgba(0,0,0,0.6), 0 6px 18px rgba(0,0,0,0.45);
  --shadow: 0 4px 28px rgba(0,0,0,0.7);
}
[data-theme="dark"] .card,
body.dark-bg .card {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(60,160,200,0.15);
}
[data-theme="dark"] .bottom-nav,
body.dark-bg .bottom-nav {
  background: rgba(4, 16, 28, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top-color: rgba(60,160,200,0.15);
}
[data-theme="dark"] .stat-card,
body.dark-bg .stat-card {
  background: rgba(8, 26, 44, 0.88);
  border: 1px solid rgba(60,160,200,0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
[data-theme="dark"] .user-bar,
body.dark-bg .user-bar {
  background: rgba(2, 12, 22, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.user-bar-theme {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
.user-bar-theme svg { width: 15px; height: 15px; stroke-width: 2; }
.user-bar-theme:active { background: var(--surface2); }

.user-bar-settings {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
.user-bar-settings svg { width: 15px; height: 15px; stroke-width: 2; }
.user-bar-settings:active { background: var(--surface2); }

/* ── ACCOUNT MODAL extras ── */
.account-status {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 18px;
}
.account-status .pro-pill {
  display: inline-block;
  background: rgba(224,123,0,0.12);
  color: var(--warning);
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 6px;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
}
.account-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.account-link {
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}
.account-link:active { opacity: 0.7; }
.account-danger-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 14px;
  background: transparent;
  color: var(--error);
  border: 1.5px solid var(--error);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
.account-danger-btn:active { background: rgba(220,38,38,0.08); }

/* ── ADMIN PANEL ── */
.admin-card { max-width: 560px; max-height: 85vh; overflow: hidden; display: flex; flex-direction: column; padding-bottom: 0; }
.admin-search-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 12px;
  box-sizing: border-box;
}
.admin-search-input:focus { outline: none; border-color: var(--accent, #006994); }
.admin-list {
  flex: 1;
  overflow-y: auto;
  margin: 0 -8px;
  padding: 0 8px 16px;
  min-height: 200px;
}
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--surface2);
}
.admin-row-info { flex: 1; min-width: 0; }
.admin-row-email {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-row-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.admin-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  background: var(--accent, #006994);
  color: #fff;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 700;
  vertical-align: middle;
}
.admin-toggle {
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--accent, #006994);
  background: transparent;
  color: var(--accent, #006994);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.admin-toggle.is-pro {
  border-color: var(--error);
  color: var(--error);
}
.admin-toggle:disabled { opacity: 0.5; cursor: wait; }
.admin-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px;
  font-size: 0.9rem;
}

/* ── FREEMIUM: locked states ── */
.topic-card.locked { opacity: 0.6; }
.topic-card.locked .topic-lock { display: flex; }
.topic-lock { display: none; align-items: center; color: var(--text-muted); flex-shrink: 0; }
.topic-lock svg { width: 16px; height: 16px; stroke-width: 2; }
.mode-card.locked { opacity: 0.55; }
.mode-card.locked .mode-lock { display: flex; }
.mode-lock { display: none; align-items: center; color: var(--text-muted); flex-shrink: 0; }
.mode-lock svg { width: 16px; height: 16px; stroke-width: 2; }
.free-badge {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  background: var(--primary-soft); color: var(--primary); border-radius: 4px;
  padding: 2px 5px; margin-left: 6px; vertical-align: middle;
}
.pro-badge {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  background: rgba(224,123,0,0.12); color: var(--warning); border-radius: 4px;
  padding: 2px 5px; margin-left: 6px; vertical-align: middle;
}
.daily-limit-bar {
  margin: 0 16px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 10px;
}
.daily-limit-bar .dlb-track { flex: 1; height: 5px; background: var(--border); border-radius: 99px; overflow: hidden; }
.daily-limit-bar .dlb-fill { height: 100%; border-radius: 99px; background: var(--primary); transition: width 0.4s; }

/* ── UPGRADE MODAL ── */
.upgrade-overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 1000;
  display: none;
  align-items: flex-end; justify-content: center;
}
.upgrade-overlay.active {
  display: flex;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade-in 0.2s ease;
}
.upgrade-card {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 28px 24px 40px;
  width: 100%; max-width: 480px;
  position: relative;
  animation: slide-up 0.3s cubic-bezier(.22,1,.36,1);
}
.upgrade-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--surface2); border: none; border-radius: 50%;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted);
}
.upgrade-close svg { width: 16px; height: 16px; stroke-width: 2.5; }
.upgrade-anchor { text-align: center; color: var(--primary); margin-bottom: 8px; }
.upgrade-anchor svg { width: 32px; height: 32px; stroke-width: 1.5; }
.upgrade-badge {
  text-align: center; font-size: 0.65rem; font-weight: 800; letter-spacing: 0.12em;
  color: var(--warning); background: rgba(224,123,0,0.12); border-radius: 6px;
  padding: 3px 10px; display: inline-block; margin: 0 auto 10px;
  left: 50%; position: relative; transform: translateX(-50%);
}
.upgrade-title { text-align: center; font-size: 1.4rem; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.upgrade-subtitle { text-align: center; font-size: 0.88rem; color: var(--text-muted); margin-bottom: 20px; }
.upgrade-perks { list-style: none; margin: 0 0 24px; display: flex; flex-direction: column; gap: 10px; }
.upgrade-perks li { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; color: var(--text-dim); }
.upgrade-perks li svg { width: 16px; height: 16px; stroke-width: 2.5; color: var(--success); flex-shrink: 0; }
.upgrade-btn {
  display: block; width: 100%; padding: 16px;
  background: var(--primary); color: #fff; border-radius: var(--radius);
  text-align: center; font-size: 1rem; font-weight: 700; text-decoration: none;
  transition: opacity 0.2s;
}
.upgrade-btn:active { opacity: 0.85; }
.upgrade-fine { text-align: center; font-size: 0.75rem; color: var(--text-muted); margin-top: 10px; }
