/* =============================================================
   Imparare l'AI con Claude — Foglio di stile
   Design: laboratorio digitale, sfondo chiaro, accenti blu/viola,
   card arrotondate, micro-animazioni leggere, alta accessibilità.
   ============================================================= */

/* ----------------------- Variabili ------------------------- */
:root {
  /* Colori di base */
  --bg: #f6f7fb;
  --bg-soft: #eef1f8;
  --surface: #ffffff;
  --surface-2: #fbfcff;

  /* Testo (contrasto elevato su sfondo chiaro) */
  --text: #1a1f36;
  --text-soft: #4a5068;
  --text-muted: #6b7280;

  /* Accenti blu/viola */
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --violet: #7c3aed;
  --violet-dark: #6d28d9;
  --accent-grad: linear-gradient(120deg, #2563eb 0%, #7c3aed 100%);
  --accent-grad-soft: linear-gradient(120deg, #eff4ff 0%, #f3eefe 100%);

  /* Stati */
  --success: #0f8a5f;
  --success-bg: #e6f7ef;
  --success-border: #b8e6d2;
  --success-text: #0a5c40;
  --error: #c0392b;
  --error-bg: #fdeceb;
  --error-border: #f3c9c4;
  --error-text: #8a2b20;
  --warn: #b26a00;
  --warn-bg: #fff4e0;
  --warn-border: #f3dfb0;
  --warn-text: #6b4500;
  --info-border: #d9def5;

  /* Bordi e ombre */
  --border: #e2e6f0;
  --border-strong: #cfd5e6;
  --shadow-sm: 0 1px 2px rgba(26, 31, 54, 0.06);
  --shadow: 0 6px 20px rgba(26, 31, 54, 0.08);
  --shadow-lg: 0 14px 40px rgba(37, 99, 235, 0.16);

  /* Superfici e accenti che cambiano con il tema */
  --header-bg: rgba(255, 255, 255, 0.86);
  --code-bg: #f4f6fc;
  --toast-bg: #1a1f36;
  --toast-text: #ffffff;
  --chip-violet-bg: #f3eefe;
  --chip-violet-border: #e6dcfb;

  /* Forme */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;

  /* Tipografia e spazi */
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --maxw: 1100px;
  --gap: 20px;

  --focus-ring: 0 0 0 3px var(--bg), 0 0 0 6px var(--violet);
}

/* ----------------------- Tema scuro ------------------------ */
/* Attivabile con l'interruttore nell'header oppure in automatico dalle
   preferenze di sistema. Pensato per il risparmio energetico (specie su
   schermi OLED) e per il comfort visivo, mantenendo un contrasto elevato. */
:root[data-theme="dark"] {
  --bg: #0c0e14;
  --bg-soft: #161a24;
  --surface: #141822;
  --surface-2: #1b2131;

  --text: #e8ebf5;
  --text-soft: #c3c9db;
  --text-muted: #959cb1;

  --blue: #6ea0ff;
  --blue-dark: #9cc0ff;
  --violet: #b794ff;
  --violet-dark: #cdb6ff;
  --accent-grad: linear-gradient(120deg, #3f6fe0 0%, #8b5cf6 100%);
  --accent-grad-soft: linear-gradient(120deg, #19233a 0%, #221a3a 100%);

  --success: #34d399;
  --success-bg: #102a20;
  --success-border: #1f5c45;
  --success-text: #9bedc9;
  --error: #f87171;
  --error-bg: #2c1614;
  --error-border: #5e2b27;
  --error-text: #fdc7c1;
  --warn: #fbbf24;
  --warn-bg: #2a2110;
  --warn-border: #5c4715;
  --warn-text: #fbe2a3;
  --info-border: #2c3656;

  --border: #272d3c;
  --border-strong: #3a4356;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.6);

  --header-bg: rgba(12, 14, 20, 0.85);
  --code-bg: #0e131d;
  --toast-bg: #232a3b;
  --toast-text: #f1f3f9;
  --chip-violet-bg: #221a3a;
  --chip-violet-border: #352a55;

  --focus-ring: 0 0 0 3px var(--bg), 0 0 0 6px var(--violet);
}

/* Transizione morbida nel passaggio chiaro/scuro (azzerata da reduce-motion). */
body,
.app-header,
.panel,
.certificate,
.progress-tracker {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ----------------------- Reset leggero --------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 110% -10%, rgba(124, 58, 237, 0.08), transparent 60%),
    radial-gradient(1000px 480px at -10% 0%, rgba(37, 99, 235, 0.08), transparent 55%),
    var(--bg);
  line-height: 1.6;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4 { line-height: 1.25; color: var(--text); margin: 0 0 0.5em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; color: var(--text-soft); }
ul { color: var(--text-soft); }

a { color: var(--blue-dark); }

/* ----------------------- Accessibilità --------------------- */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  background: var(--surface);
  color: var(--blue-dark);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--blue);
  font-weight: 700;
  z-index: 1000;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 12px; outline: none; box-shadow: var(--focus-ring); }

/* Anello di focus visibile e coerente ovunque */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 6px;
}

/* ----------------------- Header ---------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.app-header__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}
.brand__logo {
  font-size: 1.8rem;
  background: var(--accent-grad-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
}
.brand__text { display: flex; flex-direction: column; }
.brand__title { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em; }
.brand__subtitle { font-size: 0.8rem; color: var(--text-muted); }

.main-nav__list {
  list-style: none;
  display: flex;
  gap: 6px;
  margin: 0; padding: 0;
}
.nav-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}
.nav-btn:hover { background: var(--bg-soft); color: var(--text); }
.nav-btn[aria-current="page"] {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 11px 10px;
  cursor: pointer;
}
.menu-toggle__bar {
  width: 22px; height: 2.5px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Azioni a destra nell'header (interruttore tema + menu mobile) */
.header-actions { display: flex; align-items: center; gap: 8px; }
.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--text);
  transition: background 0.18s ease, transform 0.12s ease, border-color 0.18s ease;
}
.theme-toggle:hover { background: var(--bg-soft); border-color: var(--blue); }
.theme-toggle:active { transform: translateY(1px); }
.theme-toggle__icon { display: block; }

