/* ============================================================
   NORMA — Design System
   Warm cream paper · Tannengrün accent · Serif reading + Sans UI
   ============================================================ */

:root {
  /* Background layers (warm cream paper) */
  --bg-base: #efe9d9;          /* outermost frame / sidebar */
  --bg-sidebar: #ebe4d0;       /* nav rail */
  --bg-paper: #f7f3e8;         /* main content surface */
  --bg-elevated: #fdfaf1;      /* cards / popovers */
  --bg-overlay: rgba(31, 28, 22, 0.42);

  /* Ink */
  --ink-1: #1c1a14;            /* titles, primary */
  --ink-2: #38342b;            /* body */
  --ink-3: #6f6859;            /* secondary */
  --ink-4: #a59d88;            /* muted, dividers in text */
  --ink-5: #c8c0a7;            /* very muted */

  /* Lines */
  --line: #d9d1ba;
  --line-soft: #e4dcc4;
  --line-strong: #b9af93;

  /* Accent — Tannengrün */
  --accent: #1f4d3a;
  --accent-hover: #2a6450;
  --accent-tint: #dfe7df;      /* soft chip bg */
  --accent-ink: #f6f2e9;       /* foreground on accent */

  /* Status colors (rating buttons + flags) */
  --red: #9a3a2d;
  --red-tint: #f1d9d3;
  --amber: #a8761a;
  --amber-tint: #f3e3c3;
  --green: #3a7a52;
  --green-tint: #d9e6dd;
  --blue: #2f5d8c;
  --blue-tint: #d6e0ee;

  /* Highlight (paper-marker) */
  --highlight-yellow: #f6e6a2;
  --highlight-green: #c8e2c8;
  --highlight-pink: #f4ccd0;

  /* Type */
  --font-serif: "Newsreader", "Source Serif Pro", Georgia, serif;
  --font-sans: "Geist", "Söhne", system-ui, sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, monospace;

  /* Geometry */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Density */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;

  /* Shadow (very subtle, paper-feel) */
  --shadow-soft: 0 1px 2px rgba(31, 28, 22, 0.04), 0 4px 14px rgba(31, 28, 22, 0.05);
  --shadow-pop: 0 8px 28px rgba(31, 28, 22, 0.14), 0 1px 3px rgba(31, 28, 22, 0.08);
  --shadow-card: 0 1px 0 rgba(31, 28, 22, 0.04), 0 8px 24px rgba(31, 28, 22, 0.06);

  /* Layout */
  --sidebar-w: 232px;
  --sidebar-w-collapsed: 64px;
  --secondary-w: 280px;
  --topbar-h: 56px;
  /* Bibliotheks-Drawer im Lernmodus — breit genug zum Lesen, schmale
     Fenster skaliert die Karte mit. */
  --drawer-w: clamp(320px, 34vw, 460px);
}

/* Dark mode */
[data-theme="dark"] {
  --bg-base: #16140f;
  --bg-sidebar: #1c1a14;
  --bg-paper: #1f1d16;
  --bg-elevated: #2a271f;
  --bg-overlay: rgba(0, 0, 0, 0.55);
  --ink-1: #f3eedc;
  --ink-2: #d8d1bc;
  --ink-3: #9b9480;
  --ink-4: #6e6857;
  --ink-5: #4a4537;
  --line: #36322a;
  --line-soft: #2b2820;
  --line-strong: #4d4738;
  --accent: #6fb094;
  --accent-hover: #87c4aa;
  --accent-tint: #25342c;
  --accent-ink: #0e1612;
  --shadow-soft: 0 1px 2px rgba(0,0,0,0.4), 0 4px 14px rgba(0,0,0,0.4);
  --shadow-pop: 0 8px 28px rgba(0,0,0,0.55), 0 1px 3px rgba(0,0,0,0.3);
  --shadow-card: 0 1px 0 rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.45);
  --highlight-yellow: #5a4e1c;
  --highlight-green: #2a4030;
  --highlight-pink: #4a2c30;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; overflow-x: hidden; }
/* App-Seiten (mit Sidebar + 100vh-Container) brauchen kein
   Body-Scroll, das übernimmt der innere Content-Bereich. Auf
   Landing-/Public-Seiten (Pricing, Login, Register, /preise etc.)
   muss Body dagegen scrollbar sein, sonst sieht man Inhalte
   unterhalb des ersten Bildschirms nicht. */
body:has(.app) { overflow-y: hidden; }

button { font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, select, textarea { font: inherit; color: inherit; }

/* Selection */
::selection { background: var(--accent-tint); color: var(--ink-1); }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--line-strong); background-clip: padding-box; border: 2px solid transparent; }

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ============================================================
   APP SHELL
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  background: var(--bg-base);
  transition: grid-template-columns 0.25s ease;
}
.app[data-collapsed="true"] { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.app[data-fullscreen="true"] { grid-template-columns: 0 1fr; }
.app[data-fullscreen="true"] .sidebar { display: none; }

/* SIDEBAR */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 4px;
  overflow: hidden;
  min-width: 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
  color: var(--ink-1);
}
.sidebar-mark {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: grid; place-items: center;
  color: var(--accent-ink);
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 18px;
  flex-shrink: 0;
}
.sidebar-name {
  font-family: var(--font-serif);
  font-size: 19px;
  letter-spacing: -0.01em;
  font-weight: 500;
}
.sidebar-name em { font-style: italic; font-weight: 400; color: var(--ink-3); margin-left: 4px; font-size: 0.85em; }

.sidebar-group { margin-top: 10px; }
.sidebar-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  padding: 4px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--ink-2);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
  position: relative;
}
.nav-item:hover { background: rgba(0,0,0,0.04); }
.nav-item[data-active="true"] {
  background: var(--bg-paper);
  color: var(--ink-1);
  font-weight: 500;
  box-shadow: 0 1px 0 var(--line-soft) inset, 0 -1px 0 var(--line-soft) inset;
}
.nav-item[data-active="true"]::before {
  content: "";
  position: absolute; left: -12px; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; color: var(--ink-3); }
.nav-item[data-active="true"] svg { color: var(--accent); }
.nav-item .nav-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  background: var(--bg-base);
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}
.nav-item[data-active="true"] .nav-badge { background: var(--accent); color: var(--accent-ink); }

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 9px;
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #c9b890 0%, #8a7752 100%);
  color: #fdfaf1;
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.user-meta { min-width: 0; }
.user-name { font-size: 13px; color: var(--ink-1); font-weight: 500; }
.user-mail { font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* COLLAPSED */
.app[data-collapsed="true"] .sidebar-name,
.app[data-collapsed="true"] .sidebar-label,
.app[data-collapsed="true"] .nav-item span:not(.nav-badge),
.app[data-collapsed="true"] .nav-item .nav-badge,
.app[data-collapsed="true"] .user-meta { display: none; }
.app[data-collapsed="true"] .nav-item { justify-content: center; padding: 8px; }
.app[data-collapsed="true"] .sidebar-foot { justify-content: center; }

/* ============================================================
   TOPBAR
   ============================================================ */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-paper);
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px 0 14px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-paper);
  position: relative;
  z-index: 10;
}
.icon-btn {
  background: transparent;
  border: none;
  padding: 6px;
  border-radius: 6px;
  color: var(--ink-3);
  display: grid; place-items: center;
  transition: background 0.12s;
}
.icon-btn:hover { background: rgba(0,0,0,0.05); color: var(--ink-1); }
.icon-btn svg { width: 18px; height: 18px; }

.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
  color: var(--ink-3);
  min-width: 0;
}
.breadcrumb a { cursor: pointer; }
.breadcrumb a:hover { color: var(--ink-1); }
.breadcrumb .crumb-sep { color: var(--ink-4); }
.breadcrumb .crumb-current { color: var(--ink-1); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar-search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 5px 9px 5px 11px;
  color: var(--ink-3);
  width: 260px;
  cursor: text;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.topbar-search:hover { border-color: var(--line); }
.topbar-search svg { width: 14px; height: 14px; }
.topbar-search-label { font-size: 13px; flex: 1; }
.kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--bg-base);
  border: 1px solid var(--line-soft);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--ink-3);
}

/* ============================================================
   CONTENT SHELL
   ============================================================ */
.content {
  flex: 1;
  overflow: auto;
  min-width: 0;
  position: relative;
}
.content-pad {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 48px 80px;
}

/* Page heading */
.page-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  margin-bottom: 10px;
}
.page-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 38px;
  letter-spacing: -0.02em;
  color: var(--ink-1);
  margin: 0 0 10px;
  line-height: 1.1;
}
.page-title em { font-style: italic; font-weight: 400; color: var(--ink-3); }
.page-sub {
  font-size: 15px;
  color: var(--ink-3);
  margin: 0 0 28px;
  max-width: 60ch;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-1);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: rgba(0,0,0,0.05); }
.btn-outline {
  border-color: var(--line);
  background: var(--bg-elevated);
  color: var(--ink-1);
}
.btn-outline:hover { border-color: var(--line-strong); background: var(--bg-paper); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-lg { padding: 11px 20px; font-size: 14.5px; border-radius: 9px; }
.btn-block { width: 100%; }

/* Google-Login (M16). */
.btn-google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #ffffff;
  color: #1f1f1f;
  border: 1px solid #d9d6cf;
  text-decoration: none;
  font-weight: 500;
}
.btn-google:hover {
  background: #f7f5ef;
  border-color: #b9b4a7;
}
.btn-google svg { flex: none; }
.auth-form-hint {
  margin-top: 14px;
  font-size: 13px;
  color: rgba(28, 26, 20, 0.72);
  line-height: 1.55;
}
.form-info {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  font-size: 13px;
  color: var(--ink-2);
}
.form-info code {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 12px;
}

/* Hintergrund-Job-Fortschritt (M15 B2). */
.job-status {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  padding: 18px 20px;
}
.job-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.job-status-badge {
  font: 600 11px/1 "Geist Mono", ui-monospace, monospace;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 99px;
  background: var(--bg-base);
  color: var(--ink-3);
}
.job-status[data-status="running"] .job-status-badge {
  background: var(--accent-tint); color: var(--accent);
}
.job-status[data-status="finished"] .job-status-badge {
  background: var(--green-tint); color: var(--green);
}
.job-status[data-status="failed"] .job-status-badge {
  background: var(--red-tint); color: var(--red);
}
.job-status-count {
  font: 500 13px/1 "Geist Mono", ui-monospace, monospace;
  color: var(--ink-2);
}
.job-progress-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-base);
  overflow: hidden;
}
.job-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width 200ms;
}
.job-status-detail {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-3);
}

/* Einrichtungsassistent (M18). */
.wiz-stage {
  min-height: 100vh;
  background: var(--bg-paper);
  display: flex;
  flex-direction: column;
}
.wiz-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 32px;
  border-bottom: 1px solid var(--line);
  gap: 24px;
  flex-wrap: wrap;
}
.wiz-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-1);
  text-decoration: none;
  font-family: var(--font-serif);
  font-size: 18px;
}
.wiz-mark {
  width: 32px; height: 32px;
  background: var(--accent);
  color: var(--bg-paper);
  border-radius: 8px;
  display: grid; place-items: center;
  font-style: italic;
}
.wiz-stepper {
  display: flex;
  gap: 18px;
  align-items: center;
  list-style: none;
  margin: 0; padding: 0;
}
.wiz-step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-3);
}
.wiz-step-num {
  width: 24px; height: 24px;
  border-radius: 999px;
  background: var(--bg-base);
  color: var(--ink-3);
  display: grid; place-items: center;
  font: 600 12px/1 "Geist Mono", ui-monospace, monospace;
}
.wiz-step[data-state="current"] {
  color: var(--ink-1);
  font-weight: 500;
}
.wiz-step[data-state="current"] .wiz-step-num {
  background: var(--accent);
  color: var(--bg-paper);
}
.wiz-step[data-state="done"] .wiz-step-num {
  background: var(--accent-tint);
  color: var(--accent);
}
.wiz-main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 48px 24px 64px;
}
.wiz-card {
  width: 100%;
  max-width: 640px;
}
.wiz-eyebrow {
  font: 600 11px/1 "Geist Mono", ui-monospace, monospace;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 12px;
}
.wiz-title {
  font-family: var(--font-serif);
  font-size: 36px;
  line-height: 1.15;
  margin: 0 0 12px;
  color: var(--ink-1);
}
.wiz-lead {
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0 0 28px;
  max-width: 56ch;
}
.wiz-form { display: flex; flex-direction: column; gap: 20px; }
.wiz-field { display: flex; flex-direction: column; gap: 6px; }
/* `display: flex` würde sonst das HTML-`hidden`-Attribut überstimmen. */
.wiz-field[hidden] { display: none; }
.wiz-label {
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 500;
}
.wiz-hint { font-size: 12px; color: var(--ink-3); }
.wiz-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 560px) {
  .wiz-grid-2 { grid-template-columns: 1fr; }
}
.wiz-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.wiz-choices {
  display: grid;
  gap: 12px;
  margin: 8px 0 24px;
}
.wiz-choice {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 14px;
  align-items: start;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--ink-1);
  text-decoration: none;
  transition: border-color 120ms, background 120ms;
}
.wiz-choice:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.wiz-choice-icon { color: var(--accent); }
.wiz-choice-body { min-width: 0; }
.wiz-choice-title {
  font-family: var(--font-serif);
  font-size: 18px;
  margin-bottom: 4px;
}
.wiz-choice-text {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.5;
}

/* Wizard-Hero (Willkommen + Fertig). */
.wiz-main-wide { max-width: none; }
.wiz-main-wide .wiz-hero { max-width: 880px; }

.wiz-hero {
  width: 100%;
}
.wiz-hero-eyebrow {
  font: 600 12px/1 "Geist Mono", ui-monospace, monospace;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 14px;
}
.wiz-hero-title {
  font-family: var(--font-serif);
  font-size: 48px;
  line-height: 1.1;
  color: var(--ink-1);
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}
.wiz-hero-title em {
  font-style: italic;
  color: var(--accent);
}
.wiz-hero-lead {
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 0 0 36px;
  max-width: 64ch;
}
.wiz-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 36px;
}
@media (max-width: 760px) {
  .wiz-hero-title { font-size: 36px; }
  .wiz-features { grid-template-columns: 1fr; }
}
.wiz-feature {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 16px;
  align-items: start;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}
