/* ============================================================
   GP2 Lerntrainer – Elektroniker Energie- und Gebäudetechnik
   ============================================================ */

:root {
  --bg:        #eef1f5;
  --bg-deep:   #e3e8ee;
  --surface:   #ffffff;
  --surface-2: #f7f9fb;
  --ink:       #131922;
  --ink-2:     #3d4a58;
  --muted:     #6b7a89;
  --line:      #d7dee6;
  --line-soft: #e6ebf1;

  --accent:    #0b5fa5;
  --accent-ink:#ffffff;
  --accent-bg: #e7f0f9;
  --green:     #1f8a4c;
  --green-bg:  #e6f4ec;
  --amber:     #b8790a;
  --amber-bg:  #fdf3e0;
  --red:       #c0392b;
  --red-bg:    #fbeceb;
  --violet:    #6c4bb6;
  --violet-bg: #f0ecf9;

  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 2px rgba(16,32,48,.06), 0 6px 20px rgba(16,32,48,.07);
  --shadow-lg: 0 2px 6px rgba(16,32,48,.08), 0 18px 50px rgba(16,32,48,.14);
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "Cascadia Mono", "Consolas", "SF Mono", monospace;
  --serif: "Cambria", "Georgia", serif;
}

:root[data-theme="dark"] {
  --bg:        #0e1319;
  --bg-deep:   #090d12;
  --surface:   #161d26;
  --surface-2: #1b232d;
  --ink:       #e9eef4;
  --ink-2:     #c2ced9;
  --muted:     #8397a8;
  --line:      #28323e;
  --line-soft: #212a34;

  --accent:    #4a9fe0;
  --accent-ink:#08131d;
  --accent-bg: #14273a;
  --green:     #4cc182;
  --green-bg:  #12291d;
  --amber:     #e0a33c;
  --amber-bg:  #2e2312;
  --red:       #ef6a5c;
  --red-bg:    #301715;
  --violet:    #a68ae6;
  --violet-bg: #221c33;

  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.5), 0 18px 50px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
h1,h2,h3,h4 { margin: 0 0 .4em; line-height: 1.25; font-weight: 650; }
p { margin: 0 0 .7em; }
code, .mono { font-family: var(--mono); font-size: .92em; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.brand .logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 750; font-size: 15px; letter-spacing: -.01em;
}
.brand .bolt {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(150deg, var(--accent), #0a4a80);
  display: grid; place-items: center; color: #fff; font-size: 16px;
  flex: none;
}
.brand .sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; letter-spacing: .02em; }

.nav { padding: 10px 10px 4px; flex: 1; }
.nav-group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); font-weight: 700; padding: 12px 10px 6px;
}
.nav button {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 2px;
  border: 0; background: none; border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; color: var(--ink-2); text-align: left;
  cursor: pointer; transition: background .12s, color .12s;
}
.nav button:hover { background: var(--surface-2); color: var(--ink); }
.nav button.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.nav button .ico { width: 18px; text-align: center; font-size: 15px; flex: none; }
.nav button .badge {
  margin-left: auto; background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px;
}
.nav button.active .badge { background: var(--accent); color: #fff; }

.side-foot { padding: 12px; border-top: 1px solid var(--line-soft); }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 28px;
  display: flex; align-items: center; gap: 14px;
}
.topbar h1 { font-size: 19px; margin: 0; }
.topbar .spacer { flex: 1; }
.view { padding: 24px 28px 64px; max-width: 1180px; }

