/* ============================================================================
   styles.css — Basis, Schale, Bausteine, Muster, Bewegung.
   Alles Farbige, jeder Abstand und jede Dauer kommt aus theme.css.
   ========================================================================= */

/* ---------------------------------------------------------------- 1 · Basis */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  font-feature-settings: 'cv05' 1, 'cv08' 1, 'ss03' 1;   /* offenes l, gerades y */
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  min-height: 100dvh;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: var(--weight-semi);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-snug);
  text-wrap: balance;
}
h1 { font-size: var(--text-3xl); letter-spacing: var(--tracking-tight); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

p { margin: 0 0 var(--sp-3); max-width: var(--measure); }
p:last-child { margin-bottom: 0; }

a { color: var(--brand-text); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand-hover); }

::selection { background: var(--brand-subtle-2); color: var(--text); }

/* Ein Fokusring, ueberall gleich, nur fuer Tastatur. */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
:focus:not(:focus-visible) { outline: none; }

/* Zahlen laufen nicht, wenn sie sich aendern. */
.tnum, .stat-value, .agenda-time, .plan-date, .mastery-pct {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); font-size: var(--text-sm); }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.wrap { flex-wrap: wrap; }
.scroll-x { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }

hr, .divider {
  border: none; height: 1px; background: var(--border);
  margin: var(--sp-4) 0;
}

/* --------------------------------------------------------------- 2 · Icons */

lwm-icon { display: inline-flex; flex: none; line-height: 0; color: inherit; }
lwm-icon svg {
  width: var(--icon-md); height: var(--icon-md);
  stroke: currentColor;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
lwm-icon[data-size='sm'] svg { width: var(--icon-sm); height: var(--icon-sm); stroke-width: 1.9; }
lwm-icon[data-size='lg'] svg { width: var(--icon-lg); height: var(--icon-lg); }
lwm-icon[data-size='xl'] svg { width: 32px; height: 32px; stroke-width: 1.6; }

/* --------------------------------------------------------------- 3 · Schale */

#app { min-height: 100dvh; }

.shell {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
}

/* Kopfzeile: auf dem Handy die einzige feste Leiste oben. */
.topbar {
  position: sticky; top: 0; z-index: var(--z-nav);
  display: flex; align-items: center; gap: var(--sp-3);
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--gutter) 0;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-base) var(--ease-standard);
}
.topbar[data-scrolled='true'] { border-bottom-color: var(--border); }

.brand {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  color: var(--text); text-decoration: none;
  font-weight: var(--weight-bold); letter-spacing: var(--tracking-tight);
  font-size: var(--text-lg);
}
.brand lwm-icon { color: var(--brand); }
.brand lwm-icon svg { width: 26px; height: 26px; }

.topbar .spacer { flex: 1; }

/* Streak- und Level-Anzeige in der Kopfzeile */
.status-pill {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 34px; padding: 0 var(--sp-3);
  border-radius: var(--r-full);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard);
}
.status-pill:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text); }
.status-pill .flame { color: var(--warn); }
.status-pill .lvl { color: var(--brand-text); font-weight: var(--weight-semi); }

/* Inhaltsspalte */
.view {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-5) var(--gutter)
           calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--sp-8));
}

/* Seitenkopf: Titel, Unterzeile, Aktionen */
.page-head {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  flex-wrap: wrap; margin-bottom: var(--sp-5);
}
.page-head .titles { min-width: 0; flex: 1 1 auto; }
.page-head h1 { margin-bottom: var(--sp-1); }
.page-head .sub { color: var(--text-muted); font-size: var(--text-sm); margin: 0; }
.page-head .actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

.section-head {
  display: flex; align-items: center; gap: var(--sp-2);
  margin: var(--sp-6) 0 var(--sp-3);
}
.section-head:first-child { margin-top: 0; }
.section-head h2, .section-head h3 { flex: 1; min-width: 0; font-size: var(--text-lg); }

/* ------------------------------------------------------ 4 · Navigation */

/* Handy: Tableiste unten. Fuenf Ziele, mehr passt nicht in den Daumenbereich. */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: var(--z-nav);
  display: flex;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg-elevated) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(16px);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  position: relative;
  flex: 1 1 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  min-height: 48px;
  color: var(--text-subtle); text-decoration: none;
  font-size: var(--text-2xs); font-weight: var(--weight-medium);
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--dur-fast) var(--ease-standard);
}
.tabbar a lwm-icon { transition: transform var(--dur-slow) var(--ease-spring); }
.tabbar a[aria-current='page'] { color: var(--brand-text); }
.tabbar a[aria-current='page'] lwm-icon { transform: translateY(-1px) scale(1.06); }
.tabbar a:active lwm-icon { transform: scale(.9); }
/* Der laufende Punkt zeigt, wo man ist — ohne den ganzen Reiter zu faerben. */
.tabbar a::after {
  content: ''; position: absolute; top: 6px;
  width: 4px; height: 4px; border-radius: var(--r-full);
  background: var(--brand);
  opacity: 0; transform: scale(.4);
  transition: opacity var(--dur-base) var(--ease-standard),
              transform var(--dur-slow) var(--ease-spring);
}
.tabbar a[aria-current='page']::after { opacity: 1; transform: scale(1); }