.wiz-feature-link {
  color: var(--ink-1);
  text-decoration: none;
  transition: border-color 120ms, background 120ms;
}
.wiz-feature-link:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.wiz-feature-icon {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  background: var(--accent-tint);
  color: var(--accent);
  border-radius: 12px;
}
.wiz-feature-body { min-width: 0; }
.wiz-feature-title {
  font-family: var(--font-serif);
  font-size: 19px;
  color: var(--ink-1);
  margin-bottom: 4px;
}
.wiz-feature-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}
.wiz-hero-cta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.wiz-hero-cta-meta {
  font-size: 13px;
  color: var(--ink-3);
}
.wiz-actions-spacer { flex: 1; }

/* Juristische Outline-Liste (M20).
   Acht Ebenen — A. I. 1. a) aa) (1) (a) (aa) — über CSS-Counter,
   ohne Klassen an jeder Unter-Liste. Greift im Editor, im Karten-
   iframe und im Befund-Popup, weil das Stylesheet überall geladen
   wird. Padding pro Ebene bewusst klein gehalten, damit auch acht
   Ebenen in einem schmalen Container nicht rechts überlaufen. */

@counter-style jura-double-lower {
  system: fixed;
  symbols: 'aa' 'bb' 'cc' 'dd' 'ee' 'ff' 'gg' 'hh' 'ii' 'jj' 'kk' 'll' 'mm'
           'nn' 'oo' 'pp' 'qq' 'rr' 'ss' 'tt' 'uu' 'vv' 'ww' 'xx' 'yy' 'zz';
  suffix: '';
}

ol.jura-list,
ol.jura-list ol,
ol.jura-list ul {
  list-style: none;
  /* Top-level + jede Sub-Ebene bekommen denselben kleinen Einzug.
     Der Marker hängt links aus dem LI raus (right:100%) und blutet
     in genau diesen Einzug. So kostet jede Ebene NUR das Einzug-Maß
     statt zusätzlich padding für den Marker. */
  padding-left: 1.6em;
  margin: 0;
}
ol.jura-list { margin: 6px 0; }
ol.jura-list li {
  position: relative;
  margin: 3px 0;
  /* Lange Wörter umbrechen, kurze bleiben ganz. */
  overflow-wrap: break-word;
}
ol.jura-list li::before {
  position: absolute;
  right: 100%;
  top: 0;
  margin-right: 0.4em;
  white-space: nowrap;
  color: var(--ink-1);
  font-variant-numeric: tabular-nums;
}

/* Acht Ebenen — gleicher Padding-Step, nur Marker-Stil wechselt. */
ol.jura-list { counter-reset: jura-l0; margin: 6px 0; }
ol.jura-list > li { counter-increment: jura-l0; }
ol.jura-list > li::before {
  content: counter(jura-l0, upper-alpha) '.';
  font-weight: 600;
}

ol.jura-list ol { counter-reset: jura-l1; }
ol.jura-list > li > ol > li { counter-increment: jura-l1; }
ol.jura-list > li > ol > li::before {
  content: counter(jura-l1, upper-roman) '.';
  font-weight: 500;
}

ol.jura-list > li > ol > li > ol { counter-reset: jura-l2; }
ol.jura-list > li > ol > li > ol > li { counter-increment: jura-l2; }
ol.jura-list > li > ol > li > ol > li::before {
  content: counter(jura-l2, decimal) '.';
}

ol.jura-list > li > ol > li > ol > li > ol { counter-reset: jura-l3; }
ol.jura-list > li > ol > li > ol > li > ol > li { counter-increment: jura-l3; }
ol.jura-list > li > ol > li > ol > li > ol > li::before {
  content: counter(jura-l3, lower-alpha) ')';
}

ol.jura-list > li > ol > li > ol > li > ol > li > ol { counter-reset: jura-l4; }
ol.jura-list > li > ol > li > ol > li > ol > li > ol > li {
  counter-increment: jura-l4;
}
ol.jura-list > li > ol > li > ol > li > ol > li > ol > li::before {
  content: counter(jura-l4, jura-double-lower) ')';
}

ol.jura-list > li > ol > li > ol > li > ol > li > ol > li > ol {
  counter-reset: jura-l5;
}
ol.jura-list > li > ol > li > ol > li > ol > li > ol > li > ol > li {
  counter-increment: jura-l5;
}
ol.jura-list > li > ol > li > ol > li > ol > li > ol > li > ol > li::before {
  content: '(' counter(jura-l5, decimal) ')';
}

ol.jura-list > li > ol > li > ol > li > ol > li > ol > li > ol > li > ol {
  counter-reset: jura-l6;
}
ol.jura-list > li > ol > li > ol > li > ol > li > ol > li > ol > li > ol > li {
  counter-increment: jura-l6;
}
ol.jura-list > li > ol > li > ol > li > ol > li > ol > li > ol > li > ol > li::before {
  content: '(' counter(jura-l6, lower-alpha) ')';
}

ol.jura-list > li > ol > li > ol > li > ol > li > ol > li > ol > li > ol > li > ol {
  counter-reset: jura-l7;
}
ol.jura-list > li > ol > li > ol > li > ol > li > ol > li > ol > li > ol > li > ol > li {
  counter-increment: jura-l7;
}
ol.jura-list > li > ol > li > ol > li > ol > li > ol > li > ol > li > ol > li > ol > li::before {
  content: '(' counter(jura-l7, jura-double-lower) ')';
}

/* Chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--bg-base);
  color: var(--ink-2);
  border: 1px solid var(--line-soft);
  font-family: var(--font-mono);
}
.chip-accent { background: var(--accent-tint); color: var(--accent); border-color: transparent; }
.chip-green { background: var(--green-tint); color: var(--green); border-color: transparent; }
.chip-amber { background: var(--amber-tint); color: var(--amber); border-color: transparent; }
.chip-red { background: var(--red-tint); color: var(--red); border-color: transparent; }
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Card */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}

/* ============================================================
   NORM TEXT (Reading)
   ============================================================ */
.norm-reader {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.65;
  color: var(--ink-1);
  max-width: 64ch;
}
.norm-reader p { margin: 0.8em 0; }
.norm-reader .abs { display: flex; gap: 14px; margin: 1em 0; }
.norm-reader .abs-marker {
  font-family: var(--font-serif);
  color: var(--ink-3);
  flex-shrink: 0;
  font-style: italic;
  font-variant-numeric: tabular-nums;
  min-width: 28px;
}
.norm-reader ol { padding-left: 26px; margin: 0.4em 0; }
.norm-reader ol li { margin: 0.3em 0; padding-left: 4px; }
.norm-reader ol li::marker { color: var(--ink-3); }

.norm-ref {
  font-style: normal;
  border-bottom: 1px dotted var(--accent);
  cursor: pointer;
  color: var(--ink-1);
  transition: background 0.12s;
  padding: 0 1px;
  border-radius: 2px;
}
.norm-ref:hover { background: var(--accent-tint); }

/* Norm-Verweise aus norma_core (Norm-Popover und Bibliotheks-Drawer).
   norma_core vergibt die Klasse .norma-norm-ref; im Karten-iframe wird
   sie separat gestylt (app/anki_templates.py). */
.norma-norm-ref {
  font-style: normal;
  border-bottom: 1px dotted var(--accent);
  cursor: pointer;
  color: inherit;
  transition: background 0.12s;
  padding: 0 1px;
  border-radius: 2px;
}
.norma-norm-ref:hover { background: var(--accent-tint); }

.norm-highlight { background: var(--highlight-yellow); padding: 0 2px; border-radius: 2px; }
.norm-highlight.green { background: var(--highlight-green); }
.norm-highlight.pink { background: var(--highlight-pink); }

.norm-headline {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink-1);
  margin: 0 0 4px;
}
.norm-headline em { font-style: italic; font-weight: 400; }
.norm-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--ink-3);
  margin: 0 0 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-soft);
}
.norm-meta a { color: var(--accent); border-bottom: 1px solid transparent; }
.norm-meta a:hover { border-bottom-color: var(--accent); }

/* ============================================================
   POPOVER (Norm preview, menus)
   ============================================================ */
.popover {
  position: absolute;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  padding: 14px 16px;
  max-width: 420px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--ink-2);
  z-index: 100;
  animation: popIn 0.14s ease-out;
}
@keyframes popIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.popover-head {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-1);
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.popover-body {
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.55;
  max-height: 180px;
  overflow: hidden;
  position: relative;
}
.popover-body::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 30px;
  background: linear-gradient(to bottom, transparent, var(--bg-elevated));
}
.popover-foot {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--ink-3);
}

/* ============================================================
   COMMAND PALETTE
   ============================================================ */
.cmdk-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 200;
  display: grid;
  place-items: start center;
  padding-top: 12vh;
  animation: fadeIn 0.12s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.cmdk {
  width: 640px;
  max-width: calc(100vw - 32px);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: popIn 0.16s ease;
}
.cmdk-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  padding: 16px 18px;
  font-size: 16px;
  color: var(--ink-1);
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-sans);
}
.cmdk-results { max-height: 50vh; overflow: auto; padding: 6px; }
.cmdk-section-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  padding: 10px 12px 4px;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-2);
}
.cmdk-item[data-active="true"] { background: var(--accent-tint); color: var(--ink-1); }
.cmdk-item svg { width: 16px; height: 16px; color: var(--ink-3); flex-shrink: 0; }
.cmdk-item[data-active="true"] svg { color: var(--accent); }
.cmdk-item .cmdk-key { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); flex-shrink: 0; min-width: 70px; }
.cmdk-item .cmdk-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-item .cmdk-hint { font-size: 11px; color: var(--ink-4); }
.cmdk-foot {
  display: flex;
  gap: 14px;
  padding: 9px 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--ink-4);
  font-family: var(--font-mono);
  background: var(--bg-paper);
}

/* ============================================================
   3-pane: BOOKS · TOC · NORM
   ============================================================ */
.three-pane {
  display: grid;
  grid-template-columns: var(--secondary-w) 1fr;
  flex: 1;
  min-height: 0;
}
.pane-secondary {
  background: var(--bg-paper);
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.pane-secondary .pane-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.pane-secondary .pane-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink-1);
  margin: 0 0 8px;
  display: flex; align-items: center; gap: 8px;
}
.pane-secondary .pane-search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-base);
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 13px;
  color: var(--ink-3);
}
.pane-secondary .pane-search input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  flex: 1;
  width: 100%;
  min-width: 0;
}
.pane-secondary .pane-search svg { width: 13px; height: 13px; }

.toc-list { overflow-y: auto; padding: 6px 4px 24px; flex: 1; min-height: 0; }
.toc-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink-2);
  font-size: 13px;
  position: relative;
}
.toc-row:hover { background: rgba(0,0,0,0.04); }
.toc-row[data-active="true"] {
  background: var(--accent-tint);
  color: var(--ink-1);
}
.toc-row[data-active="true"]::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 2px; background: var(--accent); border-radius: 1px;
}
.toc-key {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  min-width: 56px;
  flex-shrink: 0;
}
.toc-row[data-active="true"] .toc-key { color: var(--accent); font-weight: 600; }
.toc-label {
  color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.toc-row[data-active="true"] .toc-label { color: var(--ink-1); }

.toc-section {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  padding: 18px 12px 5px;
  font-weight: 600;
}
.toc-section:first-child { padding-top: 10px; }

/* Book grid */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.book-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  position: relative;
}
.book-chip:hover { border-color: var(--line); transform: translateY(-1px); }
.book-chip .book-code {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 500;
  color: var(--ink-1);
  letter-spacing: -0.01em;
}
.book-chip .book-name {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 6px;
  line-height: 1.35;
}
.book-chip .book-count {
  position: absolute;
  top: 16px; right: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
}
.book-chip[data-fav="true"]::after {
  content: "★";
  position: absolute;
  top: 10px; left: 12px;
  font-size: 10px;
  color: var(--accent);
}

/* ============================================================
   GESETZBÜCHER — Listen-Browser (Suche + Bereich + Tabelle)
   ============================================================ */

.books-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 18px 0 14px;
}
.books-search {
  position: relative;
  flex: 1 1 280px;
  min-width: 220px;
}
.books-search svg {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--ink-4);
  pointer-events: none;
}
.books-search input {
  width: 100%;
  padding-left: 36px;
  height: 38px;
}

