/* ===== Medientechnik-Trainer — Dark Gaming Theme ===== */
:root {
  --bg: #0b1020;
  --bg2: #0d1226;
  --panel: #141b36;
  --panel2: #1a2242;
  --line: #2a3350;
  --txt: #e6e9f5;
  --muted: #8b94b8;
  --cyan: #22d3ee;
  --violet: #a78bfa;
  --pink: #f472b6;
  --amber: #fbbf24;
  --green: #34d399;
  --red: #f87171;
  --xp: #fbbf24;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  background-image:
    radial-gradient(1000px 500px at 85% -10%, rgba(167,139,250,.12), transparent 60%),
    radial-gradient(800px 400px at -10% 30%, rgba(34,211,238,.10), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, rgba(244,114,182,.08), transparent 60%);
  color: var(--txt);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  min-height: 100vh;
  line-height: 1.55;
}
#app { max-width: 1120px; margin: 0 auto; padding: 0 18px 80px; }

/* ---------- Header ---------- */
header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 18px 0 14px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  display: grid; place-items: center; font-size: 24px;
  box-shadow: 0 0 18px rgba(34,211,238,.4);
}
.brand h1 { font-size: 20px; letter-spacing: .5px; }
.brand .sub { font-size: 12px; color: var(--muted); }
.hud { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hud .pill {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px; font-size: 13px;
  display: flex; align-items: center; gap: 7px;
}
.hud .pill b { font-variant-numeric: tabular-nums; }
.streak-on { color: var(--amber); text-shadow: 0 0 10px rgba(251,191,36,.5); }

/* ---------- Cloud-Sync ---------- */
.hud .pill.sync { cursor: pointer; transition: border-color .2s, transform .15s; user-select: none; }
.hud .pill.sync:hover { transform: translateY(-1px); border-color: var(--cyan); }
.pill.sync-on { color: var(--green); border-color: rgba(52,211,153,.45) !important; }
.pill.sync-off { color: var(--muted); }
.pill.sync-err { color: var(--red); border-color: rgba(248,113,113,.5) !important; }
.pill.sync-busy { color: var(--cyan); animation: syncpulse 1s ease-in-out infinite; }
@keyframes syncpulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.field {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px;
  color: var(--fg); padding: 12px 14px; font-size: 15px; margin-bottom: 12px; font-family: inherit;
}
.field:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34,211,238,.15); }

/* ---------- Navigation ---------- */
nav.tabs {
  display: flex; gap: 6px; background: var(--bg2); border: 1px solid var(--line);
  padding: 6px; border-radius: 999px; margin-bottom: 22px; flex-wrap: wrap;
}
nav.tabs button {
  flex: 1 1 auto; border: 0; background: transparent; color: var(--muted);
  padding: 9px 16px; border-radius: 999px; font-size: 14px; cursor: pointer;
  transition: all .18s; white-space: nowrap; font-weight: 600;
}
nav.tabs button:hover { color: var(--txt); }
nav.tabs button.active {
  background: linear-gradient(135deg, rgba(34,211,238,.18), rgba(167,139,250,.18));
  color: var(--txt); box-shadow: inset 0 0 0 1px var(--line);
}
nav.tabs button .badge {
  background: var(--red); color: #fff; border-radius: 999px;
  font-size: 11px; padding: 1px 7px; margin-left: 6px; font-weight: 700;
}