.rail, .sidebar { display: none; }

/* Tablet: schmale Leiste mit Icons an der Seite. */
@media (min-width: 720px) {
  .shell {
    grid-template-columns: var(--rail-w) 1fr;
    grid-template-areas: 'rail topbar' 'rail main';
    grid-template-rows: auto 1fr;
  }
  .topbar { grid-area: topbar; }
  /* Marke und Schnellzugriffe stehen dort schon in der Leiste. */
  .brand-mobile, .topbar-shortcuts { display: none; }
  .view { grid-area: main; padding-bottom: var(--sp-10); }
  .tabbar { display: none; }

  .rail {
    grid-area: rail;
    position: sticky; top: 0; align-self: start;
    display: flex; flex-direction: column; align-items: center; gap: var(--sp-1);
    height: 100dvh; padding: var(--sp-4) var(--sp-2) var(--sp-4);
    border-right: 1px solid var(--border);
    background: var(--bg-elevated);
  }
  .rail .brand-mark { margin-bottom: var(--sp-4); color: var(--brand); line-height: 0; }
  .rail .brand-mark svg { width: 30px; height: 30px; }
  .rail a {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    width: 56px; height: 52px;
    border-radius: var(--r-md);
    color: var(--text-subtle); text-decoration: none;
    font-size: 10px; font-weight: var(--weight-medium);
    transition: background var(--dur-fast) var(--ease-standard),
                color var(--dur-fast) var(--ease-standard);
  }
  .rail a:hover { background: var(--surface-hover); color: var(--text); }
  .rail a[aria-current='page'] { background: var(--brand-subtle); color: var(--brand-text); }
  .rail .rail-end { margin-top: auto; }
}

/* Desktop: volle Seitenleiste mit Beschriftung. */
@media (min-width: 1100px) {
  .shell { grid-template-columns: var(--sidebar-w) 1fr; grid-template-areas: 'side topbar' 'side main'; }
  .rail { display: none; }

  .sidebar {
    grid-area: side;
    position: sticky; top: 0; align-self: start;
    display: flex; flex-direction: column; gap: var(--sp-1);
    height: 100dvh; padding: var(--sp-5) var(--sp-3);
    border-right: 1px solid var(--border);
    background: var(--bg-elevated);
  }
  .sidebar .brand { margin: 0 var(--sp-2) var(--sp-6); }
  .sidebar .nav-group-label {
    padding: var(--sp-4) var(--sp-3) var(--sp-1);
    font-size: var(--text-2xs); font-weight: var(--weight-semi);
    letter-spacing: var(--tracking-wide); text-transform: uppercase;
    color: var(--text-subtle);
  }
  .sidebar a {
    position: relative;
    display: flex; align-items: center; gap: var(--sp-3);
    padding: 9px var(--sp-3);
    border-radius: var(--r-md);
    color: var(--text-muted); text-decoration: none;
    font-size: var(--text-md); font-weight: var(--weight-medium);
    transition: background var(--dur-fast) var(--ease-standard),
                color var(--dur-fast) var(--ease-standard);
  }
  .sidebar a:hover { background: var(--surface-hover); color: var(--text); }
  .sidebar a[aria-current='page'] {
    background: var(--brand-subtle); color: var(--brand-text);
    font-weight: var(--weight-semi);
  }
  .sidebar a[aria-current='page']::before {
    content: ''; position: absolute; left: calc(var(--sp-3) * -1);
    top: 50%; translate: 0 -50%;
    width: 3px; height: 20px; border-radius: var(--r-full);
    background: var(--brand);
  }
  .sidebar .count {
    margin-left: auto; font-size: var(--text-xs); font-weight: var(--weight-semi);
    color: var(--text-subtle);
    font-variant-numeric: tabular-nums;
  }
  .sidebar a[aria-current='page'] .count { color: var(--brand-text); }
  .sidebar .sidebar-end { margin-top: auto; }
}

/* -------------------------------------------------------- 5 · Bausteine */

/* Karte: Traeger von Inhalt, kein Schmuck. Schatten nur, wenn sie schwebt. */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
}
.card + .card { margin-top: var(--sp-3); }
.card-head {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.card-head h2, .card-head h3 { flex: 1; min-width: 0; font-size: var(--text-lg); }
.card-head .head-icon { color: var(--text-subtle); }
.card.flat { background: transparent; border-color: var(--border); }
.card.sunken { background: var(--surface-sunken); border-color: transparent; }
.card.accent { background: var(--brand-subtle); border-color: var(--brand-subtle-2); }
.card.pad-0 { padding: 0; overflow: hidden; }
.card.pad-lg { padding: var(--sp-6); }

.grid { display: grid; gap: var(--sp-3); align-items: start; }
/* Kartenlisten: auto-fill, damit eine einzelne Karte nicht die ganze Breite fuellt. */
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
/* Kennzahlen: immer so viele nebeneinander wie passen. */
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(min(50% - var(--sp-3) / 2, 170px), 1fr)); }
/* Zwei ungleiche Spalten — die linke traegt den Hauptinhalt. */
.grid.split { grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid.split { grid-template-columns: 1.35fr 1fr; } }

