:root {
  --bg:      #0f1117;
  --bg2:     #181c27;
  --bg3:     #1e2338;
  --bg4:     #252b42;
  --border:  #2d3555;
  --border2: #3d4870;
  --text:    #e8eaf6;
  --text2:   #8b93b8;
  --text3:   #5a6290;
  --accent:  #4f7fff;
  --accent2: #3a5fd9;
  --accent3: #1a3aab;
  --green:   #2ecc71;
  --red:     #e74c3c;
  --amber:   #f39c12;
  --teal:    #1abc9c;
  --purple:  #9b59b6;
  --radius:  10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; height: 100vh; overflow: hidden; }

/* ── Utilities ────────────────────────────────────────── */
.hidden  { display: none !important; }
.flex    { display: flex; }
.col     { flex-direction: column; }
.gap8    { gap: 8px; }
.gap12   { gap: 12px; }
.gap16   { gap: 16px; }
.center  { align-items: center; justify-content: center; }
.flex1   { flex: 1; }
.bold    { font-weight: 600; }
.muted   { color: var(--text2); }
.small   { font-size: 12px; }
.tiny    { font-size: 11px; }

/* ── Views ───────────────────────────────────────────── */
.view { display: none; height: 100vh; flex-direction: column; }
.view.active { display: flex; }

