/* =====================================================================
   EasyLern – Design System
   Dunkles, minimalistisches Glassmorphism. Ein Akzent, viel Ruhe.
   ===================================================================== */
:root {
  --bg: #07070a;
  --bg-elev: #0d0d12;
  --surface: rgba(255, 255, 255, 0.028);
  --surface-2: rgba(255, 255, 255, 0.05);
  --surface-3: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #ececf1;
  --muted: #8d8d99;
  --dim: #5d5d68;
  --accent: #8b8cf6;
  --accent-soft: rgba(139, 140, 246, 0.14);
  --accent-line: rgba(139, 140, 246, 0.38);
  --green: #4ade80;
  --green-soft: rgba(74, 222, 128, 0.12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.12);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.12);
  --r-lg: 18px;
  --r: 14px;
  --r-sm: 10px;
  --blur: blur(16px) saturate(130%);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --side: 240px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  font: 400 14.5px/1.55 var(--font);
  font-feature-settings: 'cv11', 'ss01';
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(70% 45% at 50% -8%, rgba(139, 140, 246, 0.10), transparent 70%),
    radial-gradient(40% 35% at 100% 100%, rgba(139, 140, 246, 0.04), transparent 70%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body::before { /* feines Raster für Tiefe */
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(80% 60% at 50% 0%, #000 30%, transparent 75%);
}
.hidden { display: none !important; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
ul, ol { margin: 6px 0 10px; padding-left: 20px; }
li + li { margin-top: 4px; }
::selection { background: rgba(139, 140, 246, 0.35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.16); }
.i { flex: none; display: inline-block; vertical-align: middle; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- Glas ---------- */
.glass, .card {
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 1px 2px rgba(0, 0, 0, 0.4);
}
.card { padding: 20px; position: relative; min-width: 0; }
.card.pad-0 { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; min-width: 0; }
.card-h h2 { display: flex; align-items: center; gap: 9px; }
.card-h h2 .i { color: var(--muted); }
.card.hover { transition: border-color .2s, background .2s, transform .25s var(--ease); }
.card.hover:hover { border-color: var(--line-2); background: var(--surface-2); transform: translateY(-2px); }
.sub { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); font-size: 12.5px; }
.small { font-size: 13px; }
.center { text-align: center; }
.mt { margin-top: 16px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 16px; } .mb-s { margin-bottom: 8px; }
.grow { flex: 1; min-width: 0; }
.grow-wide { flex: 1 1 260px; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-green { color: var(--green); } .c-red { color: var(--red); } .c-amber { color: var(--amber); } .c-accent { color: var(--accent); }

/* ---------- Layout ---------- */
.app { min-height: 100dvh; }
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: var(--side); z-index: 30;
  display: flex; flex-direction: column; padding: 20px 12px 14px;
  border-right: 1px solid var(--line); background: rgba(10, 10, 14, 0.6);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; font-weight: 650; font-size: 16px; letter-spacing: -0.02em; }
.logo { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: linear-gradient(145deg, #fff, #b9b9c8); color: #0a0a0f; box-shadow: 0 0 0 1px rgba(255,255,255,.1), 0 4px 18px rgba(139,140,246,.25); }
.logo .i { stroke-width: 2.2; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); padding: 14px 10px 6px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 11px; height: 36px; padding: 0 10px; border-radius: var(--r-sm);
  color: var(--muted); font-weight: 500; font-size: 13.5px; transition: color .15s, background .15s;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--text); background: var(--surface-3); }
.nav a.active::before { content: ''; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 2px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 12px var(--accent); animation: grow .3s var(--ease); }
.nav a.active .i { color: var(--accent); }
@keyframes grow { from { transform: scaleY(0); } }
.side-user { display: flex; align-items: center; gap: 10px; padding: 10px; margin-top: 8px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); }
.avatar { width: 32px; height: 32px; flex: none; border-radius: 9px; display: grid; place-items: center; font-weight: 600; font-size: 13px; background: var(--surface-3); border: 1px solid var(--line-2); }

.main { margin-left: var(--side); padding: 28px 36px 48px; max-width: calc(1240px + var(--side)); min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; min-height: 40px; }
.topbar h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.025em; }
.topbar .crumb { font-size: 12.5px; color: var(--dim); margin-bottom: 2px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.m-head { display: none; }
.bottom-nav { display: none; }

/* ---------- Grid ---------- */
.grid { display: grid; gap: 14px; }
.grid > * { min-width: 0; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.row.nowrap { flex-wrap: nowrap; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
.stack > * + * { margin-top: 10px; }
.section + .section { margin-top: 14px; }

/* ---------- Buttons ---------- */
.btn {
  --h: 38px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--h); padding: 0 14px;
  border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font: 500 13.5px var(--font); cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .15s, border-color .15s, transform .12s, opacity .15s, box-shadow .2s;
}
.btn:hover { background: var(--surface-3); border-color: var(--line-2); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn:focus-visible, .seg button:focus-visible, .nav a:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
.btn .i { color: currentColor; opacity: .9; }
.btn-primary { background: #ececf1; color: #0a0a0f; border-color: transparent; font-weight: 600; box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 6px 20px -6px rgba(255,255,255,.25); }
.btn-primary:hover { background: #fff; border-color: transparent; }
.btn-accent { background: var(--accent-soft); border-color: var(--accent-line); color: #d6d6ff; }
.btn-accent:hover { background: rgba(139, 140, 246, .22); border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); border-color: transparent; }
.btn-danger { color: #fca5a5; }
.btn-danger:hover { background: var(--red-soft); border-color: rgba(248, 113, 113, .35); }
.btn-sm { --h: 32px; padding: 0 11px; font-size: 13px; }
.btn-lg { --h: 46px; padding: 0 20px; font-size: 14.5px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--h); padding: 0; }
.btn-icon.btn-sm { width: 32px; }

/* ---------- Formulare ---------- */
label, .label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 7px; font-weight: 500; }
.field { margin-bottom: 14px; min-width: 0; }
input, select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35); color: var(--text); font: 400 14px var(--font); outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { height: auto; min-height: 120px; padding: 11px 12px; line-height: 1.6; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--dim); }
input:hover, select:hover, textarea:hover { border-color: var(--line-2); }
input:focus, select:focus, textarea:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(139, 140, 246, .12); background: rgba(0, 0, 0, .45); }
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238d8d99' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
select option { background: #121218; }
input[type='date'] { color-scheme: dark; }
input[type='checkbox'] { width: auto; height: auto; }

.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; margin: 0; color: var(--text); font-size: 13.5px; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle .track { width: 36px; height: 20px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line-2); position: relative; transition: background .2s, border-color .2s; flex: none; }
.toggle .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #9a9aa6; transition: transform .25s var(--ease), background .2s; }
.toggle input:checked + .track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(16px); background: #fff; }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent-line); outline-offset: 2px; }

/* Segmented Control */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; background: rgba(0, 0, 0, .35); border: 1px solid var(--line); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: 500 13px var(--font); cursor: pointer; white-space: nowrap; transition: color .15s, background .2s; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line), 0 1px 2px rgba(0,0,0,.4); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 7px; font-size: 11.5px; font-weight: 550; color: var(--muted); border: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
.badge .i { width: 12px; height: 12px; }
.b-green { color: var(--green); background: var(--green-soft); border-color: rgba(74, 222, 128, .22); }
.b-red { color: var(--red); background: var(--red-soft); border-color: rgba(248, 113, 113, .22); }
.b-amber { color: var(--amber); background: var(--amber-soft); border-color: rgba(251, 191, 36, .22); }
.b-accent { color: #c4c5ff; background: var(--accent-soft); border-color: var(--accent-line); }
.b-plan-user { color: var(--muted); }
.b-plan-pro { color: #c4c5ff; border-color: var(--accent-line); background: var(--accent-soft); }
.b-plan-ultra { color: #fff; border-color: rgba(255,255,255,.3); background: linear-gradient(135deg, rgba(139,140,246,.35), rgba(255,255,255,.08)); box-shadow: 0 0 14px rgba(139,140,246,.25); }
.b-plan-admin { color: #fde68a; border-color: rgba(251, 191, 36, .3); background: var(--amber-soft); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.off { background: var(--red); }

/* Icon-Kachel */
.tile { width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); }
.tile.sm { width: 30px; height: 30px; border-radius: 8px; }
.tile.lg { width: 48px; height: 48px; border-radius: 13px; }
.tile.accent { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.tile.green { color: var(--green); background: var(--green-soft); border-color: rgba(74,222,128,.22); }
.tile.red { color: var(--red); background: var(--red-soft); border-color: rgba(248,113,113,.22); }
.tile.amber { color: var(--amber); background: var(--amber-soft); border-color: rgba(251,191,36,.22); }

/* ---------- Statistiken ---------- */
.stat { display: flex; flex-direction: column; gap: 10px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat-top .i { color: var(--dim); }
.stat-val { font-size: 28px; font-weight: 650; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-val small { font-size: 14px; color: var(--muted); font-weight: 500; letter-spacing: 0; margin-left: 4px; }

/* ---------- Listen ---------- */
.list { display: flex; flex-direction: column; gap: 6px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid transparent; background: var(--surface); transition: background .15s, border-color .15s; min-width: 0; }
.item:hover { background: var(--surface-2); border-color: var(--line); }
.item.click { cursor: pointer; }
.item .t { font-weight: 550; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 32px 16px; color: var(--muted); font-size: 13.5px; }
.empty .tile { margin-bottom: 4px; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 16px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; border: 1px solid var(--line-2); background: var(--surface-2); font-size: 11px; color: var(--muted); font-family: var(--font); }

/* ---------- Fortschritt ---------- */
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; border-radius: 99px; background: var(--accent); transition: width .6s var(--ease); }
.progress.green > div { background: var(--green); }
.ring { --p: 0; --c: var(--accent); width: 112px; height: 112px; flex: none; border-radius: 50%; display: grid; place-items: center; position: relative;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), rgba(255, 255, 255, .06) 0); animation: ringIn 1s var(--ease); }
.ring::before { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: var(--bg-elev); }
.ring > * { position: relative; text-align: center; }
.ring span { position: relative; font-size: 24px; font-weight: 650; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.ring small { position: relative; display: block; font-size: 11px; color: var(--muted); text-align: center; font-weight: 500; }
@property --p { syntax: '<number>'; inherits: false; initial-value: 0; }
@keyframes ringIn { from { --p: 0; } }

/* ---------- Heatmap ---------- */
.heat-wrap { overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 11px); grid-auto-columns: 11px; gap: 3px; width: max-content; }
.heatmap i { border-radius: 3px; background: rgba(255, 255, 255, .045); }
.heatmap .l1 { background: rgba(139, 140, 246, .28); }
.heatmap .l2 { background: rgba(139, 140, 246, .5); }
.heatmap .l3 { background: rgba(139, 140, 246, .75); }
.heatmap .l4 { background: #a5a6ff; box-shadow: 0 0 6px rgba(139, 140, 246, .6); }
.heatmap .now { outline: 1px solid rgba(255,255,255,.6); outline-offset: 1px; }
.legend { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--dim); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Karteikarten ---------- */
.flashcard { perspective: 1400px; height: 280px; cursor: pointer; max-width: 560px; margin: 0 auto; outline: none; }
.flashcard .inner { position: relative; width: 100%; height: 100%; transition: transform .6s var(--ease); transform-style: preserve-3d; }
.flashcard.flipped .inner { transform: rotateY(180deg); }
.flashcard .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 28px; border-radius: 22px; border: 1px solid var(--line-2); background: linear-gradient(160deg, rgba(255,255,255,.07), rgba(255,255,255,.02)); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: 0 30px 60px -30px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.06); }
.flashcard .word { font-size: clamp(22px, 5vw, 32px); font-weight: 600; letter-spacing: -.02em; word-break: break-word; }
.flashcard .back { transform: rotateY(180deg); border-color: var(--accent-line); }
.flashcard .cap { position: absolute; top: 18px; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.flashcard .hint { position: absolute; bottom: 18px; font-size: 12px; color: var(--dim); display: flex; gap: 6px; align-items: center; }
.rate { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 560px; margin: 16px auto 0; }
.rate .btn { --h: 56px; flex-direction: column; gap: 2px; font-size: 13px; }
.rate .btn small { color: var(--dim); font-size: 11px; font-weight: 500; }
.rate .r1:hover { border-color: rgba(248,113,113,.4); background: var(--red-soft); }
.rate .r4:hover { border-color: rgba(74,222,128,.4); background: var(--green-soft); }
.fade-up { animation: rise .45s var(--ease) both; }

/* Vokabel-Editor */
.vgrid { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.vrow { display: grid; grid-template-columns: 24px 1fr 1fr 32px; gap: 6px; align-items: center; animation: rise .3s var(--ease) both; }
.vrow .n { color: var(--dim); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.vrow input { height: 36px; font-size: 13.5px; }

/* ---------- Chat ---------- */
.chat-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 14px; height: calc(100dvh - 120px); min-height: 460px; }
.chat-side { display: flex; flex-direction: column; padding: 12px; gap: 8px; min-height: 0; }
.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.chat-link { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px; color: var(--muted); font-size: 13px; cursor: pointer; transition: background .15s, color .15s; min-width: 0; }
.chat-link:hover { background: var(--surface-2); color: var(--text); }
.chat-link.active { background: var(--surface-3); color: var(--text); }
.chat-link .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-link .del { opacity: 0; transition: opacity .15s; }
.chat-link:hover .del, .chat-link.active .del { opacity: 1; }
.chat-group { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); padding: 12px 10px 4px; }
.chat { display: flex; flex-direction: column; min-height: 0; padding: 0; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-head select { width: auto; height: 32px; font-size: 13px; }
.msgs { flex: 1; overflow-y: auto; padding: 24px clamp(14px, 4vw, 40px); display: flex; flex-direction: column; gap: 20px; scroll-behavior: smooth; }
.msg { display: flex; gap: 12px; max-width: 760px; width: 100%; margin: 0 auto; animation: rise .35s var(--ease) both; }
.msg .who { width: 28px; height: 28px; flex: none; border-radius: 8px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
.msg.assistant .who { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.msg .body { min-width: 0; flex: 1; padding-top: 3px; }
.msg.user .body { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; flex: 0 1 auto; margin-left: auto; white-space: pre-wrap; word-break: break-word; }
.msg.user { flex-direction: row-reverse; }
.msg img.att { max-width: 220px; border-radius: 10px; display: block; margin-bottom: 8px; border: 1px solid var(--line); }
.composer { padding: 12px clamp(12px, 3vw, 28px) 14px; }
.composer-box { max-width: 760px; margin: 0 auto; display: flex; align-items: flex-end; gap: 6px; padding: 6px; border-radius: 16px; border: 1px solid var(--line-2); background: rgba(0,0,0,.4); transition: border-color .15s, box-shadow .15s; }
.composer-box:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 3px rgba(139,140,246,.1); }
.composer textarea { border: 0; background: transparent; min-height: 38px; max-height: 180px; height: 38px; padding: 9px 6px; resize: none; box-shadow: none; }
.composer textarea:focus { box-shadow: none; background: transparent; }
.composer .att-prev { max-width: 760px; margin: 0 auto 8px; display: flex; align-items: center; gap: 8px; }
.composer .att-prev img { height: 44px; border-radius: 8px; border: 1px solid var(--line); }
.typing { display: inline-flex; gap: 4px; padding: 10px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.suggest { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; max-width: 560px; width: 100%; }
.suggest button { text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: 400 13px var(--font); cursor: pointer; transition: all .15s; }
.suggest button:hover { color: var(--text); border-color: var(--line-2); background: var(--surface-2); }
.suggest b { display: block; color: var(--text); font-weight: 550; margin-bottom: 2px; }

/* ---------- Markdown ---------- */
.md { line-height: 1.7; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.1em 0 .45em; font-size: 15px; }
.md h1 { font-size: 17px; }
.md strong { font-weight: 600; color: #fff; }
.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.md code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: .88em; }
.md pre { background: rgba(0,0,0,.45); border: 1px solid var(--line); padding: 12px 14px; border-radius: 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; margin: .6em 0; width: 100%; font-size: 13.5px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.md th { background: var(--surface-2); font-weight: 600; }
.md blockquote { border-left: 2px solid var(--accent); margin: .6em 0; padding: .1em 1em; color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
.md .katex-display { overflow-x: auto; overflow-y: hidden; padding: 6px 0; margin: .6em 0; }
.chart-box { position: relative; height: 280px; margin: 12px 0; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0,0,0,.3); }

/* ---------- Prüfung ---------- */
.exam-bar { position: sticky; top: 12px; z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 18px; margin-bottom: 16px; background: rgba(13,13,18,.75); }
.timer { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.3); font-variant-numeric: tabular-nums; font-size: 16px; font-weight: 600; letter-spacing: .02em; }
.timer.warn { color: var(--amber); border-color: rgba(251,191,36,.3); }
.timer.danger { color: var(--red); border-color: rgba(248,113,113,.35); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.task-n { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 13px; font-weight: 600; background: var(--surface-3); border: 1px solid var(--line-2); flex: none; }
.material { margin: 12px 0; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,.25); }
details > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 500; user-select: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary .i { transition: transform .2s; }
details[open] > summary .i { transform: rotate(90deg); }
details > summary:hover { color: var(--text); }
.grade { font-size: 48px; font-weight: 650; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }

/* ---------- Analyzer ---------- */
.issue { padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); animation: rise .35s var(--ease) both; }
.issue + .issue { margin-top: 8px; }
.issue .from { color: #fca5a5; text-decoration: line-through; text-decoration-color: rgba(248,113,113,.5); }
.issue .to { color: var(--green); font-weight: 550; }
.issue .up { color: #c4c5ff; font-weight: 550; }
.issue .arrow { color: var(--dim); margin: 0 6px; }

/* ---------- Mindmap ---------- */
.mm { height: min(620px, 70dvh); position: relative; }
.mm svg { width: 100%; height: 100%; display: block; }
.mm .markmap { --markmap-text-color: #ececf1; --markmap-a-color: #8b8cf6; --markmap-code-bg: rgba(255,255,255,.06); --markmap-code-color: #ececf1; --markmap-circle-open-bg: #0d0d12; --markmap-font: 500 14px/20px Inter, system-ui, sans-serif; }
.mm-tools { position: absolute; top: 12px; right: 12px; z-index: 2; display: flex; gap: 4px; padding: 4px; border-radius: 12px; }

/* ---------- Quiz ---------- */
.quiz { max-width: 620px; margin: 0 auto; }
.options { display: grid; gap: 8px; margin-top: 18px; }
.option { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: 400 14px var(--font); cursor: pointer; transition: background .15s, border-color .15s, transform .12s; animation: rise .35s var(--ease) both; }
.option:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line-2); }
.option:active:not(:disabled) { transform: scale(.99); }
.option:disabled { cursor: default; }
.option .key { width: 26px; height: 26px; flex: none; border-radius: 7px; display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--muted); border: 1px solid var(--line-2); }
.option.correct { border-color: rgba(74,222,128,.5); background: var(--green-soft); }
.option.correct .key { background: var(--green); color: #052e12; border-color: transparent; }
.option.wrong { border-color: rgba(248,113,113,.5); background: var(--red-soft); animation: shake .35s; }
.option.wrong .key { background: var(--red); color: #3b0909; border-color: transparent; }
.option.faded { opacity: .45; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.feedback { display: flex; gap: 10px; margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-size: 13.5px; animation: rise .3s var(--ease) both; }
.feedback.ok { background: var(--green-soft); border: 1px solid rgba(74,222,128,.25); }
.feedback.bad { background: var(--red-soft); border: 1px solid rgba(248,113,113,.25); }
.feedback .i { margin-top: 2px; }
.feedback.ok > .i { color: var(--green); } .feedback.bad > .i { color: var(--red); }
.big-q { font-size: clamp(22px, 5vw, 30px); font-weight: 600; letter-spacing: -.02em; margin: 6px 0 18px; word-break: break-word; }
.steps { display: flex; gap: 4px; }
.steps i { flex: 1; height: 4px; border-radius: 99px; background: var(--surface-3); transition: background .3s; }
.steps i.done-ok { background: var(--green); } .steps i.done-bad { background: var(--red); } .steps i.cur { background: var(--text); }

/* ---------- Kalender ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dow { text-align: center; font-size: 11px; font-weight: 600; color: var(--dim); padding: 4px 0 6px; text-transform: uppercase; letter-spacing: .05em; }
.cal-d { min-height: 76px; padding: 6px; border-radius: 10px; border: 1px solid transparent; background: var(--surface); font-size: 12px; min-width: 0; transition: background .15s; }
.cal-d:hover { background: var(--surface-2); }
.cal-d .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-d.other { opacity: .3; }
.cal-d.today { border-color: var(--line-2); }
.cal-d.today .n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--text); color: var(--bg); font-weight: 600; }
.ev { display: block; margin-top: 4px; padding: 2px 6px; border-radius: 5px; font-size: 11px; font-weight: 500; background: var(--accent-soft); color: #d6d6ff; border-left: 2px solid var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev.urgent { background: var(--red-soft); color: #fecaca; border-left-color: var(--red); }
.prio { display: flex; align-items: center; gap: 10px; }
.prio + .prio { margin-top: 12px; }

/* ---------- Admin ---------- */
.utable { display: flex; flex-direction: column; }
.urow { display: grid; grid-template-columns: minmax(160px, 1.6fr) 150px 70px repeat(4, 64px) 40px; gap: 12px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.urow.head { color: var(--dim); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; border-bottom-color: var(--line-2); }
.urow:not(.head):hover { background: var(--surface); }
.urow select { height: 32px; font-size: 13px; }
.urow .num { font-variant-numeric: tabular-nums; color: var(--muted); }
.urow .ml { display: none; }
.urow .stats { display: contents; }

/* ---------- Auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; padding: 32px 28px 28px; animation: rise .5s var(--ease) both; }
.auth-card .logo { width: 44px; height: 44px; border-radius: 13px; margin: 0 auto 18px; }
.auth-card h1 { font-size: 22px; text-align: center; letter-spacing: -.03em; }

/* ---------- Toasts & Modal ---------- */
.toasts { position: fixed; bottom: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 10px; max-width: 380px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: rgba(18, 18, 24, .92); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); box-shadow: 0 16px 40px -12px rgba(0,0,0,.7); font-size: 13.5px; pointer-events: auto; animation: toastIn .35s var(--ease) both; }
.toast .i { margin-top: 1px; color: var(--muted); }
.toast.error .i { color: var(--red); } .toast.success .i { color: var(--green); }
.toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }
.backdrop { position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .2s ease both; }
.modal { width: 100%; max-width: 520px; max-height: min(86dvh, 760px); overflow-y: auto; padding: 22px; background: rgba(16, 16, 22, .94); border-radius: 20px; animation: pop .3s var(--ease) both; }
.modal.wide { max-width: 860px; }
.modal .card-h { position: sticky; top: -22px; margin: -22px -22px 16px; padding: 18px 22px 14px; background: rgba(16,16,22,.96); z-index: 2; border-bottom: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Upload ---------- */
.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 16px; border: 1px dashed var(--line-2); border-radius: 14px; text-align: center; cursor: pointer; color: var(--muted); font-size: 13.5px; transition: background .15s, border-color .15s; }
.drop:hover, .drop.drag { background: var(--surface-2); border-color: var(--accent-line); color: var(--text); }
.drop .tile { margin-bottom: 4px; }
.drop .prev { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 6px; }
.drop .prev img { height: 72px; border-radius: 8px; border: 1px solid var(--line); }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 13.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); }
.notice .i { color: var(--amber); margin-top: 1px; }
.notice.accent .i { color: var(--accent); }

/* ---------- Lade-Zustände & Animation ---------- */
.skel { border-radius: var(--r-lg); background: linear-gradient(90deg, rgba(255,255,255,.03) 0%, rgba(255,255,255,.07) 50%, rgba(255,255,255,.03) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border: 1px solid var(--line); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 56px 16px; color: var(--muted); font-size: 13.5px; text-align: center; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.15); border-top-color: currentColor; animation: spin .7s linear infinite; flex: none; }
.loading .spinner { width: 28px; height: 28px; color: var(--accent); }
.orbit { position: relative; width: 44px; height: 44px; }
.orbit::before, .orbit::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid transparent; border-top-color: var(--accent); animation: spin 1s linear infinite; }
.orbit::after { inset: 8px; border-top-color: var(--text); animation-duration: 1.6s; animation-direction: reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.view > *, .stagger > * { animation: rise .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* =====================================================================
   Tablet & Handy
   ===================================================================== */
@media (max-width: 1180px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 24px 24px 40px; }
  .urow { grid-template-columns: minmax(140px, 1.4fr) 140px 60px repeat(4, 52px) 36px; gap: 8px; }
}
@media (max-width: 960px) {
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat-layout { grid-template-columns: minmax(0, 1fr); }
  .chat-side { display: none; }
  .chat-side.open { display: flex; position: fixed; z-index: 120; top: 12px; left: 12px; bottom: 12px; width: min(300px, 85vw); background: rgba(14,14,20,.97); animation: slideIn .3s var(--ease) both; }
  .chat-scrim { position: fixed; inset: 0; z-index: 110; background: rgba(0,0,0,.5); animation: fade .2s both; }
  .only-wide { display: none !important; }
}
@keyframes slideIn { from { transform: translateX(-16px); opacity: 0; } }
@media (min-width: 961px) { .only-narrow { display: none !important; } }

@media (max-width: 820px) {
  :root { --nav-h: 62px; }
  body { font-size: 14px; }
  .sidebar { display: none; }
  .main { margin: 0; padding: 0 14px calc(var(--nav-h) + var(--safe-b) + 28px); }
  .m-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px; position: sticky; top: 0; z-index: 40;
    margin: 0 -14px 14px; padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
    background: rgba(7, 7, 10, .72); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border-bottom: 1px solid var(--line);
  }
  .m-head .brand { padding: 0; font-size: 15px; }
  .m-head .logo { width: 26px; height: 26px; }
  .topbar { margin-bottom: 14px; min-height: 0; }
  .topbar h1 { font-size: 20px; }
  .topbar .top-actions { display: none; }
  .g-2, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid { gap: 10px; }
  .span-2 { grid-column: auto; }
  .card { padding: 16px; border-radius: 16px; }
  .card-h { margin-bottom: 12px; flex-wrap: wrap; }
  .stat-val { font-size: 24px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
    height: calc(var(--nav-h) + var(--safe-b)); padding: 6px 6px var(--safe-b);
    background: rgba(9, 9, 13, .82); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border-top: 1px solid var(--line);
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border-radius: 12px; color: var(--dim); font-size: 10.5px; font-weight: 500; transition: color .15s; position: relative; }
  .bottom-nav a .i { width: 21px; height: 21px; transition: transform .25s var(--ease); }
  .bottom-nav a.active { color: var(--text); }
  .bottom-nav a.active .i { color: var(--accent); transform: translateY(-1px); }
  .bottom-nav a.active::after { content: ''; position: absolute; top: -7px; width: 18px; height: 2px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
  .toasts { left: 12px; right: 12px; bottom: calc(var(--nav-h) + var(--safe-b) + 12px); align-items: stretch; }
  .toast { max-width: none; }
  .backdrop { place-items: end stretch; padding: 0; }
  .modal, .modal.wide { max-width: none; max-height: 88dvh; border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); animation: sheet .35s var(--ease) both; border-bottom: 0; }
  .modal .card-h { top: -18px; margin: -18px -16px 14px; padding: 14px 16px 12px; }
  .modal .card-h::before { content: ''; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: var(--line-2); }
  .chat-layout { height: calc(100dvh - 58px - 50px - var(--nav-h) - var(--safe-b) - 24px); min-height: 280px; }
  .msgs { padding: 16px 12px; gap: 16px; }
  .msg .who { display: none; }
  .msg.user .body { max-width: 88%; }
  .suggest { grid-template-columns: minmax(0, 1fr); }
  .composer { padding: 8px; }
  .exam-bar { top: 62px; padding: 8px 8px 8px 12px; }
  .exam-bar .t-title { font-size: 13px; }
  .flashcard { height: 230px; }
  .rate { grid-template-columns: repeat(2, 1fr); }
  .rate .btn { --h: 52px; }
  .cal-d { min-height: 46px; padding: 4px; border-radius: 8px; }
  .cal-d .ev { font-size: 0; height: 4px; padding: 0; margin-top: 3px; border: 0; background: var(--accent); }
  .cal-d .ev.urgent { background: var(--red); }
  .urow.head { display: none; }
  .urow { grid-template-columns: 1fr auto; gap: 8px 12px; padding: 14px 4px; }
  .urow .uname { grid-column: 1; grid-row: 1; }
  .urow .del-cell { grid-column: 2; grid-row: 1; justify-self: end; }
  .urow .ml { display: inline; color: var(--dim); font-size: 11.5px; margin-right: 4px; }
  .urow .num { font-size: 12.5px; }
  .urow .stats { grid-column: 1 / -1; display: flex; gap: 14px; flex-wrap: wrap; }
  .mm { height: 62dvh; }
  .hide-m { display: none !important; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
@media (max-width: 420px) {
  .g-4 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .stat-val { font-size: 22px; }
  .btn { --h: 40px; }
  .btn-sm { --h: 34px; }
  .ring { width: 96px; height: 96px; }
  .ring span { font-size: 20px; }
}
@media (min-width: 821px) { .show-m { display: none !important; } }