/* Kennzahl-Kachel */
.stat {
  display: flex; flex-direction: column; gap: var(--sp-1);
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: inherit; text-decoration: none;
  transition: border-color var(--dur-base) var(--ease-standard),
              transform var(--dur-base) var(--ease-spring),
              box-shadow var(--dur-base) var(--ease-standard);
}
a.stat:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-md); }
a.stat:active { transform: translateY(0) scale(.99); }
.stat-top { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-subtle); }
.stat-top .label { font-size: var(--text-sm); font-weight: var(--weight-medium); }
.stat-value {
  font-size: var(--text-4xl); font-weight: var(--weight-bold);
  line-height: 1; letter-spacing: var(--tracking-tight);
}
.stat-value.small { font-size: var(--text-2xl); }
.stat-note { font-size: var(--text-sm); color: var(--text-muted); }
.stat.is-active { border-color: var(--brand); background: var(--brand-subtle); }
.stat.is-active .stat-value, .stat.is-active .stat-top { color: var(--brand-text); }

/* Knoepfe */
.btn {
  --btn-bg: var(--brand);
  --btn-fg: var(--text-on-brand);
  --btn-border: transparent;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 40px; padding: 0 var(--sp-4);
  border: 1px solid var(--btn-border);
  border-radius: var(--r-md);
  background: var(--btn-bg); color: var(--btn-fg);
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-semi);
  letter-spacing: 0;
  text-decoration: none; cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard),
              transform var(--dur-instant) var(--ease-standard),
              opacity var(--dur-fast) var(--ease-standard);
}
.btn:hover { --btn-bg: var(--brand-hover); }
.btn:active { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: .45; cursor: not-allowed; transform: none; }

.btn.secondary { --btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--border-strong); }
.btn.secondary:hover { --btn-bg: var(--surface-hover); }
.btn.ghost { --btn-bg: transparent; --btn-fg: var(--text-muted); --btn-border: transparent; }
.btn.ghost:hover { --btn-bg: var(--surface-hover); --btn-fg: var(--text); }
.btn.quiet { --btn-bg: var(--surface-sunken); --btn-fg: var(--text); --btn-border: transparent; }
.btn.quiet:hover { --btn-bg: var(--surface-active); }
.btn.danger { --btn-bg: var(--danger); --btn-fg: #fff; }
.btn.danger:hover { --btn-bg: var(--danger-hover); }
.btn.danger-ghost { --btn-bg: transparent; --btn-fg: var(--danger); --btn-border: transparent; }
.btn.danger-ghost:hover { --btn-bg: var(--danger-subtle); }

.btn.sm { min-height: 34px; padding: 0 var(--sp-3); font-size: var(--text-sm); }
.btn.lg { min-height: 48px; padding: 0 var(--sp-6); font-size: var(--text-md); }
.btn.block { width: 100%; }

/* Icon-Knopf: sichtbar klein, Trefferflaeche trotzdem 44px. */
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: transparent; color: var(--text-muted);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard),
              transform var(--dur-instant) var(--ease-standard);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.bordered { border-color: var(--border-strong); background: var(--surface); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: var(--danger-subtle); }
.icon-btn.sm { width: 34px; height: 34px; }

.btn-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.btn-row.end { justify-content: flex-end; }

/* Segmentierte Auswahl (Ansichtswechsel, Modus) */
.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-sunken);
  border-radius: var(--r-md);
}
.segmented button {
  min-height: 32px; padding: 0 var(--sp-3);
  border: none; border-radius: calc(var(--r-md) - 3px);
  background: transparent; color: var(--text-muted);
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium);
  cursor: pointer; display: inline-flex; align-items: center; gap: var(--sp-2);
  transition: background var(--dur-base) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed='true'] {
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-xs);
  font-weight: var(--weight-semi);
}

/* Chips und Marken */
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  height: 26px; padding: 0 10px;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  color: var(--text-muted);
  font-size: var(--text-xs); font-weight: var(--weight-medium);
  white-space: nowrap;
}
.chip lwm-icon svg { width: 14px; height: 14px; }
.chip.brand { background: var(--brand-subtle); color: var(--brand-text); }
.chip.warn { background: var(--warn-subtle); color: var(--warn); }
.chip.danger { background: var(--danger-subtle); color: var(--danger); }
.chip.info { background: var(--info-subtle); color: var(--info); }
.chip.outline { background: transparent; border: 1px solid var(--border); }