/* Barra di progresso globale */
.global-progress {
  height: 5px;
  width: 100%;
  background: var(--bg-soft);
  overflow: hidden;
}
.global-progress__fill {
  height: 100%;
  width: 0%;
  background: var(--accent-grad);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----------------------- Layout main ----------------------- */
.app-main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 32px 20px 56px;
  outline: none;
}

/* Animazione di ingresso vista */
.view { animation: fadeUp 0.4s ease both; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ----------------------- Hero / Dashboard ------------------ */
.hero {
  background: var(--accent-grad);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 34px 32px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: auto -40px -60px auto;
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(255,255,255,0.22), transparent 65%);
  pointer-events: none;
}
.hero h1 { color: #fff; max-width: 30ch; }
.hero p { color: rgba(255,255,255,0.92); max-width: 60ch; margin-bottom: 0; }
.hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Griglia generica di card */
.grid {
  display: grid;
  gap: var(--gap);
  margin-top: 28px;
}
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid--modules { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }

/* Card generica */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card--hover:hover,
.card--hover:focus-within {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 36px 0 4px;
  flex-wrap: wrap;
}
.section-title p { margin: 0; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--violet-dark);
}

/* Card informative (dashboard) */
.info-card__icon {
  font-size: 1.6rem;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  background: var(--accent-grad-soft);
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.info-card h3 { margin-bottom: 6px; }
.info-card p { margin: 0; font-size: 0.95rem; }

/* ----------------------- Progress Tracker ------------------ */
.progress-tracker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-top: 24px;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
  align-items: center;
}
.progress-ring-wrap { display: flex; align-items: center; gap: 20px; }
.progress-ring { flex: 0 0 auto; }
.progress-ring__track { stroke: var(--bg-soft); }
.progress-ring__value {
  stroke: url(#ringGrad);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}
.progress-ring__label {
  font-size: 1.5rem;
  font-weight: 800;
  fill: var(--text);
}
.progress-stats { display: flex; flex-direction: column; gap: 4px; }
.progress-stats__big { font-size: 1.05rem; font-weight: 700; }
.progress-stats__sub { color: var(--text-muted); font-size: 0.9rem; }

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-content: flex-start;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
}
.badge--earned {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
  animation: pop 0.4s ease;
}
.badge__icon { font-size: 1rem; }
@keyframes pop {
  0% { transform: scale(0.8); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

/* ----------------------- Module Card ----------------------- */
.module-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}
.module-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.module-card__icon {
  font-size: 1.5rem;
  width: 50px; height: 50px;
  display: grid; place-items: center;
  background: var(--accent-grad-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.module-card__num {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--violet-dark);
  background: var(--chip-violet-bg);
  border: 1px solid var(--chip-violet-border);
  border-radius: 999px;
  padding: 3px 10px;
}
.module-card h3 { margin: 0; }
.module-card__tagline { font-size: 0.92rem; color: var(--text-muted); margin: 0; }
.module-card__foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
}
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.status-chip--done { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.module-card__go {
  font-weight: 700;
  color: var(--blue-dark);
  font-size: 0.92rem;
}

/* ----------------------- Buttons --------------------------- */
.btn {
  appearance: none;
  font: inherit;
  font-weight: 700;
  border-radius: 12px;
  padding: 12px 20px;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease, opacity 0.18s ease;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover { box-shadow: var(--shadow); }
.btn--ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn--ghost:hover { background: var(--bg-soft); }
.btn--block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.link-btn {
  background: none;
  border: none;
  color: var(--blue-dark);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}
.link-btn:hover { color: var(--violet-dark); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
}
.toolbar--between { justify-content: space-between; }

/* ----------------------- Lesson Panel ---------------------- */
.lesson-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.lesson-head__icon {
  font-size: 2rem;
  width: 64px; height: 64px;
  display: grid; place-items: center;
  background: var(--accent-grad);
  color: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.lesson-head__meta { flex: 1 1 260px; }
.lesson-head__num { font-size: 0.8rem; font-weight: 800; color: var(--violet-dark); text-transform: uppercase; letter-spacing: .06em;}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-top: 20px;
}
.panel__label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--violet-dark);
  margin-bottom: 12px;
}

.objectives { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 10px; }
.objectives li { display: flex; gap: 10px; align-items: flex-start; }
.objectives li::before {
  content: "✓";
  color: var(--success);
  font-weight: 900;
  background: var(--success-bg);
  border-radius: 50%;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  flex: 0 0 auto;
  font-size: 0.8rem;
  margin-top: 2px;
}

/* Example cards inline */
.examples { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.example {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.example__label { font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.example__label .ic { font-size: 1.1rem; }
.example p { margin: 0; font-size: 0.94rem; }

/* ----------------------- Prompt Comparison ----------------- */
.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.compare__col {
  border-radius: var(--radius-sm);
  padding: 16px;
  border: 1px solid var(--border);
}
.compare__col--before { background: var(--error-bg); border-color: var(--error-border); }
.compare__col--after { background: var(--success-bg); border-color: var(--success-border); }
.compare__tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.compare__col--before .compare__tag { color: var(--error); }
.compare__col--after .compare__tag { color: var(--success); }
.compare__prompt {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  background: var(--code-bg);
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
.why-better { margin: 14px 0 0; padding-left: 0; list-style: none; display: grid; gap: 8px; }
.why-better li { display: flex; gap: 10px; font-size: 0.92rem; }
.why-better li::before { content: "→"; color: var(--blue-dark); font-weight: 900; }

/* ----------------------- Quiz Card ------------------------- */
.quiz-card { margin-top: 16px; }
.quiz-progress { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
.quiz-question { font-size: 1.1rem; font-weight: 700; margin-bottom: 14px; }
.quiz-options { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  font: inherit;
  background: var(--surface-2);
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.1s ease;
  color: var(--text);
}
.quiz-option:hover:not(:disabled) { border-color: var(--blue); background: var(--surface); }
.quiz-option:disabled { cursor: default; }
.quiz-option__key {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 800;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-soft);
}
.quiz-option--correct {
  border-color: var(--success);
  background: var(--success-bg);
}
.quiz-option--correct .quiz-option__key { background: var(--success); color: #fff; border-color: var(--success); }
.quiz-option--wrong {
  border-color: var(--error);
  background: var(--error-bg);
}
.quiz-option--wrong .quiz-option__key { background: var(--error); color: #fff; border-color: var(--error); }

/* ----------------------- Feedback Box ---------------------- */
.feedback {
  margin-top: 16px;
  border-radius: 12px;
  padding: 14px 16px;
  border: 1px solid;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: fadeUp 0.3s ease both;
}
.feedback__icon { font-size: 1.3rem; flex: 0 0 auto; }
.feedback p { margin: 0; font-size: 0.95rem; color: inherit; }
.feedback--correct { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.feedback--wrong { background: var(--error-bg); border-color: var(--error-border); color: var(--error-text); }
.feedback--info { background: var(--accent-grad-soft); border-color: var(--info-border); color: var(--text); }
.feedback--warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }

/* ----------------------- Practice -------------------------- */
.practice-box { background: var(--accent-grad-soft); border-color: var(--info-border); }
.checklist { margin: 12px 0 0; padding-left: 0; list-style: none; display: grid; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; font-size: 0.93rem; }
.checklist li::before { content: "☐"; font-size: 1.05rem; color: var(--violet-dark); }

textarea.field, input.field {
  width: 100%;
  font: inherit;
  font-size: 0.98rem;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  padding: 14px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
textarea.field { min-height: 120px; }
textarea.field:focus, input.field:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.field-label { display: block; font-weight: 700; margin-bottom: 8px; }
.field-hint { font-size: 0.85rem; color: var(--text-muted); margin-top: 6px; }

/* ----------------------- Prompt Lab ------------------------ */
.lab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}
.lab-score {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.lab-score__bar {
  flex: 1;
  height: 12px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}
.lab-score__fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.5s ease, background 0.4s ease;
  background: var(--accent-grad);
}
.lab-score__num { font-weight: 800; font-size: 1.1rem; min-width: 64px; text-align: right; }
.suggestion-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.suggestion {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--violet);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.93rem;
  animation: fadeUp 0.3s ease both;
}
.suggestion--ok { border-left-color: var(--success); }
.suggestion__ic { font-size: 1.1rem; flex: 0 0 auto; }
.lab-rewrite {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--code-bg);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 14px;
  color: var(--text);
}
.lab-examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip-btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 7px 12px;
  cursor: pointer;
  color: var(--text-soft);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip-btn:hover { background: var(--accent-grad-soft); color: var(--violet-dark); border-color: var(--info-border); }

/* ----------------------- Certificate ----------------------- */
.certificate {
  background:
    repeating-linear-gradient(45deg, rgba(37,99,235,0.03) 0 12px, transparent 12px 24px),
    var(--surface);
  border: 2px solid var(--violet);
  border-radius: var(--radius-lg);
  padding: 36px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow);
  margin-top: 20px;
}
.certificate__seal {
  font-size: 2.4rem;
  width: 76px; height: 76px;
  margin: 0 auto 12px;
  display: grid; place-items: center;
  background: var(--accent-grad);
  color: #fff;
  border-radius: 50%;
  box-shadow: var(--shadow);
}
.certificate__title { font-size: 1.6rem; margin-bottom: 4px; }
.certificate__name {
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 10px 0;
}
.certificate__meta { color: var(--text-muted); font-size: 0.9rem; }
.cert-pre {
  text-align: left;
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-top: 18px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  max-height: 280px;
  overflow: auto;
}

/* ----------------------- Errors summary -------------------- */
.error-summary { display: grid; gap: 10px; margin-top: 12px; }
.error-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.error-row__topic { font-weight: 600; font-size: 0.95rem; }
.error-row__count {
  font-weight: 800;
  font-size: 0.85rem;
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid var(--warn-border);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

/* ----------------------- Toast ----------------------------- */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  width: min(92vw, 420px);
}
.toast {
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s ease both;
}
.toast--success { background: #0a5c40; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ----------------------- Footer ---------------------------- */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 40px;
}
.app-footer__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 20px;
  text-align: center;
}
.app-footer__note { font-size: 0.88rem; color: var(--text-soft); margin: 0 0 8px; }
.app-footer__note--muted { color: var(--text-muted); font-size: 0.82rem; }
.app-footer__actions { margin: 8px 0 0; }

/* ----------------------- Misc ------------------------------ */
.stack { display: grid; gap: 14px; }
.muted { color: var(--text-muted); }
.center { text-align: center; }
.divider { height: 1px; background: var(--border); margin: 22px 0; border: 0; }
.pill-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ----------------------- Responsive ------------------------ */
@media (max-width: 820px) {
  .progress-tracker { grid-template-columns: 1fr; }
  .compare { grid-template-columns: 1fr; }
  .lab-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  body { font-size: 16px; }
  .brand__subtitle { display: none; }
  .menu-toggle { display: flex; }
  .main-nav {
    position: absolute;
    top: calc(100% + 1px);
    right: 12px;
    left: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px;
    display: none;
  }
  .main-nav.is-open { display: block; animation: fadeUp 0.2s ease both; }
  .main-nav__list { flex-direction: column; gap: 4px; }
  .nav-btn { width: 100%; text-align: left; border-radius: 10px; }
  .hero { padding: 26px 22px; }
  .panel { padding: 18px; }
  .certificate { padding: 24px 18px; }
}

/* ----------------------- Reduced motion -------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