.books-filter {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip-radio {
  position: relative;
  cursor: pointer;
}
.chip-radio input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.chip-radio span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--bg-elevated);
  font-size: 13px;
  color: var(--ink-2);
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.chip-radio:hover span { border-color: var(--line); }
.chip-radio input:checked + span {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.chip-radio input:checked + span .muted {
  color: var(--accent-ink);
  opacity: 0.75;
}

.books-list {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  overflow: hidden;
}
.books-row {
  display: grid;
  grid-template-columns: 130px 1fr 90px 120px;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-1);
  transition: background 0.1s;
}
.books-row:last-child { border-bottom: none; }
.books-row:hover { background: rgba(0, 0, 0, 0.035); }
.books-row-code {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.books-row-name {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--ink-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.books-row-area {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 4px;
  text-align: center;
  background: var(--accent-tint);
  color: var(--accent);
  justify-self: start;
}
.books-row-area[data-area="land"] {
  background: rgba(180, 130, 60, 0.14);
  color: rgb(140, 95, 30);
}
.books-row-count {
  font-size: 12.5px;
  color: var(--ink-4);
  font-family: var(--font-mono);
  text-align: right;
}

@media (max-width: 640px) {
  .books-row {
    grid-template-columns: 110px 1fr;
    grid-template-areas:
      "code name"
      "area count";
    gap: 4px 12px;
  }
  .books-row-code  { grid-area: code; }
  .books-row-name  { grid-area: name; }
  .books-row-area  { grid-area: area; }
  .books-row-count { grid-area: count; }
}

/* Norm reader pane scroll */
.pane-main {
  overflow: auto;
  min-height: 0;
}
.pane-main-pad {
  padding: 36px 56px 80px;
  max-width: 780px;
  margin: 0 auto;
}

/* ============================================================
   STUDY MODE (Lernen)
   ============================================================ */
.study-stage {
  position: fixed;
  inset: 0;
  background: var(--bg-paper);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: right 0.22s cubic-bezier(.16, 1, .3, 1);
}
/* Offener Drawer: die Lernbühne weicht zur Seite, statt überlagert zu
   werden — die Karte rückt mit. */
.study-stage[data-drawer="open"] { right: var(--drawer-w); }
.study-top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line-soft);
}
.study-progress {
  flex: 1;
  height: 4px;
  background: var(--bg-base);
  border-radius: 2px;
  overflow: hidden;
}
.study-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.4s cubic-bezier(.4,.0,.2,1);
}
.study-counter {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-3);
  display: flex; gap: 14px;
}
.study-counter b { font-weight: 600; }
.study-counter .c-new { color: var(--blue); }
.study-counter .c-learn { color: var(--red); }
.study-counter .c-rev { color: var(--green); }

/* Schriftgrößen-Steller im Lernmodus */
.study-fontsize { display: flex; gap: 3px; flex-shrink: 0; }
.font-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  border-radius: 7px;
  font: 600 12px var(--font-sans);
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.font-btn:hover { border-color: var(--line-strong); color: var(--ink-1); }

.study-card-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Responsiver Außenrand: 24px auf engen Screens, bis 56px auf weiten. */
  padding: clamp(20px, 3.2vh, 56px) clamp(20px, 4vw, 56px);
  overflow: auto;
  /* Kein Scroll-Anchoring: die iframe pendelt ihre Höhe schrittweise
     ein — ohne dies triebe der Scroll dabei nach unten und der
     Kartenanfang wäre abgeschnitten. */
  overflow-anchor: none;
}
.study-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-top: 3px solid var(--accent);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  /* Padding wächst mit dem Viewport — eng auf 360 px, großzügig auf 1440 px. */
  padding: clamp(28px, 4vh, 56px) clamp(24px, 4.2vw, 72px);
  /* Karte darf bis ~1040 px breit werden — auf 4K-Displays sieht ein
     720er-Kasten verloren in der Mitte aus; gleichzeitig bremst die
     obere Grenze die Zeilenlänge auf augenfreundliche ~80 Zeichen. */
  max-width: clamp(560px, 72vw, 1040px);
  width: 100%;
  min-height: clamp(220px, 28vh, 320px);
  /* Karten, die höher als die Bühne sind, nicht stauchen, sondern die
     Bühne scrollen lassen. margin:auto zentriert kurze Karten und kippt
     lange sauber nach oben — ohne margin:auto schnitte place-items/
     justify-content:center den Anfang ab und machte ihn unerreichbar. */
  flex-shrink: 0;
  margin: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: transform 0.3s ease, opacity 0.25s ease;
}
/* Karte bleibt unsichtbar, bis die iframe-Höhe steht — sanftes
   Einblenden statt sichtbarem Höhen-Springen. */
.study-card.card-loading { opacity: 0; transform: translateY(10px); }
.study-card.flipping { animation: flipReveal 0.4s ease; }
@keyframes flipReveal {
  0% { transform: rotateX(0deg); }
  50% { transform: rotateX(-8deg); opacity: 0.7; }
  100% { transform: rotateX(0deg); }
}
.study-card.entering { animation: enterCard 0.32s cubic-bezier(.16,1,.3,1); }
@keyframes enterCard {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.study-front {
  font-family: var(--font-serif);
  font-size: 22px;
  line-height: 1.5;
  color: var(--ink-1);
  text-align: center;
}
.study-back {
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1.55;
  color: var(--ink-2);
  border-top: 1px solid var(--line-soft);
  padding-top: 24px;
  margin-top: 24px;
  animation: revealBack 0.3s ease;
}
@keyframes revealBack { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.cloze {
  display: inline-block;
  background: var(--bg-base);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 8px;
  margin: 0 2px;
  color: var(--red);
  font-weight: 500;
}
.cloze.revealed {
  background: var(--accent-tint);
  border-color: transparent;
  color: var(--ink-1);
  font-weight: 500;
}

.study-actions {
  padding: 22px 28px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.study-rate {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 640px;
  width: 100%;
}
.rate-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--ink-1);
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
  position: relative;
}
.rate-btn:hover { transform: translateY(-1px); }
.rate-btn:active { transform: translateY(0); }
.rate-btn .rate-label { font-size: 14px; font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
.rate-btn .rate-when { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.rate-btn .rate-key { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3); background: var(--bg-base); padding: 1px 5px; border-radius: 3px; }
.rate-btn[data-r="1"] { border-color: var(--red-tint); }
.rate-btn[data-r="1"]:hover { background: var(--red-tint); border-color: var(--red); }
.rate-btn[data-r="2"] { border-color: var(--amber-tint); }
.rate-btn[data-r="2"]:hover { background: var(--amber-tint); border-color: var(--amber); }
.rate-btn[data-r="3"] { border-color: var(--green-tint); }
.rate-btn[data-r="3"]:hover { background: var(--green-tint); border-color: var(--green); }
.rate-btn[data-r="4"] { border-color: var(--blue-tint); }
.rate-btn[data-r="4"]:hover { background: var(--blue-tint); border-color: var(--blue); }

.show-answer-btn {
  background: var(--ink-1);
  color: var(--bg-paper);
  border: none;
  border-radius: 10px;
  padding: 13px 28px;
  font-size: 14px;
  font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.show-answer-btn:hover { background: var(--ink-2); }
.show-answer-btn .kbd-inline {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: rgba(255,255,255,0.15);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--bg-paper);
}

/* ============================================================
   DECKS LIST
   ============================================================ */
.deck-list { display: flex; flex-direction: column; gap: 10px; }
.deck-row {
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  align-items: center;
  gap: 22px;
  transition: border-color 0.12s;
}
.deck-row:hover { border-color: var(--line); }
.deck-name {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink-1);
}
.deck-tags { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.deck-stat { text-align: center; min-width: 44px; }
.deck-stat-num { font-family: var(--font-mono); font-size: 16px; font-weight: 500; }
.deck-stat-num.new { color: var(--blue); }
.deck-stat-num.learn { color: var(--red); }
.deck-stat-num.review { color: var(--green); }
.deck-stat-label { font-size: 10.5px; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.06em; font-family: var(--font-mono); margin-top: 2px; }

/* ============================================================
   FORMS / INPUTS
   ============================================================ */
.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-1);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.form-help { font-size: 12px; color: var(--ink-3); margin-top: 4px; line-height: 1.5; }
.input, .select, .textarea {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  color: var(--ink-1);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.input::placeholder { color: var(--ink-4); }
.textarea { resize: vertical; font-family: var(--font-sans); min-height: 80px; }
.select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236f6859' stroke-width='2' stroke-linecap='round'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 32px; }

/* Tabs */
.tabs {
  display: inline-flex;
  background: var(--bg-base);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.tab {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  color: var(--ink-3);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  border: none;
  background: transparent;
}
.tab:hover { color: var(--ink-1); }
.tab[data-active="true"] {
  background: var(--bg-elevated);
  color: var(--ink-1);
  box-shadow: 0 1px 2px rgba(31,28,22,0.06);
}

/* Callout */
.callout {
  background: var(--amber-tint);
  border: 1px solid color-mix(in oklab, var(--amber) 24%, transparent);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13.5px;
  color: color-mix(in oklab, var(--amber) 60%, var(--ink-1));
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.callout svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; color: var(--amber); }
.callout b { color: var(--amber); }
.callout-accent { background: var(--accent-tint); border-color: color-mix(in oklab, var(--accent) 24%, transparent); color: var(--ink-1); }
.callout-accent svg, .callout-accent b { color: var(--accent); }

/* ============================================================
   CARD EDITOR
   ============================================================ */
.editor-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  height: 100%;
  min-height: 0;
}
.editor-pane, .preview-pane { display: flex; flex-direction: column; min-height: 0; }
.editor-pane { border-right: 1px solid var(--line-soft); }
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-paper);
  flex-wrap: wrap;
}
.tool-btn {
  background: transparent;
  border: none;
  padding: 6px 8px;
  border-radius: 5px;
  color: var(--ink-2);
  font-size: 13px;
  display: inline-flex; align-items: center; gap: 4px;
  min-width: 30px;
  justify-content: center;
}
.tool-btn:hover { background: rgba(0,0,0,0.05); }
.tool-btn[data-on="true"] { background: var(--accent-tint); color: var(--accent); }
.tool-btn svg { width: 14px; height: 14px; }
.tool-sep { width: 1px; height: 18px; background: var(--line-soft); margin: 0 6px; }

.editor-area {
  flex: 1;
  padding: 22px 28px;
  overflow: auto;
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-1);
  background: var(--bg-elevated);
  outline: none;
  white-space: pre-wrap;
  min-height: 0;
}
.editor-area:empty:before {
  content: attr(data-placeholder);
  color: var(--ink-4);
  font-style: italic;
}
.editor-side {
  border-top: 1px solid var(--line-soft);
  padding: 14px 18px;
  background: var(--bg-paper);
  display: flex;
  gap: 14px;
  align-items: center;
}

.preview-pane { background: var(--bg-base); }
.preview-head {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-paper);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.preview-head .preview-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
}
.preview-body {
  flex: 1;
  overflow: auto;
  padding: 32px 36px;
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink-1);
  min-height: 0;
}

/* AI Check */
.ai-check {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 7px 12px;
  background: var(--green-tint);
  border-radius: 999px;
  font-size: 12px;
  color: var(--green);
  font-weight: 500;
}
.ai-check .ai-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 2s ease-in-out infinite; }
.ai-check.warn { background: var(--amber-tint); color: var(--amber); }
.ai-check.warn .ai-dot { background: var(--amber); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ============================================================
   DIGEST / Rechtsprechung
   ============================================================ */
.digest-area {
  margin-bottom: 36px;
}
.digest-area-head {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.digest-area-head .digest-count {
  color: var(--ink-4);
  margin-left: auto;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}
.digest-topic {
  padding: 16px 0;
  border-bottom: 1px solid var(--line-soft);
}
.digest-topic:last-child { border-bottom: none; }
.digest-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 500;
  color: var(--ink-1);
  margin: 0 0 6px;
  letter-spacing: -0.005em;
  line-height: 1.3;
}
.digest-sum {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--ink-2);
  line-height: 1.55;
  margin: 0 0 10px;
}
.digest-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  align-items: center;
}
.digest-meta a:hover { color: var(--accent); }

/* ============================================================
   AUTH / LANDING
   ============================================================ */
.auth-stage {
  height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--bg-base);
}
.auth-side {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 56px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-side .auth-mark {
  font-family: var(--font-serif);
  font-size: 22px;
  font-style: italic;
  font-weight: 500;
}
.auth-side .auth-hero {
  font-family: var(--font-serif);
  font-size: 56px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 500;
}
.auth-side .auth-hero em { font-style: italic; color: rgba(246,242,233,0.7); }
.auth-side .auth-foot { font-family: var(--font-mono); font-size: 11.5px; color: rgba(246,242,233,0.6); }
.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px;
}
.auth-form {
  width: 100%;
  max-width: 360px;
}
.auth-form h2 {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
  color: var(--ink-1);
}
.auth-form .auth-form-sub { font-size: 14px; color: var(--ink-3); margin-bottom: 28px; }
.auth-foot-link { font-size: 13px; color: var(--ink-3); text-align: center; margin-top: 22px; }
.auth-foot-link a { color: var(--accent); border-bottom: 1px solid transparent; }
.auth-foot-link a:hover { border-bottom-color: var(--accent); }

/* Landing — Footer klebt am Boden, Hero füllt den Rest. */
.landing {
  background: var(--bg-paper);
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 56px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}
.landing-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-serif); font-size: 22px; font-weight: 500; }
.landing-nav-cta { display: flex; gap: 10px; align-items: center; }
.landing-hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 80px 56px 100px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 80px;
  align-items: center;
}
.landing-hero h1 {
  font-family: var(--font-serif);
  font-size: 64px;
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.025em;
  margin: 0 0 20px;
  color: var(--ink-1);
}
.landing-hero h1 em { font-style: italic; font-weight: 400; color: var(--accent); }
.landing-hero p {
  font-family: var(--font-serif);
  font-size: 19px;
  color: var(--ink-2);
  line-height: 1.55;
  margin: 0 0 28px;
  max-width: 50ch;
}
.landing-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  background: var(--accent-tint);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 500;
  margin-bottom: 22px;
}
.hero-cta { display: flex; gap: 12px; }
.hero-side-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  /* Platz für den schwebenden „Immer aktuell"-Stempel — der hängt
     unter der Karte und darf nicht in den Norm-Text rutschen. */
  padding-bottom: 12px;
}
.hero-side {
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 28px 32px;
  box-shadow: var(--shadow-card);
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink-1);
  width: 100%;
  box-sizing: border-box;
}
.hero-side-badge {
  position: relative;
  margin-top: -14px;
  margin-right: -14px;
  background: var(--bg-paper);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
  z-index: 1;
}

/* Settings tabs / sections */
.settings-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 28px;
}
.settings-tab {
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 14px;
  font-weight: 500;
  position: relative;
  cursor: pointer;
}
.settings-tab:hover { color: var(--ink-1); }
.settings-tab[data-active="true"] { color: var(--ink-1); }
.settings-tab[data-active="true"]::after {
  content: ""; position: absolute; left: 16px; right: 16px; bottom: -1px;
  height: 2px; background: var(--accent); border-radius: 1px;
}