.count-badge {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r-full);
  background: var(--brand); color: var(--text-on-brand);
  font-size: var(--text-2xs); font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
}
.count-badge.warn { background: var(--warn); color: #fff; }
.count-badge.quiet { background: var(--surface-sunken); color: var(--text-muted); }

/* Auswahl-Chips (Faecher im Setup, Filter) */
.choice {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: 40px; padding: 0 var(--sp-4);
  border: 1px solid var(--border-strong); border-radius: var(--r-full);
  background: var(--surface); color: var(--text-muted);
  font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard),
              transform var(--dur-instant) var(--ease-standard);
}
.choice:hover { border-color: var(--brand); color: var(--text); }
.choice:active { transform: scale(.97); }
.choice[aria-pressed='true'] {
  background: var(--brand-subtle); border-color: var(--brand);
  color: var(--brand-text); font-weight: var(--weight-semi);
}

/* Formulare */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field:last-child { margin-bottom: 0; }
.field > label, .label {
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--text-muted);
}
.field .hint { font-size: var(--text-xs); color: var(--text-subtle); }
.field .error { font-size: var(--text-xs); color: var(--danger); display: flex; align-items: center; gap: 4px; }
.field-row { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: flex-end; }
.field-row > .field { flex: 1 1 160px; margin-bottom: 0; }

input[type='text'], input[type='email'], input[type='password'], input[type='number'],
input[type='date'], input[type='time'], input[type='search'], select, textarea {
  width: 100%;
  min-height: 42px; padding: 9px var(--sp-3);
  font: inherit; font-size: var(--text-md);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease-standard),
              box-shadow var(--dur-fast) var(--ease-standard),
              background var(--dur-fast) var(--ease-standard);
}
input::placeholder, textarea::placeholder { color: var(--text-subtle); }
input:hover, select:hover, textarea:hover { border-color: var(--text-subtle); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-subtle-2);
}
textarea { min-height: 96px; resize: vertical; line-height: var(--leading-normal); }
select {
  appearance: none; cursor: pointer; padding-right: var(--sp-8);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 18px center, right 13px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
input[type='color'] {
  flex: none; width: 42px; height: 42px; padding: 3px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface);
}
input[type='range'] {
  /* Gleiche Hoehe wie ein Eingabefeld, damit Zeilen mit gemischten
     Bedienelementen auf einer Linie sitzen. */
  width: 100%; min-height: 42px; padding: 0; background: transparent;
  appearance: none; cursor: pointer; border: none;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 5px; border-radius: var(--r-full); background: var(--surface-sunken);
}
input[type='range']::-webkit-slider-thumb {
  appearance: none; width: 20px; height: 20px; margin-top: -7.5px;
  border-radius: var(--r-full); background: var(--brand);
  border: 2px solid var(--surface); box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease-spring);
}
input[type='range']:active::-webkit-slider-thumb { transform: scale(1.15); }
input[type='range']::-moz-range-track { height: 5px; border-radius: var(--r-full); background: var(--surface-sunken); }
input[type='range']::-moz-range-thumb {
  width: 18px; height: 18px; border: 2px solid var(--surface);
  border-radius: var(--r-full); background: var(--brand);
}

/* Kontrollkaestchen als eigenes Element, damit es in beiden Themen sitzt. */
.check {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  cursor: pointer; min-height: 44px;
}
.check input[type='checkbox'] { position: absolute; opacity: 0; width: 0; height: 0; }
.check .box {
  flex: none; display: grid; place-items: center;
  width: 22px; height: 22px;
  border: 1.5px solid var(--border-strong); border-radius: var(--r-xs);
  background: var(--surface);
  color: transparent;
  transition: background var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard);
}
.check .box lwm-icon svg { width: 15px; height: 15px; stroke-width: 2.6; }
.check input:checked + .box {
  background: var(--brand); border-color: var(--brand); color: var(--text-on-brand);
}
.check input:focus-visible + .box { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.check .text { font-size: var(--text-md); }

/* Listen */
.list { list-style: none; margin: 0; padding: 0; }
.list > li {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}
.list > li:last-child { border-bottom: none; padding-bottom: 0; }
.list > li:first-child { padding-top: 0; }
.list .li-title { font-weight: var(--weight-medium); }
.list .li-sub { font-size: var(--text-sm); color: var(--text-muted); }
.list.interactive > li { transition: background var(--dur-fast) var(--ease-standard); }
.list.rows > li {
  padding: var(--sp-3); border-radius: var(--r-md); border-bottom: none;
}
.list.rows > li:hover { background: var(--surface-hover); }

/* Leerzustand */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
  padding: var(--sp-10) var(--sp-5);
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  color: var(--text-muted);
}
.empty .empty-icon {
  display: grid; place-items: center;
  width: 52px; height: 52px; border-radius: var(--r-full);
  background: var(--surface-sunken); color: var(--text-subtle);
}
.empty h2, .empty h3 { color: var(--text); font-size: var(--text-xl); }
.empty p { max-width: 42ch; }