/* ── Login ───────────────────────────────────────────── */
#view-login { background: var(--bg); align-items: center; justify-content: center; }
.login-card { background: var(--bg2); border: 1px solid var(--border2); border-radius: 16px; padding: 40px; width: 380px; }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; }
.login-logo-icon { width: 44px; height: 44px; background: var(--accent); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; color: #fff; }
.login-title { font-size: 22px; font-weight: 700; }
.login-sub { font-size: 13px; color: var(--text3); margin-top: 2px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 6px; }
.form-group input, .form-group select {
  width: 100%; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; color: var(--text); font-size: 14px; outline: none; transition: .15s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border-radius: 8px; border: none; cursor: pointer; font-size: 14px; font-weight: 500; transition: .15s; }
.btn-primary { background: var(--accent); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--accent2); }
.btn-secondary { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg4); color: var(--text); }
.btn-danger { background: #3a1a1a; color: var(--red); border: 1px solid #6a222244; }
.btn-danger:hover { background: #4a1a1a; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: 8px; }
.error-msg { color: var(--red); font-size: 12px; margin-top: 8px; text-align: center; min-height: 18px; }
.login-toggle { text-align: center; margin-top: 16px; font-size: 12px; color: var(--text3); }
.login-toggle a { color: var(--accent); cursor: pointer; }

/* ── Topbar ──────────────────────────────────────────── */
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 20px; height: 48px; background: var(--bg2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.logo { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; }
.logo-icon { width: 30px; height: 30px; background: var(--accent); border-radius: 7px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; }
.topbar-user { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 13px; }
.role-badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; }
.role-fl { background: #1a2a3a; color: var(--accent); border: 1px solid var(--accent3); }
.role-fs { background: #1a3a2a; color: var(--teal); border: 1px solid #1abc9c44; }
.topbar-nav { display: flex; gap: 4px; margin-left: 20px; }
.nav-btn { padding: 5px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text2); border: none; background: transparent; transition: .15s; }
.nav-btn:hover { background: var(--bg3); color: var(--text); }
.nav-btn.active { background: var(--accent3); color: #fff; }

/* ── Dashboard ───────────────────────────────────────── */
#view-dashboard .content { flex: 1; overflow-y: auto; padding: 24px; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.kurs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.kurs-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; cursor: pointer; transition: .15s; }
.kurs-card:hover { border-color: var(--border2); transform: translateY(-1px); }
.kurs-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.kurs-icon { width: 40px; height: 40px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.kurs-klasse-B { background: #1a2a3a; color: var(--accent); }
.kurs-klasse-A { background: #1a3a2a; color: var(--green); }
.kurs-klasse-C { background: #2a1a0a; color: var(--amber); }
.kurs-klasse-default { background: var(--bg4); color: var(--text2); }
.progress-bar { height: 4px; background: var(--bg4); border-radius: 2px; margin: 12px 0 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; background: var(--accent); }
.meta-row { display: flex; gap: 14px; flex-wrap: wrap; }
.meta-item { font-size: 11px; color: var(--text3); display: flex; align-items: center; gap: 4px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.add-card { border: 1px dashed var(--border2); background: transparent; color: var(--text3); display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; min-height: 120px; }
.add-card:hover { border-color: var(--accent); color: var(--accent); }

/* ── Kurs-Detail ─────────────────────────────────────── */
#view-kurs .content { flex: 1; overflow-y: auto; padding: 24px; }
.back-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--text3); cursor: pointer; font-size: 13px; margin-bottom: 16px; border: none; background: none; padding: 0; }
.back-btn:hover { color: var(--text); }
.kurs-header { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.kurs-header-info { flex: 1; }
.kurs-header-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.kurs-header-meta { font-size: 13px; color: var(--text3); }
.kurs-actions { display: flex; gap: 8px; }
.section-h { font-size: 13px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; margin-top: 24px; }
.thema-list { display: flex; flex-direction: column; gap: 6px; }
.thema-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--bg2); border: 1px solid var(--border); border-radius: 9px; }
.thema-num { width: 38px; height: 38px; border-radius: 8px; background: var(--bg4); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--text2); flex-shrink: 0; }
.thema-num.done { background: #1a3a1a; color: var(--green); }
.thema-num.active { background: var(--accent3); color: #fff; }
.thema-info { flex: 1; }
.thema-title { font-size: 13px; color: var(--text); }
.thema-desc { font-size: 11px; color: var(--text3); margin-top: 2px; }
.thema-badge { font-size: 11px; padding: 3px 10px; border-radius: 5px; white-space: nowrap; }
.badge-done  { background: #1a3a1a; color: var(--green); }
.badge-aktiv { background: var(--accent3); color: #fff; }
.badge-plan  { background: var(--bg4); color: var(--text3); }
.badge-pflicht { background: #2a1a0a; color: var(--amber); }
.tn-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tn-chip { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--bg2); border: 1px solid var(--border); border-radius: 20px; }
.tn-av { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; background: var(--bg4); color: var(--text2); }

/* ── Classroom ───────────────────────────────────────── */
#view-classroom { flex-direction: row; }
.classroom-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.classroom-topbar { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 48px; background: var(--bg2); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.session-info { display: flex; flex-direction: column; }
.session-info .si-title { font-size: 13px; font-weight: 600; }
.session-info .si-topic { font-size: 11px; color: var(--text3); }
.live-badge { display: flex; align-items: center; gap: 6px; padding: 3px 12px; background: #1a3a1a; border: 1px solid #2ecc7155; border-radius: 20px; font-size: 12px; color: var(--green); }
.timer { font-size: 13px; color: var(--text2); font-variant-numeric: tabular-nums; min-width: 60px; text-align: right; }

/* Video grid */
.video-grid { flex: 1; display: grid; gap: 8px; padding: 12px; background: var(--bg); overflow: hidden; }
.video-tile { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.video-tile.self { border-color: var(--accent3); }
.video-tile.speaking { border-color: var(--green); }
.video-tile video { width: 100%; height: 100%; object-fit: cover; border-radius: 9px; display: block; }
.video-tile .tile-info { position: absolute; bottom: 8px; left: 8px; right: 8px; display: flex; align-items: center; gap: 6px; }
.tile-name { background: rgba(0,0,0,.7); color: #fff; font-size: 11px; padding: 3px 8px; border-radius: 4px; }
.tile-icons { display: flex; gap: 4px; margin-left: auto; }
.tile-icon { width: 20px; height: 20px; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 10px; }
.ti-mic-off { background: var(--red); }
.ti-hand    { background: var(--amber); }
.tile-avatar { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; flex-shrink: 0; }

/* Controlbar */
.controlbar { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; background: var(--bg2); border-top: 1px solid var(--border); flex-shrink: 0; }
.ctrl-btn { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 16px; border-radius: 9px; cursor: pointer; border: 1px solid var(--border); background: var(--bg3); color: var(--text2); font-size: 10px; min-width: 60px; transition: .15s; }
.ctrl-btn:hover { background: var(--bg4); color: var(--text); }
.ctrl-btn .ci { font-size: 20px; }
.ctrl-btn.on { background: var(--accent3); border-color: var(--accent); color: #fff; }
.ctrl-btn.off { background: #3a1a1a; border-color: var(--red); color: var(--red); }
.ctrl-btn.end { background: var(--red); border-color: var(--red); color: #fff; }
.ctrl-btn.end:hover { background: #c0392b; }

/* Sidebar */
.classroom-sidebar { width: 260px; display: flex; flex-direction: column; background: var(--bg2); border-left: 1px solid var(--border); flex-shrink: 0; }
.sidebar-tabs { display: flex; border-bottom: 1px solid var(--border); }
.stab { flex: 1; padding: 10px 4px; text-align: center; font-size: 12px; cursor: pointer; color: var(--text3); border-bottom: 2px solid transparent; transition: .15s; }
.stab:hover { color: var(--text2); }
.stab.on { color: var(--accent); border-bottom-color: var(--accent); }
.stab-badge { background: var(--red); color: #fff; border-radius: 10px; padding: 1px 5px; font-size: 10px; margin-left: 4px; }
.sidebar-content { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }

/* Chat */
.chat-msg { background: var(--bg3); border-radius: 8px; padding: 8px 10px; border: 1px solid var(--border); }
.chat-msg-head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.chat-msg-who { font-size: 11px; font-weight: 600; color: var(--accent); }
.chat-msg-who.fl { color: var(--amber); }
.chat-msg-ts { font-size: 10px; color: var(--text3); }
.chat-msg-text { font-size: 13px; color: var(--text); line-height: 1.5; }
.chat-input-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-input { flex: 1; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; color: var(--text); font-size: 13px; outline: none; }
.chat-input:focus { border-color: var(--accent); }
.chat-send { background: var(--accent); border: none; border-radius: 8px; color: #fff; padding: 0 14px; cursor: pointer; font-size: 16px; }

/* Peer list */
.peer-item { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--border); }
.peer-av { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.peer-info { flex: 1; }
.peer-name { font-size: 13px; color: var(--text); }
.peer-role { font-size: 10px; color: var(--text3); }
.peer-icons { font-size: 14px; display: flex; gap: 3px; }

/* Anwesenheits-Bestätigung Toast */
.sign-toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--bg2); border: 1px solid var(--green); border-radius: 12px; padding: 16px 24px; display: flex; align-items: center; gap: 16px; box-shadow: 0 8px 32px rgba(0,0,0,.5); z-index: 100; transition: .3s; }
.sign-toast.hidden { opacity: 0; pointer-events: none; }

/* Quiz overlay */
.quiz-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 200; }
.quiz-card { background: var(--bg2); border: 1px solid var(--border2); border-radius: 16px; padding: 32px; width: 480px; max-width: 90vw; }
.quiz-question { font-size: 16px; font-weight: 600; margin-bottom: 20px; line-height: 1.5; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-opt { padding: 12px 16px; background: var(--bg3); border: 1px solid var(--border); border-radius: 9px; cursor: pointer; font-size: 14px; transition: .15s; }
.quiz-opt:hover { border-color: var(--accent); }
.quiz-opt.selected { background: var(--accent3); border-color: var(--accent); }
.quiz-opt.correct { background: #1a3a1a; border-color: var(--green); }
.quiz-opt.wrong { background: #3a1a1a; border-color: var(--red); }

/* Anwesenheit-View */
#view-anwesenheit .content { flex: 1; overflow-y: auto; padding: 24px; }
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 16px; text-align: center; }
.stat-num { font-size: 28px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--text3); margin-top: 4px; }
.anw-table { width: 100%; border-collapse: collapse; }
.anw-table th { font-size: 11px; color: var(--text3); text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); font-weight: 500; }
.anw-table td { font-size: 13px; padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text2); }
.anw-table tr:hover td { background: var(--bg2); }
.sig-ok   { color: var(--green); }
.sig-pend { color: var(--amber); }
.sig-no   { color: var(--red); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; z-index: 300; }
.modal { background: var(--bg2); border: 1px solid var(--border2); border-radius: 14px; padding: 28px; width: 420px; max-width: 90vw; }
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }

.standort-chip {
  display:inline-flex;align-items:center;gap:6px;padding:3px 10px;
  background:var(--bg3);border:1px solid var(--border);border-radius:20px;
  font-size:11px;color:var(--text2);
}
.themen-section { margin-bottom:24px; }
.themen-section-head {
  display:flex;align-items:center;gap:10px;
  font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.08em;
  color:var(--text3);margin-bottom:10px;padding-bottom:8px;
  border-bottom:1px solid var(--border);
}
.themen-section-head .ts-count {
  background:var(--bg4);border-radius:10px;padding:1px 8px;
  font-size:10px;color:var(--text2);
}
.badge-tenant_admin    { background:#2a1a3a;color:#9b59b6;border:1px solid #9b59b644; }
.badge-fahrschul_admin { background:#1a2a3a;color:var(--accent);border:1px solid var(--accent)44; }
.badge-fahrlehrer      { background:#2a1a0a;color:var(--amber);border:1px solid var(--amber)44; }
.badge-fahrschueler    { background:#1a3a2a;color:var(--green);border:1px solid var(--green)44; }
.role-label { font-size:11px;padding:2px 8px;border-radius:4px; }

.user-table-wrap { overflow-x:auto; }
.user-table { width:100%;border-collapse:collapse; }
.user-table th { font-size:11px;color:var(--text3);text-align:left;padding:8px 12px;border-bottom:1px solid var(--border);font-weight:500; }
.user-table td { font-size:13px;padding:9px 12px;border-bottom:1px solid var(--border);color:var(--text2); }
.user-table tr:hover td { background:var(--bg2); }
.verwaltung-tabs { display:flex;gap:4px;margin-bottom:20px; }
.vtab { padding:8px 18px;border-radius:8px;border:1px solid var(--border);background:var(--bg2);color:var(--text2);cursor:pointer;font-size:13px;transition:.15s; }
.vtab:hover { background:var(--bg3);color:var(--text); }
.vtab.active { background:var(--accent3);border-color:var(--accent);color:#fff; }
.standort-card {
  background:var(--bg2);border:1px solid var(--border);border-radius:var(--radius);
  padding:16px;cursor:pointer;transition:.15s;
}
.standort-card:hover { border-color:var(--border2); }
.standort-head { display:flex;align-items:center;gap:10px;margin-bottom:10px; }
.standort-icon {
  width:36px;height:36px;border-radius:8px;
  background:var(--accent3);color:var(--accent);
  display:flex;align-items:center;justify-content:center;font-size:16px;flex-shrink:0;
}
.standort-name { font-size:14px;font-weight:600; }
.standort-ort  { font-size:11px;color:var(--text3); }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* Responsive video grid helpers */
.grid-1  { grid-template-columns: 1fr; }
.grid-2  { grid-template-columns: 1fr 1fr; }
.grid-3  { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.grid-4  { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.grid-6  { grid-template-columns: repeat(3, 1fr); grid-template-rows: 1fr 1fr; }
.grid-9  { grid-template-columns: repeat(3, 1fr); }