.settings-section {
  padding: 4px 0 32px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 28px;
}
.settings-section:last-child { border-bottom: none; }
.settings-section-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  margin: 0 0 4px;
  color: var(--ink-1);
}
.settings-section-sub { font-size: 13px; color: var(--ink-3); margin: 0 0 18px; max-width: 60ch; }

/* Utility */
.row { display: flex; align-items: center; gap: 12px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--ink-3); }
.text-mono { font-family: var(--font-mono); }
.text-serif { font-family: var(--font-serif); }
.divider { height: 1px; background: var(--line-soft); margin: 18px 0; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.hidden { display: none !important; }

/* ============================================================
   LAW DRAWER (Bibliothek im Lernmodus)
   ============================================================ */
/* Das hidden-Attribut muss die display-Regeln dieser Klassen
   übersteuern (sonst stünde der Drawer dauerhaft offen). */
.law-drawer[hidden],
.law-drawer-tab[hidden],
.popover[hidden] { display: none !important; }

.law-drawer {
  position: fixed;
  top: 0; bottom: 0; right: 0;
  width: var(--drawer-w);
  max-width: 100vw;
  background: var(--bg-paper);
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 40px rgba(31, 28, 22, 0.10);
  z-index: 60;
  display: flex;
  flex-direction: column;
  animation: drawerIn 0.22s cubic-bezier(.16,1,.3,1);
}
@keyframes drawerIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.law-drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  flex-shrink: 0;
}
.law-drawer-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink-1);
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.law-drawer-title .chip { font-family: var(--font-mono); font-size: 11px; }
.law-drawer-search {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-paper);
}
.law-drawer-search .input {
  background: var(--bg-elevated);
  font-size: 13px;
  padding: 7px 11px;
}
.law-drawer-body {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.law-drawer-toc {
  padding: 8px 8px 24px;
}
.law-drawer-norm {
  padding: 22px 24px 60px;
}
.law-drawer-norm .norm-headline { font-size: 22px; margin-bottom: 6px; }
.law-drawer-norm .norm-meta { font-size: 12px; padding-bottom: 14px; margin-bottom: 18px; }
.law-drawer-norm .norm-reader { font-size: 15px; }
.law-drawer-norm .norm-reader .abs { gap: 10px; margin: 0.7em 0; }
.law-drawer-norm .norm-reader .abs-marker { min-width: 24px; }
.law-drawer-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-3);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  margin-bottom: 14px;
}
.law-drawer-back:hover { color: var(--ink-1); }

/* Side-toggle button on study stage right edge */
.law-drawer-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-right: none;
  border-radius: 8px 0 0 8px;
  padding: 10px 8px;
  color: var(--ink-3);
  cursor: pointer;
  z-index: 45;
  writing-mode: vertical-rl;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: -4px 0 12px rgba(31, 28, 22, 0.04);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.law-drawer-tab:hover { color: var(--accent); border-color: var(--accent); background: var(--bg-paper); }
.law-drawer-tab svg { transform: rotate(90deg); }

@media (max-width: 760px) {
  .law-drawer { width: 100vw; border-left: none; }
  .law-drawer-tab { display: none; }
  /* Mobil überlagert der Drawer ganzflächig — die Bühne bleibt voll. */
  .study-stage[data-drawer="open"] { right: 0; }
}

/* ============================================================
   EDITOR (Visual Cloze, Streitstand-Form, etc.)
   ============================================================ */

/* Card-type tabs */
.editor-types {
  display: flex;
  gap: 4px;
  padding: 12px 18px 0;
  border-bottom: 1px solid var(--line-soft);
  overflow-x: auto;
  flex-shrink: 0;
}
.editor-type {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px 11px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  position: relative;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
  margin-bottom: -1px;
}
.editor-type:hover { color: var(--ink-1); }
.editor-type[data-active="true"] { color: var(--ink-1); border-bottom-color: var(--accent); }
.editor-type .editor-type-glyph {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--accent);
  width: 18px;
  text-align: center;
}

/* Field labels (structured forms) */
.field-block { margin-bottom: 18px; }
.field-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  font-weight: 500;
}
.field-help {
  font-size: 11.5px;
  color: var(--ink-4);
  margin-left: auto;
}
.field-input, .field-textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--ink-1);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-textarea { resize: vertical; min-height: 80px; line-height: 1.55; }
.field-input:focus, .field-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

/* Visual Lückentext editor */
.vis-editor {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px 24px;
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink-1);
  outline: none;
  min-height: 200px;
  position: relative;
}
.vis-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.vis-editor:empty:before {
  content: attr(data-placeholder);
  color: var(--ink-4);
  font-style: italic;
}

/* Cloze chips inside the visual editor */
.vis-editor .vc-cloze {
  display: inline-block;
  background: var(--accent-tint);
  color: var(--accent);
  border-radius: 5px;
  padding: 0 8px 0 22px;
  margin: 0 1px;
  font-weight: 500;
  font-style: italic;
  position: relative;
  cursor: text;
  border: 1px solid color-mix(in oklab, var(--accent) 18%, transparent);
}
.vis-editor .vc-cloze::before {
  content: attr(data-n);
  position: absolute;
  left: 4px; top: 50%;
  transform: translateY(-50%);
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-style: normal;
  font-weight: 600;
  border-radius: 3px;
  padding: 1px 4px 0;
  line-height: 1.1;
  height: 14px;
  display: inline-flex;
  align-items: center;
}

/* Hidden block ([[...]]) */
.vis-editor .vc-hide {
  display: block;
  border-left: 3px solid var(--ink-4);
  background: color-mix(in oklab, var(--ink-4) 8%, transparent);
  padding: 6px 10px 6px 12px;
  margin: 8px 0;
  border-radius: 0 6px 6px 0;
  position: relative;
}
.vis-editor .vc-hide::before {
  content: "▾ versteckt bis Lücke darin abgefragt";
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  margin-bottom: 4px;
  font-style: normal;
}

/* Stage separator (>>>) */
.vis-editor .vc-stage {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  padding: 0 4px;
  user-select: none;
}
.vis-editor .vc-stage::before {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.vis-editor .vc-stage::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.vis-editor .vc-stage-badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  background: var(--bg-base);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  font-style: normal;
}

/* Pair separator (||) */
.vis-editor .vc-pair {
  display: inline-block;
  vertical-align: middle;
  color: var(--accent);
  margin: 0 4px;
  font-weight: 600;
  font-style: normal;
  user-select: none;
}

/* Tabellen-Tool: einfaches Gitter im Editor. Dünne Linien, dezenter
   Header — die Tabelle wird beim Speichern unverändert nach Anki
   übernommen, da das gemeinsame Karten-CSS Tabellen schon kennt. */
.vis-editor table.vc-table {
  border-collapse: collapse;
  margin: 10px 0;
  width: 100%;
  font-size: 15px;
}
.vis-editor table.vc-table th,
.vis-editor table.vc-table td {
  border: 1px solid var(--line);
  padding: 6px 9px;
  vertical-align: top;
  min-width: 60px;
}
.vis-editor table.vc-table th {
  background: var(--bg-base);
  font-weight: 600;
  text-align: left;
}
.vis-editor table.vc-table td:focus,
.vis-editor table.vc-table th:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Tabellen-Picker — Hover-Grid à la Google Docs Bausteine. */
.vc-table-picker {
  position: absolute;
  z-index: 80;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12),
              0 2px 6px rgba(0, 0, 0, 0.06);
  padding: 12px 14px 10px;
  user-select: none;
}
.vc-table-picker-head {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.vc-table-picker-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 10), 22px);
  gap: 3px;
}
.vc-table-picker-cell {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  background: var(--bg-paper);
  border-radius: 3px;
  padding: 0;
  cursor: pointer;
  transition: background 0.05s, border-color 0.05s;
}
.vc-table-picker-cell.hot {
  background: var(--accent-tint, #d8e7da);
  border-color: var(--accent);
}
.vc-table-picker-label {
  margin-top: 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  text-align: center;
}

/* Inline-Tabellen-Toolbar: schwebt über der gerade fokussierten
   Tabelle und bietet + / − Zeile/Spalte. Wird per JS positioniert. */
.vc-table-inline {
  position: absolute;
  z-index: 70;
  display: flex;
  gap: 4px;
  padding: 4px 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  font-family: var(--font-sans);
  font-size: 11.5px;
}
.vc-table-inline[hidden] { display: none; }
.vc-table-inline button {
  border: none;
  background: transparent;
  color: var(--ink-2);
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
}
.vc-table-inline button:hover { background: var(--bg-base); color: var(--ink-1); }
.vc-table-inline button:last-child { color: var(--red); }

/* KI-Quota-Anzeige (Settings-Tab + Dashboard-Streifen) */
.ki-quota-bar {
  height: 6px;
  background: var(--bg-base);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
}
.ki-quota-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* ------------------------------------------------------------ */
/* Lernpläne                                                     */
/* ------------------------------------------------------------ */
.plan-block { transition: border-color 0.12s; }
.plan-block-current {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 4%, var(--bg-elevated));
}
.plan-block-week {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  min-width: 56px;
  text-align: center;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-base));
  padding: 4px 8px;
  border-radius: 8px;
}
.plan-row:last-child { border-bottom: none !important; }

/* Aktueller-Block-Karte auf dem Dashboard. */
.dash-plan-current {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  margin-bottom: 22px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
}
.dash-plan-current a { color: var(--accent-ink); }
.dash-plan-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.75;
  margin-bottom: 6px;
}
.dash-plan-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 500;
  line-height: 1.2;
  margin: 0 0 8px;
}
.dash-plan-meta {
  font-size: 13.5px;
  opacity: 0.9;
}
.dash-plan-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.dash-plan-chips .chip {
  background: rgba(255,255,255,0.18);
  color: var(--accent-ink);
  border: none;
}

/* Toolbar buttons styled for visual editor */
.vis-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bg-paper);
  border: 1px solid var(--line-soft);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  margin-bottom: -1px;
}
.vis-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.vis-tool:hover { background: var(--bg-elevated); border-color: var(--line-soft); }
.vis-tool:disabled { opacity: 0.4; cursor: not-allowed; }
.vis-tool svg { width: 13px; height: 13px; }
.vis-tool-sep {
  display: inline-block;
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 4px;
  align-self: center;
}
.vis-tool-primary {
  background: var(--accent-tint);
  color: var(--accent);
}
.vis-tool-primary:hover { background: color-mix(in oklab, var(--accent) 22%, var(--bg-base)); border-color: transparent; }
.vis-tool-shortcut {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  margin-left: 4px;
  font-weight: 400;
}
.vis-tool-sep { width: 1px; height: 18px; background: var(--line-soft); margin: 0 6px; align-self: center; }

.vis-editor-wrap {
  margin-top: 8px;
}
.vis-editor-wrap > .vis-editor { border-radius: 0 0 10px 10px; }
.vis-editor-wrap > .vis-editor:focus { border-radius: 0 0 10px 10px; }

/* Streitstand Ansichten card */
.ansicht-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.ansicht-card .ansicht-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.ansicht-card .ansicht-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.ansicht-card .ansicht-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
  margin-bottom: 8px;
}
.ansicht-card .ansicht-meta input {
  background: var(--bg-paper);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 13px;
  outline: none;
  width: 100%;
}
.ansicht-card .ansicht-meta input:focus { border-color: var(--accent); }
.ansicht-card .ansicht-content {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--font-serif);
  font-size: 15px;
  resize: vertical;
  min-height: 60px;
  outline: none;
}
.ansicht-card .ansicht-args {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}
.arg-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 6px;
}
.arg-row .arg-kind {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 4px;
}
.arg-row .arg-kind.pro { background: var(--green-tint); color: var(--green); }
.arg-row .arg-kind.contra { background: var(--red-tint); color: var(--red); }
.arg-row input {
  flex: 1;
  background: var(--bg-paper);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 13px;
  outline: none;
}
.arg-row input:focus { border-color: var(--accent); }

/* Preview card cycler */
.preview-cycler {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--font-mono);
}
.preview-cycler-btn {
  width: 24px; height: 24px;
  border-radius: 5px;
  background: var(--bg-base);
  border: 1px solid var(--line-soft);
  color: var(--ink-3);
  display: grid; place-items: center;
  cursor: pointer;
}
.preview-cycler-btn:hover { color: var(--ink-1); border-color: var(--line); }
.preview-cycler-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.preview-cycler-btn svg { width: 12px; height: 12px; }

/* Preview rendering — cloze rendering */
.preview-body .pv-cloze {
  background: color-mix(in oklab, var(--ink-3) 16%, var(--bg-base));
  color: var(--ink-3);
  border-radius: 4px;
  padding: 0 6px;
  margin: 0 2px;
  font-family: var(--font-serif);
}
.preview-body .pv-cloze-asked {
  background: var(--accent-tint);
  color: var(--red);
  font-weight: 500;
  border: 1px dashed var(--red);
  padding: 0 8px;
}
.preview-body .pv-cloze-revealed {
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 500;
}
.preview-body .pv-hidden { opacity: 0.25; }

/* Hint banner */
.editor-hint {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  background: var(--accent-tint);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--ink-1);
  align-items: flex-start;
  margin-bottom: 16px;
}
.editor-hint svg { color: var(--accent); flex-shrink: 0; margin-top: 1px; }
.editor-hint b { color: var(--accent); }

/* ============================================================
   CARD TYPES grid (Settings)
   ============================================================ */
.cardtypes-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  margin-top: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-elevated);
}
.cardtypes-list {
  border-right: 1px solid var(--line-soft);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-paper);
}
.cardtypes-detail { padding: 20px 24px; min-width: 0; }

/* ============================================================
   MOBILE NAV (drawer + bottom tabs on phones)
   ============================================================ */
.mobile-topbar { display: none; }
.mobile-tabbar { display: none; }
.sidebar-scrim { display: none; }

/* ============================================================
   RESPONSIVE BREAKPOINTS
   ============================================================ */