/* Fortschritt */
.bar {
  height: 6px; border-radius: var(--r-full);
  background: var(--surface-sunken); overflow: hidden;
}
.bar > span {
  display: block; height: 100%; border-radius: var(--r-full);
  background: var(--brand);
  transition: width var(--dur-slower) var(--ease-out);
}
.bar.thin { height: 4px; }
.bar.warn > span { background: var(--warn); }
.bar.danger > span { background: var(--danger); }

/* Ladeanzeige: Platzhalter statt Kreisel — die Seite springt dann nicht. */
.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(100deg,
    var(--surface-sunken) 30%, var(--surface-hover) 50%, var(--surface-sunken) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 180% 0; } to { background-position: -20% 0; } }
.skeleton.text { height: 12px; margin: 6px 0; }
.skeleton.title { height: 22px; width: 46%; margin-bottom: var(--sp-3); }
.skeleton.block { height: 88px; }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.spinner {
  width: 16px; height: 16px; flex: none;
  border: 2px solid var(--border-strong); border-top-color: var(--brand);
  border-radius: var(--r-full);
  animation: spin .6s linear infinite;
}
@keyframes spin { to { rotate: 360deg; } }
.loading { display: flex; align-items: center; justify-content: center; gap: var(--sp-3);
  padding: var(--sp-8); color: var(--text-muted); font-size: var(--text-sm); }

/* Dialog */
dialog {
  width: min(560px, calc(100vw - var(--sp-8)));
  max-height: min(88dvh, 760px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog::backdrop { background: var(--scrim); backdrop-filter: blur(3px); }
dialog[open] { animation: dialog-in var(--dur-slow) var(--ease-out); }
dialog[open]::backdrop { animation: fade-in var(--dur-base) var(--ease-standard); }
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.dialog-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-3);
}
.dialog-head h2, .dialog-head h3 { flex: 1; font-size: var(--text-xl); font-weight: var(--weight-semi); }
.dialog-body { padding: 0 var(--sp-5) var(--sp-2); overflow-y: auto; max-height: 60dvh; }
.dialog-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--surface-sunken);
}
.dialog-foot .spacer { flex: 1; }

/* Auf dem Handy laeuft der Dialog als Blatt von unten ein. */
@media (max-width: 560px) {
  dialog {
    width: 100vw; max-width: 100vw;
    margin: auto auto 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    border-bottom: none;
    padding-bottom: env(safe-area-inset-bottom);
  }
  dialog[open] { animation: sheet-in var(--dur-slow) var(--ease-out); }
  @keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
}

/* Kurznachrichten */
.toast-host {
  position: fixed; z-index: var(--z-toast);
  left: 50%; translate: -50% 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--sp-3));
  display: flex; flex-direction: column-reverse; align-items: center; gap: var(--sp-2);
  width: min(440px, calc(100vw - var(--sp-8)));
  pointer-events: none;
}
@media (min-width: 720px) { .toast-host { bottom: var(--sp-5); } }
.toast {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 10px var(--sp-4);
  border-radius: var(--r-full);
  background: var(--sand-900); color: var(--sand-100);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in var(--dur-slow) var(--ease-spring);
}
:root[data-theme='dark'] .toast { background: var(--sand-200); color: var(--sand-900); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .toast { background: var(--sand-200); color: var(--sand-900); }
}
.toast.error { background: var(--danger); color: #fff; }
.toast.leaving { animation: toast-out var(--dur-base) var(--ease-in) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(.96); } }

/* ---------------------------------------------------- 6 · Bewegung */

/* Ansichtswechsel: kurzer Auftritt, kein Karussell. */
.view-enter { animation: view-in var(--dur-slow) var(--ease-out); }
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Listen laufen gestaffelt ein — die Verzoegerung setzt JS als Variable. */
.stagger > * {
  animation: stagger-in var(--dur-slow) var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}
@keyframes stagger-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.pop { animation: pop var(--dur-slow) var(--ease-spring); }
@keyframes pop { from { transform: scale(.9); } to { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .view-enter, .stagger > *, .pop, .toast, dialog[open] { animation: none !important; }
  * { scroll-behavior: auto !important; }
}

/* ================================================================== 7 · Muster */

/* --- Anmeldung und Setup --- */

.auth {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: var(--sp-5) var(--gutter);
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, var(--brand-subtle), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  padding: var(--sp-6);
  box-shadow: var(--shadow-md);
  animation: view-in var(--dur-slower) var(--ease-out);
}
.auth-card.wide { max-width: 540px; }
.auth-brand {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-5); text-align: center;
}
.auth-brand h1 { font-size: var(--text-2xl); }
.auth-brand p { color: var(--text-muted); font-size: var(--text-sm); margin: 0; }
.auth-switch {
  margin-top: var(--sp-4); padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  text-align: center; font-size: var(--text-sm); color: var(--text-muted);
}
.auth-switch button {
  border: none; background: none; padding: 0; cursor: pointer;
  color: var(--brand-text); font: inherit; font-weight: var(--weight-semi);
  text-decoration: underline; text-underline-offset: 2px;
}

