/* ============ Design-Tokens ============ */
:root {
  /* Abstand oben: sicherer Bereich, auf dem iPad als App mindestens die Höhe der (Liquid-Glass-)Statusleiste, siehe main.js */
  --top-inset: max(env(safe-area-inset-top), var(--top-min, 0px));
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #f1efe8;
  --surface-3: #e7e4db;
  --text: #1c1b19;
  --muted: #69675f;
  --faint: #9a978e;
  --border: #e4e1d8;
  --accent: var(--brand, #3d5af1);
  --accent-strong: color-mix(in srgb, var(--accent) 80%, black);
  --accent-soft: color-mix(in srgb, var(--accent) 11%, white);
  --on-accent: #ffffff;
  --danger: #d33a2f;
  --danger-soft: #fdecea;
  --success: #2b8a3e;
  --success-soft: #e5f4e9;
  --warn: #b86e00;
  --warn-soft: #fff2d9;
  --shadow: 0 1px 2px rgba(20, 18, 10, .04), 0 6px 20px rgba(20, 18, 10, .04);
  --radius: 14px;
  --radius-sm: 9px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121214;
    --surface: #1b1b1f;
    --surface-2: #24242a;
    --surface-3: #2e2e35;
    --text: #ecebe6;
    --muted: #a5a39c;
    --faint: #75736d;
    --border: #2d2d34;
    --accent: color-mix(in srgb, var(--brand, #3d5af1) 60%, white);
    --accent-strong: color-mix(in srgb, var(--brand, #3d5af1) 45%, white);
    --accent-soft: color-mix(in srgb, var(--brand, #3d5af1) 24%, #1b1b1f);
    --on-accent: #0e1022;
    --danger: #ff6f63;
    --danger-soft: #3b1f1d;
    --success: #5cc57a;
    --success-soft: #1b3323;
    --warn: #f2b14a;
    --warn-soft: #3a2d14;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121214;
  --surface: #1b1b1f;
  --surface-2: #24242a;
  --surface-3: #2e2e35;
  --text: #ecebe6;
  --muted: #a5a39c;
  --faint: #75736d;
  --border: #2d2d34;
  --accent: color-mix(in srgb, var(--brand, #3d5af1) 60%, white);
  --accent-strong: color-mix(in srgb, var(--brand, #3d5af1) 45%, white);
  --accent-soft: color-mix(in srgb, var(--brand, #3d5af1) 24%, #1b1b1f);
  --on-accent: #0e1022;
  --danger: #ff6f63;
  --danger-soft: #3b1f1d;
  --success: #5cc57a;
  --success-soft: #1b3323;
  --warn: #f2b14a;
  --warn-soft: #3a2d14;
  --shadow: none;
  color-scheme: dark;
}

/* ============ Grundlagen ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.warn-text { color: var(--danger); font-weight: 600; }

/* ============ Layout ============ */
.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -.01em;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
}
.brand-mark svg { width: 20px; height: 20px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-weight: 550;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .short { display: none; }
.nav .badge-count {
  margin-left: auto;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.sidebar-foot { margin-top: auto; padding: 0 10px; font-size: 12px; color: var(--faint); }

.view {
  width: 100%;
  min-width: 0;
  max-width: 1240px;
  padding: 32px clamp(16px, 4vw, 44px) 64px;
  outline: none;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-head h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 30px);
  line-height: 1.2;
  letter-spacing: -.02em;
}
.page-head .sub { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn .ic { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.link:hover { text-decoration: underline; }

/* ============ Karten & Kennzahlen ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 650; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  display: block;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: border-color .15s;
  min-width: 0;
}
a.stat:hover { border-color: var(--accent); }
.stat-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 550; }
.stat-label .ic { width: 16px; height: 16px; }
.stat-value {
  display: block;
  margin: 6px 0 2px;
  font-size: 28px;
  font-weight: 720;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-value small { font-size: 15px; font-weight: 600; color: var(--muted); }
.stat-sub { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { height: 6px; margin-top: 10px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s; }

.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }

/* ============ Tags ============ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 1px 9px 1px 7px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  color: color-mix(in srgb, var(--c) 70%, var(--text));
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; }

/* ============ Listen / Aufgaben ============ */
.list { list-style: none; margin: 0; padding: 0; }
.task {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 2px;
  border-top: 1px solid var(--border);
}
.task:first-child { border-top: 0; }
.checkbox {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  padding: 0;
  border: 1.8px solid var(--faint);
  border-radius: 7px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.checkbox:hover { border-color: var(--accent); }
.checkbox .ic { width: 14px; height: 14px; stroke-width: 3; }
.task.done .checkbox { background: var(--success); border-color: var(--success); }
.task-main {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.task-title { display: block; font-weight: 550; overflow-wrap: anywhere; }
.task.done .task-title { color: var(--faint); text-decoration: line-through; }
.task-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
}
.due { display: inline-flex; align-items: center; gap: 4px; }
.due .ic { width: 13px; height: 13px; }
.task.overdue .due { color: var(--danger); font-weight: 650; }
.task.today .due { color: var(--warn); font-weight: 650; }
.prio { color: var(--danger); font-weight: 650; }
.note-hint { display: inline-flex; align-items: center; gap: 3px; }
.note-hint .ic { width: 13px; height: 13px; }

.group-title {
  margin: 22px 0 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.group-title:first-child { margin-top: 0; }
.group-title.danger { color: var(--danger); }
.group-title .count { color: var(--faint); font-weight: 600; margin-left: 4px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.chips { display: flex; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: 11px; }
.chip, .seg-btn {
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover, .seg-btn:hover { color: var(--text); }
.chip.active, .seg-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.chip .n { color: var(--faint); margin-left: 3px; font-weight: 600; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 10px; }
.seg-btn { padding: 4px 10px; font-size: 12.5px; }

.quick-add { display: flex; gap: 8px; flex: 1; min-width: 220px; }
.quick-add input { flex: 1; min-width: 0; }

.input, .field input, .field select, .field textarea, .toolbar select, .quick-add input, .setting-row input, .setting-row select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.toolbar select { width: auto; max-width: 100%; padding: 7px 10px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus, .toolbar select:focus, .quick-add input:focus, .setting-row input:focus, .setting-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}
.empty .ic { width: 28px; height: 28px; color: var(--faint); margin-bottom: 6px; }
.empty p { margin: 4px 0 14px; }

/* ============ Heute (Dashboard) ============ */
.today-item {
  display: grid;
  grid-template-columns: 50px 4px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
}
.today-item + .today-item { border-top: 1px solid var(--border); }
.today-item.past { opacity: .5; }
.ti-time { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.25; }
.ti-time span { color: var(--faint); font-weight: 500; }
.ti-bar { align-self: stretch; border-radius: 4px; background: var(--c); }
.ti-main { min-width: 0; }
.ti-main strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ti-main span { font-size: 13px; color: var(--muted); }
.badge {
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.live { background: var(--success-soft); color: var(--success); }
.next-day-label { margin: 0 0 6px; font-size: 13px; color: var(--muted); }

.mini-exam {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
}
.mini-exam + .mini-exam { border-top: 1px solid var(--border); }
.mini-count {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--c) 14%, var(--surface));
  color: color-mix(in srgb, var(--c) 75%, var(--text));
  font-size: 18px;
  font-weight: 750;
  line-height: 1;
}
.mini-count small { font-size: 10px; font-weight: 600; margin-top: 2px; }
.mini-exam strong { display: block; font-weight: 600; }
.mini-exam .muted { font-size: 13px; }

/* ============ Pomodoro ============ */
.pomo-body { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.ring { position: relative; width: 132px; height: 132px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring-bg { stroke: var(--surface-3); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .4s linear; }
.ring-fg.break { stroke: var(--success); }
.ring-time {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.pomo-side { flex: 1; min-width: 180px; }
.pomo-side p { margin: 0 0 12px; }
.pomo-side p.small { margin: 12px 0 0; }

/* ============ Stundenplan ============ */
.tt-card { padding: 0; overflow: hidden; }
.tt-scroll { overflow-x: auto; }
.tt { min-width: 660px; }
.tt-head, .tt-body { display: grid; grid-template-columns: 58px repeat(var(--days), minmax(0, 1fr)); }
.tt-head { border-bottom: 1px solid var(--border); background: var(--surface); }
.tt-dayname { padding: 12px 8px; text-align: center; font-size: 13px; font-weight: 650; color: var(--muted); }
.tt-dayname.is-today { color: var(--accent); }
.tt-dayname .short { display: none; }
.tt-body { height: var(--h); }
.tt-times { position: relative; }
.tt-hour {
  position: absolute;
  right: 9px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.tt-day {
  position: relative;
  border-left: 1px solid var(--border);
  background-image: repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px 60px);
  cursor: cell;
}
.tt-day.is-today { background-color: color-mix(in srgb, var(--accent) 5%, transparent); }
.slot {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 5px 8px;
  border: 0;
  border-left: 3px solid var(--c);
  border-radius: 7px;
  background: color-mix(in srgb, var(--c) 16%, var(--surface));
  color: var(--text);
  text-align: left;
  font-size: 12px;
  line-height: 1.3;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
}
.slot:hover { box-shadow: 0 3px 12px rgba(0, 0, 0, .14); z-index: 2; }
.slot-name { font-weight: 680; font-size: 12.5px; color: color-mix(in srgb, var(--c) 55%, var(--text)); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.slot-meta { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-type { color: var(--muted); font-size: 11px; }
.slot.compact { padding: 2px 7px; }
.slot.compact .slot-type, .slot.compact .slot-meta { display: none; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.hint { margin: 12px 2px 0; font-size: 13px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.legend .tag { cursor: pointer; border: 0; }

/* ============ Prüfungen ============ */
.exam-list { display: grid; gap: 12px; }
.exam-card {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--c);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s;
}
.exam-card:hover { border-color: color-mix(in srgb, var(--c) 60%, var(--border)); border-left-color: var(--c); }
.countdown {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 76px;
  height: 76px;
  border-radius: 13px;
  background: var(--surface-2);
}
.countdown .num { font-size: 27px; font-weight: 760; line-height: 1; font-variant-numeric: tabular-nums; }
.countdown .num.word { font-size: 17px; }
.countdown .unit { margin-top: 3px; font-size: 12px; color: var(--muted); }
.exam-card.soon .countdown { background: var(--danger-soft); color: var(--danger); }
.exam-card.near .countdown { background: var(--warn-soft); color: var(--warn); }
.exam-card.soon .countdown .unit, .exam-card.near .countdown .unit { color: inherit; opacity: .8; }
.exam-info { display: block; min-width: 0; flex: 1; }
.exam-title { display: block; font-size: 16px; font-weight: 650; }
.exam-meta { display: block; margin-top: 2px; font-size: 13.5px; color: var(--muted); }
.exam-notes { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); white-space: pre-line; }
.section-title { margin: 32px 0 12px; font-size: 16px; font-weight: 650; }

.past-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--border);
}
.past-row:first-child { border-top: 0; }
.past-row .grow { flex: 1; min-width: 0; }
.past-row strong { display: block; font-weight: 600; }

/* ============ Module & Noten ============ */
.module-list { display: grid; }
.module-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 6px;
  border: 0;
  border-top: 1px solid var(--border);
  background: none;
  text-align: left;
  cursor: pointer;
  border-radius: 0;
}
.module-row:first-child { border-top: 0; }
.module-row:hover { background: var(--surface-2); }
.module-main { display: block; flex: 1; min-width: 0; }
.module-name { display: block; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.module-sub { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.module-ects { font-size: 13.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.grade {
  min-width: 82px;
  padding: 4px 10px;
  border-radius: 8px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.grade.open { background: var(--surface-2); color: var(--muted); font-weight: 600; }
.grade.pass { background: var(--success-soft); color: var(--success); }
.grade.top { background: var(--accent-soft); color: var(--accent); }
.grade.fail { background: var(--danger-soft); color: var(--danger); }

/* ============ Einstellungen ============ */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.setting-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.setting-row:last-child { margin-bottom: 0; }
.setting-row label, .setting-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.setting-inline { display: flex; gap: 10px; }
.setting-inline > * { flex: 1; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 550; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.data-actions { display: grid; gap: 8px; }
.data-actions .btn { justify-content: flex-start; }
.card p.desc { margin: -4px 0 14px; color: var(--muted); font-size: 13.5px; }

/* ============ Dialog ============ */
.dialog {
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}
.dialog::backdrop { background: rgba(14, 14, 20, .45); backdrop-filter: blur(2px); }
.dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 4px; }
.dlg-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.dlg-body { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; padding: 12px 20px 4px; }
.field { display: flex; flex-direction: column; gap: 5px; grid-column: 1 / -1; min-width: 0; }
.field.half { grid-column: span 1; }
.field label, .field .field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.form-error { grid-column: 1 / -1; margin: 0; padding: 8px 12px; border-radius: 9px; background: var(--danger-soft); color: var(--danger); font-size: 13.5px; font-weight: 550; }
.dlg-foot { display: flex; align-items: center; gap: 8px; padding: 16px 20px 18px; }
.spacer { flex: 1; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; padding: 4px 2px; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { display: block; width: 28px; height: 28px; border-radius: 50%; background: var(--c); cursor: pointer; transition: box-shadow .15s; }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.swatch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 5px; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ Responsiv ============ */
@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 20;
    height: auto;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--border);
    flex-direction: row;
  }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; justify-content: space-around; width: 100%; gap: 0; }
  .nav a {
    position: relative;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    padding: 6px 2px;
    font-size: 10.5px;
    text-align: center;
  }
  .nav .long { display: none; }
  .nav .short { display: inline; }
  .nav .badge-count { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; min-width: 16px; line-height: 16px; font-size: 10px; padding: 0 4px; }
  .view { padding: 22px 16px 100px; }
  .dash-grid, .settings-grid { grid-template-columns: 1fr; }
  .toast { bottom: 84px; }
}

@media (max-width: 520px) {
  .stats { gap: 10px; }
  .stat { padding: 13px 14px; }
  .stat-value { font-size: 23px; }
  .page-head { align-items: flex-start; }
  .exam-card { gap: 14px; padding: 14px; }
  .countdown { width: 62px; height: 62px; }
  .countdown .num { font-size: 22px; }
  .module-row { flex-wrap: wrap; row-gap: 6px; }
  .module-main { flex-basis: calc(100% - 30px); }
  .module-ects { margin-left: 26px; }
  .grade { margin-left: auto; }
  .tt { min-width: 560px; }
  .tt-dayname .long { display: none; }
  .tt-dayname .short { display: inline; }
  .dlg-foot { flex-wrap: wrap; }
}

/* ============ Fachprofil: Marke & Kopfzeile ============ */
.brand-mark { background: var(--accent-soft); font-size: 19px; line-height: 1; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-text small { max-width: 160px; font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin: -12px 0 20px;
  padding: 4px 12px 4px 6px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}
.pl-emoji { font-size: 15px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field small { font-size: 12px; }

/* ============ Onboarding ============ */
body.onboarding .sidebar { display: none; }
body.onboarding .app { grid-template-columns: minmax(0, 1fr); }
body.onboarding .view { max-width: 980px; margin: 0 auto; padding-bottom: 48px; }
.ob h1 { margin: 0; font-size: clamp(24px, 3.4vw, 32px); letter-spacing: -.02em; line-height: 1.2; }
.ob-lead { max-width: 680px; margin: 8px 0 22px; color: var(--muted); }
.ob-steps { display: flex; gap: 6px; margin-bottom: 18px; }
.ob-steps span { width: 34px; height: 5px; border-radius: 99px; background: var(--surface-3); transition: background .2s; }
.ob-steps span.on { background: var(--accent); }
.ob-search {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 460px;
  margin-bottom: 16px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
}
.ob-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ob-search input { flex: 1; min-width: 0; padding: 11px 0; border: 0; background: none; outline: none; color: var(--text); }
.ob-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 10px; }
.ob-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 14px 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.ob-card[hidden] { display: none; }
.ob-card:hover { border-color: var(--c); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0, 0, 0, .06); }
.ob-card.selected { border-color: var(--c); box-shadow: 0 0 0 2px var(--c); }
.ob-emoji { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 4px; border-radius: 11px; background: color-mix(in srgb, var(--c) 14%, var(--surface)); font-size: 21px; }
.ob-card { min-width: 0; }
.ob-name { max-width: 100%; font-weight: 650; line-height: 1.3; hyphens: auto; overflow-wrap: anywhere; }
.ob-meta { font-size: 12px; color: var(--muted); }
.ob-form { padding: 20px; }
.ob-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 22px; }
.ob-mods { display: grid; gap: 2px; }
.ob-mod { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 9px; cursor: pointer; }
.ob-mod:hover { background: var(--surface-2); }
.ob-mod input { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.ob-mod span:nth-of-type(1) { flex: 1; font-weight: 550; }
.ob-mod.exists { opacity: .55; cursor: default; }
.ob-includes { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.ob-includes span { display: inline-flex; align-items: center; gap: 6px; }
.ob-includes .ic { width: 15px; height: 15px; color: var(--accent); }

/* ============ Übersicht: Werkzeuge & Tipp ============ */
.tool-sum { display: block; padding: 8px 0; color: inherit; text-decoration: none; }
.tool-sum + .tool-sum { padding-top: 12px; border-top: 1px solid var(--border); }
.tool-sum-head { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.tool-sum-head span { font-size: 13px; color: var(--muted); white-space: nowrap; }
.tool-sum .progress { margin-top: 7px; }
.tip-card { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); }
.tip-card h2 { display: inline-flex; align-items: center; gap: 8px; }
.tip-card h2 .ic { color: var(--accent); }
.tip-card p { margin: 0; font-size: 15px; line-height: 1.55; }

/* ============ Aufgaben: Vorschläge ============ */
.suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -4px 0 16px; font-size: 13px; color: var(--muted); }
.suggest > span { margin-right: 2px; }
.suggest-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px 4px 7px;
  border: 1px dashed var(--border);
  border-radius: 99px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
}
.suggest-chip .ic { width: 13px; height: 13px; }
.suggest-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ============ Fach-Werkzeuge ============ */
.tools-list { display: grid; gap: 18px; }
.tool .card-head { align-items: flex-start; margin-bottom: 16px; }
.tool .desc { margin: 3px 0 0; font-size: 13.5px; color: var(--muted); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.sheet-mod { padding: 14px 0; border-top: 1px solid var(--border); }
.sheet-mod:first-of-type { padding-top: 0; border-top: 0; }
.sheet-mod-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.sheet-pct { font-size: 18px; font-weight: 720; font-variant-numeric: tabular-nums; }
.sheet-sum { margin-left: auto; }
.progress.thr { position: relative; overflow: visible; }
.progress.thr > span { border-radius: 99px; }
.progress.thr::after {
  content: "";
  position: absolute;
  top: -4px;
  bottom: -4px;
  left: var(--thr);
  width: 2px;
  border-radius: 2px;
  background: var(--text);
  opacity: .55;
}
.sheet-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.sheet-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
}
.sheet-chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.sheet-chip.ok b { color: var(--success); }
.sheet-chip.low b { color: var(--warn); }
.sheet-chip:hover { border-color: var(--accent); }
.sheet-chip.add { border-style: dashed; }
.sheet-chip.add .ic { width: 13px; height: 13px; }
.counter-big { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.counter-big .num { font-size: 40px; font-weight: 760; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.counter-big .of { font-size: 16px; font-weight: 600; color: var(--muted); }
.counter-big .of .link { font-size: 16px; }
.counter-big .small { margin-left: auto; }
.entry-list { margin-top: 14px; }
.entry {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 4px;
  border: 0;
  border-top: 1px solid var(--border);
  background: none;
  text-align: left;
  cursor: pointer;
}
.entry-list li:first-child .entry { border-top: 0; }
.entry:hover { background: var(--surface-2); }
.entry-date { flex: none; width: 110px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.entry-note { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-amount { font-weight: 650; color: var(--success); white-space: nowrap; }
.check-progress { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.check-progress span { white-space: nowrap; }
.check-progress .progress { flex: 1; margin: 0; }

/* ============ Einstellungen: Studium ============ */
.profile-summary { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.profile-summary > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.ps-emoji { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 11px; background: var(--accent-soft); font-size: 22px; }

@media (max-width: 860px) {
  .nav a { padding: 6px 0; font-size: 10px; }
  .nav a .ic { width: 20px; height: 20px; }
  .profile-line { margin-top: -14px; }
}

@media (max-width: 520px) {
  .ob-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ob-card { padding: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .field.half { grid-column: 1 / -1; }
  .dlg-body.form-grid { grid-template-columns: 1fr 1fr; }
  .dlg-body.form-grid .field.half { grid-column: span 1; }
  .entry-date { width: 84px; }
  .counter-big .small { width: 100%; margin-left: 0; }
  .sheet-sum { margin-left: 0; }
}

/* ============ Anpassungen: Schriftgröße & Dichte ============ */
#view { zoom: var(--scale, 1); }
.dialog { zoom: var(--scale, 1); width: min(540px, calc((100vw - 32px) / var(--scale, 1))); }
@media (min-width: 1081px) {
  .stats { grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); }
}
body.compact .view { padding-top: 20px; }
body.compact .page-head { margin-bottom: 14px; }
body.compact .card { padding: 12px 16px; }
body.compact .stat { padding: 10px 14px; }
body.compact .stat-value { margin: 2px 0 0; font-size: 23px; }
body.compact .stats, body.compact .dash-grid, body.compact .settings-grid, body.compact .tools-list { gap: 10px; }
body.compact .stats { margin-bottom: 10px; }
body.compact .card-head { margin-bottom: 8px; }
body.compact .task { padding: 6px 2px; }
body.compact .today-item, body.compact .mini-exam { padding: 5px 0; }
body.compact .module-row { padding: 8px 6px; }
body.compact .exam-main { padding: 10px 14px; }
body.compact .exam-actions { padding: 6px 14px; }
body.compact .countdown { width: 60px; height: 60px; }
body.compact .ring { width: 104px; height: 104px; }
body.compact .ring-time { font-size: 21px; }

/* ============ Einstellungen: Unterseiten ============ */
.settings-tabs {
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 18px;
  overflow-x: auto;
  scrollbar-width: none;
}
.settings-tabs .chip { flex: none; }
.settings-grid .span-2 { grid-column: 1 / -1; }

.toggle-row, .order-row, .tool-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.toggle-row:first-of-type, .order-row:first-child, .tool-row:first-child { border-top: 0; }
.card-head + .toggle-row { border-top: 0; }
.toggle-row { justify-content: space-between; cursor: pointer; }
.toggle-row.disabled { opacity: .55; cursor: default; }
.tr-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tr-label { font-weight: 550; }
.tr-hint { font-size: 12.5px; color: var(--muted); }

.switch-input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 40px;
  height: 23px;
  margin: 0;
  border-radius: 99px;
  background: var(--surface-3);
  cursor: pointer;
  transition: background .18s;
}
.switch-input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s;
}
.switch-input:checked { background: var(--accent); }
.switch-input:checked::before { transform: translateX(17px); }
.switch-input:disabled { cursor: default; }

.accent-picker { display: flex; flex-wrap: wrap; gap: 9px; padding: 4px 2px; }
.accent-swatch {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--c);
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
}
.accent-swatch:hover { transform: scale(1.08); }
.accent-swatch.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.accent-swatch.fach { background: color-mix(in srgb, var(--c) 18%, var(--surface)); }
.accent-swatch.custom { border: 1.5px dashed var(--faint); }
.accent-swatch.custom .ic { width: 15px; height: 15px; }
.accent-swatch.custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

.order-list { list-style: none; margin: 0; padding: 0; }
.or-label { flex: 1; min-width: 0; font-weight: 550; }
.order-row.off .or-label, .tool-row.off .tr-label { color: var(--faint); }
.icon-btn:disabled { opacity: .3; cursor: default; background: none; }

.tool-row.off .kind-badge { opacity: .5; }
.kind-badge {
  flex: none;
  min-width: 96px;
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
}

.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.edit-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 3px 3px 11px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 550;
}
.chip-x {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.chip-x:hover { background: var(--danger-soft); color: var(--danger); }
.chip-x .ic { width: 13px; height: 13px; }
.list-add { display: flex; gap: 8px; }
.list-add input {
  flex: 1;
  min-width: 0;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}
.list-add input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

@media (max-width: 520px) {
  .kind-badge { min-width: 0; }
  .tool-row { flex-wrap: wrap; }
  .tool-row .tr-text { flex-basis: calc(100% - 110px); }
  .list-add .btn { padding: 8px 10px; }
  .list-add .btn-text { display: none; }
  .setting-inline { flex-direction: column; gap: 0; }
}
.setting-inline > * { min-width: 0; }
.data-actions .btn { white-space: normal; text-align: left; }

/* ============ Version 3: Kalender, Prüfungen, Sync, App ============ */
code { padding: 1px 5px; border-radius: 5px; background: var(--surface-2); font-size: .92em; }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge .ic { width: 12px; height: 12px; margin-right: 3px; vertical-align: -2px; }
.badge.warn { white-space: nowrap; }

/* Hinweis-Banner (Backup) */
.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: var(--radius);
  background: var(--accent-soft);
}
.banner > .ic { width: 22px; height: 22px; color: var(--accent); }
.banner-text { flex: 1; min-width: 220px; font-size: 14px; }
.banner-text strong { display: block; }
.banner-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }

/* Stundenplan: Wochen-Navigation, Feiertage, Ausfälle, Drag & Drop */
.week-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: -8px 0 12px; }
.week-label { margin-left: 4px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.tt-dayname { display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.25; }
.tt-date { font-size: 11.5px; font-weight: 500; color: var(--faint); }
.tt-dayname.is-today .tt-date { color: var(--accent); }
.tt-free {
  max-width: 100%;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tt-day.is-free {
  background-image:
    repeating-linear-gradient(135deg, color-mix(in srgb, var(--warn) 8%, transparent) 0 6px, transparent 6px 12px),
    repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px 60px);
}
.slot.is-off { opacity: .55; background: var(--surface-2); }
.slot.is-off .slot-name { text-decoration: line-through; }
.slot.is-off .slot-meta b { color: var(--danger); }
.slot.is-outside { opacity: .45; }
.slot { touch-action: none; }
.slot.dragging { z-index: 20; opacity: .9; box-shadow: 0 10px 28px rgba(0, 0, 0, .25); cursor: grabbing; transition: none; }
.tt-day.drop { background-color: color-mix(in srgb, var(--accent) 10%, transparent); }
.today-item.is-off .ti-main strong { text-decoration: line-through; color: var(--muted); }

/* Prüfungen: Karte mit Aktionen, Ergebnis */
.exam-card { flex-direction: column; align-items: stretch; gap: 0; padding: 0; cursor: default; overflow: hidden; }
.exam-main {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 16px 20px;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.exam-main:hover { background: color-mix(in srgb, var(--c) 5%, transparent); }
.exam-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.exam-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 9px 20px; border-top: 1px solid var(--border); }
.exam-actions .btn { padding: 6px 12px; font-size: 13px; }
.exam-actions .progress { flex: 1; min-width: 80px; max-width: 220px; margin: 0; }
.plan-progress { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.plan-progress .ic { width: 15px; height: 15px; color: var(--accent); }
.past-row { flex-wrap: wrap; }
.past-result { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.past-result .btn { padding: 5px 10px; font-size: 13px; }
.result-ask { font-size: 13px; color: var(--muted); }

/* Notenrechner */
.calc-card { margin-bottom: 18px; }
.calc-card h2 { display: inline-flex; align-items: center; gap: 8px; }
.calc-card h2 .ic { color: var(--accent); }
.calc-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.calc-row label { font-size: 13px; font-weight: 600; color: var(--muted); }
.calc-row input {
  width: 96px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.calc-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.calc-result { flex: 1; min-width: 220px; margin: 0; }
.calc-need { font-size: 18px; color: var(--accent); }
.calc-good, .calc-bad { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; }
.calc-good { color: var(--success); }
.calc-bad { color: var(--danger); }
.calc-good .ic, .calc-bad .ic { width: 16px; height: 16px; }

/* Unteraufgaben */
.task { flex-wrap: wrap; }
.subtasks { list-style: none; flex-basis: 100%; margin: 2px 0 0 34px; padding: 0; }
.subtask { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13.5px; cursor: pointer; }
.subtask input { width: 15px; height: 15px; accent-color: var(--accent); }
.subtask.done span { color: var(--faint); text-decoration: line-through; }

/* Fokus-Timer: Modul wählen */
.pomo-module {
  width: 100%;
  margin-bottom: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font-size: 13.5px;
}

/* Einstellungen: freie Tage, Archiv */
.free-list { list-style: none; margin: 8px 0 12px; padding: 0; }
.free-list li + li { border-top: 1px solid var(--border); }
.free-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 8px 4px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.free-item:hover { background: var(--surface-2); }
.archive-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.archive-item > span:first-child { display: flex; flex-direction: column; flex: 1; min-width: 0; }

/* Dialoge: Einleitung, Import, Konflikt */
.dlg-intro { grid-column: 1 / -1; margin: 0; font-size: 14px; color: var(--muted); }
.field[hidden] { display: none; }
.imp-body { display: block; max-height: min(60vh, 520px); overflow-y: auto; }
.imp-body .group-title { margin-top: 18px; }
.imp-row { display: flex; align-items: center; gap: 12px; padding: 9px 2px; border-top: 1px solid var(--border); cursor: pointer; }
.imp-row input[type=checkbox] { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.imp-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.imp-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-as { flex: none; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 13px; }
.conflict-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.conflict-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.conflict-opt:hover { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.conflict-opt .ic { width: 24px; height: 24px; color: var(--accent); margin-bottom: 4px; }

/* Konto & Sync */
.sync-state {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--faint);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.sync-state .ic { width: 15px; height: 15px; flex: none; }
.sync-state.s-ok .ic { color: var(--success); }
.sync-state.s-error .ic, .sync-state.s-conflict .ic { color: var(--danger); }
.sync-state.s-syncing .ic, .sync-state.s-pending .ic { color: var(--accent); animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sync-status { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-weight: 650; }
.sync-status .ic { width: 18px; height: 18px; }
.sync-status.s-ok { color: var(--success); }
.sync-status.s-error, .sync-status.s-conflict, .sync-status.s-unavailable { color: var(--danger); }
.sync-msg { margin: 4px 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); font-size: 13.5px; }
.sync-form .actions { margin-top: 4px; }

/* Toast mit Aktion */
.toast { display: flex; align-items: center; gap: 14px; }
.toast.has-action { pointer-events: auto; }
.toast-action {
  padding: 4px 10px;
  border: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 18%, transparent);
  color: inherit;
  font-weight: 750;
  cursor: pointer;
}

@media (max-width: 520px) {
  .conflict-grid { grid-template-columns: 1fr; }
  .exam-main { gap: 12px; padding: 14px; }
  .exam-actions { padding: 8px 14px; }
  .week-label { flex-basis: 100%; margin-left: 0; }
  .subtasks { margin-left: 34px; }
}

/* Altersbestätigung bei der Registrierung */
.age-check { display: flex; align-items: flex-start; gap: 10px; margin: 2px 0 14px; font-size: 14px; cursor: pointer; }
.age-check input { width: 18px; height: 18px; margin-top: 1px; flex: none; accent-color: var(--accent); }

/* Rechtstexte & Fußzeile */
.legal-foot { margin: 36px 0 0; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--faint); text-align: center; }
.legal-foot a { color: var(--muted); text-decoration: none; }
.legal-foot a:hover { color: var(--accent); text-decoration: underline; }
.legal-text { max-width: 820px; line-height: 1.65; }
.legal-text h2 { margin: 26px 0 8px; font-size: 17px; }
.legal-text h2:first-child { margin-top: 0; }
.legal-text h3 { margin: 18px 0 6px; font-size: 15px; }
.legal-text p, .legal-text ul { margin: 0 0 10px; }
.legal-text ul { padding-left: 22px; }
.legal-text a { color: var(--accent); }
.legal-text pre.license { overflow-x: auto; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); font-size: 12px; line-height: 1.5; white-space: pre-wrap; }
.legal-warn { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: var(--danger-soft); }
.legal-warn > .ic { color: var(--danger); }
.age-check a { color: var(--accent); }
body.onboarding .legal-foot { margin-top: 28px; }

/* ============ Karteikarten ============ */
:root { --hi: #ffd60a; --hi-ink: #1b1a10; --rule: color-mix(in srgb, var(--accent) 14%, var(--surface)); --card-red: var(--danger); }
.btn.hi { background: var(--hi); border-color: var(--hi); color: var(--hi-ink); }
.btn.hi:hover { background: color-mix(in srgb, var(--hi) 85%, black); }
.btn.onbox { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .35); color: #fff; }
.btn.onbox:hover { background: rgba(255, 255, 255, .2); border-color: #fff; }
.badge-count.info { background: var(--accent); color: var(--on-accent); }
code.tex { padding: 0 4px; border-radius: 4px; background: var(--surface-2); font-size: .9em; }

/* Kopfbereich: Karteikasten in Akzentfarbe mit 7-Tage-Vorschau */
.kartei-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 380px);
  gap: 22px;
  align-items: end;
  margin-bottom: 26px;
  padding: 22px 24px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 88%, black);
  color: #fff;
}
.kh-sum { display: flex; flex-wrap: wrap; gap: 10px 26px; margin-bottom: 18px; }
.kh-big { display: block; font-size: clamp(28px, 4vw, 38px); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.kh-sum small { font-size: 13.5px; opacity: .85; }
.kh-forecast { padding: 12px 14px 8px; border-radius: 12px; background: rgba(255, 255, 255, .09); }
.kh-forecast h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.kh-bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: end; height: 92px; }
.kh-bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; font-size: 12.5px; }
.kh-bar i { display: block; width: 100%; min-height: 3px; border-radius: 4px 4px 0 0; background: rgba(255, 255, 255, .38); }
.kh-bar.today i { background: var(--hi); }
.kh-bar b { font-weight: 650; font-variant-numeric: tabular-nums; }
.kh-labels { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-top: 4px; font-size: 12px; text-align: center; opacity: .85; }

/* Karteikarte: weiß, rote Kopflinie, hellblaue Linien */
.kcard {
  --lo: 58px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--surface);
  background-image: linear-gradient(var(--surface), var(--surface)), repeating-linear-gradient(to bottom, transparent 0 31px, var(--rule) 31px 32px);
  background-size: 100% var(--lo), auto;
  background-repeat: no-repeat, repeat;
  background-position: 0 0, 0 var(--lo);
  box-shadow: 0 1px 0 var(--border), 0 10px 24px -18px rgba(15, 25, 60, .45);
}
.kc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding-bottom: 10px; border-bottom: 2px solid var(--card-red); }
.kc-head h3 { margin: 0; font-size: 19px; font-weight: 750; letter-spacing: -.01em; overflow-wrap: anywhere; }
.kc-sec { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 10px; margin: 6px 0 14px; }
.kc-sec h2 { margin: 0; font-size: 20px; }
.kc-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); }
.kc-legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 2px; background: var(--c); }
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 18px; margin-bottom: 30px; }
.deck-tile { --lo: 62px; display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; }
.kc-counts { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14.5px; line-height: 32px; }
.kc-counts b, .study-counts span { font-weight: 750; font-variant-numeric: tabular-nums; }
.kn { color: var(--accent); }
.kl { color: var(--danger); }
.kr { padding: 0 6px; border-radius: 3px; background: var(--hi); color: var(--hi-ink); }
.kc-mix { display: flex; height: 8px; overflow: hidden; border-radius: 4px; background: var(--surface-2); }
.kc-mix i { display: block; height: 100%; }
.kc-actions { margin-top: auto; }
.kc-empty { --lo: 0px; max-width: 640px; padding: 26px; }
.kc-empty h3 { margin: 0 0 8px; font-size: 22px; }

/* Lernen */
.study-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; max-width: 760px; margin: 0 auto 16px; }
.study-top.wide { max-width: none; }
.study-top h2 { flex: 1 1 200px; margin: 0; font-size: 21px; }
.study-counts { display: flex; gap: 12px; font-size: 17px; }
.study-counts .cur { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; }
.study { max-width: 760px; margin: 0 auto; }
.study-card { --lo: 62px; display: flex; flex-direction: column; min-height: min(46vh, 400px); padding: 16px clamp(18px, 4vw, 40px) 28px; }
.study-card .kc-head { align-items: center; height: 46px; padding: 0; font-size: 14px; color: var(--muted); }
.face { padding-top: 16px; font: 20px/32px Charter, Georgia, Cambria, serif; overflow-wrap: anywhere; }
.face .katex-display { margin: 8px 0; padding: 4px 0; overflow-x: auto; overflow-y: hidden; }
.face .katex { font-size: 1.1em; }
.face-sep { margin: 22px 0 4px; border: 0; border-top: 2px dashed var(--card-red); opacity: .55; }
.reveal { width: 100%; min-height: 58px; margin-top: 18px; font-size: 17px; }
.rate { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.rate .btn { flex-direction: column; gap: 0; min-height: 62px; padding: 6px; line-height: 1.2; white-space: normal; }
.rate small { font-size: 12.5px; font-weight: 400; opacity: .85; }
.kbd-hint { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.study-under { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 12px; }
.study-done { --lo: 62px; padding: 24px clamp(18px, 4vw, 40px); }
.study-done h3 { margin: 14px 0 6px; font-size: 28px; }
.flip { animation: kflip .28s ease-out; }
@keyframes kflip { from { transform: perspective(900px) rotateX(8deg); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .flip { animation: none; } }

/* Bearbeiten */
.kc-panel { margin-bottom: 18px; }
.kc-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.kc-editor textarea, .kc-bulk {
  width: 100%;
  min-height: 110px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font: 14.5px/1.5 ui-monospace, Menlo, Consolas, monospace;
  resize: vertical;
}
.kc-editor textarea:focus, .kc-bulk:focus, .kc-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pv { --lo: 0px; min-height: 60px; margin-top: 8px; padding: 6px 14px; }
.pv .face { padding-top: 0; font-size: 17px; line-height: 28px; }
.pv:empty::before { content: "Vorschau"; font-size: 13px; color: var(--muted); }
.kc-panel details summary { display: flex; align-items: center; min-height: 36px; font-weight: 650; cursor: pointer; }
.hint { margin: 10px 0 0; font-size: 13.5px; color: var(--muted); }
.hint code, .kc-empty code { padding: 0 4px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); font-size: 12.5px; }
.kc-search { flex: 0 1 280px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.kc-list { display: flex; flex-direction: column; gap: 10px; }
.kc-item { --lo: 0px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 12px 14px; background-image: none; }
.kc-item .face { padding: 0; font-size: 16.5px; line-height: 26px; }
.kc-item.editing { outline: 3px solid var(--hi); }
.kc-lab { display: block; font-size: 12.5px; color: var(--muted); }
.kc-item-acts { display: flex; gap: 6px; }
.kc-item-acts .btn { padding: 6px 10px; font-size: 13px; }

/* Übersicht-Kachel */
.kw-sum { display: flex; gap: 22px; margin-bottom: 14px; }
.kw-sum > div { display: flex; flex-direction: column; }
.kw-big { font-size: 28px; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
  .kartei-head { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .kc-editor, .kc-item { grid-template-columns: minmax(0, 1fr); }
  .rate { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .face { font-size: 18px; line-height: 30px; }
  .kartei-head { padding: 18px 16px; }
  .kartei-head .actions .btn { flex: 1 1 auto; }
  .nav a { font-size: 9.5px; }
}

/* Lückentexte, Bilder, Prüfungsvorbereitung */
.cloze { padding: 0 3px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); font-weight: 650; }
.cloze.blank { display: inline-block; min-width: 2.4em; text-align: center; background: var(--hi); color: var(--hi-ink); }
.kimg { display: block; max-width: 100%; max-height: 52vh; margin: 8px 0; border-radius: 6px; background: var(--surface-2); object-fit: contain; }
.kimg:not([src]) { width: 160px; height: 90px; }
.kimg.missing { width: auto; height: auto; padding: 6px 10px; font: 13px/1.4 system-ui, sans-serif; color: var(--muted); }
.kc-item .kimg { max-height: 140px; }
.pv .kimg { max-height: 200px; }
.kc-label-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.kc-label-row label { margin: 0; }
.kc-tools { display: flex; gap: 6px; }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn.small svg { width: 15px; height: 15px; }
.kc-exam { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px 10px; border-radius: 8px; background: color-mix(in srgb, var(--hi) 45%, transparent); font-size: 13.5px; line-height: 1.4; }
.kc-exam svg { flex: none; width: 16px; height: 16px; }
.kc-exam span { flex: 1 1 160px; }
.cram-bar { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.rate.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Lernkalender */
.kc-stats { margin-top: 8px; }
.ks-sum { display: flex; flex-wrap: wrap; gap: 12px 30px; margin-bottom: 16px; }
.ks-sum small { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); }
.ks-sum .kh-big { font-size: clamp(24px, 3.4vw, 32px); }
.heat-wrap { overflow-x: auto; padding-bottom: 4px; direction: rtl; } /* schmal: neueste Wochen zuerst sichtbar */
.heat-wrap > * { direction: ltr; }
.heat-months, .heat { display: grid; grid-template-columns: repeat(var(--w), 14px); gap: 3px; min-width: max-content; }
.heat-months { margin-bottom: 4px; font-size: 11px; color: var(--muted); }
.heat-months span { white-space: nowrap; overflow: visible; width: 14px; }
.heat { grid-template-rows: repeat(7, 14px); grid-auto-flow: column; }
.heat i, .heat-legend i { display: block; width: 14px; height: 14px; border-radius: 3px; background: var(--surface-2); }
.heat i.future { background: transparent; }
.heat .l1, .heat-legend .l1 { background: color-mix(in srgb, var(--accent) 28%, var(--surface-2)); }
.heat .l2, .heat-legend .l2 { background: color-mix(in srgb, var(--accent) 50%, var(--surface-2)); }
.heat .l3, .heat-legend .l3 { background: color-mix(in srgb, var(--accent) 74%, var(--surface-2)); }
.heat .l4, .heat-legend .l4 { background: var(--accent); }
.heat-legend { display: flex; align-items: center; gap: 4px; margin-top: 8px; font-size: 12px; color: var(--muted); }

/* ---------- Notizen: Bibliothek ---------- */
.nb-actions { margin-bottom: 18px; }
.nb-filter { flex-wrap: wrap; width: fit-content; max-width: 100%; margin-bottom: 20px; }
.nb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 168px), 1fr)); gap: 26px 22px; }
.nb-item { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.nb-cover {
  position: relative; display: flex; align-items: flex-start; width: 100%; aspect-ratio: 3 / 4; padding: 26px 14px 0 26px;
  border: 0; border-radius: 5px 12px 12px 5px; cursor: pointer; text-align: left;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 82%, white), var(--c) 55%, color-mix(in srgb, var(--c) 80%, black));
  box-shadow: inset -2px 0 0 rgba(255, 255, 255, .12), 0 1px 1px rgba(0, 0, 0, .1), 0 10px 22px -12px rgba(0, 0, 0, .45);
  transition: transform .15s ease, box-shadow .15s ease;
}
.nb-cover:hover { transform: translateY(-3px); box-shadow: 0 1px 1px rgba(0, 0, 0, .1), 0 16px 28px -14px rgba(0, 0, 0, .5); }
.nb-cover:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.nb-band { position: absolute; inset: 0 auto 0 0; width: 13px; border-radius: 5px 0 0 5px; background: rgba(0, 0, 0, .18); box-shadow: 1px 0 0 rgba(255, 255, 255, .15); }
.nb-label { display: flex; flex-direction: column; gap: 3px; width: 100%; padding: 10px 12px; border-radius: 6px; background: rgba(255, 255, 255, .93); color: #1c1b19; box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.nb-label strong { font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.nb-label small { font-size: 12px; color: #69675f; }
.nb-pdf { position: absolute; right: 12px; bottom: 12px; padding: 2px 7px; border-radius: 6px; background: rgba(255, 255, 255, .85); color: #1c1b19; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.nb-meta { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 13px; color: var(--muted); }
.nb-meta .icon-btn { width: 32px; height: 32px; }
.nb-empty .empty .btn { margin: 4px; }

/* ---------- Notizen: Editor (Vollbild) ---------- */
body.ne-open { overflow: hidden; }
.ne {
  position: fixed; inset: 0; z-index: 80; display: grid; grid-template-rows: auto minmax(0, 1fr);
  background: #e6e4dd; color: var(--text);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ne { background: #0d0d10; } }
:root[data-theme="dark"] .ne { background: #0d0d10; }
.ne-bar {
  display: flex; align-items: center; gap: 6px; padding: 7px 10px; overflow-x: auto; scrollbar-width: none;
  background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: 0 1px 8px rgba(0, 0, 0, .06);
}
.ne-group { display: flex; align-items: center; gap: 3px; flex: none; padding: 0 4px; border-left: 1px solid var(--border); }
.ne-spacer { flex: 1 1 0; min-width: 4px; }
.ne-spacer + .ne-group { border-left: 0; }
.ne-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; flex: none; min-width: 38px; height: 38px; padding: 0 9px;
  border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.ne-btn:hover { background: var(--surface-2); }
.ne-btn.on { background: var(--accent-soft); color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.ne-btn.danger { color: var(--danger); }
.ne-btn svg { width: 19px; height: 19px; }
.ne-chip { height: 32px; font-size: 13px; border-color: var(--border); }
.ne-title {
  flex: 0 1 220px; min-width: 90px; height: 38px; padding: 0 10px; border: 1px solid transparent; border-radius: 9px;
  background: transparent; color: var(--text); font: inherit; font-size: 15px; font-weight: 700; text-overflow: ellipsis;
}
.ne-title:hover, .ne-title:focus { border-color: var(--border); background: var(--surface-2); outline: none; }
.ne-opts { gap: 5px; }
.ne-swatch {
  position: relative; flex: none; width: 26px; height: 26px; padding: 0; border: 2px solid var(--surface); border-radius: 50%;
  background: var(--c); box-shadow: 0 0 0 1px var(--border); cursor: pointer;
}
.ne-swatch.on { box-shadow: 0 0 0 2px var(--accent); }
.ne-custom { background: conic-gradient(#f03e3e, #fab005, #40c057, #15aabf, #4c6ef5, #be4bdb, #f03e3e); }
.ne-custom.on { background: var(--c); }
.ne-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.ne-sep { width: 1px; height: 24px; margin: 0 4px; background: var(--border); }
.ne-size { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--text); cursor: pointer; }
.ne-size i { display: block; width: var(--d); height: var(--d); border-radius: 50%; background: currentColor; }
.ne-size.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--accent-strong); }
.ne-hint { padding: 0 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.ne-scroll { position: relative; overflow: auto; outline: none; overscroll-behavior: contain; }
.ne-pages {
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  width: max(100%, calc(var(--pw) + 28px)); padding: 20px 14px 96px; touch-action: none; user-select: none; -webkit-user-select: none;
}
.ne-page {
  position: relative; flex: none; width: var(--pw); aspect-ratio: var(--ar); background: #fff; cursor: crosshair;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 8px 24px -10px rgba(0, 0, 0, .35);
}
.ne-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ne-ov { pointer-events: none; }
.ne-pagemenu {
  position: absolute; top: 6px; right: 6px; z-index: 2; display: grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 8px; background: rgba(255, 255, 255, .75); color: #555; cursor: pointer; opacity: .55;
}
.ne-pagemenu:hover, .ne-pagemenu:focus-visible { opacity: 1; }
.ne-pagemenu svg { width: 18px; height: 18px; }
.ne-selbox { position: absolute; z-index: 1; border: 1.5px dashed var(--accent); border-radius: 4px; background: color-mix(in srgb, var(--accent) 6%, transparent); pointer-events: none; }
.ne-addpage {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: var(--pw); height: 64px; flex: none;
  border: 2px dashed color-mix(in srgb, var(--muted) 45%, transparent); border-radius: 10px; background: none; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer;
}
.ne-foot, .ne-selbar {
  position: fixed; z-index: 81; display: flex; align-items: center; gap: 4px; padding: 5px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface); box-shadow: 0 6px 22px -8px rgba(0, 0, 0, .35);
}
.ne-foot { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); }
.ne-foot .ne-btn { min-width: 34px; height: 34px; font-size: 16px; }
.ne-foot .ne-zoomval { min-width: 64px; font-size: 13px; font-variant-numeric: tabular-nums; }
.ne-pageno { padding: 0 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.ne-selbar { left: 50%; bottom: calc(70px + env(safe-area-inset-bottom)); transform: translateX(-50%); }
.ne-selbar[hidden] { display: none; }
.ne-bar::-webkit-scrollbar { display: none; }
@media (max-width: 1220px) { .ne-lab { display: none; } .ne-hint { display: none; } }
.ne-row2 { display: contents; }
@media (max-width: 760px) {
  .ne-bar { flex-wrap: wrap; row-gap: 4px; }
  .ne-row2 { order: 10; display: flex; align-items: center; flex: 1 1 100%; gap: 3px; overflow-x: auto; scrollbar-width: none; padding-top: 5px; border-top: 1px solid var(--border); }
  .ne-row2::-webkit-scrollbar { display: none; }
  .ne-row2 .ne-group:first-child { border-left: 0; }
  .ne-title { flex: 1 1 80px; font-size: 14px; }
  .ne-bar { gap: 3px; padding: 6px; }
  .ne-pageno { display: none; }
  .ne-hint { display: none; }
}
.kc-warn { background: color-mix(in srgb, var(--danger) 14%, transparent); }

/* ---------- Notizen: iPad-Feinschliff ---------- */
/* Sicherer Bereich (Statusleiste, Fenster-Steuerung, abgerundete Ecken) */
.ne-bar {
  padding-top: max(7px, var(--top-inset));
  padding-left: max(10px, env(safe-area-inset-left));
  padding-right: max(10px, env(safe-area-inset-right));
}
.ne-foot { right: max(14px, env(safe-area-inset-right)); transition: opacity .25s ease, transform .25s ease; }
.ne-foot.idle { opacity: 0; transform: translateY(8px); pointer-events: none; }
.ne-pages { -webkit-touch-callout: none; }
.ne-optbtn { min-width: 34px; height: 34px; color: var(--muted); }

/* Radierer-Vorschau */
.ne-ring { position: absolute; z-index: 3; border: 1.5px solid rgba(60, 60, 70, .7); border-radius: 50%; background: rgba(255, 255, 255, .25); box-shadow: 0 0 0 1px rgba(255, 255, 255, .8); pointer-events: none; }

/* Werkzeug-Optionen */
.ne-pop {
  position: fixed; z-index: 82; top: calc(max(7px, var(--top-inset)) + 58px); left: 50%; transform: translateX(-50%);
  width: min(400px, calc(100vw - 24px)); max-height: calc(100vh - 140px); overflow-y: auto; padding: 6px 14px 12px;
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text);
  box-shadow: 0 18px 44px -14px rgba(0, 0, 0, .45);
}
.ne-pop[hidden] { display: none; }
.ne-pop-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 2px; font-size: 16px; }
.ne-pop-sec { padding: 10px 0; border-top: 1px solid var(--border); }
.ne-pop-head + .ne-pop-sec { border-top: 0; }
.ne-pop-lab { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 13px; font-weight: 650; color: var(--muted); }
.ne-pop-lab output, .ne-pop-lab small { font-weight: 500; font-variant-numeric: tabular-nums; }
.ne-pop input[type="range"] { width: 100%; accent-color: var(--accent); }
.ne-segs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ne-seg { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 4px; border: 1px solid var(--border); border-radius: 10px; background: none; color: var(--text); font: inherit; cursor: pointer; }
.ne-seg strong { font-size: 13.5px; }
.ne-seg small { font-size: 11px; color: var(--muted); }
.ne-seg.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.ne-preview { display: block; width: 100%; height: 36px; margin-top: 6px; border-radius: 8px; background: #fff; }
.ne-palette { display: flex; flex-wrap: wrap; gap: 10px; }
.ne-pal { position: relative; display: inline-flex; }
.ne-pal-x {
  position: absolute; top: -7px; right: -7px; display: grid; place-items: center; width: 17px; height: 17px; padding: 0;
  border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--muted); font-size: 12px; line-height: 1; cursor: pointer;
}
.ne-tog { display: flex; align-items: flex-start; gap: 10px; padding: 8px 0; cursor: pointer; }
.ne-tog input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--accent); flex: none; }
.ne-tog span { display: flex; flex-direction: column; gap: 1px; font-size: 14px; }
.ne-tog small { font-size: 12px; color: var(--muted); }
.ne-pop-foot .ne-tog { padding-bottom: 0; }

/* ---------- Notizen: Lineal, Text, Auswahl, Seitenübersicht ---------- */
.ne-ruler {
  position: fixed; left: 0; top: 0; z-index: 79; transform-origin: center; touch-action: none; cursor: grab;
  border: 1px solid rgba(40, 50, 70, .35); border-radius: 8px;
  background: rgba(236, 240, 246, .72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  box-shadow: 0 6px 18px -8px rgba(0, 0, 0, .4);
}
.ne-ruler.snap { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent), 0 6px 18px -8px rgba(0, 0, 0, .4); }
.ne-ruler-ticks { position: absolute; inset: 0; width: 100%; height: 100%; stroke: #3b4252; stroke-width: 1; font: 10px system-ui, sans-serif; fill: #3b4252; pointer-events: none; }
.ne-ruler-ang {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 3px 10px; border: 0; border-radius: 12px;
  background: rgba(30, 34, 44, .82); color: #fff; font: 600 13px system-ui, sans-serif; cursor: pointer;
}
.ne-ruler-rot {
  position: absolute; right: -14px; top: 50%; width: 26px; height: 26px; margin-top: -13px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); cursor: alias;
}
.ne-text {
  position: absolute; z-index: 4; padding: 0; margin: 0; border: 1.5px dashed var(--accent); border-radius: 3px; outline: none;
  background: rgba(255, 255, 255, .85); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; line-height: 1.3; resize: none; overflow: hidden;
}
.ne-selh {
  position: absolute; right: -11px; bottom: -11px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); pointer-events: auto; cursor: nwse-resize; touch-action: none;
}
.ne-segs5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ne-lab2 { margin-left: 2px; }
@media (max-width: 560px) { .ne-lab2 { display: none; } }

/* Seitenübersicht */
.ne-side {
  position: fixed; z-index: 83; left: 0; top: 0; bottom: 0; width: min(250px, 80vw); display: flex; flex-direction: column;
  padding: max(8px, var(--top-inset)) 10px 10px max(10px, env(safe-area-inset-left));
  background: var(--surface); border-right: 1px solid var(--border); box-shadow: 8px 0 30px -12px rgba(0, 0, 0, .4);
}
.ne-side[hidden] { display: none; }
.ne-side-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 2px 8px; font-size: 16px; }
.ne-side-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 4px 2px; }
.ne-th { display: flex; flex-direction: column; gap: 4px; }
.ne-th-img { display: block; width: 100%; aspect-ratio: var(--ar); padding: 0; border: 2px solid var(--border); border-radius: 6px; background: #fff; overflow: hidden; cursor: pointer; }
.ne-th.cur .ne-th-img { border-color: var(--accent); }
.ne-th-img canvas { display: block; width: 100%; height: 100%; }
.ne-th-bar { display: flex; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); }
.ne-th-bar span { flex: 1; padding-left: 4px; font-weight: 650; }
.ne-th-bar .ne-btn { min-width: 30px; height: 30px; padding: 0 5px; }
.ne-th-bar .ne-btn svg { width: 16px; height: 16px; }
.ne-th-bar .ne-btn:disabled { opacity: .35; }
.ne-side-add { display: flex; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.ne-side-add select { flex: 1; min-width: 0; height: 34px; padding: 0 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }

/* iPad/iPhone (iPadOS 26, „Liquid Glass“): Inhalt nicht unter die durchsichtige Statusleiste scrollen lassen,
   sondern den Bereich deckend in der App-Farbe füllen und alles darunter beginnen lassen. */
body { padding-top: var(--top-inset); }
body::before {
  content: ""; position: fixed; z-index: 75; top: 0; left: 0; right: 0; height: var(--top-inset);
  background: var(--surface); pointer-events: none;
}
/* nur die Seitenleiste am Tablet/Desktop; am Handy ist sie die Leiste unten */
@media (min-width: 861px) {
  .sidebar { top: var(--top-inset); height: calc(100vh - var(--top-inset)); padding-left: max(14px, env(safe-area-inset-left)); }
}

/* ---------- Wissen (verknüpfte Notizen) ---------- */
.wk-actions { margin-bottom: 18px; }
.wk-actions .btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.wk { display: grid; grid-template-columns: minmax(220px, 290px) minmax(0, 1fr); gap: 20px; align-items: start; }
.wk-list { position: sticky; top: calc(var(--top-inset) + 12px); max-height: calc(100vh - 40px); overflow: auto; display: flex; flex-direction: column; gap: 10px; padding: 2px; }
.wk-search { width: 100%; }
.wk-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.wk-items, .wk-also { display: flex; flex-direction: column; gap: 2px; }
.wk-sub { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 10px 8px 4px; }
.wk-item { display: flex; align-items: center; gap: 10px; text-align: left; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); cursor: pointer; font: inherit; }
.wk-item:hover { background: var(--surface-2); }
.wk-item.on { background: var(--accent-soft); }
.wk-item > span { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.wk-item strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-item small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wk-item > svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.wk-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.wk-main { min-width: 0; }
.wk-placeholder { padding: 40px 0; }
.wk-note { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px 22px; }
.wk-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wk-backbtn { display: none; }
.wk-title { flex: 1; min-width: 180px; font-size: 24px; font-weight: 700; border: 0; background: none; color: var(--text); padding: 4px 2px; border-radius: 6px; }
.wk-title:focus { outline: 2px solid var(--accent-soft); }
.wk-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 14px; }
.wk-meta select, .wk-search { height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13.5px; }
.wk-meta select { max-width: 220px; min-width: 0; }
.wk-search { height: 38px; font-size: 14.5px; }
.wk-search:focus, .wk-meta select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.wk-body { display: grid; gap: 18px; }
.wk-body.mode-split { grid-template-columns: 1fr 1fr; }
.wk-body.mode-edit .wk-preview, .wk-body.mode-read .wk-edit { display: none; }
.wk-edit { position: relative; }
.wk-editor { width: 100%; min-height: 58vh; resize: vertical; font: 15px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; padding: 14px; border-radius: var(--radius-sm); tab-size: 2; }
.wk-ac { position: absolute; left: 12px; right: 12px; top: 44px; z-index: 5; max-height: 290px; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 4px; }
.wk-ac[hidden] { display: none; }
.wk-ac-item { display: flex; justify-content: space-between; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.wk-ac-item small { color: var(--muted); }
.wk-ac-item.on, .wk-ac-item:hover { background: var(--accent-soft); }
.wk-preview { min-height: 120px; overflow-wrap: anywhere; }
.wk-body.mode-split .wk-preview { border-left: 1px solid var(--border); padding-left: 18px; max-height: 70vh; overflow: auto; }
.wk-foot { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 320px); gap: 20px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.wk-foot h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 0 0 10px; }
.wk-foot h3 svg { width: 17px; height: 17px; color: var(--muted); }
.wk-foot h3 small { color: var(--muted); font-weight: 500; }
.wk-foot h4 { font-size: 13px; color: var(--muted); margin: 16px 0 6px; }
.wk-ref { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: inherit; margin-bottom: 6px; cursor: pointer; }
div.wk-ref { cursor: default; }
.wk-ref small { color: var(--muted); font-size: 12.5px; }
.wk-ref .btn { margin-top: 4px; }
.wk-graph-local { width: 100%; height: 240px; border-radius: var(--radius-sm); background: var(--surface-2); display: block; }
.wk-graphbox { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.wk-graphbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.wk-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; }
.wk-graph-full { width: 100%; height: calc(100vh - 230px); min-height: 380px; display: block; cursor: grab; }

/* Markdown-Darstellung */
.md { line-height: 1.65; font-size: 15.5px; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { line-height: 1.3; margin: 1.3em 0 .5em; }
.md h1 { font-size: 1.6em; }
.md h2 { font-size: 1.35em; }
.md h3 { font-size: 1.15em; }
.md h4, .md h5, .md h6 { font-size: 1em; }
.md p { margin: .6em 0; }
.md ul, .md ol { margin: .5em 0; padding-left: 1.5em; }
.md li { margin: .15em 0; }
.md li.md-task { list-style: none; margin-left: -1.4em; }
.md li.md-task > input { margin-right: 4px; vertical-align: -2px; accent-color: var(--accent); width: 16px; height: 16px; }
.md li.md-task:has(> input:checked) { color: var(--muted); text-decoration: line-through; }
.md blockquote { margin: .8em 0; padding: 4px 14px; border-left: 3px solid var(--border); color: var(--muted); }
.md code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--surface-2); padding: 12px 14px; border-radius: var(--radius-sm); overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; margin: .8em 0; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--surface-2); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.4em 0; }
.md mark { background: var(--hi); color: var(--hi-ink); padding: 0 2px; border-radius: 3px; }
.md a { color: var(--accent-strong); }
.md-link { text-decoration: none; border-bottom: 1px solid var(--accent-soft); cursor: pointer; }
.md-link:hover { border-bottom-color: var(--accent); }
.md-link.md-unresolved { color: var(--muted) !important; border-bottom-style: dashed; border-bottom-color: var(--muted); }
.md-link.md-module::before, .md-link.md-deck::before, .md-link.md-notebook::before { font-size: .8em; margin-right: 3px; }
.md-link.md-module::before { content: "▣"; }
.md-link.md-deck::before { content: "▤"; }
.md-link.md-notebook::before { content: "✎"; }
.md-tag { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: .86em; text-decoration: none; border: 0; font-family: inherit; cursor: pointer; }
button.md-tag { font-size: 12.5px; padding: 3px 9px; }
.md-tag small { color: var(--muted); }
.md-tag.on { background: var(--accent); color: var(--on-accent); }
.md-callout { border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius-sm); padding: 8px 14px; margin: .8em 0; color: var(--text); }
.md-callout-title { font-weight: 700; margin-bottom: 2px; }
.md-callout-warning, .md-callout-caution, .md-callout-attention, .md-callout-important { border-color: var(--warn); background: var(--warn-soft); }
.md-callout-danger, .md-callout-error, .md-callout-bug, .md-callout-failure { border-color: var(--danger); background: var(--danger-soft); }
.md-callout-success, .md-callout-check, .md-callout-done, .md-callout-tip, .md-callout-hint { border-color: var(--success); background: var(--success-soft); }
.md .md-math[data-display="1"] { display: block; text-align: center; margin: .8em 0; overflow-x: auto; }

@media (max-width: 1100px) {
  .wk-body.mode-split { grid-template-columns: 1fr; }
  .wk-body.mode-split .wk-preview { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 14px; max-height: none; }
}
@media (max-width: 860px) {
  .wk { grid-template-columns: 1fr; }
  .wk-list { position: static; max-height: none; }
  .wk.has-main .wk-list { display: none; }
  .wk-backbtn { display: inline-flex; }
  .wk-note { padding: 14px; }
  .wk-foot { grid-template-columns: 1fr; }
  .wk-title { font-size: 20px; }
  .wk-editor { min-height: 50vh; }
  .wk-graph-full { height: calc(100vh - 260px); }
}

/* Lineal: Griffe zum Ändern der Länge */
.ne-ruler-end {
  position: absolute; top: 50%; width: 12px; height: 34px; margin-top: -17px; border-radius: 6px; cursor: ew-resize; touch-action: none;
  background: rgba(30, 34, 44, .55); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .55);
}
.ne-ruler-end::after { content: ""; position: absolute; inset: -14px -12px; } /* größere Tippfläche */
.ne-ruler-end[data-end="-1"] { left: 6px; }
.ne-ruler-end[data-end="1"] { right: 18px; }
/* Am Heft-Ende weiterziehen: neue Seite */
.ne-pull {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 78; display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px; background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600;
  border: 1px solid var(--border); box-shadow: 0 6px 22px -8px rgba(0, 0, 0, .35); pointer-events: none;
  transform: translate(-50%, calc((1 - var(--p, 0)) * 30px)); opacity: calc(.35 + var(--p, 0) * .65);
}
.ne-pull svg { width: 18px; height: 18px; transition: transform .2s; }
.ne-pull.ready { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.ne-pull.ready svg { transform: rotate(90deg); }

/* ---------- Notizen: Ordner ---------- */
.nb-crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: -6px 0 18px; color: var(--muted); }
.nb-crumb { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 0; border-radius: 8px; background: none; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.nb-crumb svg { width: 16px; height: 16px; }
.nb-crumb:hover { background: var(--surface-2); color: var(--text); }
.nb-crumb.on { color: var(--text); }
.nb-search { width: min(100%, 320px); height: 38px; margin: 0 0 18px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; }
.nb-folder {
  position: relative; display: flex; flex-direction: column; width: 100%; aspect-ratio: 3 / 4; padding: 0; border: 0; background: none; cursor: pointer; text-align: left;
  transition: transform .15s ease;
}
.nb-folder:hover { transform: translateY(-2px); }
.nb-folder-tab { width: 46%; height: 14%; margin-top: 12%; border-radius: 10px 10px 0 0; background: color-mix(in srgb, var(--c) 75%, black); }
.nb-folder-body {
  flex: 1; display: flex; align-items: flex-end; margin-top: -2px; padding: 14px; border-radius: 0 12px 12px 12px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 78%, white), var(--c));
  box-shadow: 0 1px 1px rgba(0, 0, 0, .1), 0 10px 22px -12px rgba(0, 0, 0, .45);
}
.nb-folder-body strong { width: 100%; padding: 8px 10px; border-radius: 6px; background: rgba(255, 255, 255, .93); color: #1c1b19; font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; }
.nb-label small svg { width: 12px; height: 12px; vertical-align: -1px; margin-right: 3px; }
.nb-dragging [data-drop] { outline: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 3px; }
[data-drop].drop-on { outline: 3px solid var(--accent) !important; outline-offset: 3px; }

/* ---------- KI-Funktionen ---------- */
body:not(.ai-on) .ai-only { display: none !important; }
.dlg-foot { flex-wrap: wrap; }
.dialog:has(.ai-dlg.wide) { width: min(820px, calc(100vw - 32px)); }
.ai-dlg { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.ai-dlg .dlg-head h2 { display: flex; align-items: center; gap: 8px; }
.ai-dlg .dlg-head h2 svg { width: 19px; height: 19px; color: var(--accent); flex: none; }
.ai-dlg .dlg-body { display: block; overflow: auto; padding-bottom: 8px; }
.ai-dlg .form-grid { display: grid; gap: 12px; }
.ai-dlg .field { margin-bottom: 10px; }
.ai-dlg textarea, .ai-dlg select, .ai-dlg input:not([type=checkbox]) { width: 100%; }
.ai-busy { display: grid; justify-items: center; gap: 6px; padding: 22px 0 10px; text-align: center; }
.ai-busy p { margin: 0; }
.ai-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: ai-spin .8s linear infinite; }
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-h { font-size: 14px; margin: 16px 0 6px; color: var(--muted); }
.ai-pick { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; }
.ai-pick:hover { background: var(--surface-2); }
.ai-pick input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.ai-pick > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ai-pick small { color: var(--muted); font-size: 12.5px; }
.ai-cards { display: grid; gap: 4px; }
.ai-card { display: grid !important; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; font-size: 14px; }
.ai-card .katex { font-size: 1em; }
.ai-events { display: grid; gap: 6px; }
.ai-ev { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; border: 1px solid var(--border); border-radius: 10px; padding: 4px 8px 4px 0; }
.ai-ev-opts { display: flex; gap: 6px; padding-left: 36px; }
.ai-ev-opts select { width: auto !important; height: 32px; font-size: 13px; }
.ai-hub { display: grid; gap: 6px; }
.ai-hub-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.ai-hub-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.ai-hub-item > svg { width: 22px; height: 22px; color: var(--accent); flex: none; }
.ai-hub-item > span { display: flex; flex-direction: column; gap: 1px; }
.ai-hub-item small { color: var(--muted); font-size: 12.5px; }
.ai-setup { margin: 8px 0; padding-left: 20px; line-height: 1.6; }
.setting-check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.setting-check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.setting-check > span { display: flex; flex-direction: column; gap: 2px; }
.setting-check small { color: var(--muted); font-size: 12.5px; }
/* Fragen an die Notizen */
.ai-ask { display: flex; flex-direction: column; min-height: min(72vh, 760px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ai-ask .wk-graphbar strong { display: inline-flex; align-items: center; gap: 6px; }
.ai-ask .wk-graphbar strong svg { width: 17px; height: 17px; color: var(--accent); }
.ai-chat { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; max-height: 64vh; }
.ai-q { align-self: flex-end; max-width: 85%; padding: 9px 13px; border-radius: 14px 14px 4px 14px; background: var(--accent); color: var(--on-accent); white-space: pre-wrap; }
.ai-a { align-self: stretch; padding: 4px 2px; }
.ai-a-tools { display: flex; gap: 6px; margin-top: 4px; }
.ai-empty { display: grid; gap: 8px; justify-items: start; color: var(--muted); }
.ai-empty .chip { text-align: left; white-space: normal; height: auto; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); cursor: pointer; font: inherit; font-size: 14px; }
.ai-input { display: flex; gap: 8px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--border); }
.ai-input textarea { flex: 1; min-height: 44px; max-height: 180px; resize: vertical; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; }
/* Lernen */
.ai-study { width: 100%; max-width: 640px; margin: 12px auto 0; display: grid; gap: 10px; }
.ai-answer { display: flex; gap: 8px; align-items: flex-end; }
.ai-answer textarea { flex: 1; min-height: 44px; resize: vertical; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; }
.ai-grade { padding: 10px 14px; border-radius: 12px; border-left: 4px solid var(--warn); background: var(--warn-soft); }
.ai-grade.richtig { border-color: var(--success); background: var(--success-soft); }
.ai-grade.falsch { border-color: var(--danger); background: var(--danger-soft); }
.ai-grade .md { font-size: 14.5px; margin: 4px 0; }
.ai-explain { padding: 10px 14px; border-radius: 12px; background: var(--surface-2); }
.ai-explain .md { font-size: 14.5px; }
.ai-study-tools { justify-content: center; }
@media (max-width: 600px) { .ai-card { grid-template-columns: 1fr; gap: 2px; } .ai-ev-opts { padding-left: 10px; } }
.ne-ai { color: var(--accent-strong); }
.ne-ai .ne-lab2 { display: inline; margin-left: 4px; font-weight: 650; font-size: 13px; }
.ai-status-line { font-weight: 550; }

/* ---------- Hefte: erweiterte Werkzeugleiste ---------- */
.ne:has(.ne-tabs) { grid-template-rows: auto auto minmax(0, 1fr); }
.ne-tabs {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: max(6px, var(--top-inset)) 10px 0 max(10px, env(safe-area-inset-left));
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.ne-tabs::-webkit-scrollbar { display: none; }
.ne-tabs + .ne-bar { padding-top: 6px; }
.ne-tab { display: inline-flex; align-items: center; flex: none; max-width: 240px; border-radius: 10px 10px 0 0; background: transparent; }
.ne-tab.on { background: var(--surface); box-shadow: 0 -1px 0 var(--border) inset; }
.ne-tab > button:first-child { display: inline-flex; align-items: center; gap: 8px; min-width: 0; height: 34px; padding: 0 6px 0 12px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ne-tab > button:first-child::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c); flex: none; }
.ne-tab.on > button:first-child { color: var(--text); }
.ne-tab-x { display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 4px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.ne-tab-x:hover { background: var(--surface-2); }
.ne-tab-x svg { width: 14px; height: 14px; }
.ne .tb-off { display: none !important; }
.ne-left { border-left: 0; }
.ne-ro .ne-lab2:empty { display: none; }
.ne-bar.ro .ne-tools { opacity: .45; }
.ne-bar.ro .ne-ro { background: var(--accent); color: var(--on-accent); }
.ne-rec.on { color: #fff; background: #e03131; border-color: #e03131; animation: ne-pulse 1.6s ease-in-out infinite; }
@keyframes ne-pulse { 50% { box-shadow: 0 0 0 5px rgba(224, 49, 49, .18); } }
.ne-segs4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* zwei Zeilen: oben Navigation und Zubehör, darunter mittig die Werkzeuge */
@media (max-width: 1500px) {
  .ne-bar { flex-wrap: wrap; row-gap: 4px; }
  .ne-row2 { order: 10; display: flex; align-items: center; justify-content: center; flex: 1 1 100%; gap: 3px; overflow-x: auto; scrollbar-width: none; padding-top: 5px; border-top: 1px solid var(--border); }
  .ne-row2::-webkit-scrollbar { display: none; }
  .ne-row2 .ne-group:first-child { border-left: 0; }
}
@media (max-width: 760px) { .ne-row2 { justify-content: flex-start; } }
.ne-pop { top: calc(max(7px, var(--top-inset)) + 104px); }

/* Haftnotiz beim Schreiben */
.ne-text.ne-sticky { border: 0; border-radius: 2px; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); line-height: 1.3; }

/* Seitenleisten (Suche, KI, Aufnahmen, Sticker) */
.ne-panel {
  position: fixed; z-index: 84; top: calc(var(--top-inset) + 112px); bottom: 12px; width: min(360px, calc(100vw - 24px)); display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: 0 18px 50px -14px rgba(0, 0, 0, .45);
}
.ne-panel-right { right: max(12px, env(safe-area-inset-right)); }
.ne-panel-left { left: max(12px, env(safe-area-inset-left)); }
.ne-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 6px 14px; border-bottom: 1px solid var(--border); }
.ne-panel-head strong { display: inline-flex; align-items: center; gap: 7px; }
.ne-panel-head strong svg { width: 18px; height: 18px; color: var(--accent); }
.ne-panel-body { flex: 1; min-height: 0; overflow: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.ne-find-in { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; }
.ne-find-res { display: flex; flex-direction: column; gap: 6px; }
.ne-find-hit { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; text-align: left; padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.ne-find-hit:hover { border-color: var(--accent); }
.ne-find-hit small { color: var(--muted); justify-self: end; }
.ne-find-hit span { grid-column: 1 / -1; font-size: 13.5px; color: var(--muted); }
.ne-find-hit mark { background: var(--hi); color: var(--hi-ink); border-radius: 3px; padding: 0 2px; }
.ne-page.ne-flash { animation: ne-flash 1.2s ease; }
@keyframes ne-flash { 30% { box-shadow: 0 0 0 4px var(--accent); } }
.ne-ai-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.ne-ai-quick .chip { height: auto; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.ne-ai-quick .chip:hover { border-color: var(--accent); }
.ne-ai-chat { flex: 1; min-height: 120px; max-height: none; overflow: auto; padding: 4px 0; }
.ne-ai-form { padding: 0; border: 0; }
.ne-el-sec { display: flex; flex-direction: column; gap: 8px; }
.ne-el-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ne-el { display: grid; place-items: center; height: 74px; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.ne-el:hover { border-color: var(--accent); }
.ne-el img { max-width: 100%; max-height: 56px; }
.ne-el-list { display: flex; flex-direction: column; gap: 6px; }
.ne-el-own { display: flex; align-items: center; gap: 4px; }
.ne-el-wide { flex: 1; display: flex; justify-content: flex-start; gap: 8px; height: 44px; color: var(--text); font: inherit; font-weight: 600; }
.ne-el-wide svg { width: 18px; height: 18px; color: var(--accent); }
/* Menü (Zubehör) */
.ne-menu { position: fixed; z-index: 85; width: 250px; padding: 6px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 18px 44px -14px rgba(0, 0, 0, .45); display: flex; flex-direction: column; }
.ne-menu-title { padding: 6px 10px 8px; font-size: 13px; color: var(--muted); }
.ne-menu-item { display: flex; align-items: center; gap: 10px; padding: 10px; border: 0; border-radius: 9px; background: none; color: var(--text); font: inherit; font-size: 14.5px; text-align: left; cursor: pointer; }
.ne-menu-item:hover { background: var(--surface-2); }
.ne-menu-item svg { width: 18px; height: 18px; color: var(--muted); }
.ne-menu-item small { margin-left: auto; color: var(--muted); }
/* Aufnahme */
.ne-recpill { position: fixed; z-index: 84; right: max(14px, env(safe-area-inset-right)); top: calc(var(--top-inset) + 114px); display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; border-radius: 999px; background: #1d1d1f; color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; box-shadow: 0 8px 22px -8px rgba(0, 0, 0, .5); }
.ne-recpill .ne-btn { color: #fff; height: 32px; }
.ne-recpill .ne-btn:hover { background: rgba(255, 255, 255, .12); }
.ne-recdot { width: 10px; height: 10px; border-radius: 50%; background: #ff4d4f; animation: ne-blink 1s steps(2) infinite; }
@keyframes ne-blink { 50% { opacity: .25; } }
.ne-recs { display: flex; flex-direction: column; gap: 10px; }
.ne-recitem { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; }
.ne-rec-top { display: flex; justify-content: space-between; gap: 8px; }
.ne-rec-top small { color: var(--muted); }
.ne-recitem audio { width: 100%; height: 36px; }
.ne-rec-tools { display: flex; flex-wrap: wrap; gap: 6px; }
/* Laserpointer */
.ne-laser { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 79; pointer-events: none; }
/* Zeitmesser */
.ne-timer { position: fixed; z-index: 84; right: max(14px, env(safe-area-inset-right)); top: calc(var(--top-inset) + 164px); width: 190px; padding: 8px 10px 10px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 14px 34px -12px rgba(0, 0, 0, .45); cursor: grab; touch-action: none; user-select: none; }
.ne-timer.done { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.ne-tm-top { display: flex; align-items: center; justify-content: space-between; }
.ne-tm-top .ne-btn { min-width: 28px; height: 28px; padding: 0; }
.ne-tm-mode { border: 0; background: none; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; text-transform: uppercase; letter-spacing: .04em; }
.ne-tm-time { font-size: 34px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; margin: 2px 0 6px; }
.ne-tm-btns { display: flex; gap: 6px; justify-content: center; }
.ne-tm-pre { display: flex; gap: 4px; justify-content: center; margin-top: 8px; }
.ne-tm-pre .chip { min-width: 30px; height: 26px; padding: 0 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 12px; cursor: pointer; }
.ne-tm-pre .chip.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
/* Lupe */
.ne.has-zoom .ne-pages { padding-bottom: calc(38vh + 40px); }
.ne-zpanel { position: fixed; z-index: 83; left: 0; right: 0; bottom: 0; height: 36vh; min-height: 220px; display: flex; flex-direction: column; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -10px 30px -12px rgba(0, 0, 0, .35); padding-bottom: env(safe-area-inset-bottom); }
.ne-zbar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.ne-zbar strong { display: inline-flex; align-items: center; gap: 6px; }
.ne-zbar strong svg { width: 18px; height: 18px; color: var(--accent); }
.ne-zcanvas { flex: 1; width: 100%; min-height: 0; display: block; cursor: crosshair; }
.ne-zframe { position: absolute; z-index: 5; border: 2px solid var(--accent); border-radius: 4px; background: rgba(61, 90, 241, .06); cursor: move; touch-action: none; }
@media (max-width: 760px) { .ne-panel { top: auto; height: 62vh; left: 8px; right: 8px; width: auto; } }
.ne.has-zoom .ne-panel { bottom: calc(max(36vh, 220px) + 12px); }

/* Hinweis: App umgezogen */
.moved-banner { position: fixed; z-index: 95; left: 50%; top: calc(var(--top-inset) + 10px); transform: translateX(-50%); width: min(760px, calc(100vw - 24px)); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--accent); box-shadow: 0 14px 40px -14px rgba(0, 0, 0, .45); font-size: 14px; }
.moved-banner > span { flex: 1 1 280px; }