/* Tablet: hide sidebar by default, hide topbar search label */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 200px;
    --secondary-w: 240px;
  }
  .content-pad { padding: 32px 32px 64px; }
  .pane-main-pad { padding: 28px 36px 64px; }
  .landing-hero { padding: 60px 40px 80px; gap: 48px; }
  .landing-hero h1 { font-size: 52px; }
  .topbar-search { width: 200px; }
}

/* Mobile: stack everything */
@media (max-width: 760px) {
  body { font-size: 14px; }

  /* App becomes single column */
  .app {
    grid-template-columns: 1fr;
  }
  .app .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-pop);
  }
  .app[data-mobile-nav="true"] .sidebar { transform: translateX(0); }
  .app[data-mobile-nav="true"] .sidebar-scrim {
    display: block;
    position: fixed; inset: 0;
    background: var(--bg-overlay);
    z-index: 59;
    animation: fadeIn 0.15s ease;
  }
  .app[data-collapsed="true"] { grid-template-columns: 1fr; }
  .app[data-collapsed="true"] .sidebar-name,
  .app[data-collapsed="true"] .nav-item span:not(.nav-badge),
  .app[data-collapsed="true"] .nav-item .nav-badge,
  .app[data-collapsed="true"] .user-meta { display: initial; }
  .app[data-collapsed="true"] .nav-item { justify-content: flex-start; padding: 7px 10px; }

  /* Topbar slimmer */
  .topbar { padding: 0 12px; gap: 8px; height: 52px; }
  .topbar-search { width: auto; padding: 6px; }
  .topbar-search-label { display: none; }
  .topbar-search .kbd { display: none; }
  .breadcrumb { font-size: 12px; }
  .breadcrumb a:not(:last-child), .breadcrumb .crumb-sep { display: none; }

  /* Content padding */
  .content-pad { padding: 24px 18px 80px; }
  .pane-main-pad { padding: 20px 20px 60px; }
  .page-title { font-size: 28px; }
  .page-sub { font-size: 14px; margin-bottom: 22px; }

  /* Three-pane → stacked, secondary drawer */
  .three-pane { grid-template-columns: 1fr; }
  .pane-secondary {
    position: fixed;
    inset: 52px 0 0 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    background: var(--bg-paper);
  }
  .three-pane[data-show-toc="true"] .pane-secondary { transform: translateX(0); }
  .pane-main { width: 100%; }

  /* Book grid: tighter */
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .book-chip { padding: 12px 14px; }
  .book-chip .book-code { font-size: 22px; }

  /* Norm headline */
  .norm-headline { font-size: 24px; }
  .norm-headline .text-mono { font-size: 18px !important; }
  .norm-reader { font-size: 16px; }
  .norm-meta { flex-wrap: wrap; gap: 8px; font-size: 12px; }

  /* Dashboard hero card grid */
  .content-pad > div[style*="grid-template-columns: 2fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .content-pad > div[style*="grid-template-columns: 1.4fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  .landing-hero { grid-template-columns: 1fr !important; gap: 40px; padding: 40px 24px 60px; }
  .landing-hero h1 { font-size: 40px; }
  .landing-nav { padding: 18px 20px; gap: 12px; }
  .landing-nav-cta { gap: 8px; }
  .landing-nav-cta .btn { padding: 8px 14px; }
  .auth-stage { grid-template-columns: 1fr !important; }
  .auth-side {
    padding: 28px 24px;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 14px;
    min-height: auto;
  }
  .auth-side .auth-hero { display: none; }
  .auth-side > div:not(:first-child) { display: none; }
  .auth-side > div:last-child { display: none; }
  .auth-form-side { padding: 32px 24px; }

  /* Decks list — vertical layout */
  .deck-row {
    grid-template-columns: 1fr 1fr 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 10px 14px;
    padding: 14px 16px;
  }
  .deck-row > div:first-child { grid-column: 1 / -1; grid-row: 1; }
  .deck-row .deck-stat { grid-row: 2; }
  .deck-row > button { grid-column: 1 / -1; grid-row: 3; width: 100%; }
  .deck-row .deck-stat { text-align: left; }
  .deck-name { font-size: 15px; }

  /* Study mode */
  .study-stage .study-top { padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
  .study-top > div[style*="font-family: var(--font-serif)"] { display: none; }
  .study-card { padding: 28px 22px; min-height: 240px; border-radius: 12px; }
  .study-front { font-size: 18px; }
  .study-back { font-size: 16px; }
  .study-card-wrap { padding: 16px; }
  .study-rate { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .rate-btn { padding: 11px 12px; }
  .study-actions { padding: 16px 16px 22px; }

  /* Editor: stack panes, switchable */
  .editor-shell { grid-template-columns: 1fr; }
  .editor-pane { border-right: none; border-bottom: 1px solid var(--line-soft); }
  .preview-pane { display: none; }
  .app[data-editor-side="preview"] .editor-pane { display: none; }
  .app[data-editor-side="preview"] .preview-pane { display: flex; }
  .editor-toolbar { padding: 8px 12px; }
  .editor-toolbar .tool-btn span { display: none; }
  .editor-area { padding: 18px 20px; font-size: 15px; }
  .preview-body { padding: 22px 20px; font-size: 15px; }

  /* Settings */
  .settings-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .settings-tab { white-space: nowrap; padding: 10px 12px; font-size: 13px; }
  .cardtypes-grid { grid-template-columns: 1fr; }
  .cardtypes-list {
    border-right: none;
    border-bottom: 1px solid var(--line-soft);
    flex-direction: row;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 6px;
  }
  .cardtypes-list .toc-row { flex-shrink: 0; padding: 8px 10px !important; min-width: 130px; }

  /* Mobile chrome additions */
  .mobile-nav-btn { display: inline-flex !important; }
  .mobile-tabbar {
    display: flex;
    position: fixed;
    inset: auto 0 0 0;
    background: var(--bg-elevated);
    border-top: 1px solid var(--line-soft);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    z-index: 40;
    justify-content: space-around;
    box-shadow: 0 -2px 12px rgba(31, 28, 22, 0.04);
  }
  .mobile-tabbar .tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    border-radius: 8px;
    color: var(--ink-3);
    font-size: 10px;
    font-weight: 500;
    background: transparent;
    border: none;
    cursor: pointer;
  }
  .mobile-tabbar .tab-item[data-active="true"] { color: var(--accent); }
  .mobile-tabbar .tab-item svg { width: 20px; height: 20px; }

  /* Reserve space for bottom tabbar */
  .content { padding-bottom: 72px; }

  /* Command palette */
  .cmdk { width: calc(100vw - 24px); }
  .cmdk-backdrop { padding-top: 6vh; }

  /* Hero cards */
  .hero-cta { flex-wrap: wrap; }

  /* Tabs (segmented) wrap */
  .tabs { flex-wrap: wrap; }
}

/* Extra small */
@media (max-width: 400px) {
  .page-title { font-size: 24px; }
  .book-grid { grid-template-columns: repeat(2, 1fr); }
  .deck-row { grid-template-columns: repeat(3, 1fr); }
  .study-rate { grid-template-columns: 1fr 1fr; }
}

/* Hide mobile-only chrome on desktop */
@media (min-width: 761px) {
  .mobile-nav-btn { display: none !important; }
  .mobile-tabbar { display: none !important; }
}

@media (max-width: 760px) {
  .desktop-only-btn { display: none !important; }
  [data-mobile-editor-tabs="true"] { display: inline-flex !important; }
}

/* ============================================================
   WEBAPP-ERGÄNZUNGEN (server-gerendert · Jinja / HTMX)
   ============================================================ */

a.card { transition: border-color 0.15s, transform 0.15s; }
a.card:hover { border-color: var(--line); transform: translateY(-1px); }

.form-error {
  background: var(--red-tint);
  border: 1px solid color-mix(in oklab, var(--red) 30%, transparent);
  color: var(--red);
  padding: 10px 13px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
}

.norm-body {
  white-space: pre-wrap;
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink-1);
}

.file-input { font-size: 13px; color: var(--ink-3); max-width: 100%; }
.file-input::file-selector-button {
  font: inherit;
  font-weight: 500;
  margin-right: 10px;
  padding: 7px 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg-paper);
  color: var(--ink-1);
  cursor: pointer;
}
.file-input::file-selector-button:hover { border-color: var(--line-strong); }

.result-list { display: flex; flex-direction: column; gap: 2px; }

/* Deck-Zeile (flexibel, zwei Kennzahlen) */
.deck-card {
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 22px;
  transition: border-color 0.12s;
}
.deck-card:hover { border-color: var(--line); }
.deck-card-main { flex: 1; min-width: 0; }
@media (max-width: 600px) {
  .deck-card { flex-wrap: wrap; gap: 14px; }
  .deck-card-main { flex-basis: 100%; }
}

/* Bewertungs-Formulare als direkte Grid-Items der Studienkarte */
.study-rate form { display: contents; }

/* Nur auf Mobilgeräten sichtbar */
.mobile-only { display: none; }
@media (max-width: 760px) {
  .mobile-only { display: inline-flex; }
}

/* Stapelbaum (Lern-Übersicht) */
.deck-tree-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 10px;
  border-radius: 7px;
}
.deck-tree-row:hover { background: rgba(0, 0, 0, 0.04); }
.deck-tree-name {
  flex: 1;
  min-width: 0;
  color: var(--ink-1);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deck-tree-name:hover { color: var(--accent); }
.deck-rename-input {
  flex: 1;
  min-width: 0;
  max-width: 340px;
  padding: 3px 8px;
  font-size: 14px;
}
.deck-tree-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  flex-shrink: 0;
  /* Feste Spaltenbreite, rechtsbündig — sorgt dafür, dass die Symbol-
     und Aktions-Buttons in jeder Zeile in derselben x-Position landen,
     egal ob der Stat-Text „22" oder „21 fällig · 711" lang ist. */
  min-width: 160px;
  text-align: right;
}
/* Konsistente Spaltenbreite für die Aktions-Buttons in der Deck-Zeile.
   Vorher schwankte die Position um die Stat-Spaltenbreite. */
.deck-tree-row > .icon-btn { width: 30px; flex: none; }
.deck-tree-row > .deck-delete-form { flex: none; }
/* Der „Lernen"/„Ansehen"-Knopf ganz rechts in fester Mindestbreite —
   sonst tanzt er je nach Wort um 12-14 px. */
.deck-tree-row > .btn { min-width: 92px; justify-content: center; }
/* Einklappbarer Stapelbaum (M5) */
.deck-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--ink-3);
  border-radius: 5px;
  cursor: pointer;
}
.deck-toggle:hover { background: rgba(0, 0, 0, 0.06); color: var(--ink-1); }
.deck-toggle svg { transition: transform 0.12s; transform: rotate(90deg); }
.deck-node.collapsed > .deck-tree-row .deck-toggle svg {
  transform: rotate(0deg);
}
.deck-toggle-spacer { width: 20px; flex-shrink: 0; }
.deck-node.collapsed > .deck-children { display: none; }

/* ============================================================
   M4 — Norm-Reader-Tiefe (Notiz, Markier-Picker)
   ============================================================ */
.norm-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.norm-note {
  margin-top: 30px;
  padding: 14px 16px;
  background: var(--bg-base);
  border: 1px dashed var(--line);
  border-radius: 12px;
}
.norm-note summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--ink-1);
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
}
.norm-note summary::-webkit-details-marker { display: none; }
.norm-note[open] summary { margin-bottom: 8px; }

/* Mini-Popover zur Auswahl der Markier-Farbe. */
.hl-picker {
  position: fixed;
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow-pop);
  z-index: 90;
}
.hl-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.12);
  cursor: pointer;
  padding: 0;
}
.hl-swatch:hover { transform: scale(1.12); }
.hl-swatch[data-color="yellow"] { background: var(--highlight-yellow); }
.hl-swatch[data-color="green"] { background: var(--highlight-green); }
.hl-swatch[data-color="pink"] { background: var(--highlight-pink); }
.hl-remove {
  border: 1px solid var(--line);
  background: var(--bg-paper);
  border-radius: 6px;
  font-size: 12px;
  padding: 2px 8px;
  cursor: pointer;
  color: var(--ink-2);
}
mark.norm-highlight { cursor: pointer; }

/* ============================================================
   CARD BROWSER (M5)
   ============================================================ */
.kb-search {
  display: flex;
  gap: 10px;
  margin: 20px 0 10px;
  flex-wrap: wrap;
}
.kb-search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink-3);
  cursor: text;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.kb-search-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.kb-search-field .input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 10px 0;
}
.kb-search-field .input:focus { box-shadow: none; }
.kb-search .select { width: auto; min-width: 190px; flex-shrink: 0; }

.kb-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--bg-base);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  margin-bottom: 16px;
}

/* Mobile: solange nichts ausgewählt ist, die Bulk-Aktionen ausblenden.
   Sobald eine Karte markiert wird, erscheint die volle Leiste. */
@media (max-width: 700px) {
  .kb-toolbar.is-empty .kb-tb-actions,
  .kb-toolbar.is-empty .kb-spin {
    display: none;
  }
  .kb-toolbar.is-empty {
    padding: 8px 14px;
  }
}
.kb-toolbar-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
}
.kb-date { width: auto; padding: 6px 10px; font-size: 13px; }
.kb-spin {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-4);
  opacity: 0;
  transition: opacity 0.15s;
}
.kb-spin.htmx-request { opacity: 1; }

.kb-count {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
  margin: 0 2px 10px;
}
.kb-list { display: flex; flex-direction: column; gap: 6px; }
.kb-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  transition: border-color 0.12s;
}
.kb-row:hover { border-color: var(--line-strong); }
.kb-check {
  display: flex;
  align-items: center;
  padding-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}
