/* ANRE IIB — vocabular vizual de tablou electric:
   carcasă RAL 7035, galben de avertizare, verde-galben PE pentru „corect”,
   albastru de neutru pentru referințe, maro de fază pentru greșeli. */
:root {
  --enclosure: #e4e6e1;      /* RAL 7035, deschis */
  --panel: #f7f8f5;
  --rail: #c9ccc5;
  --ink: #20262c;
  --ink-soft: #57606a;
  --line: #c3c7c0;
  --signal: #f2b705;         /* galben de avertizare */
  --pe-green: #2f8a3e;
  --pe-yellow: #e9c81a;
  --ok: #24723a;
  --ok-bg: #e5f1e3;
  --bad: #8a3b12;            /* maro de fază */
  --bad-bg: #f6e6dc;
  --neutral: #2456a4;        /* albastru de neutru */
  --neutral-bg: #e6ecf6;
  --radius-s: 4px;
  --radius-m: 8px;
  --sans: "Barlow", system-ui, sans-serif;
  --cond: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --enclosure: #1c2024; --panel: #262b30; --rail: #343a40; --ink: #e8ebe6; --ink-soft: #a5adb4;
    --line: #3d444b; --ok: #7fd08c; --ok-bg: #1f3324; --bad: #f0a479; --bad-bg: #3a2519;
    --neutral: #8fb3f0; --neutral-bg: #1f2a3c; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--enclosure); color: var(--ink);
  font: 17px/1.5 var(--sans); min-height: 100vh;
}
a { color: var(--neutral); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

/* ---------- antet ---------- */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--enclosure);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; text-decoration: none; color: var(--ink);
  font: 600 19px/1 var(--cond); letter-spacing: .02em; }
.brand b { font-weight: 700; }
.brand-mark { width: 26px; height: 26px; border-radius: 6px; display: block; }
.topnav { display: flex; gap: 4px; }
.topnav a { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 12px; border-radius: var(--radius-s); text-decoration: none; color: var(--ink-soft);
  font: 600 16px/1 var(--cond); }
.topnav a[aria-current="page"] { color: var(--ink); background: var(--panel); box-shadow: inset 0 -3px 0 var(--signal); }

main { max-width: 760px; margin: 0 auto; outline: none;
  padding: 20px max(16px, env(safe-area-inset-right)) 96px max(16px, env(safe-area-inset-left)); }