/* Schrittanzeige im Setup */
.steps { display: flex; align-items: center; gap: 6px; justify-content: center; margin-top: var(--sp-5); }
.steps i {
  display: block; width: 7px; height: 7px; border-radius: var(--r-full);
  background: var(--border-strong);
  transition: width var(--dur-slow) var(--ease-spring), background var(--dur-base) var(--ease-standard);
}
.steps i.done { background: var(--brand); }
.steps i.now { width: 22px; background: var(--brand); }

/* Moki-Auswahl */
.moki-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-3); }
.moki-option {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-3);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text);
  cursor: pointer; font: inherit; text-align: center;
  transition: border-color var(--dur-base) var(--ease-standard),
              background var(--dur-base) var(--ease-standard),
              transform var(--dur-base) var(--ease-spring);
}
.moki-option:hover { border-color: var(--brand); transform: translateY(-2px); }
.moki-option[aria-pressed='true'] {
  border-color: var(--brand); background: var(--brand-subtle);
  box-shadow: 0 0 0 1px var(--brand);
}
.moki-option .name { font-weight: var(--weight-semi); font-size: var(--text-sm); }
.moki-option .hint { font-size: var(--text-xs); color: var(--text-muted); line-height: var(--leading-snug); }
.moki-option[disabled] { opacity: .5; cursor: not-allowed; }

/* --- Mokis Ecke --- */

.moki-dock {
  position: fixed; z-index: var(--z-dock);
  right: var(--gutter);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--sp-3));
  display: flex; justify-content: flex-end; align-items: flex-end;
  max-width: min(340px, calc(100vw - var(--sp-8)));
  pointer-events: none;
}
@media (min-width: 720px) { .moki-dock { bottom: var(--sp-5); } }
/* Moki nimmt keine Klicks entgegen — sonst blockiert er Knoepfe, die unter
   ihm liegen. Er tritt zurueck, solange er nichts sagt. */
.moki-dock, .moki-dock * { pointer-events: none; }
.moki-dock moki-bubble {
  width: 100%;
  opacity: .5;
  transition: opacity var(--dur-slow) var(--ease-standard);
}
.moki-dock.speaking moki-bubble { opacity: 1; }

/* --- Fachmarke --- */

subject-chip { display: inline-flex; vertical-align: middle; }

/* --- Agenda --- */

.agenda { display: flex; flex-direction: column; }
.agenda-item {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}
.agenda-item:last-child { border-bottom: none; padding-bottom: 0; }
.agenda-item:first-child { padding-top: 0; }
.agenda-time {
  width: 46px; flex: none; padding-top: 1px;
  font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-muted);
}
.agenda-rule { width: 3px; align-self: stretch; flex: none; border-radius: var(--r-full); background: var(--border-strong); }
.agenda-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.agenda-title { display: flex; align-items: center; gap: var(--sp-2); font-weight: var(--weight-medium); }
.agenda-title lwm-icon { color: var(--text-subtle); }
.agenda-meta { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; font-size: var(--text-sm); color: var(--text-muted); }
.agenda-item.is-done .agenda-title { text-decoration: line-through; color: var(--text-subtle); }

/* --- Kalender: Monat --- */

.month {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--r-md);
  overflow: hidden;
}
.month .dow {
  background: var(--surface-sunken); padding: var(--sp-2) 0;
  text-align: center; font-size: var(--text-2xs); font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--text-subtle);
}
.month-day {
  position: relative;
  background: var(--surface);
  min-height: 76px; padding: 6px;
  border: none; text-align: left; cursor: pointer;
  font: inherit; color: inherit;
  display: flex; flex-direction: column; gap: 4px;
  transition: background var(--dur-fast) var(--ease-standard);
}
.month-day:hover { background: var(--surface-hover); }
.month-day.other { background: var(--surface-sunken); color: var(--text-subtle); }
.month-day .n {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: var(--r-full);
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
}
.month-day.today .n { background: var(--brand); color: var(--text-on-brand); font-weight: var(--weight-bold); }
.month-day.selected { box-shadow: inset 0 0 0 2px var(--brand); }
.month-dots { display: flex; flex-wrap: wrap; gap: 3px; }
.month-dots i { width: 5px; height: 5px; border-radius: var(--r-full); background: var(--text-subtle); }
.month-more { font-size: 10px; color: var(--text-subtle); }
@media (min-width: 720px) { .month-day { min-height: 104px; padding: var(--sp-2); } }

/* --- Kalender: Woche --- */