/* ---------- Bausteine ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card.pad-lg { padding: 24px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .g3, .g4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 700px)  { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 550; cursor: pointer;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.lg { padding: 12px 22px; font-size: 15px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 650; padding: 2px 9px; border-radius: 20px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line-soft);
  white-space: nowrap;
}
.chip.accent { background: var(--accent-bg); color: var(--accent); border-color: transparent; }
.chip.green  { background: var(--green-bg);  color: var(--green);  border-color: transparent; }
.chip.amber  { background: var(--amber-bg);  color: var(--amber);  border-color: transparent; }
.chip.red    { background: var(--red-bg);    color: var(--red);    border-color: transparent; }
.chip.violet { background: var(--violet-bg); color: var(--violet); border-color: transparent; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.stat .v { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat .h { font-size: 12.5px; color: var(--muted); }

.bar { height: 7px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .35s ease; }
.bar.green > i { background: var(--green); }
.bar.amber > i { background: var(--amber); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny  { font-size: 12px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hr { height: 1px; background: var(--line-soft); margin: 16px 0; border: 0; }
.stack > * + * { margin-top: 12px; }

input[type=text], input[type=number], input[type=date], select, textarea {
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label.fld { display: block; }
label.fld > span { display: block; font-size: 12.5px; font-weight: 650; color: var(--muted); margin-bottom: 4px; }

/* ---------- Dashboard ---------- */
.hero {
  background: linear-gradient(135deg, var(--accent), #08406f 85%);
  color: #fff; border-radius: var(--radius); padding: 24px 26px;
  box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.hero::after {
  content:""; position:absolute; right:-60px; top:-60px; width: 260px; height: 260px;
  border-radius: 50%; background: rgba(255,255,255,.07);
}
.hero h2 { font-size: 22px; margin: 0 0 6px; }
.hero .lead { opacity: .88; font-size: 14px; margin: 0; max-width: 60ch; }
.hero .hero-actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; position: relative; }
.hero .btn { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.28); color: #fff; }
.hero .btn:hover { background: rgba(255,255,255,.24); }
.hero .btn.solid { background: #fff; color: var(--accent); border-color: #fff; }

.countdown { position: relative; display: flex; gap: 22px; margin-top: 20px; }
.countdown div { display: flex; flex-direction: column; }
.countdown .n { font-size: 26px; font-weight: 750; line-height: 1; }
.countdown .l { font-size: 11px; opacity: .8; text-transform: uppercase; letter-spacing: .08em; margin-top: 3px; }

.ring { --p: 0; width: 92px; height: 92px; flex: none; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: var(--line-soft); }
.ring .val { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.ring .lbl {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 19px; font-weight: 750;
}

/* ---------- Modul-Liste ---------- */
.mod {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .08s;
}
.mod:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.mod .num {
  width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-bg); color: var(--accent); font-weight: 750; font-size: 15px;
}
.mod h3 { font-size: 15.5px; margin: 0 0 3px; }
.mod .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.mod .right { text-align: right; min-width: 96px; }
.mod .pct { font-size: 20px; font-weight: 750; }

/* ---------- Flashcards ---------- */
.fc-stage { display: grid; place-items: center; min-height: 380px; }
.flashcard {
  width: 100%; max-width: 760px; min-height: 300px;
  perspective: 1600px; cursor: pointer;
}
.fc-inner {
  position: relative; width: 100%; min-height: 300px;
  transform-style: preserve-3d; transition: transform .48s cubic-bezier(.4,.1,.2,1);
}
.flashcard.flipped .fc-inner { transform: rotateX(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 30px 34px;
  display: flex; flex-direction: column; justify-content: center;
}
.fc-face.back { transform: rotateX(180deg); background: var(--surface-2); }
.fc-q { font-size: 21px; font-weight: 620; line-height: 1.4; }
.fc-a { font-size: 16px; line-height: 1.6; color: var(--ink-2); }
.fc-a b, .fc-a strong { color: var(--ink); }
.fc-tag { position: absolute; top: 14px; left: 18px; }
.fc-hint { position: absolute; bottom: 12px; right: 18px; font-size: 11.5px; color: var(--muted); }
.fc-grade { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; max-width: 760px; margin: 18px auto 0; }
.fc-grade .btn { flex-direction: column; gap: 2px; padding: 11px 8px; }
.fc-grade .btn b { font-size: 14px; }
.fc-grade .btn span { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.fc-grade .g0 { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }
.fc-grade .g1 { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); }
.fc-grade .g2 { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.fc-grade .g3 { border-color: color-mix(in srgb, var(--green) 45%, var(--line)); }

/* ---------- Quiz ---------- */
.opt {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 15px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; transition: border-color .12s, background .12s;
  margin-bottom: 9px; font-size: 14.5px;
}
.opt:hover { border-color: var(--accent); }
.opt .key {
  width: 24px; height: 24px; flex: none; border-radius: 6px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; font-weight: 700; color: var(--muted);
}
.opt.sel { border-color: var(--accent); background: var(--accent-bg); }
.opt.sel .key { background: var(--accent); color: #fff; border-color: var(--accent); }
.opt.right { border-color: var(--green); background: var(--green-bg); }
.opt.right .key { background: var(--green); color: #fff; border-color: var(--green); }
.opt.wrong { border-color: var(--red); background: var(--red-bg); }
.opt.wrong .key { background: var(--red); color: #fff; border-color: var(--red); }
.opt.locked { cursor: default; }

.explain {
  border-left: 3px solid var(--accent); background: var(--accent-bg);
  padding: 12px 15px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 14px;
}
.explain.ok  { border-color: var(--green); background: var(--green-bg); }
.explain.bad { border-color: var(--red);   background: var(--red-bg); }
.explain b { display: block; margin-bottom: 3px; }

.progress-dots { display: flex; gap: 4px; flex-wrap: wrap; }
.progress-dots i { width: 9px; height: 9px; border-radius: 3px; background: var(--line); display: block; }
.progress-dots i.ok  { background: var(--green); }
.progress-dots i.bad { background: var(--red); }
.progress-dots i.now { background: var(--accent); transform: scale(1.25); }

/* ---------- Checkliste ---------- */
.check {
  display: flex; gap: 11px; align-items: flex-start; padding: 10px 12px;
  border-radius: var(--radius-sm); cursor: pointer; transition: background .12s;
}
.check:hover { background: var(--surface-2); }
.check input { margin: 3px 0 0; width: 17px; height: 17px; accent-color: var(--accent); flex: none; cursor: pointer; }
.check.done > span { color: var(--muted); text-decoration: line-through; }

/* ---------- Formeln / Rechner ---------- */
.formula {
  font-family: var(--serif); font-size: 18px; background: var(--surface-2);
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm);
  padding: 11px 15px; margin: 6px 0; overflow-x: auto; white-space: nowrap;
}
.calc-out {
  background: var(--accent-bg); border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 14px 16px; font-family: var(--serif); font-size: 16px;
}
.calc-out .res { font-size: 24px; font-weight: 700; color: var(--accent); font-family: var(--sans); }
.calc-out .warn-txt { color: var(--red); font-family: var(--sans); font-size: 13.5px; font-weight: 600; }
.calc-out .ok-txt { color: var(--green); font-family: var(--sans); font-size: 13.5px; font-weight: 600; }
.calc-steps { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); line-height: 1.75; margin-top: 8px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; padding: 8px 10px; background: var(--surface-2);
  border-bottom: 2px solid var(--line); font-weight: 650; font-size: 12.5px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
}
table.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Heatmap ---------- */
.heat { display: grid; grid-template-columns: repeat(auto-fill, 13px); gap: 3px; }
.heat i { width: 13px; height: 13px; border-radius: 3px; background: var(--line-soft); display: block; }
.heat i[data-l="1"] { background: color-mix(in srgb, var(--accent) 28%, var(--line-soft)); }
.heat i[data-l="2"] { background: color-mix(in srgb, var(--accent) 52%, var(--line-soft)); }
.heat i[data-l="3"] { background: color-mix(in srgb, var(--accent) 76%, var(--line-soft)); }
.heat i[data-l="4"] { background: var(--accent); }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(10,16,24,.55); backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 100; padding: 24px;
}
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-width: 660px; width: 100%; max-height: 84vh; overflow-y: auto; padding: 24px;
  border: 1px solid var(--line);
}

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 550; box-shadow: var(--shadow-lg);
  animation: pop .25s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Lesemodus ---------- */
.reader h3 { color: var(--accent); font-size: 16px; margin-top: 22px; }
.reader ul { margin: 6px 0 12px; padding-left: 20px; }
.reader li { margin-bottom: 5px; }
.reader .kv { display: grid; grid-template-columns: 190px 1fr; gap: 4px 14px; font-size: 14px; }
.reader .kv b { color: var(--ink); }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 46px; margin-bottom: 10px; }

kbd {
  font-family: var(--mono); font-size: 11.5px; background: var(--surface-2);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  padding: 1px 6px; color: var(--ink-2);
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); }
  .nav-group-label { grid-column: 1/-1; }
  .view { padding: 18px 16px 50px; }
  .topbar { padding: 12px 16px; }
}

@media print { .sidebar, .topbar { display: none; } .app { grid-template-columns: 1fr; } }