a, button, .chip, .opt, .mod { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.loading { color: var(--ink-soft); }
h1, h2, h3 { font-family: var(--cond); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
.muted { color: var(--ink-soft); }
.small { font-size: 14px; }

/* ---------- butoane ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px;
  padding: 10px 18px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--panel);
  font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--ink-soft); }
.btn-primary { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.btn-primary:hover { background: #000; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.spread { justify-content: space-between; }

/* ---------- acasă ---------- */
.home-head { margin: 8px 0 22px; }
.home-head p { margin: 6px 0 0; max-width: 60ch; }
.domains { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.dom { background: var(--panel); padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.dom h3 { font-size: 19px; }
.dom .meter { grid-column: 1 / -1; height: 8px; background: var(--rail); border-radius: 2px; overflow: hidden; display: flex; }
.dom .meter i { display: block; height: 100%; }
.meter .m-mast { background: var(--pe-green); }
.meter .m-seen { background: var(--neutral); opacity: .55; }
.dom .nums { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-size: 14px; text-align: right; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-soft); margin: 8px 2px 0; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.legend .l-mast::before { background: var(--pe-green); }
.legend .l-seen::before { background: var(--neutral); opacity: .55; }
.legend .l-new::before { background: var(--rail); }
.modes { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 24px 0; }
.mode { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.mode p { margin: 0; color: var(--ink-soft); font-size: 15px; }
.mode .btn { margin-top: auto; align-self: flex-start; }
.history { margin-top: 28px; }
.history table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 15px; }
.history td, .history th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.history th { font-weight: 600; color: var(--ink-soft); font-size: 13px; }
.pass { color: var(--ok); font-weight: 600; }
.fail { color: var(--bad); font-weight: 600; }

/* ---------- filtre ---------- */
summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
summary::before { content: "▸"; display: inline-block; width: 1.2em; transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }
summary::-webkit-details-marker { display: none; }
summary { list-style: none; }
.filters { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; margin: 14px 0 18px; display: grid; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span { display: inline-flex; align-items: center; min-height: 44px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; font-size: 15px; background: var(--enclosure); }
.chip input:checked + span { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.chip input:focus-visible + span { outline: 3px solid var(--signal); outline-offset: 2px; }
.field-label { font-size: 14px; color: var(--ink-soft); margin-bottom: 6px; }

/* ---------- întrebare ---------- */
.qmeta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-soft); margin-bottom: 10px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 3px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; color: var(--ink-soft); }
.tag-new { border-color: var(--neutral); color: var(--neutral); }
.stem { font: 500 21px/1.4 var(--sans); margin: 0 0 18px; max-width: 64ch; }
.opts { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.opt { width: 100%; text-align: left; display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start;
  padding: 14px 14px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--panel);
  cursor: pointer; line-height: 1.4; position: relative; }
.opt:hover:not([disabled]) { border-color: var(--ink-soft); }
.opt .key { width: 30px; height: 30px; border-radius: 3px; display: grid; place-items: center; font: 700 16px/1 var(--cond);
  background: var(--enclosure); border: 1px solid var(--line); }
.opt[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.opt[aria-pressed="true"] .key { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.opt[disabled] { cursor: default; }
/* corect = conductor PE */
.opt.is-correct { border-color: var(--ok); background: var(--ok-bg); padding-left: 22px; }
.opt.is-correct::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; border-radius: var(--radius-m) 0 0 var(--radius-m);
  background: repeating-linear-gradient(180deg, var(--pe-green) 0 10px, var(--pe-yellow) 10px 20px); }
.opt.is-correct .key { background: var(--ok); color: #fff; border-color: var(--ok); }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.is-wrong .key { background: var(--bad); color: #fff; border-color: var(--bad); }
.opt.is-dim { opacity: .62; }

.verdict { margin: 20px 0 0; padding: 14px 16px; border-radius: var(--radius-m); border: 1px solid var(--line); background: var(--panel); }
.verdict-head { font: 700 20px/1.2 var(--cond); margin-bottom: 8px; }
.verdict.ok .verdict-head { color: var(--ok); }
.verdict.bad .verdict-head { color: var(--bad); }
.explain { font: 17px/1.62 var(--serif); margin: 0; max-width: 66ch; }
.refs { margin: 14px 0 0; display: grid; gap: 10px; }
.ref { border-left: 3px solid var(--neutral); background: var(--neutral-bg); padding: 10px 12px; border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.ref-head { font: 600 14px/1.3 var(--sans); color: var(--neutral); }
.ref blockquote { margin: 6px 0 0; font: 15.5px/1.55 var(--serif); color: var(--ink); }
.vnote { margin-top: 12px; font-size: 14px; color: var(--ink-soft); }
.actions { position: sticky; bottom: 0; margin: 20px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--enclosure) 75%, transparent); display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.kbd { font-size: 13px; color: var(--ink-soft); }
@media (max-width: 560px) { .kbd { display: none; } .stem { font-size: 19px; } h1 { font-size: 26px; } }

/* ---------- examen: șina DIN cu 25 de module ---------- */
.exam-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.timer { font: 700 28px/1 var(--cond); font-variant-numeric: tabular-nums; padding: 6px 12px; border-radius: var(--radius-s); background: var(--panel); border: 1px solid var(--line); }
.timer.low { background: var(--signal); color: #1d1d1d; border-color: var(--signal); }
.rail { position: relative; display: grid; grid-template-columns: repeat(25, 1fr); gap: 3px; padding: 10px 8px; margin: 0 0 20px;
  background: var(--rail); border-radius: var(--radius-s); }
.rail::before { content: ""; position: absolute; left: 4px; right: 4px; top: 50%; height: 14px; transform: translateY(-50%);
  background: repeating-linear-gradient(90deg, transparent 0 10px, rgba(0,0,0,.08) 10px 12px); border-top: 1px solid rgba(0,0,0,.12); border-bottom: 1px solid rgba(0,0,0,.12); }
.mod { position: relative; height: 46px; border: 1px solid #9aa097; border-radius: 3px; background: #f3f4f0; cursor: pointer; padding: 0;
  font: 600 12px/1 var(--cond); color: #444; }
.mod span { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; }
/* maneta siguranței: jos = liber, sus = răspuns dat */
.mod::after { content: ""; position: absolute; left: 22%; right: 22%; top: 16px; height: 10px; border-radius: 2px; background: #b9bdb5; transition: top .15s, background .15s; }
.mod.answered::after { background: var(--ink); top: 4px; }
.mod.res-ok::after { background: var(--pe-green); top: 4px; }
.mod.res-bad::after { background: var(--bad); }
.mod.current { outline: 3px solid var(--signal); outline-offset: 1px; }
@media (max-width: 640px) {
  .rail { grid-template-columns: repeat(9, 1fr); gap: 4px; }
  .mod { height: 44px; }
  .mod::after { top: 13px; } .mod.answered::after, .mod.res-ok::after { top: 3px; }
}
@media (prefers-reduced-motion: reduce) { .mod::after { transition: none; } }
.score { display: flex; align-items: baseline; gap: 14px; margin: 6px 0 4px; }
.score b { font: 700 64px/1 var(--cond); font-variant-numeric: tabular-nums; }
.score .of { font: 600 26px/1 var(--cond); color: var(--ink-soft); }
.result-line { font: 600 20px/1.3 var(--cond); }
.review-item { border-top: 1px solid var(--line); padding: 18px 0; }
.review-item .stem { font-size: 18px; }
dialog { border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--panel); color: var(--ink); max-width: min(520px, 92vw); padding: 18px; }
dialog::backdrop { background: rgba(20,24,28,.45); }
textarea { width: 100%; min-height: 90px; font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--enclosure); color: var(--ink); }
.empty { padding: 30px 0; }

.keywarn { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-s); background: #fff4cc; color: #3a2e00; border-left: 4px solid var(--signal); font-size: 15px; line-height: 1.45; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .keywarn { background: #3a3110; color: #f5e7b0; } }

main:focus, main:focus-visible { outline: none; }

/* ---------- ajustări mobile ---------- */
.btn { white-space: nowrap; }
@media (hover: none) { .kbd { display: none; } }
@media (max-width: 420px) {
  .hide-sm { display: none; }
  .actions .btn { padding: 10px 14px; }
}
@media (max-height: 520px) { .top { position: static; } }
.filters:not([open]) { padding-top: 4px; padding-bottom: 4px; }