.kb-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.kb-main { flex: 1; min-width: 0; }
.kb-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.kb-type {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--accent-tint);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 999px;
}
.kb-deck { font-size: 12px; color: var(--ink-3); }
.kb-due {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-4);
}
.kb-due.is-due { color: var(--accent); font-weight: 500; }
.kb-excerpt {
  font-family: var(--font-serif);
  font-size: 14.5px;
  color: var(--ink-2);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.kb-edit { flex-shrink: 0; }
.kb-empty {
  padding: 44px 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* Filterzeile — Stapel, Flag, Zustand */
.kb-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.kb-filters .select {
  width: auto;
  flex: 1;
  min-width: 150px;
}

/* Massenaktionen-Leiste (M7 Phase 6). Den „inaktiv"-Zustand zeigen die
   ausgegrauten Aktionsknöpfe — keine opacity auf der ganzen Leiste, die
   würde sonst das aufgeklappte Dropdown durchscheinen lassen. */
.kb-sel-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-3);
  white-space: nowrap;
}
.kb-tb-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.kb-tb-actions [data-kb-action]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.kb-tb-actions .flag-dot { width: 20px; height: 20px; }
.kb-tb-sep {
  align-self: stretch;
  width: 1px;
  min-height: 22px;
  margin: 0 3px;
  background: var(--line);
}
.kb-tb-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-4);
}
/* Durchsuchbares Stapel-Dropdown (Filter + „Stapel wechseln") */
.combo { position: relative; }
.kb-filters .combo { flex: 1; min-width: 150px; }
.kb-tb-actions .combo-tb { min-width: 168px; }
.combo-btn {
  width: 100%;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
}
.combo-tb .combo-btn { padding-top: 6px; padding-bottom: 6px; font-size: 13px; }
.combo-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.combo-open .combo-btn {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.combo-panel {
  position: absolute;
  z-index: 60;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: 360px;
  padding: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(31, 28, 22, 0.18);
}
.combo-search { margin-bottom: 6px; padding: 7px 10px; font-size: 13px; }
.combo-list { max-height: 280px; overflow-y: auto; }
.combo-opt {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  border-radius: 6px;
  padding: 6px 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.combo-opt:hover { background: var(--accent-tint); color: var(--accent); }
.combo-opt[hidden] { display: none; }

/* Auswahl-Kopf der Trefferliste */
.kb-selectall {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  color: var(--ink-2);
}
.kb-selectall input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Status-Badges je Trefferzeile */
.kb-badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.kb-badge-suspended {
  background: var(--bg-base);
  color: var(--ink-3);
  border: 1px solid var(--line);
}
.kb-badge-buried { background: var(--amber-tint); color: var(--amber); }
.kb-badge-leech { background: var(--red-tint); color: var(--red); }

/* Info-Banner — Hinweis über einem Formular (z. B. importierte Karte) */
.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--amber-tint);
  border-radius: var(--radius);
  color: var(--amber);
}
.info-banner svg { flex-shrink: 0; margin-top: 1px; }

/* ============================================================
   REVIEW VERWAISTER MARKIERUNGEN (M5)
   ============================================================ */
.hl-review {
  margin: 0 0 20px;
  padding: 14px 16px;
  background: var(--amber-tint);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.hl-review-head {
  font-size: 13.5px;
  color: var(--ink-1);
  margin-bottom: 10px;
}
.hl-review-list { display: flex; flex-direction: column; gap: 6px; }
.hl-review-item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}
.hl-review-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
}
.hl-review-dot[data-color="yellow"] { background: var(--highlight-yellow); }
.hl-review-dot[data-color="green"] { background: var(--highlight-green); }
.hl-review-dot[data-color="pink"] { background: var(--highlight-pink); }
.hl-review-text {
  flex: 1;
  min-width: 150px;
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hl-review-hint {
  flex: 1;
  min-width: 150px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--accent);
}
.hl-review-actions { display: flex; gap: 6px; flex-shrink: 0; }
.hl-review-btn {
  border: 1px solid var(--line);
  background: var(--bg-paper);
  border-radius: 6px;
  font-size: 12px;
  padding: 4px 10px;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 0.12s;
}
.hl-review-btn:hover { border-color: var(--line-strong); }
.hl-review-reanchor { color: var(--accent); }
/* Aktiv-Zustand: Hinweis + Abbrechen statt Text + Setzen/Löschen. */
.hl-review-item .hl-review-hint { display: none; }
.hl-review-item .hl-review-cancel { display: none; }
.hl-review-item.is-active .hl-review-text { display: none; }
.hl-review-item.is-active .hl-review-hint { display: block; }
.hl-review-item.is-active .hl-review-cancel { display: inline-block; }
.hl-review-item.is-active .hl-review-reanchor { display: none; }
.hl-review-item.is-active .hl-review-delete { display: none; }

/* ============================================================
   KARTEN-AKTIONEN im Lernmodus (M7)
   ============================================================ */
.card-menu { position: relative; }
.card-menu > summary { list-style: none; cursor: pointer; }
.card-menu > summary::-webkit-details-marker { display: none; }
.card-menu-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  width: 236px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.card-menu-label {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  padding: 4px 8px 2px;
}
.card-menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-1);
  text-align: left;
  cursor: pointer;
}
.card-menu-item:hover { background: var(--bg-base); }
.flag-row { display: flex; gap: 6px; padding: 4px 8px 8px; }
.flag-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
}
.flag-dot.flag-active { border-color: var(--ink-1); }
.flag-off { background: var(--bg-base); color: var(--ink-3); }
.flag-c1 { background: var(--red); }
.flag-c2 { background: var(--amber); }
.flag-c3 { background: var(--green); }
.flag-c4 { background: var(--blue); }
.card-menu-due {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink-2);
}
.card-menu-days {
  width: 54px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-base);
  color: var(--ink-1);
  font-size: 13px;
}
.card-menu-apply {
  margin-left: auto;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-base);
  color: var(--ink-1);
  font-size: 12px;
  cursor: pointer;
}
.flag-mark {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ============================================================
   AKTIVITÄTS-HEATMAP (Decks-Seite, M7)
   ============================================================ */
.heatmap-card { margin-bottom: 24px; }
.hm-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.hm-card-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink-1);
}
.hm-card-sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.hm-head-right { display: flex; align-items: center; gap: 10px; }
.hm-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-tint);
  padding: 3px 9px;
  border-radius: 999px;
}
.hm-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.hm-range { font-size: 12px; color: var(--ink-3); }
.heatmap { display: flex; gap: 8px; overflow-x: auto; }
.hm-weekdays {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 20px;
  flex-shrink: 0;
}
.hm-weekdays span {
  height: 15px;
  line-height: 15px;
  font-size: 10px;
  color: var(--ink-3);
}
.hm-body { display: flex; flex-direction: column; gap: 4px; }
.hm-months { display: flex; gap: 4px; height: 12px; }
.hm-month {
  width: 15px;
  font-size: 10px;
  color: var(--ink-3);
  white-space: nowrap;
}
.hm-grid { display: flex; gap: 4px; }
.hm-col { display: flex; flex-direction: column; gap: 4px; }
.hm-cell {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  flex-shrink: 0;
}
.hm-empty { background: transparent; }
.hm-0 { background: var(--bg-base); }
.hm-1 { background: color-mix(in srgb, var(--accent) 30%, var(--bg-base)); }
.hm-2 { background: color-mix(in srgb, var(--accent) 55%, var(--bg-base)); }
.hm-3 { background: color-mix(in srgb, var(--accent) 78%, var(--bg-base)); }
.hm-4 { background: var(--accent); }
.hm-scale {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 12px;
  font-size: 11px;
  color: var(--ink-3);
}
.hm-scale .hm-cell { width: 12px; height: 12px; }

/* Heatmap-Variante „volle Breite" auf der Lern-Übersicht. Die Spalten
   teilen sich den verfügbaren Platz, damit auch 52 Wochen ohne Scroll
   sichtbar bleiben — ohne sie zu schmal werden zu lassen. */
.heatmap-card-wide .heatmap { gap: 6px; overflow: visible; }
.heatmap-card-wide .heatmap .hm-body { flex: 1; min-width: 0; gap: 3px; }
.heatmap-card-wide .heatmap .hm-grid,
.heatmap-card-wide .heatmap .hm-months { gap: 2px; }
.heatmap-card-wide .heatmap .hm-col {
  gap: 2px;
  flex: 1 1 0;
  min-width: 0;
}
.heatmap-card-wide .heatmap .hm-cell {
  width: 100%;
  height: 11px;
  border-radius: 2px;
  flex-shrink: 0;
}
.heatmap-card-wide .heatmap .hm-month {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  overflow: visible;
  font-size: 10px;
}
.heatmap-card-wide .heatmap .hm-months { height: 12px; }
.heatmap-card-wide .heatmap .hm-weekdays { gap: 2px; padding-top: 16px; }
.heatmap-card-wide .heatmap .hm-weekdays span { height: 11px; line-height: 11px; }

/* ============================================================
   STATISTIK — fünf Tabs, server-gerechnet
   ============================================================ */

/* Tab-Leiste */
.st-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  margin: 4px 0 18px;
  overflow-x: auto;
  overflow-y: hidden;
}
.st-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--ink-3);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
}
.st-tab svg { opacity: 0.65; }
.st-tab:hover { color: var(--ink-1); }
.st-tab[data-active="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.st-tab[data-active="true"] svg { opacity: 1; }

/* Zeitraum-Wähler */
.st-rangebar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.st-rangebar[hidden] { display: none; }
.st-range-caption {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
}
.st-range {
  display: inline-flex;
  background: var(--bg-base);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.st-range-btn {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-3);
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.st-range-btn:hover { color: var(--ink-1); }
.st-range-btn[data-active="true"] {
  background: var(--bg-elevated);
  color: var(--ink-1);
  box-shadow: var(--shadow-soft);
}

/* Tab-Inhalt */
.st-panel { display: flex; flex-direction: column; gap: 16px; }
.st-panel[hidden] { display: none; }

.st-grid { display: grid; gap: 14px; }
.st-grid > * { min-width: 0; }
.st-grid-4 { grid-template-columns: repeat(4, 1fr); }
.st-grid-2 { grid-template-columns: repeat(2, 1fr); }

/* Kennzahl-Kacheln */
.st-tile {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
}
.st-tile-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-4);
  margin-bottom: 9px;
}
.st-tile-value {
  font-family: var(--font-serif);
  font-size: 31px;
  font-weight: 500;
  line-height: 1;
  color: var(--ink-1);
}
.st-tile-sub { font-size: 12px; color: var(--ink-3); margin-top: 7px; }
.st-tile[data-tone="green"] .st-tile-value { color: var(--green); }
.st-tile[data-tone="amber"] .st-tile-value { color: var(--amber); }

/* Hinweis-Banner */
.st-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--ink-1);
}
.st-banner svg { flex: none; }
.st-banner[data-tone="accent"] {
  background: var(--accent-tint);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
}
.st-banner[data-tone="accent"] svg { color: var(--accent); }
.st-banner[data-tone="green"] {
  background: var(--green-tint);
  border-color: color-mix(in srgb, var(--green) 32%, transparent);
}
.st-banner[data-tone="green"] svg { color: var(--green); }
.st-banner[data-tone="amber"] {
  background: var(--amber-tint);
  border-color: color-mix(in srgb, var(--amber) 32%, transparent);
}
.st-banner[data-tone="amber"] svg { color: var(--amber); }
.st-banner[data-tone="red"] {
  background: var(--red-tint);
  border-color: color-mix(in srgb, var(--red) 32%, transparent);
}
.st-banner[data-tone="red"] svg { color: var(--red); }

/* KI-Anbieter — vertikale Auswahl mit Tannengrün-Akzent (M15). */
.ki-providers {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.ki-provider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}
.ki-provider:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.ki-provider input[type="radio"] {
  margin: 0;
  accent-color: var(--accent);
}
.ki-provider-label {
  font-size: 14px;
  color: var(--ink-1);
  font-weight: 500;
}
.ki-provider[data-active="true"] {
  border-color: var(--accent);
  background: var(--accent-tint);
  box-shadow: inset 4px 0 0 var(--accent);
  padding-left: 18px;
}

/* KI-Befunde: Inbox + Popup (M15 Phase 5). */
.kb-status-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
}
.kb-status-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--ink-3);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.kb-status-tab:hover { color: var(--ink-1); }
.kb-status-tab[data-active="true"] {
  color: var(--ink-1);
  border-bottom-color: var(--accent);
}
.kb-tab-count {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  background: var(--bg-base);
  color: var(--ink-2);
  border-radius: 99px;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}

.bef-list { display: flex; flex-direction: column; gap: 12px; }
.bef-card {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
}
.bef-card-head {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: start;
  gap: 14px;
  padding: 16px 18px;
  width: 100%;
}
.bef-dot {
  width: 8px;
  height: 100%;
  background: var(--ink-4, var(--ink-3));
  border-radius: 4px;
  align-self: stretch;
}
.bef-card[data-verdict="ueberholt"] .bef-dot { background: var(--red); }
.bef-card[data-verdict="moeglicherweise_ueberholt"] .bef-dot { background: var(--amber); }
.bef-card[data-verdict="unbedenklich"] .bef-dot { background: var(--green); }
.bef-card[data-verdict="nicht_verifizierbar"] .bef-dot { background: var(--ink-3); }
.bef-card-titles { display: flex; flex-direction: column; gap: 4px; }
.bef-verdict-label {
  font: 600 11px/1 "Geist Mono", ui-monospace, monospace;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.bef-card[data-verdict="ueberholt"] .bef-verdict-label { color: var(--red); }
.bef-card[data-verdict="moeglicherweise_ueberholt"] .bef-verdict-label { color: var(--amber); }
.bef-card[data-verdict="unbedenklich"] .bef-verdict-label { color: var(--green); }
.bef-trigger-title {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--ink-1);
}
.bef-summary { font-size: 13.5px; color: var(--ink-2); }
.bef-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}
.bef-meta-time {
  font: 500 12px/1 "Geist Mono", ui-monospace, monospace;
  color: var(--ink-3);
  margin-left: 4px;
}