.week {
  display: grid; grid-template-columns: 54px repeat(7, minmax(58px, 1fr));
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--r-md);
  overflow: hidden; min-width: 560px;
}
.week > * { background: var(--surface); }
.week .corner, .week .dayhead {
  background: var(--surface-sunken); padding: var(--sp-2) 4px; text-align: center;
}
.week .dayhead .d { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--text-subtle); }
.week .dayhead .n { font-size: var(--text-md); font-weight: var(--weight-semi); font-variant-numeric: tabular-nums; }
.week .dayhead.today .n { color: var(--brand-text); }
.week .hour { background: var(--surface-sunken); padding: 2px 6px; text-align: right;
  font-size: var(--text-2xs); color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.week .cell { min-height: 30px; padding: 2px; display: flex; flex-direction: column; gap: 2px; }
.week-block {
  border-radius: var(--r-xs); padding: 2px 5px;
  font-size: var(--text-2xs); font-weight: var(--weight-semi);
  color: #fff; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

/* --- Lernkarten --- */

.review-stage { display: grid; place-items: center; min-height: 46dvh; padding: var(--sp-4) 0; }
.review-grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); margin-top: var(--sp-5); }
.review-grades .btn {
  flex-direction: column; gap: 1px; min-height: 62px; padding: var(--sp-2);
}
.review-grades .btn .g-label { font-size: var(--text-sm); font-weight: var(--weight-semi); }
.review-grades .btn .g-when { font-size: var(--text-2xs); font-weight: var(--weight-normal); opacity: .85; }
.review-grades .again { --btn-bg: var(--danger); --btn-fg: #fff; }
.review-grades .again:hover { --btn-bg: var(--danger-hover); }
.review-grades .hard { --btn-bg: var(--warn); --btn-fg: #fff; }
.review-grades .good { --btn-bg: var(--brand); --btn-fg: var(--text-on-brand); }
.review-grades .easy { --btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--border-strong); }
.review-grades .easy:hover { --btn-bg: var(--surface-hover); }
.kbd-hint {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  margin-top: var(--sp-4); font-size: var(--text-xs); color: var(--text-subtle);
  flex-wrap: wrap;
}
/* Auf Touchgeraeten gibt es keine Tastatur — der Hinweis waere nur Ballast. */
@media (pointer: coarse) { .kbd-hint { display: none; } }
kbd {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: var(--r-xs); background: var(--surface);
  font-family: var(--font); font-size: var(--text-2xs); font-weight: var(--weight-semi);
  color: var(--text-muted);
}

/* --- Handschrift --- */

.train-glyph {
  font-size: 64px; line-height: 1; font-weight: var(--weight-medium);
  text-align: center; color: var(--text-subtle);
  font-variant-numeric: lining-nums;
}
.train-canvas-wrap { display: grid; place-items: center; margin: var(--sp-4) 0 var(--sp-3); }
ink-canvas { width: 100%; }
.ink-toolbar {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.glyph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; }
.glyph-cell {
  aspect-ratio: 1; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--r-xs);
  background: var(--surface-sunken); color: var(--text-subtle);
  font-size: var(--text-sm);
}
.glyph-cell.done { background: var(--brand-subtle); border-color: var(--brand-subtle-2); color: var(--brand-text); font-weight: var(--weight-semi); }

.ink-preview {
  background:
    linear-gradient(45deg, var(--surface-sunken) 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, var(--surface-sunken) 25%, transparent 25%) 0 8px / 16px 16px,
    linear-gradient(45deg, transparent 75%, var(--surface-sunken) 75%) 8px -8px / 16px 16px,
    linear-gradient(-45deg, transparent 75%, var(--surface-sunken) 75%) -8px 0 / 16px 16px,
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: auto;
}
.ink-preview canvas { display: block; max-width: 100%; }

/* --- Pruefung --- */

.stepper { display: flex; flex-direction: column; gap: var(--sp-3); }
.step-card { position: relative; padding-left: var(--sp-12); }
.step-card::before {
  content: attr(data-step);
  position: absolute; left: var(--sp-4); top: var(--sp-4);
  display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: var(--r-full);
  background: var(--surface-sunken); color: var(--text-subtle);
  font-size: var(--text-sm); font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
}
.step-card.is-done::before {
  content: ''; background: var(--brand);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5 9.5 17 19 6.5'/%3E%3C/svg%3E");
  background-size: 15px; background-position: center; background-repeat: no-repeat;
}
.step-card.is-active::before { background: var(--brand); color: var(--text-on-brand); }

.mastery-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 7px 0; max-width: 620px;
}
.mastery-name { flex: 0 1 190px; min-width: 0; font-size: var(--text-sm); }
.mastery-row .bar { flex: 1 1 auto; min-width: 80px; }
.mastery-row input[type='range'] { flex: 1 1 auto; min-width: 100px; }
.mastery-pct { width: 38px; text-align: right; font-size: var(--text-sm); color: var(--text-muted); }