/* ---------- Panels / Cards ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 860px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

h2.viewtitle { font-size: 22px; margin-bottom: 4px; }
.viewsub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel2); color: var(--txt);
  padding: 11px 20px; border-radius: 10px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: all .15s; text-decoration: none;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--cyan); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, #0891b2, #7c3aed);
  border: 0; box-shadow: 0 4px 18px rgba(124,58,237,.35);
}
.btn.primary:hover:not(:disabled) { box-shadow: 0 6px 22px rgba(124,58,237,.55); border: 0; }
.btn.success { background: linear-gradient(135deg, #059669, #10b981); border: 0; }
.btn.danger { background: linear-gradient(135deg, #dc2626, #ef4444); border: 0; }
.btn.warn { background: linear-gradient(135deg, #d97706, #f59e0b); border: 0; color: #1a1005; }
.btn.ghost { background: transparent; }
.btn.big { padding: 15px 28px; font-size: 17px; border-radius: 12px; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ---------- Dashboard ---------- */
.dash-hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
@media (max-width: 860px) { .dash-hero { grid-template-columns: 1fr; } }
.level-wrap { display: flex; align-items: center; gap: 16px; }
.level-badge {
  width: 64px; height: 64px; border-radius: 16px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--amber), #f97316);
  display: grid; place-items: center; font-size: 26px; font-weight: 800; color: #221503;
  box-shadow: 0 0 22px rgba(251,191,36,.45);
}
.xpbar { height: 12px; background: var(--bg2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.xpbar > div {
  height: 100%; background: linear-gradient(90deg, var(--amber), #fde68a);
  border-radius: 999px; transition: width .5s ease; box-shadow: 0 0 12px rgba(251,191,36,.6);
}
.stat-num { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

/* Fortschrittsring */
.ring { transform: rotate(-90deg); }
.ring .bgc { stroke: var(--bg2); }
.ring .fgc { stroke: var(--green); stroke-linecap: round; transition: stroke-dashoffset .6s ease; filter: drop-shadow(0 0 6px rgba(52,211,153,.6)); }
.ring-wrap { position: relative; width: 120px; height: 120px; }
.ring-wrap .ring-center {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
}

/* Modulkarten */
.modcard {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; background: var(--bg2);
  transition: all .18s; position: relative; overflow: hidden;
}
.modcard::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--modcolor, var(--cyan));
}
.modcard h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.modcard .modsub { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.mbar { height: 9px; background: var(--panel); border-radius: 999px; overflow: hidden; display: flex; }
.mbar > span { display: block; height: 100%; }
.modstats { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 8px; }
.modstats .due { color: var(--amber); font-weight: 700; }

/* ---------- Lernkarten ---------- */
.cardview { max-width: 760px; margin: 0 auto; }
.card-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.chip {
  font-size: 12px; padding: 3px 11px; border-radius: 999px;
  background: var(--bg2); border: 1px solid var(--line); color: var(--muted);
}
.chip.mod { color: var(--modcolor, var(--cyan)); border-color: var(--modcolor, var(--cyan)); }
.chip.d3 { color: var(--red); border-color: var(--red); }
.chip.d2 { color: var(--amber); border-color: var(--amber); }
.chip.d1 { color: var(--green); border-color: var(--green); }
.qtext { font-size: 19px; line-height: 1.6; margin-bottom: 18px; }
.qtext code, .solution code, .fitem .f {
  font-family: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  background: rgba(34,211,238,.08); padding: 1px 6px; border-radius: 6px; font-size: .94em;
}
.answer-input {
  width: 100%; min-height: 90px; background: var(--bg2); color: var(--txt);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  font-size: 15px; font-family: inherit; resize: vertical;
}
.answer-input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34,211,238,.15); }
.answer-hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.numline { display: flex; gap: 10px; align-items: center; }
.numline input {
  flex: 1; background: var(--bg2); color: var(--txt); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; font-size: 17px; font-family: Consolas, monospace;
}
.numline input:focus { outline: none; border-color: var(--cyan); }
.numline .unit { color: var(--muted); font-size: 14px; min-width: 80px; }

.optgrid { display: grid; gap: 10px; }
.opt {
  text-align: left; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: 13px 16px; font-size: 15px; color: var(--txt);
  cursor: pointer; transition: all .13s; line-height: 1.45;
}
.opt:hover:not(:disabled) { border-color: var(--cyan); transform: translateX(3px); }
.opt:disabled { cursor: default; }
.opt.correct { border-color: var(--green); background: rgba(52,211,153,.12); box-shadow: 0 0 14px rgba(52,211,153,.25); }
.opt.wrong { border-color: var(--red); background: rgba(248,113,113,.12); }
.opt.dim { opacity: .55; }
.opt.imgopt { text-align: center; padding: 12px; }
.opt.imgopt svg { max-width: 150px; margin: 0 auto; }

.solution {
  margin-top: 18px; border-left: 3px solid var(--green);
  background: rgba(52,211,153,.07); border-radius: 0 10px 10px 0;
  padding: 14px 18px; line-height: 1.6;
}
.solution.bad { border-left-color: var(--red); background: rgba(248,113,113,.07); }
.solution h4 { margin-bottom: 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .6px; }
.solution .own {
  background: var(--bg2); border: 1px dashed var(--line); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 12px; font-size: 14px; color: var(--muted);
}
.explain { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 14px; }

.grading { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
@media (max-width: 620px) { .grading { grid-template-columns: 1fr; } }
.grade-btn {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 10px;
  background: var(--bg2); color: var(--txt); cursor: pointer; text-align: center;
  transition: all .15s;
}
.grade-btn:hover { transform: translateY(-2px); }
.grade-btn .g1 { font-weight: 700; font-size: 15px; display: block; }
.grade-btn .g2 { font-size: 12px; color: var(--muted); }
.grade-btn.fail:hover { border-color: var(--red); box-shadow: 0 0 14px rgba(248,113,113,.3); }
.grade-btn.mid:hover { border-color: var(--amber); box-shadow: 0 0 14px rgba(251,191,36,.3); }
.grade-btn.pass:hover { border-color: var(--green); box-shadow: 0 0 14px rgba(52,211,153,.3); }

.feedback-banner {
  border-radius: 10px; padding: 12px 16px; font-weight: 700; margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px; font-size: 16px;
}
.feedback-banner.ok { background: rgba(52,211,153,.15); color: var(--green); border: 1px solid rgba(52,211,153,.4); }
.feedback-banner.no { background: rgba(248,113,113,.15); color: var(--red); border: 1px solid rgba(248,113,113,.4); }
.feedback-banner .xp { margin-left: auto; font-size: 14px; color: var(--xp); }

.session-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.session-progress .sp-bar { flex: 1; height: 8px; background: var(--bg2); border-radius: 999px; overflow: hidden; }
.session-progress .sp-bar > div { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--violet)); transition: width .3s; }
.session-progress .sp-txt { font-size: 13px; color: var(--muted); white-space: nowrap; }
.combo-flame { color: var(--amber); font-weight: 800; font-size: 14px; min-width: 70px; text-align: right; }