/* Popup */
.bef-popup-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-paper);
  padding: 0;
  max-width: 900px;
  width: calc(100% - 32px);
}
.bef-popup-dialog::backdrop {
  background: color-mix(in srgb, var(--ink-1) 60%, transparent);
}
.bef-popup { display: flex; flex-direction: column; }
.bef-popup-head {
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elevated);
}
.bef-popup-head[data-verdict="ueberholt"] {
  background: var(--red-tint);
}
.bef-popup-head[data-verdict="moeglicherweise_ueberholt"] {
  background: var(--amber-tint);
}
.bef-popup-head[data-verdict="unbedenklich"] {
  background: var(--green-tint);
}
.bef-popup-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.bef-popup-eyebrow {
  font: 600 11px/1 "Geist Mono", ui-monospace, monospace;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}
.bef-popup-head[data-verdict="ueberholt"] .bef-popup-eyebrow { color: var(--red); }
.bef-popup-head[data-verdict="moeglicherweise_ueberholt"] .bef-popup-eyebrow { color: var(--amber); }
.bef-popup-head[data-verdict="unbedenklich"] .bef-popup-eyebrow { color: var(--green); }
.bef-popup-trigger-title {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--ink-1);
}
.bef-popup-trigger-summary {
  color: var(--ink-2);
  margin-top: 4px;
  font-size: 14px;
}
.bef-popup-trigger-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-3);
}
.bef-popup-trigger-meta a { color: var(--accent); }
.bef-popup-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.bef-popup-col {
  padding: 18px 22px;
  border-right: 1px solid var(--line);
  min-height: 220px;
}
.bef-popup-col:last-child { border-right: none; }
.bef-popup-col-eyebrow {
  font: 600 11px/1 "Geist Mono", ui-monospace, monospace;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin-bottom: 12px;
}
.bef-popup-field { margin-bottom: 14px; }
.bef-popup-field-name {
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.bef-popup-field-value {
  font-size: 14px;
  color: var(--ink-1);
  line-height: 1.5;
}
.bef-popup-reasoning {
  font-size: 14px;
  color: var(--ink-2);
  margin-bottom: 12px;
}
.bef-popup-changes {
  margin: 0 0 12px 18px;
  padding: 0;
  font-size: 13.5px;
  color: var(--ink-2);
}
.bef-popup-proposal {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--bg-elevated);
  margin-bottom: 12px;
}
.bef-popup-textarea {
  width: 100%;
  margin-top: 4px;
  font-family: var(--font-serif);
  line-height: 1.5;
  resize: vertical;
}
.bef-popup-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
.bef-popup-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--bg-elevated);
}
@media (max-width: 720px) {
  .bef-popup-body { grid-template-columns: 1fr; }
  .bef-popup-col { border-right: none; border-bottom: 1px solid var(--line); }
  .bef-popup-col:last-child { border-bottom: none; }
}

/* Karten-Hinweis im Lernmodus (M15 P5b). */
.study-bef-hints {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 0;
}
.study-bef-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--ink-2);
  font-size: 13px;
  cursor: pointer;
  align-self: flex-start;
  text-align: left;
}
.study-bef-hint:hover { border-color: var(--accent); color: var(--ink-1); }
.study-bef-dot {
  width: 9px; height: 9px;
  border-radius: 999px;
  background: var(--ink-3);
}
.study-bef-hint[data-verdict="ueberholt"] .study-bef-dot { background: var(--red); }
.study-bef-hint[data-verdict="moeglicherweise_ueberholt"] .study-bef-dot { background: var(--amber); }
.study-bef-hint[data-verdict="unbedenklich"] .study-bef-dot { background: var(--green); }
.study-bef-label { font-weight: 500; color: var(--ink-1); }

/* Diagramm-Karten */
.st-card { margin: 0; }
.st-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.st-card-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink-1);
}
.st-card-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }

.st-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  flex: none;
}
.st-pill-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Säulen-Diagramm */
.st-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 152px;
}
.st-bars-24 { gap: 2px; }
.st-bars-wide { gap: 12px; }
.st-bar {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.st-bar-track {
  flex: 1;
  display: flex;
  align-items: flex-end;
  min-height: 0;
}
.st-bar-col {
  width: 100%;
  min-height: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  transition: height 0.25s ease, background 0.12s;
}
.st-bar:hover .st-bar-col { background: var(--accent-hover); }
.st-bar.is-zero .st-bar-col {
  background: var(--line);
  border-radius: 3px;
}
.st-bar.is-hot .st-bar-col { background: var(--amber); }
.st-bar-x {
  margin-top: 6px;
  height: 12px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--ink-4);
  text-align: center;
  white-space: nowrap;
}

.st-empty {
  padding: 30px 16px;
  text-align: center;
  font-family: var(--font-serif);
  font-size: 14px;
  color: var(--ink-3);
}
.st-axis-note {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  text-align: right;
}
.st-note { font-size: 12.5px; color: var(--ink-3); margin: 0; }

/* Erinnerungsquote — drei Kennzahlen nebeneinander */
.st-trio { display: flex; gap: 14px; flex-wrap: wrap; }
.st-trio-item {
  flex: 1 1 130px;
  background: var(--bg-base);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.st-trio-val {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 500;
  color: var(--ink-1);
  line-height: 1;
}
.st-trio-lbl { font-size: 12px; color: var(--ink-3); margin-top: 8px; }
.st-trio-lbl span {
  display: block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-4);
  margin-top: 2px;
}

/* Geschätztes Wissen */
.st-know {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}
.st-know-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  opacity: 0.72;
  margin-bottom: 8px;
}
.st-know-value {
  font-family: var(--font-serif);
  font-size: 44px;
  font-weight: 500;
  line-height: 1;
}
.st-know-text {
  font-size: 13.5px;
  opacity: 0.9;
  margin-top: 10px;
  max-width: 62ch;
}
.st-know-text strong { font-weight: 600; }

/* Donut + Legende */
.st-donut-row {
  display: flex;
  align-items: center;
  gap: 30px;
  flex-wrap: wrap;
}
.st-donut {
  width: 172px;
  height: 172px;
  border-radius: 50%;
  position: relative;
  flex: none;
}
.st-donut-hole {
  position: absolute;
  inset: 30px;
  background: var(--bg-elevated);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.st-donut-num {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 500;
  color: var(--ink-1);
  line-height: 1;
}
.st-donut-cap {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  margin-top: 4px;
}
.st-legend {
  flex: 1 1 300px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.st-legend-row { display: flex; align-items: center; gap: 10px; }
.st-swatch {
  width: 11px; height: 11px;
  border-radius: 3px;
  flex: none;
}
.st-legend-label {
  font-size: 13px;
  color: var(--ink-2);
  width: 116px;
  flex: none;
}
.st-legend-bar {
  flex: 1;
  height: 7px;
  background: var(--bg-base);
  border-radius: 999px;
  overflow: hidden;
}
.st-legend-fill { display: block; height: 100%; border-radius: 999px; }
.st-legend-val {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
  width: 100px;
  text-align: right;
  flex: none;
}
.st-legend-val em { font-style: normal; color: var(--ink-4); }

/* Erinnerungsquote-Tabelle */
.st-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.st-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-4);
  font-weight: 500;
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--line);
}
.st-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
}
.st-table th:first-child,
.st-table td:first-child { padding-left: 2px; }
.st-table tbody tr:last-child td { border-bottom: none; }
.st-table td:first-child { font-weight: 500; color: var(--ink-1); }
.st-dim { color: var(--ink-4); }
.st-rate { font-weight: 600; }
.st-rate[data-good="true"] { color: var(--green); }
.st-rate[data-good="mid"] { color: var(--amber); }
.st-rate[data-good="false"] { color: var(--red); }

/* Waagerechte Balken (Bewertungs-Verteilung) */
.st-hrows { display: flex; flex-direction: column; gap: 12px; }
.st-hrow { display: flex; align-items: center; gap: 12px; }
.st-hrow-label {
  width: 78px;
  flex: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-1);
}
.st-hrow-track {
  flex: 1;
  height: 10px;
  background: var(--bg-base);
  border-radius: 999px;
  overflow: hidden;
}
.st-hrow-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s;
}
.st-hrow-val {
  width: 122px;
  flex: none;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-2);
}
.st-hrow-val em { font-style: normal; color: var(--ink-4); }

/* Statistik-Heatmap: füllt die Kartenbreite, kein Scrollen — die
   Spalten teilen sich den Platz, egal wie viele Wochen der Zeitraum
   umfasst. Alle Selektoren bleiben unter .heatmap, damit die
   Skala-Legende (.hm-scale) ihre festen Zellgrößen behält. */
.st-card .heatmap { gap: 6px; overflow: visible; }
.st-card .heatmap .hm-body { flex: 1; min-width: 0; gap: 4px; }
.st-card .heatmap .hm-grid,
.st-card .heatmap .hm-months { gap: 3px; }
.st-card .heatmap .hm-col { gap: 3px; flex: 0 1 15px; min-width: 0; }
.st-card .heatmap .hm-cell {
  width: 100%;
  height: 13px;
  border-radius: 3px;
  flex-shrink: 0;
}
.st-card .heatmap .hm-month {
  flex: 0 1 15px;
  min-width: 0;
  width: auto;
  overflow: visible;
}
.st-card .heatmap .hm-months { height: 12px; }
.st-card .heatmap .hm-weekdays { gap: 3px; padding-top: 16px; }
.st-card .heatmap .hm-weekdays span { height: 13px; line-height: 13px; }

@media (max-width: 720px) {
  .st-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .st-grid-2 { grid-template-columns: 1fr; }
  .st-tile-value { font-size: 26px; }
  .st-know-value { font-size: 36px; }
  .st-rangebar { flex-wrap: wrap; gap: 8px; }
  /* Tabs/Range-Buttons sollen ohne Umbruch scrollbar bleiben — auf
     360px sonst Wrap mit halben Worten. */
  .st-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .st-tabs::-webkit-scrollbar { display: none; }
  .st-tab { flex: none; white-space: nowrap; }
  .st-range { flex-wrap: nowrap; overflow-x: auto; }
  .st-range::-webkit-scrollbar { display: none; }
  /* Bewertungs-Verteilung: Label/Value schrumpfen, Track bleibt
     der Hauptanteil. */
  .st-hrow { gap: 8px; }
  .st-hrow-label { width: 58px; font-size: 12px; }
  .st-hrow-val { width: 88px; font-size: 10.5px; }
  /* Tile-Sub und axis-note: feinere Umbrüche. */
  .st-tile { padding: 14px 14px; }
  .st-bars { height: 130px; }
}

@media (max-width: 420px) {
  /* Letzte Sicherung für ganz kleine Screens. */
  .st-grid-4 { grid-template-columns: 1fr 1fr; gap: 8px; }
  .st-tile-value { font-size: 22px; }
  .st-tile-label { font-size: 10px; }
  .st-know-value { font-size: 30px; }
  .st-hrow-label { width: 50px; }
  .st-hrow-val { width: 78px; }
}

/* ============================================================
   ÜBERSICHT — Dashboard
   ============================================================ */

.dash-top {
  display: grid;
  /* Drei gleich breite Spalten — die linke „Jetzt loslegen"-Karte
     hebt sich durch Farbe ab, braucht keine extra Breite. */
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 26px;
  align-items: stretch;
}
.dash-top > * { min-width: 0; }

/* Großer Lern-Einstieg */
.dash-start {
  display: flex;
  flex-direction: column;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  transition: background 0.12s;
}
.dash-start:hover { background: var(--accent-hover); }
.dash-start-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  opacity: 0.72;
}
.dash-start-title {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 500;
  line-height: 1.1;
  margin-top: 10px;
}
.dash-start-meta { font-size: 14px; opacity: 0.88; margin-top: 8px; }
.dash-start-deck {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 22px;
  font-size: 14px;
  font-weight: 500;
}
.dash-start-deck svg { flex: none; }

/* Schnellzugriff-Karten */
.dash-mini { display: flex; flex-direction: column; margin: 0; }
.dash-mini-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
}
.dash-mini-big {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink-1);
  line-height: 1.15;
  margin-top: 10px;
}
.dash-mini-sub { font-size: 13px; color: var(--ink-3); margin-top: 6px; }
.dash-mini-link {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: auto;
  padding-top: 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}

/* Lese-Historie + Heute — Spaltenraster mit demselben Drittel-
   Rhythmus wie .dash-top (3 Drittel). "Zuletzt gelesen" nimmt 2/3,
   "Heute" das letzte Drittel. Beide Spalten strecken sich auf
   dieselbe Höhe (align-items: stretch), die rechte Spalte verteilt
   den Platz zwischen Streak und Karten-Fortschritt. */
.dash-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: stretch;
}
.dash-cols > * { min-width: 0; }
/* Linke Spalte (2/3 Breite) — streckt ihre Card auf die volle Spalten-
   höhe, damit der untere Rand mit dem Karten-Fortschritt-Block rechts
   bündig abschließt, selbst wenn nur wenige zuletzt-gelesene Normen
   da sind. */
.dash-cols-main {
  grid-column: 1 / span 2;
  display: flex;
  flex-direction: column;
  /* Gleicher Eyebrow→Card-Abstand wie in .dash-side, damit die linke
     Card und die rechte Streak-Box auf derselben Y-Linie starten. */
  gap: 14px;
}
.dash-cols-main > .card { flex: 1; }
/* Eyebrow ohne eigene margin — der Container-gap regelt den Abstand
   zur ersten Card auf beiden Seiten gleich. */
.dash-cols .page-eyebrow { margin: 0 !important; }

.dash-read { margin: 0; padding: 6px 8px; }
.dash-read-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 11px 8px;
  border-bottom: 1px solid var(--line-soft);
  transition: background 0.12s;
}
.dash-read-row:last-child { border-bottom: none; }
.dash-read-row:hover { background: rgba(0, 0, 0, 0.035); }
.dash-read-num {
  flex: none;
  width: 116px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}
