:root {
  --bg: #f5f7f7; --card: #ffffff; --text: #16211f; --muted: #5d6b68; --line: #dde4e2;
  --accent: #0f766e; --accent-soft: #d9efec; --on-accent: #ffffff;
  --ok: #15803d; --ok-soft: #dcf3e3; --bad: #b91c1c; --bad-soft: #fbe1e1; --warn: #a16207; --warn-soft: #fbf0cf;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1514; --card: #19211f; --text: #e6eeec; --muted: #9aaaa6; --line: #2b3633;
    --accent: #2dd4bf; --accent-soft: #123532; --on-accent: #06211e;
    --ok: #4ade80; --ok-soft: #12301d; --bad: #f87171; --bad-soft: #3a1717; --warn: #facc15; --warn-soft: #33290c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1514; --card: #19211f; --text: #e6eeec; --muted: #9aaaa6; --line: #2b3633;
  --accent: #2dd4bf; --accent-soft: #123532; --on-accent: #06211e;
  --ok: #4ade80; --ok-soft: #12301d; --bad: #f87171; --bad-soft: #3a1717; --warn: #facc15; --warn-soft: #33290c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
p { margin: 0 0 10px; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.mic { font-size: .85rem; }
.gol { color: var(--muted); padding: 24px 0; }

/* ---------- Structură ---------- */
.app { min-height: 100dvh; }
.main { max-width: 860px; margin: 0 auto; padding: 20px 16px calc(84px + env(safe-area-inset-bottom)); outline: none; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.nav .brand { display: none; }
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px; font-size: .7rem; color: var(--muted); text-decoration: none; min-width: 0;
}
.nav a svg { width: 22px; height: 22px; }
.nav a.activ { color: var(--accent); font-weight: 600; }
body.in-quiz .nav { display: none; }
body.in-quiz .main { padding-bottom: 110px; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 220px 1fr; }
  .nav {
    position: sticky; top: 0; height: 100dvh; flex-direction: column; gap: 2px;
    border-top: 0; border-right: 1px solid var(--line); padding: 18px 10px;
  }
  .nav .brand { display: block; font-weight: 700; font-size: 1.1rem; padding: 4px 12px 16px; }
  .nav a { flex: none; flex-direction: row; gap: 10px; font-size: .95rem; padding: 10px 12px; border-radius: 10px; }
  .nav a.activ { background: var(--accent-soft); }
  .main { padding: 32px 28px 48px; width: 100%; }
  body.in-quiz .nav { display: flex; }
  body.in-quiz .main { padding-bottom: 110px; }
}

/* ---------- Componente ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  text-decoration: none; color: var(--text); font-weight: 600;
}
.btn.primar { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.pericol { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.rand { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.rand.intre { justify-content: space-between; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .75rem; font-weight: 700; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.gri { background: var(--line); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.hero { background: var(--accent); color: var(--on-accent); border: 0; }
.hero .zile { font-size: 2.6rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.hero p { margin: 6px 0 0; opacity: .9; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .8rem; color: var(--muted); }

.fapte { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: .93rem; }
.fapte dt { color: var(--muted); }
.fapte dd { margin: 0; }

.bara { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bara i { display: block; height: 100%; background: var(--accent); }

/* Tematică */
.carte-titlu { margin: 22px 0 2px; }
.cap { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 8px; }
.cap-sus { display: flex; gap: 10px; align-items: baseline; }
.cap-nr { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.6em; }
.cap-t { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.cap ul { margin: 6px 0 8px 2.3em; padding: 0; list-style: none; font-size: .85rem; color: var(--muted); }
.cap ul li { display: flex; justify-content: space-between; gap: 10px; padding: 1px 0; }
.cap ul li span:last-child { white-space: nowrap; }

/* Formulare */
.camp { display: block; margin-bottom: 12px; }
.camp > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
select, input[type="date"], input[type="search"], textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
}
textarea { min-height: 70px; resize: vertical; }
.grila2 { display: grid; gap: 0 14px; }
@media (min-width: 640px) { .grila2 { grid-template-columns: 1fr 1fr; } }

/* Quiz */
.qbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.qbar .bara { flex: 1; }
.qbar .timp { font-variant-numeric: tabular-nums; font-weight: 700; }
.iconbtn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; min-width: 44px; min-height: 44px; font-size: 1.1rem; }
.iconbtn.pe { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.enunt { font-size: 1.1rem; font-weight: 600; margin: 10px 0 14px; overflow-wrap: anywhere; }
.var {
  display: flex; gap: 12px; width: 100%; text-align: left; align-items: flex-start;
  background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px;
}
.var .lit { flex: none; width: 28px; height: 28px; border-radius: 8px; background: var(--line); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.var .vt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.var small { display: block; margin-top: 6px; color: var(--muted); font-size: .88rem; }
.var .verdict { display: block; font-size: .75rem; font-weight: 700; margin-top: 4px; }
.var.ales { border-color: var(--accent); background: var(--accent-soft); }
.var.ales .lit { background: var(--accent); color: var(--on-accent); }
.var.ok { border-color: var(--ok); background: var(--ok-soft); }
.var.ok .lit { background: var(--ok); color: var(--card); }
.var.ok .verdict, .var.ratat .verdict { color: var(--ok); }
.var.ratat { border-color: var(--ok); border-style: dashed; }
.var.gresit { border-color: var(--bad); background: var(--bad-soft); }
.var.gresit .lit { background: var(--bad); color: var(--card); }
.var.gresit .verdict { color: var(--bad); }
.nav a span { white-space: nowrap; }

.qfoot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; display: flex; gap: 10px; justify-content: center;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line);
}
.qfoot .btn { flex: 1; max-width: 260px; }
@media (min-width: 900px) { .qfoot { left: 220px; } }

.glosar { margin: 0; }
.glosar > div { padding: 9px 0; border-top: 1px solid var(--line); }
.glosar > div:first-child { border-top: 0; padding-top: 0; }
.glosar > div:last-child { padding-bottom: 0; }
.glosar dt { font-weight: 700; overflow-wrap: anywhere; }
.glosar dt span { font-weight: 600; color: var(--accent); }
.glosar dd { margin: 3px 0 0; color: var(--muted); font-size: .92rem; }
.retine { margin: 0; padding-left: 1.2em; }
.retine li { margin-bottom: 5px; }
.card p:last-child { margin-bottom: 0; }
.fl { color: var(--accent); font-weight: 600; text-decoration: underline dotted; text-underline-offset: 3px; }
.tipare { list-style: none; margin: 0; padding: 0; }
.tipare li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.tipare li:first-child { border-top: 0; padding-top: 0; }
.tipare li:last-child { padding-bottom: 0; }
.tipare li > span:last-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tipare small { display: block; color: var(--muted); }
a.qrow { text-decoration: none; color: inherit; }

.puncte { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.puncte button { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); font-size: .8rem; }
.puncte button.r { background: var(--accent-soft); border-color: var(--accent); }
.puncte button.c { outline: 2px solid var(--accent); }

/* Listă întrebări */
.qrow { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 8px; }
.qrow .qt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.qrow .qt small { display: block; color: var(--muted); }

.scor { font-size: 2.4rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .9rem;
  max-width: calc(100vw - 32px); opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.vizibil { opacity: 1; }