/* ---------- Quiz-Config ---------- */
.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.config-opt {
  border: 1px solid var(--line); border-radius: 12px; padding: 16px 12px;
  background: var(--bg2); cursor: pointer; text-align: center; transition: all .15s; color: var(--txt);
}
.config-opt:hover { border-color: var(--cyan); }
.config-opt.sel { border-color: var(--modcolor, var(--cyan)); background: rgba(34,211,238,.08); box-shadow: 0 0 14px rgba(34,211,238,.2); }
.config-opt .ico { font-size: 24px; display: block; margin-bottom: 6px; }

/* ---------- Klausur ---------- */
.examcard { display: flex; flex-direction: column; gap: 8px; }
.examcard .best { font-size: 13px; color: var(--muted); }
.examcard .best b { color: var(--amber); }
.timer {
  font-family: Consolas, monospace; font-size: 22px; font-weight: 700;
  padding: 8px 18px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.timer.low { color: var(--red); border-color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.exam-task-intro { font-size: 17px; margin-bottom: 6px; }
.part-block { border-top: 1px dashed var(--line); padding-top: 16px; margin-top: 16px; }
.part-label { font-weight: 700; color: var(--cyan); margin-right: 6px; }
.diagram-box { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 14px 0; overflow-x: auto; }
.notes-area {
  width: 100%; min-height: 110px; background: #0a0e1f; color: var(--txt);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
  font-family: Consolas, monospace; font-size: 14px; resize: vertical; margin-top: 12px;
}
.notes-area:focus { outline: none; border-color: var(--amber); }
.checklist { list-style: none; margin: 12px 0; }
.checklist li {
  display: flex; align-items: flex-start; gap: 10px; padding: 7px 10px;
  border-radius: 8px; cursor: pointer; font-size: 14.5px;
}
.checklist li:hover { background: var(--bg2); }
.checklist li input { margin-top: 4px; accent-color: var(--green); width: 16px; height: 16px; }
.points-slider { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.points-slider input[type=range] { flex: 1; min-width: 180px; accent-color: var(--amber); }
.points-slider .pval { font-size: 20px; font-weight: 800; color: var(--amber); min-width: 90px; font-variant-numeric: tabular-nums; }
.exam-result-grade { font-size: 52px; font-weight: 900; text-align: center; }
.scorebar-row { display: flex; align-items: center; gap: 10px; font-size: 14px; margin: 6px 0; }
.scorebar-row .lbl { width: 150px; color: var(--muted); flex-shrink: 0; }
.scorebar-row .bar { flex: 1; height: 10px; background: var(--bg2); border-radius: 999px; overflow: hidden; }
.scorebar-row .bar > div { height: 100%; }
.scorebar-row .pts { width: 90px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Formeln ---------- */
.fgroup { margin-bottom: 20px; }
.fgroup h3 { font-size: 15px; color: var(--cyan); margin-bottom: 10px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.fitem { display: flex; gap: 14px; padding: 9px 4px; border-bottom: 1px dashed rgba(42,51,80,.6); align-items: baseline; flex-wrap: wrap; }
.fitem .f { font-size: 14.5px; flex-shrink: 0; }
.fitem .n { color: var(--muted); font-size: 13.5px; }
.searchbox {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--txt);
  border-radius: 10px; padding: 12px 16px; font-size: 15px; margin-bottom: 18px;
}
.searchbox:focus { outline: none; border-color: var(--cyan); }

/* ---------- Statistik ---------- */
table.stats { width: 100%; border-collapse: collapse; font-size: 14px; }
table.stats th, table.stats td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.stats th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge-item {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: center;
  background: var(--bg2); opacity: .4; filter: grayscale(1);
}
.badge-item.unlocked { opacity: 1; filter: none; border-color: var(--amber); box-shadow: 0 0 16px rgba(251,191,36,.2); }
.badge-item .bi { font-size: 30px; }
.badge-item .bn { font-weight: 700; font-size: 13.5px; margin-top: 4px; }
.badge-item .bd { font-size: 11.5px; color: var(--muted); }

/* ---------- Toasts & Overlays ---------- */
#toast-zone { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--panel2); border: 1px solid var(--amber); color: var(--txt);
  padding: 12px 22px; border-radius: 12px; box-shadow: var(--shadow);
  animation: toastin .3s ease; font-size: 15px; text-align: center;
}
@keyframes toastin { from { transform: translateY(20px); opacity: 0; } }
.overlay {
  position: fixed; inset: 0; background: rgba(5,8,18,.85); z-index: 90;
  display: grid; place-items: center; padding: 20px;
}
.overlay .modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 32px; max-width: 520px; width: 100%; text-align: center; box-shadow: var(--shadow);
  animation: toastin .25s ease;
}
.overlay .modal h2 { font-size: 26px; margin-bottom: 8px; }
.overlay .modal .big-emoji { font-size: 56px; margin-bottom: 8px; }
.overlay .modal p { color: var(--muted); margin-bottom: 18px; }

/* ---------- Tipp-Boxen ---------- */
.tipbox {
  border: 1px solid rgba(167,139,250,.4); background: rgba(167,139,250,.07);
  border-radius: 12px; padding: 14px 18px; font-size: 14px; margin-bottom: 18px;
  display: flex; gap: 12px; align-items: flex-start;
}
.tipbox .ti { font-size: 20px; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state .big { font-size: 46px; margin-bottom: 12px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb12 { margin-bottom: 12px; }
.center { text-align: center; }
.hide { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
::selection { background: rgba(34,211,238,.3); }