.dash-read-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-serif);
  font-size: 15px;
  color: var(--ink-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-read-time { flex: none; font-size: 12px; color: var(--ink-4); }

.dash-side {
  grid-column: 3;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
/* Die Karten-Fortschritt-Karte füllt die verbleibende Höhe, damit die
   rechte Spalte denselben unteren Rand wie die Lese-Historie links
   trifft. */
.dash-side .dash-week { flex: 1; display: flex; flex-direction: column; }

.dash-streak {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
}
.dash-streak-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
}
.dash-streak-num {
  font-family: var(--font-serif);
  font-size: 34px;
  font-weight: 500;
  color: var(--ink-1);
  line-height: 1.05;
  margin-top: 4px;
}
.dash-streak-num span { font-size: 16px; color: var(--ink-3); }
.dash-streak-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--accent-tint);
  color: var(--accent);
  flex: none;
}

.dash-week { margin: 0; }
.dash-week-head { margin-bottom: 14px; }
.dash-week-title {
  display: block;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink-1);
}
.dash-week-tag {
  display: block;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-4);
}
.dash-week-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.dash-week-label {
  flex: none;
  width: 96px;
  font-size: 13px;
  color: var(--ink-2);
}
.dash-week-track {
  flex: 1;
  height: 8px;
  background: var(--bg-base);
  border-radius: 999px;
  overflow: hidden;
}
.dash-week-fill { display: block; height: 100%; border-radius: 999px; }
.dash-week-val {
  flex: none;
  width: 40px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-1);
}

/* Tablet (≤ 1100 px): die drei Kacheln bleiben sichtbar UND gleich
   groß — keine Spannweite-Logik mehr, weil sie die linke Kachel
   visuell deutlich größer wirken ließ als die rechten. Die Spalten
   schrumpfen bis zur Mobil-Schwelle einfach mit, alle gleich breit. */
@media (max-width: 1100px) and (min-width: 641px) {
  .dash-cols { grid-template-columns: 1fr; }
  .dash-cols-main { grid-column: 1; }
  .dash-side { grid-column: 1; }
}

/* Mobile: alles untereinander. */
@media (max-width: 640px) {
  .dash-top { grid-template-columns: 1fr; }
  .dash-cols { grid-template-columns: 1fr; }
  .dash-cols-main { grid-column: 1; }
  .dash-side { grid-column: 1; }
}

/* ============================================================
   EINSTELLUNGEN
   ============================================================ */
.chip-muted {
  background: var(--bg-base);
  color: var(--ink-4);
  border-color: transparent;
}
.btn-danger {
  border-color: color-mix(in srgb, var(--red) 40%, transparent);
  background: var(--bg-elevated);
  color: var(--red);
}
.btn-danger:hover { background: var(--red-tint); }

.set-section {
  padding: 22px 0;
  border-bottom: 1px solid var(--line-soft);
}
.set-section:last-of-type { border-bottom: none; }
.set-section-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 500;
  color: var(--ink-1);
}
.set-section-desc {
  font-size: 13px;
  color: var(--ink-3);
  margin-top: 4px;
  max-width: 62ch;
}
.set-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 18px;
  margin-top: 16px;
}
.set-field { margin-top: 16px; }
.set-grid-2 .set-field { margin-top: 0; }
.set-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.set-hint { font-size: 12px; color: var(--ink-4); margin-top: 5px; }
.set-row { display: flex; align-items: center; gap: 12px; }
.set-toggle-row {
  margin-top: 14px;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.set-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 24px;
}

/* Toggle-Schalter — die Checkbox selbst ist der Schalter. */
.toggle {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 40px;
  height: 22px;
  margin: 0;
  border-radius: 999px;
  background: var(--line-strong);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
.toggle::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
.toggle:checked { background: var(--accent); }
.toggle:checked::before { transform: translateX(18px); }
.toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Segmentierte Auswahl */
.seg-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.seg-opt { position: relative; }
.seg-opt input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.seg-opt span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-2);
}
.seg-opt span svg { opacity: 0.7; }
.seg-opt input:checked + span {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.seg-opt input:checked + span svg { opacity: 1; }

/* Gesetzbuch-Liste */
.set-list {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.set-list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.set-list-row:last-child { border-bottom: none; }
.set-book-code {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-1);
  width: 64px;
  flex: none;
}
.set-book-count { flex: 1; font-size: 13px; color: var(--ink-3); }

/* Kartentypen */
.set-types {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.set-type {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--bg-elevated);
}
.set-type-head { display: flex; align-items: center; gap: 8px; }
.set-type-name {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  color: var(--ink-1);
}
.set-type-info { font-size: 13px; color: var(--ink-3); margin-top: 5px; }

.set-danger .set-section-title { color: var(--red); }

@media (max-width: 720px) {
  .set-grid-2 { grid-template-columns: 1fr; }
}

/* ============================================================
   VOLLFOKUS — ablenkungsfreier Modus
   ============================================================ */
.app[data-focus="true"] { grid-template-columns: 1fr; }
.app[data-focus="true"] .sidebar,
.app[data-focus="true"] .mobile-tabbar { display: none; }
.focus-btn[data-on="true"] { color: var(--accent); background: var(--accent-tint); }

/* Konto-Verknüpfung in der Seitenleiste */
.sidebar-account {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 5px;
  margin: -5px;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}
.sidebar-account:hover { background: rgba(0, 0, 0, 0.05); }
.sidebar-account[data-active="true"] { background: rgba(0, 0, 0, 0.06); }

/* Lese-Schrift (Reiter „Anzeige") */
[data-reading-font="source-serif"] {
  --font-serif: "Source Serif Pro", "Source Serif 4", Georgia, serif;
}
[data-reading-font="geist"] { --font-serif: var(--font-sans); }

/* ============================================================
   STAPEL-VERWALTUNG — Drag & Drop, Kontextmenü
   ============================================================ */
.deck-tree-row[draggable="true"] { cursor: grab; }
.deck-tree-row.dragging { opacity: 0.4; }
.deck-tree-row.drop-target {
  background: var(--accent-tint);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 6px;
}

.ctx-menu {
  position: fixed;
  z-index: 200;
  min-width: 168px;
  padding: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font: 500 13.5px var(--font-sans);
  color: var(--ink-1);
  text-align: left;
  cursor: pointer;
}
.ctx-item:hover { background: var(--accent-tint); color: var(--accent); }
.ctx-item svg { color: var(--ink-4); }
.ctx-item:hover svg { color: var(--accent); }

/* ============================================================
   RECHTSSEITEN & SEITENFUSS (M10)
   ============================================================ */
.legal-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
}
.legal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 22px 24px;
}
.legal-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-serif);
  font-size: 19px;
  font-style: italic;
  color: var(--ink-1);
}
.legal-brand-mark {
  width: 30px;
  height: 30px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.legal-body {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 24px 64px;
}
.legal-h1 {
  font-family: var(--font-serif);
  font-size: 34px;
  font-weight: 500;
  color: var(--ink-1);
  margin: 0 0 10px;
}
.legal-body h2 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink-1);
  margin: 30px 0 8px;
}
.legal-body p {
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-2);
  margin: 0 0 12px;
}
.legal-lead { color: var(--ink-3); }
.legal-note {
  margin-top: 32px;
  padding: 12px 14px;
  background: var(--bg-paper);
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-4);
}

.site-footer {
  border-top: 1px solid var(--line-soft);
  background: var(--bg-base);
}
.site-footer-inner {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.site-footer-brand {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-4);
}
.site-footer-links {
  display: flex;
  gap: 18px;
}
.site-footer-links a { font-size: 13px; color: var(--ink-3); }
.site-footer-links a:hover { color: var(--accent); }

.set-legal-links {
  display: flex;
  gap: 18px;
  margin-top: 12px;
}
.set-legal-links a { font-size: 13.5px; color: var(--accent); }

/* Fehlerseite (404 / 500) */
.error-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg-base);
  padding: 24px;
}
.error-box {
  text-align: center;
  max-width: 420px;
}
.error-code {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.18em;
  color: var(--ink-4);
  margin-bottom: 10px;
}
.error-heading {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 500;
  color: var(--ink-1);
  margin: 0 0 10px;
}
.error-message {
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-3);
  margin: 0 0 24px;
}

/* ============================================================
   PRICING-PAGE
   ============================================================ */

.pricing-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 56px 100px;
}
.pricing-header { max-width: 760px; margin: 0 auto 56px; text-align: center; }
.pricing-header h1 {
  font-family: var(--font-serif);
  font-size: 52px;
  font-weight: 500;
  line-height: 1.05;
  margin: 18px 0 16px;
  letter-spacing: -0.01em;
}
.pricing-header p {
  font-size: 18px;
  color: var(--ink-3);
  max-width: 600px;
  margin: 0 auto;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  margin-bottom: 80px;
  align-items: stretch;
}
.pricing-card {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
}
.pricing-card-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.18);
  transform: translateY(-6px);
}
.pricing-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--accent);
  border: 1px solid var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 999px;
}
.pricing-tier-label {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.7;
}
.pricing-card-primary .pricing-tier-label { opacity: 0.85; }
.pricing-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 12px 0 18px;
}
.pricing-num {
  font-family: var(--font-serif);
  font-size: 48px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
}
.pricing-unit { font-size: 14px; opacity: 0.75; }
.pricing-lead {
  font-size: 14.5px;
  line-height: 1.5;
  margin: 0 0 22px;
  opacity: 0.9;
}
.pricing-features {
  list-style: none;
  padding: 0;
  margin: 0 0 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.pricing-features li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  line-height: 1.4;
}
.pricing-features li.muted { opacity: 0.55; }
.pricing-features svg { flex: none; margin-top: 3px; opacity: 0.85; }
.pricing-cta {
  width: 100%;
  justify-content: center;
  text-align: center;
}
.pricing-card-primary .pricing-cta.btn-primary {
  background: var(--accent-ink);
  color: var(--accent);
}
.pricing-card-primary .pricing-cta.btn-primary:hover {
  background: rgba(255, 255, 255, 0.92);
}
.pricing-foot {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
  opacity: 0.85;
}

.pricing-faq {
  max-width: 760px;
  margin: 0 auto 60px;
}
.pricing-faq h2 {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 500;
  margin: 0 0 24px;
  text-align: center;
}
.pricing-faq details {
  border-top: 1px solid var(--line-soft);
  padding: 14px 4px;
}
.pricing-faq details:last-child { border-bottom: 1px solid var(--line-soft); }
.pricing-faq summary {
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  list-style: none;
  position: relative;
  padding-right: 24px;
}
.pricing-faq summary::after {
  content: "+";
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--ink-3);
}
.pricing-faq details[open] summary::after { content: "−"; }
.pricing-faq details p {
  margin: 10px 0 0;
  font-size: 14.5px;
  color: var(--ink-3);
  line-height: 1.5;
}

.pricing-cta-row {
  text-align: center;
  padding: 40px 20px 20px;
}
.pricing-cta-row p {
  font-size: 16px;
  color: var(--ink-3);
  margin: 0 0 18px;
}

.landing-foot {
  max-width: 1200px;
  margin: 60px auto 0;
  padding: 26px 56px 32px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--ink-3);
}
.landing-foot nav { display: flex; gap: 22px; }
.landing-foot a:hover { color: var(--ink-1); }

@media (max-width: 900px) {
  .pricing-page { padding: 32px 20px 60px; }
  .pricing-header h1 { font-size: 36px; }
  .pricing-grid { grid-template-columns: 1fr; gap: 16px; }
  .pricing-card-primary { transform: none; }
  .landing-foot {
    padding: 22px 20px 28px;
    flex-direction: column;
    gap: 14px;
    text-align: center;
  }
}

/* ------------------------------------------------------------ */
/* Spinner — kleines drehendes Kreislein für asynchrone Buttons */
/* ------------------------------------------------------------ */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: rgba(255,255,255,0.95);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
  vertical-align: -2px;
}
.spinner.spinner-dark {
  border-color: rgba(0,0,0,0.15);
  border-top-color: rgba(0,0,0,0.55);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ */
/* Mobile-Polish — Befunde + Einstellungen                       */
/* Auf schmalen Screens scrollen die Tab-Leisten horizontal,     */
/* statt zu umbrechen. Befund-Karten stacken den „Öffnen"-Knopf. */
/* ------------------------------------------------------------ */
@media (max-width: 720px) {
  .kb-status-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .kb-status-tabs::-webkit-scrollbar { display: none; }
  .kb-status-tab {
    flex: none;
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 13px;
  }
  .settings-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .settings-tabs::-webkit-scrollbar { display: none; }
  .settings-tab {
    flex: none;
    white-space: nowrap;
    padding: 10px 12px;
  }
  /* Befund-Karte: Button unter den Inhalt, damit Titel die volle
     Breite bekommt. */
  .bef-card-head {
    grid-template-columns: 6px 1fr;
    gap: 12px;
    padding: 14px;
  }
  .bef-card-head > .btn {
    grid-column: 1 / -1;
    justify-self: end;
  }
  .bef-trigger-title { font-size: 16px; }
  .bef-summary { font-size: 13px; }
}

/* Abo-Sektion in Einstellungen. */
.set-abo-status {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 8px;
}
.set-abo-chip {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 500; letter-spacing: 0.02em;
  background: var(--bg-elevated, #eee); color: var(--ink-2, #555);
  border: 1px solid var(--border-soft, #e5e5e7);
}
.set-abo-active { background: #d8f5d8; color: #1a6e1a; border-color: #b9e8b9; }
.set-abo-trial { background: #fff5cc; color: #806000; border-color: #f0e0a0; }
.set-abo-canceled { background: #f0e6ff; color: #5b3a9a; border-color: #d8c8f0; }
.set-abo-danger { background: #ffd8d8; color: #9a1a1a; border-color: #f0b8b8; }
.set-abo-meta { font-size: 13px; color: var(--ink-3, #888); }
.set-abo-form { display: inline-block; margin-top: 14px; }
.set-abo-hint { margin-top: 8px; font-size: 13px; }
.set-abo-empty { font-size: 14px; color: var(--ink-2, #555); margin-top: 8px; }

.set-konto-delete { margin-top: 14px; }