.plan-day {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color var(--dur-base) var(--ease-standard),
              background var(--dur-base) var(--ease-standard);
}
.plan-day + .plan-day { margin-top: var(--sp-2); }
.plan-date {
  width: 46px; flex: none; text-align: center; line-height: 1.15;
}
.plan-date .dow { font-size: var(--text-2xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--text-subtle); }
.plan-date .dm { font-size: var(--text-md); font-weight: var(--weight-semi); }
.plan-body { flex: 1; min-width: 0; }
.plan-focus { font-weight: var(--weight-medium); }
.plan-meta { font-size: var(--text-sm); color: var(--text-muted); display: flex; align-items: center; gap: var(--sp-2); }
.plan-day.done { background: var(--brand-subtle); border-color: var(--brand-subtle-2); }
.plan-day.missed { border-color: var(--warn); background: var(--warn-subtle); }
.plan-day.is-today { box-shadow: 0 0 0 1px var(--brand); border-color: var(--brand); }

/* --- Session / LernWithMe --- */

.question {
  font-size: var(--text-xl); font-weight: var(--weight-semi);
  line-height: var(--leading-snug); letter-spacing: var(--tracking-snug);
  margin-bottom: var(--sp-4); max-width: var(--measure);
}
.feedback { border-left: 3px solid var(--brand); padding-left: var(--sp-4); }
.feedback.partly { border-color: var(--warn); }
.feedback.wrong { border-color: var(--danger); }
.score-ring {
  display: grid; place-items: center;
  width: 46px; height: 46px; flex: none; border-radius: var(--r-full);
  font-size: var(--text-sm); font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  background: conic-gradient(var(--brand) calc(var(--score, 0) * 1%), var(--surface-sunken) 0);
  color: var(--text);
}
.score-ring::after {
  content: attr(data-score); position: absolute;
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: var(--r-full);
  background: var(--surface);
}
.score-ring { position: relative; }
.score-ring::after { z-index: 1; }

details.reveal { border-top: 1px solid var(--border); margin-top: var(--sp-3); padding-top: var(--sp-3); }
details.reveal summary {
  cursor: pointer; font-size: var(--text-sm); color: var(--text-muted);
  list-style: none; display: flex; align-items: center; gap: var(--sp-2);
}
details.reveal summary::-webkit-details-marker { display: none; }
details.reveal summary::after {
  content: ''; width: 14px; height: 14px;
  background: currentColor; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9.5l6 5.8 6-5.8' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/contain no-repeat;
  transition: rotate var(--dur-base) var(--ease-standard);
}
details.reveal[open] summary::after { rotate: 180deg; }

/* --- Materialauswahl --- */

material-picker { display: block; }
.material-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color var(--dur-fast) var(--ease-standard), background var(--dur-fast) var(--ease-standard);
}
.material-row + .material-row { margin-top: var(--sp-2); }
.material-row:hover { border-color: var(--border-strong); }
.material-row.selected { border-color: var(--brand); background: var(--brand-subtle); }
.material-kind {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--surface-sunken); color: var(--text-muted);
}
.material-row.selected .material-kind { background: var(--surface); color: var(--brand-text); }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  padding: var(--sp-6) var(--sp-4);
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg);
  background: var(--surface-sunken); color: var(--text-muted);
  cursor: pointer; text-align: center;
  transition: border-color var(--dur-base) var(--ease-standard),
              background var(--dur-base) var(--ease-standard),
              color var(--dur-base) var(--ease-standard);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-subtle); color: var(--brand-text); }
.dropzone .dz-title { font-weight: var(--weight-semi); color: var(--text); }
.dropzone.is-over .dz-title { color: var(--brand-text); }

/* --- Fortschritt / Gamification --- */

.xp-bar { display: flex; align-items: center; gap: var(--sp-3); max-width: 520px; }
.xp-bar .bar { flex: 1; }
.level-badge {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: var(--r-full);
  background: var(--brand-subtle); color: var(--brand-text);
  font-size: var(--text-sm); font-weight: var(--weight-bold);
}

/* Fliegende XP-Meldung */
.xp-float {
  position: fixed; z-index: var(--z-toast);
  padding: 6px var(--sp-3); border-radius: var(--r-full);
  background: var(--brand); color: var(--text-on-brand);
  font-size: var(--text-sm); font-weight: var(--weight-bold);
  pointer-events: none;
  animation: xp-rise 1.1s var(--ease-out) forwards;
}
@keyframes xp-rise {
  0% { opacity: 0; transform: translateY(0) scale(.8); }
  25% { opacity: 1; transform: translateY(-10px) scale(1.05); }
  100% { opacity: 0; transform: translateY(-42px) scale(1); }
}
@media (prefers-reduced-motion: reduce) { .xp-float { animation: none; opacity: 0; } }

/* ------------------------------------------------- 8 · Ansichtswechsel

   Nur der Inhaltsbereich wechselt — Kopfzeile und Navigation bleiben stehen.
   Ohne das blendet der Browser die ganze Seite um und die Leiste flackert mit. */

.view { view-transition-name: page; }

::view-transition-old(root), ::view-transition-new(root) { animation: none; }

::view-transition-old(page) {
  animation: vt-out var(--dur-fast) var(--ease-in) both;
}
::view-transition-new(page) {
  animation: vt-in var(--dur-slow) var(--ease-out) both;
}
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(page), ::view-transition-new(page) { animation: none; }
}
