:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2128;
  --text-muted: #6b7280;
  --accent: #4f5fe0;
  --accent-soft: #eef0fd;
  --completed: #1a9c6d;
  --completed-soft: #e7f7f0;
  --planned: #c8790d;
  --planned-soft: #fdf1e3;
  --locked: #e0475a;
  --locked-soft: #fdeef0;
  --notoffered: #9aa1ac;
  --notoffered-soft: #f1f2f4;
  --radius: 10px;
}

* { box-sizing: border-box; }

/* html needs a background too, not just body - with viewport-fit=cover
   (see base.html) the safe-area strip below the home indicator on iOS
   standalone/PWA renders as plain black unless something behind the fixed
   bottom nav is actually colored there, and that strip is html's box, not
   body's. Same story for iOS Safari's rubber-band overscroll past the end
   of the page, which briefly reveals html's background. Matches
   .bottom-nav's own background (--surface), not the page's --bg, since
   that's the bar this strip sits flush against. */
html {
  background: var(--surface);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  /* Fill the screen, so a short page doesn't end in a strip of html's
     surface colour above the bottom nav. */
  min-height: 100vh;
  min-height: 100dvh;
}
/* Never let a too-wide child make the page wider than the screen: on iOS
   that zooms/pans the layout viewport and the fixed bottom nav slides out
   of view. clip (unlike hidden) keeps position: sticky working. */
html, body { max-width: 100%; overflow-x: hidden; }
@supports (overflow: clip) { html, body { overflow-x: clip; } }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 18px; margin: 0; white-space: nowrap; }

.tabs { display: flex; gap: 4px; }
.tab-btn {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
}
.tab-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tab-btn:disabled { opacity: .35; cursor: default; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px; }

.study-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
}
.study-chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.study-chip input { cursor: pointer; }

/* Lives at the top of Plan/Weekly (see .study-filters in app.html) instead
   of the navbar - wraps instead of the header's forced single-line scroll,
   since there's real width to spare down here. */
.study-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.study-filters:empty { display: none; }

.hidden { display: none; }

.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tag-chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 12px; cursor: pointer; color: var(--text-muted);
}
.tag-chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.selected-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.selected-summary .study-chip { cursor: default; }
.selected-summary-empty { font-size: 13px; color: var(--text-muted); font-style: italic; }

.study-selector-controls { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }

.study-list {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  max-height: 420px; overflow-y: auto; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; background: var(--surface);
}

.fetch-progress-track { width: 100%; max-width: 400px; height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; margin-top: 8px; }
.fetch-progress-fill { height: 100%; width: 0; min-width: 3%; background: var(--accent); transition: width .3s ease; }
.fetch-progress-fill.active {
  background-image: linear-gradient(90deg, var(--accent) 0%, var(--accent-soft) 50%, var(--accent) 100%);
  background-size: 200% 100%;
  animation: fetch-progress-pulse 1.4s linear infinite;
}
@keyframes fetch-progress-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: 0 0; }
}

.fetch-banner { display: flex; align-items: center; gap: 10px; background: var(--planned-soft); color: var(--planned); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }
.fetch-banner a { color: var(--planned); font-weight: 600; }
.fetch-banner.hidden { display: none; }

.meta { font-size: 13px; color: var(--text-muted); }
.meta strong { color: var(--accent); }

/* First item of the trailing (right-aligned) cluster - actions, then
   counts, then the avatar - pushes that whole cluster to the far right.
   base.html's simpler header (no undo/redo, no ECTS counts) has only the
   avatar as a topbar child, so it needs its own auto margin too - redundant
   with topbar-actions' on app.html (no free space left for it to claim
   there) but the only thing doing the job on base.html. */
.topbar-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; }

/* ---- Profile menu (top-right icon + dropdown) ---- */
.profile-menu-wrap { position: relative; display: inline-block; vertical-align: middle; margin-left: auto; }
.profile-menu-btn {
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1.5px solid var(--accent-soft);
  color: var(--accent);
  width: 36px;
  height: 36px;
  padding: 0;
}
.profile-menu-btn:hover { border-color: var(--accent); }
.profile-menu-btn svg { width: 20px; height: 20px; }
.profile-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 6px;
  z-index: 30;
}
.profile-menu.open { display: block; }
.profile-menu-email {
  padding: 8px 10px 6px;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  overflow-wrap: break-word;
}
.profile-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.profile-menu-item:hover { background: var(--accent-soft); color: var(--accent); }
.profile-menu form { margin: 0; }

main { padding: 20px 24px 60px; max-width: 1100px; margin: 0 auto; }
/* Weekly Schedule has a lot more to lay out side-by-side (course lists +
   a full week grid) than the other views, so let it use a wider column
   on desktop instead of being capped at the same width as Study Plan. */
main:has(#weeklyView.active) { max-width: 1600px; }

.view { display: none; }
.view.active { display: block; }

.legend { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.deselect-all-btn { margin-left: auto; }
.deselect-all-btn:disabled { opacity: .5; cursor: default; }
.swatch-completed { background: var(--completed); }
.swatch-planned { background: var(--planned); }
.swatch-locked { background: var(--locked); }
.swatch-notoffered { background: var(--notoffered); }

/* ---- Study sections (plan view, one per checked study filter) ---- */
.study-section { margin-bottom: 36px; }
.study-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}
.study-section-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.study-section-title { font-size: 16px; font-weight: 700; }
.study-section-progress { margin-left: auto; font-size: 13px; color: var(--text-muted); }

.section-heading {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); margin: 0 0 12px;
}
.steop-group { margin-bottom: 12px; padding-bottom: 20px; border-bottom: 2px solid var(--border); }
.steop-group .study-section:last-child { margin-bottom: 0; }

/* ---- Tree ---- */
.node { margin-bottom: 6px; }
.node-children { margin-left: 18px; padding-left: 12px; border-left: 1px dashed var(--border); }

.cat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  cursor: pointer;
  user-select: none;
}
.cat-row:hover { border-color: var(--accent); }
.cat-row .chevron { width: 14px; text-align: center; color: var(--text-muted); transition: transform .15s; font-size: 11px; }
.node.collapsed > .cat-row .chevron { transform: rotate(-90deg); }
.cat-row .title { font-weight: 600; font-size: 14px; flex: 1; }
.cat-row .progress-wrap { display: flex; align-items: center; gap: 8px; }
.cat-row .progress-bar { width: 80px; height: 6px; border-radius: 4px; background: var(--border); overflow: hidden; }
.cat-row .progress-bar > div { height: 100%; background: var(--accent); }
.cat-row.done .progress-bar > div { background: var(--completed); }
.cat-row .progress-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

.node.collapsed > .node-children { display: none; }

/* StEOP gate between the mandatory StEOP section and the rest of the tree */
.steop-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--locked);
  background: var(--locked-soft);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 8px 0 20px;
}
.steop-banner.done { color: var(--completed); background: var(--completed-soft); }
.steop-banner label { display: flex; align-items: center; gap: 6px; cursor: pointer; margin-left: auto; white-space: nowrap; }

.locked-section { opacity: .6; }

/* Choice groups (Wahlfach / Vertiefungsfeld style either-or) */
.choice-banner {
  font-size: 12px;
  color: var(--planned);
  background: var(--planned-soft);
  border-radius: 6px;
  padding: 4px 8px;
  margin: 4px 0 8px;
  display: inline-block;
}
.choice-option { position: relative; }
.choice-option > .cat-row { border-color: var(--accent); }
.choice-option.chosen > .cat-row { border-color: var(--completed); background: var(--completed-soft); }
.choice-option.not-chosen > .cat-row { opacity: .55; }
.choice-option.not-chosen > .node-children { display: none; }
.choose-btn {
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  border-radius: 999px;
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
}
.choice-option.chosen .choose-btn { border-color: var(--completed); color: var(--completed); }

/* Course rows */
.course-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
}
.course-row .lva-type {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 5px;
  padding: 2px 6px;
  min-width: 24px;
  text-align: center;
}
.course-row .title { flex: 1; }
.course-row .ects { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.course-row .semester-badge { font-size: 11px; color: var(--notoffered); white-space: nowrap; }

.companion-note {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
  cursor: help;
}
.companion-note.companion-missing { color: var(--locked); background: var(--locked-soft); font-weight: 600; }
.sidebar-course-info .companion-note { align-self: flex-start; }
.course-row.completed { background: var(--completed-soft); border-color: var(--completed); }
.course-row.planned:not(.completed) { background: var(--planned-soft); border-color: var(--planned); }
.course-row.locked { background: var(--locked-soft); border-color: var(--locked); }
.course-row.not-offered .title { color: var(--text-muted); }

.checkbox-group { display: flex; align-items: center; gap: 4px; }
.checkbox-group label { font-size: 10px; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }

.lock-icon { cursor: help; color: var(--locked); font-size: 13px; }

.milestone-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* ---- View tabs / topbar extras ---- */
.view-tabs { margin-left: 8px; }
.planned-count { color: var(--planned); font-weight: 600; margin-left: 12px; }

/* ---- Mobile bottom nav ---- */
/* Hidden on desktop - the top tabs handle navigation there. Shown (and the
   equivalent top nav hidden) below 768px, see the mobile media query. */
.bottom-nav { display: none; }
.bottom-nav-item {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 4px calc(12px + env(safe-area-inset-bottom));
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
}
.bottom-nav-item span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bottom-nav-item.active { color: var(--accent); font-weight: 600; }

.btn-secondary {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}

/* ---- Course row detail (lecturer chip, group select, session badge) ---- */
.course-detail { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.group-select {
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  max-width: 220px;
}
.lecturer-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 2px 2px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--notoffered-soft);
  color: var(--text-muted);
  font-size: 11px;
}
.lecturer-chip.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.lecturer-chip .lecturer-name { white-space: nowrap; }

.lecturer-tooltip {
  position: fixed;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  font-size: 13px;
}
.lecturer-tooltip.hidden { display: none; }
.lecturer-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; overflow: hidden; flex-shrink: 0;
}
.lecturer-avatar img { width: 100%; height: 100%; object-fit: cover; }
.lecturer-avatar.small { width: 18px; height: 18px; font-size: 8px; }

.badge.session-count { background: var(--notoffered-soft); color: var(--text-muted); cursor: pointer; font-size: 11px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.session-count:hover { background: var(--accent-soft); color: var(--accent); }

.kusss-link {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 2px 4px;
}
.kusss-link:hover { color: var(--accent); }
.group-picker-header .kusss-link { font-size: 12px; margin-left: 4px; }

/* ---- Weekly view ---- */
.weekly-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
#selectedCount { font-size: 13px; color: var(--text-muted); }

.weekly-layout { display: flex; gap: 16px; align-items: flex-start; }
.calendar-scroll { flex: 1; min-width: 0; overflow-x: auto; }

.course-sidebar { width: 380px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }
.sidebar-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.sidebar-section-header {
  width: 100%; display: flex; align-items: center; gap: 8px;
  border: none; background: transparent; padding: 10px 12px;
  font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text); text-align: left;
}
.sidebar-section-header:hover { background: var(--bg); }
.sidebar-chevron { display: inline-block; transition: transform 0.15s ease; color: var(--text-muted); font-size: 11px; }
.sidebar-section.collapsed .sidebar-chevron { transform: rotate(-90deg); }
.sidebar-section.collapsed .sidebar-section-body { display: none; }
.sidebar-section-body { max-height: 460px; overflow-y: auto; border-top: 1px solid var(--border); }

.sidebar-course-row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 12px; }
.sidebar-course-row:first-child { border-top: none; }
.sidebar-course-row input[type="checkbox"] { width: 14px; height: 14px; margin-top: 2px; cursor: pointer; flex-shrink: 0; }
.sidebar-course-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sidebar-course-title-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sidebar-course-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.sidebar-course-title { font-weight: 600; }
.sidebar-course-schedule { color: var(--text-muted); font-size: 11px; }
.sidebar-course-conflict { color: var(--locked); font-size: 11px; }
.sidebar-empty { padding: 10px 12px; color: var(--text-muted); font-size: 12px; font-style: italic; }

.calendar {
  display: grid;
  grid-template-columns: 56px repeat(5, 1fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-corner { border-bottom: 1px solid var(--border); }
.cal-day-header {
  padding: 8px; text-align: center; font-size: 13px; font-weight: 600;
  border-bottom: 1px solid var(--border); border-left: 1px solid var(--border);
}
.cal-time-col { border-right: 1px solid var(--border); position: relative; }
.cal-time-label { font-size: 10px; color: var(--text-muted); position: absolute; right: 4px; transform: translateY(-50%); }
.cal-day-col {
  position: relative;
  border-left: 1px solid var(--border);
  background-image: repeating-linear-gradient(to bottom, transparent, transparent 39px, var(--bg) 40px);
}

.cal-event {
  position: absolute;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 11px;
  line-height: 1.3;
  overflow: hidden;
  background: var(--planned-soft);
  border: 1px solid var(--planned);
  color: var(--planned);
  cursor: pointer;
}
.cal-event:hover { filter: brightness(0.97); }
.cal-event.has-options { border-style: dashed; }
.cal-event.biweekly {
  background-image: repeating-linear-gradient(135deg, currentColor 0 2px, transparent 2px 8px);
  background-blend-mode: overlay;
  opacity: 0.92;
}
.cal-event .ev-title { font-weight: 600; display: block; }
.cal-event .ev-time { opacity: 0.8; }

.ev-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin-bottom: 2px; }
.cal-event.has-count .ev-tags { padding-right: 24px; }
.ev-room {
  font-size: 9px; font-weight: 700; padding: 0 4px; border-radius: 999px;
  border: 1px solid currentColor; background: var(--surface); line-height: 1.4;
  max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.ev-room.changed { background: var(--planned); border-color: var(--planned); color: #fff; }
.ev-room s, .ev-time s, .session-room s { opacity: 0.7; font-weight: 400; }
.ev-study-tag, .sidebar-course-tag { display: inline-block; font-size: 8px; font-weight: 700; color: #fff; padding: 1px 4px; border-radius: 999px; letter-spacing: 0.02em; flex-shrink: 0; }

.ev-options-marker {
  position: absolute; bottom: 3px; right: 3px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--planned); color: #fff;
  font-size: 9px; line-height: 14px; text-align: center;
}
.ev-count-badge {
  position: absolute; top: 3px; right: 3px; min-width: 14px; height: 14px;
  padding: 0 3px; border-radius: 7px; background: var(--surface);
  border: 1px solid currentColor; color: inherit; font-size: 9px; font-weight: 700;
  line-height: 12px; text-align: center;
}

.cal-event.conflict { background: var(--locked-soft); border-color: var(--locked); color: var(--locked); }
.cal-event.conflict .ev-count-badge { border-color: var(--locked); }

/* ---- Calendar view ---- */
.calendar-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-range-label { font-size: 14px; font-weight: 600; min-width: 160px; }
.calendar-body { overflow-x: auto; }

.cal-day-header.today { color: var(--accent); }
.cal-day-col.today { background-color: var(--accent-soft); }

.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-month-weekday {
  padding: 8px; text-align: center; font-size: 12px; font-weight: 600;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
}
.cal-month-cell {
  min-height: 96px; padding: 6px; border-top: 1px solid var(--border);
  border-left: 1px solid var(--border); cursor: pointer; display: flex;
  flex-direction: column; gap: 2px;
}
.cal-month-cell:nth-child(7n+1) { border-left: none; }
.cal-month-cell.outside-month { background: var(--bg); color: var(--text-muted); }
.cal-month-cell.today .cal-month-date {
  background: var(--accent); color: #fff; border-radius: 50%;
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
}
.cal-month-date { font-size: 12px; font-weight: 600; }
.cal-month-chip {
  font-size: 10px; line-height: 1.3; padding: 1px 4px; border-radius: 3px;
  background: var(--bg); border-left: 3px solid var(--accent); overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; cursor: pointer;
}
.cal-month-chip:hover { filter: brightness(0.96); }
.cal-month-more { font-size: 10px; color: var(--text-muted); cursor: pointer; }

/* KUSSS date sync: sessions moved within the last week */
.cal-event.changed { box-shadow: 0 0 0 2px var(--planned); }
.ev-changed-badge {
  font-size: 8px; font-weight: 700; padding: 1px 4px; border-radius: 999px;
  background: var(--planned); color: #fff; flex-shrink: 0;
}
.cal-month-chip.changed { background: var(--planned-soft); font-weight: 600; }

.cal-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-refresh-btn.loading .cal-refresh-icon { display: inline-block; animation: cal-spin 0.9s linear infinite; }
.cal-refresh-btn:disabled { opacity: 0.7; cursor: progress; }
@keyframes cal-spin { to { transform: rotate(360deg); } }
.cal-shares-badge {
  display: inline-block; min-width: 16px; padding: 0 5px; margin-left: 4px; border-radius: 8px;
  background: var(--locked); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.cal-shares-badge.hidden { display: none; }

/* Shared calendar overlays: hatched + dashed in the share's colour, so they
   never read as one of the user's own (solid) courses. Colours set inline. */
.cal-legend { margin: -4px 0 12px; }
.cal-legend.hidden { display: none; }
.cal-legend-swatch { width: 14px; height: 10px; border-radius: 3px; display: inline-block; }
.cal-legend-swatch.own { background: var(--accent-soft); border: 1px solid var(--accent); }
.cal-legend-swatch.overlay { border: 1.5px dashed; }
.cal-legend-label { font-weight: 600; }
.cal-event.overlay { border-width: 2px; border-style: dashed; }
.cal-event.overlay .ev-title { font-style: italic; opacity: 0.85; }
.cal-month-chip.overlay { border-left-style: dashed; font-style: italic; background: transparent; }
.overlay-popover-row { font-size: 13px; padding: 3px 6px; }
.overlay-popover-owner { font-size: 12px; color: var(--text-muted); padding: 6px 6px 2px; border-top: 1px solid var(--border); margin-top: 4px; }

.shares-section { display: flex; flex-direction: column; gap: 6px; }
.shares-section:first-child .manual-subhead { border-top: none; padding-top: 0; margin-top: 0; }
.shares-actions { display: flex; align-items: center; gap: 6px; }
.shares-actions input[type="color"] { width: 32px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; }
.shares-overlay-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.shares-overlay-toggle input { width: 16px; height: 16px; }
.shares-invite { display: flex; gap: 8px; }
.shares-search { position: relative; flex: 1; display: flex; }
.shares-suggestions {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 10;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); max-height: 240px; overflow-y: auto; padding: 4px;
}
.shares-suggestions.hidden { display: none; }
.shares-suggestion { padding: 7px 10px; font-size: 13px; border-radius: 4px; cursor: pointer; }
.shares-suggestion.active, .shares-suggestion:hover { background: var(--accent-soft); color: var(--accent); }
.shares-suggestion.empty { color: var(--text-muted); cursor: default; background: none; }
.shares-invite .btn-primary:disabled { opacity: 0.5; cursor: default; }
.shares-invite input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit; }
.shares-invite .btn-primary { width: auto; padding: 8px 16px; }

.app-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 400;
  background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; max-width: calc(100vw - 32px);
}
.app-toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---- Workload view ---- */
.workload-toolbar { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.workload-nav { display: flex; align-items: center; gap: 10px; }
.workload-range-label { font-size: 13px; font-weight: 600; min-width: 160px; text-align: center; }
.workload-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }

.workload-chart { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 16px 12px; }
.workload-empty { color: var(--text-muted); font-size: 13px; margin: 0; }

.workload-plot-row { display: flex; align-items: stretch; }
.workload-yaxis { position: relative; width: 30px; flex-shrink: 0; height: 180px; }
.workload-ytick { position: absolute; left: 0; right: 6px; transform: translateY(50%); text-align: right; }
.workload-ytick-label { font-size: 10px; color: var(--text-muted); }

.workload-plot { position: relative; flex: 1; min-width: 0; display: flex; align-items: flex-end; gap: 2px; height: 180px; border-bottom: 1px solid var(--border); }
.workload-gridline { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--border); z-index: 0; }
.workload-col {
  position: relative; z-index: 1;
  flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; cursor: default; border-radius: 4px;
}
.workload-col:hover, .workload-col:focus-visible { background: var(--bg); outline: none; }
.workload-bar { width: 100%; max-width: 24px; min-height: 2px; background: var(--planned); border-radius: 4px 4px 0 0; }
.workload-col.empty .workload-bar { background: var(--notoffered-soft); }
.workload-col:hover .workload-bar, .workload-col:focus-visible .workload-bar { filter: brightness(0.9); }

.workload-axis-row { display: flex; margin-top: 6px; }
.workload-yaxis-spacer { width: 30px; flex-shrink: 0; }
.workload-axis { display: flex; gap: 2px; flex: 1; min-width: 0; }
.workload-axis-label { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.workload-axis-kw { font-size: 10px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.workload-axis-month { font-size: 9px; color: var(--text-muted); opacity: 0.75; white-space: nowrap; }

.workload-tooltip {
  position: fixed; z-index: 100; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 8px 10px;
  font-size: 12px; max-width: 260px; pointer-events: none;
}
.workload-tooltip.hidden { display: none; }
.workload-tooltip-range { color: var(--text-muted); margin-bottom: 2px; }
.workload-tooltip-value { font-weight: 700; margin-bottom: 4px; }
.workload-tooltip-course { color: var(--text-muted); font-size: 11px; }

/* ---- Group / Termine picker popup ---- */
.group-picker {
  position: fixed; z-index: 200; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); padding: 8px;
  display: flex; flex-direction: column; min-width: 260px; max-width: 340px;
}
.group-picker-header { font-size: 13px; font-weight: 600; padding: 4px 6px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.group-picker-divider {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted);
  padding: 8px 6px 4px; border-top: 1px solid var(--border); margin-top: 4px;
}
.group-picker-option { text-align: left; border: none; background: transparent; padding: 8px 10px; font-size: 13px; border-radius: 6px; cursor: pointer; color: var(--text); }
.group-picker-option:hover { background: var(--bg); }
.group-picker-option.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.group-picker-option.conflict { color: var(--locked); }
.group-picker-option.conflict:hover { background: var(--locked-soft); }
.group-picker-option.conflict.active { background: var(--locked-soft); color: var(--locked); }
.group-picker-option.remove-option { color: var(--locked); font-weight: 600; }
.group-picker-option.remove-option:hover { background: var(--locked-soft); }

.session-list { max-height: 260px; overflow-y: auto; }
.session-row { display: flex; align-items: baseline; gap: 8px; padding: 5px 6px; font-size: 12px; border-radius: 6px; }
.session-row:nth-child(odd) { background: var(--bg); }
.session-row-empty { color: var(--text-muted); font-style: italic; }
.session-when { flex: 1; white-space: nowrap; }
.session-room { color: var(--text-muted); white-space: nowrap; }
.session-note { color: var(--accent); font-size: 11px; white-space: nowrap; }
.session-row.conflict { background: var(--locked-soft); color: var(--locked); }
.session-row.changed .session-room { color: var(--planned); font-weight: 600; }
.session-changed {
  font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 999px;
  background: var(--planned); color: #fff; white-space: nowrap;
}
.session-row.conflict .session-room { color: var(--locked); }

.conflict-warning { background: var(--locked-soft); color: var(--locked); font-size: 12px; padding: 6px 8px; border-radius: 6px; margin-bottom: 6px; line-height: 1.5; }

/* ---- Auth / plain forms (signup, login, settings) ---- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 360px;
  max-width: 100%;
}
.auth-card h1 { font-size: 18px; margin: 0 0 20px; }
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.form-field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.form-errors { color: var(--locked); font-size: 13px; margin-bottom: 12px; }
.btn-primary {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  cursor: pointer;
}
.auth-switch { margin-top: 16px; font-size: 13px; color: var(--text-muted); text-align: center; }
.auth-switch a { color: var(--accent); }

.container { padding: 20px 24px 60px; max-width: 1100px; margin: 0 auto; }

/* ---- Notification settings ---- */
.notif-settings {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); max-width: 480px; margin-bottom: 8px;
}
.notif-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.notif-row select {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px;
}
.notif-status { font-size: 13px; color: var(--text-muted); }

/* Push devices panel (partials/push_devices.html, mountPushDevices in pwa.js) */
.push-devices-title { font-size: 14px; margin: 8px 0 0; }
.push-devices { display: flex; flex-direction: column; gap: 10px; max-width: 560px; }
.push-devices .notif-row { flex-wrap: wrap; }
.push-devices-hint { margin: 0; }
.push-help {
  padding: 12px 14px; border: 1px solid var(--locked); border-radius: 8px;
  background: var(--locked-soft); font-size: 14px; color: var(--text);
}
.push-help[hidden] { display: none; }
.push-help-title { margin: 0 0 6px; font-weight: 600; }
.push-help-detail { margin: 0 0 6px; font-size: 13px; color: var(--text-muted); }
.push-help-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.push-help-steps { margin: 10px 0 0; padding-left: 20px; font-size: 13px; line-height: 1.5; }
.push-help-steps[hidden] { display: none; }
.push-device-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.push-device {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 14px;
}
.push-device-empty { color: var(--text-muted); font-size: 13px; }
.push-device-meta, .push-device-result { font-size: 12px; color: var(--text-muted); }
.push-device-badge {
  display: inline-block; padding: 1px 6px; border-radius: 999px; font-size: 11px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}
.push-device-actions { display: flex; gap: 6px; }

/* ---- Mobile ---- */
@media (max-width: 768px) {
  /* Title on top, the done/planned/total-ECTS numbers centered directly
     below it - undo/redo and the avatar sit beside that stack and stretch
     to its full combined height instead of pinning to just the title row.
     Study filters and the view tabs don't live here at all any more
     (filters moved to Plan/Weekly's own content - see .study-filters; view
     tabs move to .bottom-nav below). base.html's simpler header (Settings/
     login - no undo/redo, no ECTS) just leaves "actions" and "counts"
     empty, which CSS grid is fine with. */
  .topbar {
    display: grid;
    /* Equal-width outer tracks (not auto) so the title in the middle sits at
       the row's true visual center regardless of how wide undo/redo vs. the
       avatar happen to be - auto/auto would skew it toward whichever side
       is narrower. */
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas:
      "actions title end"
      "actions counts end";
    align-items: stretch;
    gap: 2px 10px;
    padding: 8px 12px;
  }
  .topbar h1 { grid-area: title; font-size: 15px; text-align: center; }
  .topbar-actions {
    grid-area: actions;
    justify-self: start;
    align-items: center;
    margin-left: 0;
  }
  .meta {
    grid-area: counts;
    justify-self: center;
    display: flex;
    align-items: baseline;
    gap: 10px;
    white-space: nowrap;
    font-size: 11px;
  }
  .profile-menu-wrap {
    grid-area: end;
    justify-self: end;
    margin-left: 0;
    display: flex;
    align-items: center;
  }
  .profile-menu-btn { width: 40px; height: 40px; }

  .view-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .tab-btn { white-space: nowrap; padding: 8px 12px; }

  /* The 4 view tabs move to the bottom nav bar on mobile - hide the
     desktop equivalents (top-level Settings/Study Helper tabs and the
     in-app view tabs) so each destination only appears once. The profile
     menu (Settings/Log out) stays visible at every width instead of
     folding into either of these. */
  .page-nav, .topbar .view-tabs { display: none; }
  /* Grid with equal tracks (not flex: 1) so every item gets exactly the
     same width - flex let a long label like "Einstellungen" widen its own
     column and squeeze the others, so the bar looked different per app. */
  .bottom-nav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    /* Above sticky bars (rating, editor toolbars); below modal overlays. */
    z-index: 350;
    background: var(--surface);
    border-top: 1px solid var(--border);
    /* Own compositing layer: stays pinned during momentum scrolling. */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }
  /* Typing on a phone: the keyboard moves the visual viewport and a fixed
     bar would be scrolled away - hide it while a field has focus. */
  html.kbd-open .bottom-nav { display: none; }
  main, .container { min-width: 0; max-width: 100%; }

  main, .container {
    padding: 14px 12px calc(68px + 12px + env(safe-area-inset-bottom));
  }

  .weekly-layout { flex-direction: column; align-items: stretch; }
  /* Calendar grid first, then the Selected/Available/Available-with-conflict
     course lists below it - on desktop these sit side by side instead. */
  .calendar-scroll { order: 1; }
  .course-sidebar { order: 2; width: 100%; }
  .calendar-scroll, .calendar-body { -webkit-overflow-scrolling: touch; }

  .calendar-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .cal-nav { justify-content: space-between; }
  .cal-actions { justify-content: space-between; }
  #calViewSwitch { overflow-x: auto; }
  .app-toast { bottom: 84px; } /* clear the mobile bottom nav */

  /* Narrower day columns (see calGridColumnTemplate in weekly.js) so all
     weekdays fit without horizontal scrolling - shrink the text to match. */
  .cal-day-header { padding: 4px 2px; font-size: 11px; }
  .cal-time-label { font-size: 9px; right: 2px; }
  .cal-event { padding: 3px 4px; font-size: 10px; }
  .ev-study-tag { font-size: 7px; }

  .cal-month-cell { min-height: 60px; padding: 4px; }
  .cal-month-date { font-size: 11px; }
  .cal-month-chip { font-size: 9px; }

  .workload-toolbar { flex-direction: column; }

  .study-selector-controls { flex-direction: column; align-items: stretch; }
  .study-selector-controls input { max-width: 100% !important; }

  .notif-settings { max-width: 100%; }

  .course-row { flex-wrap: wrap; }
  .course-row .title { flex: 1 1 auto; min-width: 120px; }
  .course-row .checkbox-group { order: -1; }

  .cat-row { flex-wrap: wrap; row-gap: 6px; }
  .cat-row .progress-wrap { flex-basis: 100%; order: 1; }

  .study-section-header { flex-wrap: wrap; row-gap: 4px; }
}

@media (max-width: 480px) {
  .topbar h1 { font-size: 14px; }
  .cal-month-cell { min-height: 52px; }
  .cal-month-chip { font-size: 8px; padding: 1px 3px; }
  .group-picker { min-width: 220px; max-width: calc(100vw - 24px); }
}

/* ---- Manual course / extra-option modal ---- */
.manual-modal-overlay {
  position: fixed; inset: 0; z-index: 300; background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
  overflow-y: auto;
}
.manual-modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  width: 560px; max-width: 100%; box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  display: flex; flex-direction: column;
}
.manual-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.manual-modal-header h2 { font-size: 16px; margin: 0; }
.manual-close {
  border: none; background: transparent; font-size: 16px; cursor: pointer;
  color: var(--text-muted); line-height: 1; padding: 4px;
}
.manual-close:hover { color: var(--text); }
.manual-tabs { display: flex; gap: 4px; padding: 10px 16px 0; border-bottom: 1px solid var(--border); }
.manual-tab {
  border: none; background: transparent; padding: 8px 12px; font-size: 13px; cursor: pointer;
  color: var(--text-muted); border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0;
}
.manual-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.manual-modal-body { padding: 16px 20px 20px; }
.manual-panel { display: flex; flex-direction: column; gap: 12px; }
.manual-field { display: flex; flex-direction: column; gap: 4px; }
.manual-field-label { font-size: 12px; color: var(--text-muted); }
.manual-field input[type="text"],
.manual-field select,
.manual-termine {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-family: inherit;
}
.manual-field input[type="checkbox"] { align-self: flex-start; width: 16px; height: 16px; }
.manual-termine { resize: vertical; min-height: 120px; white-space: pre; }
.manual-subhead {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted);
  margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--border);
}
.manual-group-form { display: flex; flex-direction: column; gap: 10px; }
.manual-preview {
  font-size: 12px; color: var(--text-muted); background: var(--bg); border-radius: 6px;
  padding: 8px 10px; max-height: 180px; overflow-y: auto; line-height: 1.5;
}
.manual-preview-head { font-weight: 600; color: var(--text); }
.manual-preview-warn { color: var(--planned); }
.manual-save { width: auto; align-self: flex-start; padding: 9px 18px; }
.manual-status { font-size: 13px; color: var(--text-muted); }
.manual-manage-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.manual-manage-title { font-size: 13px; font-weight: 600; }
.manual-manage-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

@media (max-width: 480px) {
  .manual-modal-overlay { padding: 16px 8px; }
}

/* ---- Lernen (spaced repetition, /lernen/) ---- */
.learn-muted { font-size: 13px; color: var(--text-muted); }
.learn-muted strong { color: var(--accent); }
.learn-subnav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.learn-subnav a { text-decoration: none; }
.learn-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 24px;
}
.learn-hero-count { font-size: 32px; font-weight: 700; color: var(--accent); }
.learn-start, .learn-btn-inline { width: auto; padding: 10px 18px; text-decoration: none; display: inline-block; }
.learn-deck-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.learn-deck {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px;
}
.learn-deck-name { font-weight: 600; color: var(--text); text-decoration: none; }
.learn-deck-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; }
.learn-deck-actions form { margin: 0; }
.learn-deck-group { font-size: 14px; color: var(--text-muted); margin: 14px 0 8px; }
.learn-deck.paused .learn-deck-name { color: var(--text-muted); }
/* A paused group: its name and decks dimmed, whatever their own switch says. */
.learn-group.paused input.learn-group-name { color: var(--text-muted); }
.learn-group.paused .learn-group-body .learn-deck-list { opacity: .6; }
.learn-paused-chip { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); }
.learn-share-list { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.learn-share-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.learn-share-list form { margin: 0 0 0 auto; }
.learn-share-list form.learn-share-rights { margin: 0; width: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.learn-share-rights label { display: inline-flex; align-items: center; gap: 4px; }
.learn-share-form { margin: 8px 0 4px; }
/* Groups on "Inhalte anlegen": a card each, its decks inside; folds shut
   to the head (learn-groups.js). Shared groups get a neutral edge. */
.learn-groups-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.learn-groups-fold { margin-left: auto; display: flex; gap: 6px; }
.learn-group {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius); margin-bottom: 14px; overflow: hidden;
}
.learn-group.shared { border-left-color: var(--notoffered); }
.learn-group-head {
  display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap;
  padding: 8px 14px 8px 8px; background: var(--accent-soft); cursor: pointer;
}
.learn-group.shared .learn-group-head { background: var(--notoffered-soft); }
.learn-group.closed .learn-group-head { border-bottom: none; }
.learn-group:not(.closed) .learn-group-head { border-bottom: 1px solid var(--border); }
.learn-group.closed .learn-group-body { display: none; }
.learn-group-toggle {
  width: 32px; height: 32px; flex-shrink: 0; border: none; border-radius: 6px; background: none; cursor: pointer; color: var(--text-muted);
}
.learn-group-toggle::before { content: "▾"; display: inline-block; font-size: 16px; transition: transform .15s ease; }
.learn-group.closed .learn-group-toggle::before { transform: rotate(-90deg); }
.learn-group-toggle:hover { background: var(--surface); color: var(--text); }
.learn-group-rename { display: flex; gap: 6px; align-items: center; margin: 0; }
.learn-group-rename:not(:focus-within) button { display: none; }
.learn-group-name { font-weight: 700; font-size: 16px; color: var(--text); }
input.learn-group-name {
  font-family: inherit; padding: 4px 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; min-width: 0;
  field-sizing: content; max-width: 100%;
}
input.learn-group-name:hover, input.learn-group-name:focus { border-color: var(--border); background: var(--surface); cursor: text; }
.learn-group-count {
  font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface); color: var(--accent); white-space: nowrap;
}
.learn-group.shared .learn-group-count { color: var(--text-muted); }
.learn-group-body { padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.learn-group-body .learn-deck-list { margin-bottom: 0; }
.learn-group-body .learn-deck { background: var(--bg); }
.learn-group-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.learn-group-add input[type=text] {
  flex: 1; min-width: 180px; max-width: 320px; padding: 7px 10px; border: 1px dashed var(--border); border-radius: 6px;
  font-size: 14px; background: var(--surface); color: var(--text);
}
.learn-group-add input[type=text]:focus { border-style: solid; border-color: var(--accent); outline: none; }
.learn-deck-list:has(.learn-deck) > .learn-group-empty { display: none; }
.learn-group-empty { margin: 4px 0; padding: 14px; text-align: center; border: 1px dashed var(--border); border-radius: 8px; }
.learn-drag-hint { margin: -4px 0 12px; }
.learn-import { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.learn-import-choice {
  display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px dashed var(--border);
  border-radius: var(--radius); background: var(--surface); font-size: 14px; font-weight: 600; cursor: pointer;
}
.learn-import-choice:hover, .learn-import-choice:focus-within { border-color: var(--accent); }
.learn-import-choice small { font-weight: 400; }
.learn-import-choice input { font-size: 13px; font-weight: 400; margin-top: 4px; max-width: 100%; }
.learn-import .learn-inline-form { margin: 0; }
.learn-import .learn-inline-form input[type=text] { flex: 1; min-width: 220px; }

/* Drag and drop (sortable.js): a grip per row, the row itself marks where
   it lands, a lifted copy follows the pointer. */
.sort-handle {
  flex-shrink: 0; width: 28px; height: 36px; padding: 0; border: none; border-radius: 6px; background: none;
  color: var(--text-muted); font-size: 18px; line-height: 1; cursor: grab; touch-action: none; user-select: none;
}
.sort-handle:hover { background: var(--border); color: var(--text); }
.sort-placeholder { opacity: .35; outline: 2px dashed var(--accent); outline-offset: -2px; }
.sort-ghost {
  position: fixed; z-index: 1000; margin: 0; pointer-events: none; opacity: .95;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18); transform: rotate(1deg) scale(1.02); background: var(--surface);
}
body.sorting, body.sorting * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
/* A deck in its group: name and numbers left, "Verlauf" small at the top
   right (like a repo's history link), the icon actions below it. */
.learn-deck[data-deck] {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0 10px;
  grid-template-areas: "handle main history" "handle main actions";
}
.learn-deck[data-deck] > .sort-handle { grid-area: handle; }
.learn-deck-main { grid-area: main; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.learn-deck-main .learn-deck-name { overflow-wrap: anywhere; }
.learn-deck-history {
  grid-area: history; justify-self: end; display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-muted); text-decoration: none; padding: 2px 4px; border-radius: 6px;
}
.learn-deck-history .icon { width: 14px; height: 14px; }
.learn-deck-history:hover { color: var(--accent); text-decoration: underline; }
.learn-deck-icons { grid-area: actions; justify-self: end; }
.learn-paused-chip { display: none; }
.learn-deck.paused .learn-paused-chip, .learn-group.paused .learn-group-head .learn-paused-chip { display: inline; }

/* Icon buttons (edit, download, share, delete) and the switch next to them. */
.learn-icon-actions { display: flex; align-items: center; gap: 2px; }
.learn-group-head > .learn-icon-actions { margin-left: auto; }
.learn-icon-actions form { margin: 0; display: flex; }
.learn-icon-actions .ed-switch { margin: 0 6px 0 0; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid transparent; border-radius: 8px; background: none; color: var(--text-muted); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.icon-btn.active { color: var(--accent); }
.icon-danger:hover { background: var(--locked-soft); border-color: transparent; color: var(--locked); }
.icon-badge {
  position: absolute; top: 0; right: -2px; min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}

/* Sharing modal (<dialog>, learn-groups.js); a bottom sheet on phones. */
.learn-modal {
  width: min(560px, calc(100vw - 24px)); max-height: min(85vh, 760px); padding: 0; overflow: auto;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .25);
}
.learn-modal::backdrop { background: rgba(15, 20, 30, .45); }
.learn-modal-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.learn-modal-head h2 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.learn-modal-body { padding: 4px 16px 16px; }
.learn-modal-body h3 { margin: 14px 0 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.learn-modal .learn-share-list { margin: 0; gap: 0; }
.learn-modal .learn-share-list li { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }
.learn-modal .learn-share-list li:first-child { padding-top: 2px; }
.learn-share-who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.learn-share-email { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.learn-share-status { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--completed-soft); color: var(--completed); white-space: nowrap; }
.learn-share-status.pending { background: var(--planned-soft); color: var(--planned); }
.learn-share-who form { margin-left: auto; }
.learn-modal .learn-share-rights { margin-top: 6px; font-size: 13px; }

/* What to learn on /lernen/ (learn.js): open before a session, one line during it. */
.learn-picker { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.learn-picker-bar {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 16px; min-height: 44px;
  border: none; background: none; font: inherit; color: var(--text); text-align: left; cursor: pointer;
}
.learn-picker-title { font-weight: 600; }
.learn-picker-summary { flex: 1; min-width: 0; font-size: 13px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.learn-picker-chevron::before { content: "▾"; display: inline-block; color: var(--text-muted); transition: transform .15s ease; }
.learn-picker.collapsed .learn-picker-chevron::before { transform: rotate(-90deg); }
.learn-picker.collapsed .learn-picker-body { display: none; }
.learn-picker-body { padding: 0 16px 14px; }
.learn-picker-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.learn-picker-tools .learn-select { margin-left: auto; }
.learn-picker-section { font-size: 13px; font-weight: 600; color: var(--text-muted); margin: 12px 0 6px; }
.learn-picker-groups { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.learn-pick-group { border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; }
.learn-pick-row { display: flex; align-items: center; gap: 10px; min-height: 42px; }
.learn-pick-label { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.learn-pick-label input { width: 18px; height: 18px; margin: 0; flex-shrink: 0; accent-color: var(--accent); }
.learn-pick-name { font-weight: 600; }
.learn-pick-counts { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.learn-pick-counts strong { color: var(--accent); }
.learn-pick-expand {
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-muted);
  font-size: 12px; padding: 4px 10px; cursor: pointer; white-space: nowrap;
}
.learn-pick-expand::after { content: " ▸"; }
.learn-pick-expand[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.learn-pick-expand[aria-expanded="true"]::after { content: " ▾"; }
.learn-pick-decks { list-style: none; margin: 0 0 4px; padding: 0 0 0 26px; border-top: 1px dashed var(--border); }
.learn-pick-decks .learn-pick-row { min-height: 38px; }
.learn-pick-decks .learn-pick-label { font-size: 13px; }

.ed-shared-note { margin: 0 0 8px; font-size: 13px; }
.learn-history { max-width: 860px; margin: 0 auto; }
.learn-revision { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 10px; }
.learn-revision-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.learn-revision-head form { margin: 0 0 0 auto; }
.learn-revision-changes { margin: 8px 0 0; padding-left: 18px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.learn-change { font-size: 12px; padding: 1px 6px; border-radius: 6px; background: var(--border); }
.learn-change.add { background: #dcfce7; color: #166534; }
.learn-change.delete { background: #fee2e2; color: #991b1b; }
.learn-change.edit { background: #fef3c7; color: #92400e; }
.learn-diff summary { cursor: pointer; color: var(--text-muted); font-size: 13px; }
.learn-diff pre { white-space: pre-wrap; font-size: 13px; background: var(--bg, #f6f7f9); padding: 8px; border-radius: 6px; overflow-x: auto; }
.diff-line.del { background: #fee2e2; color: #991b1b; }
.diff-line.ins { background: #dcfce7; color: #166534; }
.share-combo { position: relative; flex: 1; min-width: 220px; }
.share-combo input[type=text] { width: 100%; box-sizing: border-box; }
.share-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); max-height: 260px; overflow-y: auto;
}
.share-results li { padding: 8px 10px; border-radius: 8px; font-size: 14px; color: var(--text); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-results li.active, .share-results li:hover { background: var(--accent-soft); }
.share-results li mark { background: none; color: var(--accent); font-weight: 600; }
.share-results li.share-results-note { color: var(--text-muted); cursor: default; background: none; font-size: 13px; }
.learn-deck-actions a, .learn-editor-head a { text-decoration: none; color: var(--text); }
.learn-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.learn-inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.learn-inline-form input[type=text], .learn-field input, .learn-field select, .learn-input, .learn-select, .learn-deck-title {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; background: var(--surface); color: var(--text);
}
.learn-help { margin: 20px 0; font-size: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.learn-help summary { cursor: pointer; font-weight: 600; }
.learn-help table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.learn-help td, .learn-help th { text-align: left; vertical-align: top; padding: 6px 8px; border-top: 1px solid var(--border); }
.learn-help code, .learn-muted code { background: var(--bg); padding: 1px 4px; border-radius: 4px; }

.learn-editor-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.learn-deck-title { font-size: 16px; font-weight: 600; flex: 1; min-width: 200px; }
.learn-source {
  width: 100%; min-height: 360px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.5;
  padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); resize: vertical;
}
.form-errors ul { margin: 6px 0 0; padding-left: 18px; }
.learn-card-table { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.learn-card-row { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 13px; flex-wrap: wrap; }
.learn-card-row:first-child { border-top: none; }
.learn-card-prompt { flex: 1; min-width: 180px; }
.learn-type-chip, .learn-new-chip {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.learn-new-chip { background: var(--planned-soft); color: var(--planned); }
.learn-danger { margin-top: 24px; }

.learn-settings { max-width: 560px; display: flex; flex-direction: column; gap: 12px; }
.learn-settings h2 { margin: 16px 0 0; }
.learn-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-muted); flex: 1; }
.learn-field-row { display: flex; gap: 12px; }

.learn-review { max-width: 720px; margin: 0 auto; }
/* A Tabelle card (BAB, Kalkulationsschema ...) needs more room than the
   reading column: the page and the card grow with the table, up to the
   screen width - only a table wider than that still scrolls sideways. */
main:has(.learn-review .learn-table) { max-width: 1600px; }
.learn-review:has(.learn-table) { width: fit-content; min-width: min(720px, 100%); max-width: 100%; }
.learn-status { margin-bottom: 10px; }
.learn-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.learn-card-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.learn-edit-link { margin-left: auto; font-size: 13px; color: var(--text-muted); text-decoration: none; white-space: nowrap; }
.learn-edit-link:hover { color: var(--text); text-decoration: underline; }
.learn-prompt { font-size: 20px; margin: 6px 0 12px; line-height: 1.35; }
.learn-md { font-size: 15px; line-height: 1.5; }
.learn-md table { border-collapse: collapse; }
.learn-md td, .learn-md th { border: 1px solid var(--border); padding: 4px 8px; }
.learn-answer { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.learn-textarea {
  width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 15px; resize: vertical;
}
.learn-input { font-size: 16px; max-width: 240px; }
.learn-input.ok { border-color: var(--completed); background: var(--completed-soft); }
.learn-input.wrong { border-color: var(--locked); background: var(--locked-soft); }
.learn-option {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 15px;
}
.learn-option input { margin-top: 3px; }
.learn-option.ok, .learn-assign-row.ok { border-color: var(--completed); background: var(--completed-soft); }
.learn-option.wrong, .learn-assign-row.wrong { border-color: var(--locked); background: var(--locked-soft); }
.learn-option.missed { border-color: var(--completed); border-style: dashed; }
.learn-assign-row {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px;
}
.learn-assign-label { flex: 1; min-width: 140px; }
.learn-assign-input { flex: 1; min-width: 160px; }
.ed-toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.ed-toggle input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.learn-assign-expected { width: 100%; font-size: 13px; color: var(--completed); }
.learn-actions-row { margin-top: 8px; }
.learn-solution { background: var(--bg); border-radius: 8px; padding: 4px 14px; }

/* Buchungssatz: Soll | Haben side by side (learn-cards.js, buchungRenderer) */
.learn-buchung { display: flex; flex-direction: column; gap: 14px; }
.learn-buchung-beleg { display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: 14px; }
.learn-buchung-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.learn-buchung-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.learn-buchung-side h3, .learn-buchung-table caption { margin: 0; font-size: 14px; text-align: left; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.learn-buchung-rows { display: flex; flex-direction: column; gap: 8px; }
.learn-buchung-row {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 8px;
}
.learn-buchung-row .learn-select { min-width: 0; width: 100%; }
.learn-buchung-amount { grid-column: 1 / 3; display: flex; gap: 6px; align-items: center; }
.learn-buchung-amount .learn-input { flex: 1; min-width: 0; max-width: none; text-align: right; }
.learn-buchung-remove {
  grid-column: 3; grid-row: 1 / 3; align-self: center; width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text-muted); font-size: 18px; cursor: pointer;
}
.learn-buchung-remove:disabled { opacity: .4; cursor: default; }
.learn-buchung-add { align-self: flex-start; }
.learn-buchung-row.ok { border-color: var(--completed); background: var(--completed-soft); }
.learn-buchung-row.wrong { border-color: var(--locked); background: var(--locked-soft); }
.learn-buchung-row.amount { border-color: var(--locked); }
.learn-select.ok { border-color: var(--completed); background: var(--completed-soft); }
.learn-select.wrong { border-color: var(--locked); background: var(--locked-soft); }
.learn-buchung-solution { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 8px 0; }
.learn-buchung-table { border-collapse: collapse; font-size: 14px; width: 100%; }
.learn-buchung-table th, .learn-buchung-table td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.learn-buchung-table .num { text-align: right; white-space: nowrap; }
@media (max-width: 640px) {
  .learn-buchung-columns, .learn-buchung-solution { grid-template-columns: minmax(0, 1fr); }
  .learn-buchung-row .learn-select, .learn-buchung-row .learn-input { font-size: 16px; }
}
/* Inline calculations in number fields (learn-cards.js, calcInput) */
.learn-calc { display: inline-flex; flex-direction: column; gap: 2px; min-width: 0; max-width: 100%; }
.learn-calc-row { display: flex; align-items: stretch; gap: 4px; min-width: 0; }
.learn-calc-row .learn-input { flex: 1; min-width: 0; }
.learn-calc-btn {
  flex: none; width: 32px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  color: var(--text-muted); font-weight: 700; font-size: 15px; cursor: pointer; padding: 0;
}
.learn-calc-btn:hover { color: var(--accent); border-color: var(--accent); }
.learn-calc-input:disabled ~ .learn-calc-btn { display: none; }
.learn-calc-note { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.learn-calc-note:empty { display: none; }
.learn-calc-note.error { color: var(--answer-bad-text, var(--locked)); }
.learn-buchung-amount .learn-calc { flex: 1; }
.learn-buchung-amount .learn-calc .learn-input { max-width: none; text-align: right; }

/* Tabelle (learn-cards.js, tableRenderer) */
.learn-table-wrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.learn-table { border-collapse: collapse; font-size: 14px; min-width: 100%; }
.learn-table th, .learn-table td { border: 1px solid var(--border); padding: 4px 6px; text-align: left; vertical-align: top; }
.learn-table th { background: var(--surface-muted, transparent); font-weight: 600; white-space: nowrap; }
.learn-table .lt-given { white-space: nowrap; }
.learn-table td:not(.lt-label):not(.lt-tools) { text-align: right; }
.learn-table .lt-label { text-align: left; }
.learn-table .learn-calc { width: 100%; }
.learn-table .learn-input { max-width: none; min-width: 112px; width: 100%; text-align: right; font-size: 14px; padding: 4px 6px; }
.learn-table .learn-select { min-width: 150px; width: 100%; font-size: 14px; }
.learn-table td.ok { background: var(--answer-ok-bg, var(--completed-soft)); }
.learn-table td.wrong { background: var(--answer-bad-bg, var(--locked-soft)); }
.learn-table td.moved { background: var(--locked-soft); }
.learn-table .lt-expected { display: block; font-size: 12px; font-weight: 700; color: var(--answer-ok-text, var(--completed)); white-space: nowrap; text-align: right; }
.learn-table .lt-label .lt-expected { text-align: left; }
.learn-table .lt-tools { white-space: nowrap; width: 1%; }
.learn-table .lt-tool { border: none; background: none; color: var(--text-muted); cursor: pointer; font-size: 15px; padding: 2px 4px; }
.learn-table .lt-tool:disabled { opacity: .4; cursor: default; }
.learn-table-solution .lt-sol { font-weight: 700; color: var(--answer-ok-text, var(--completed)); white-space: nowrap; }
.learn-table-add { align-self: flex-start; }
@media (max-width: 640px) {
  .learn-table .learn-input, .learn-table .learn-select { font-size: 16px; }
}
.learn-ok { color: var(--completed); font-weight: 600; }
.learn-wrong { color: var(--locked); font-weight: 600; }
.learn-ai { margin-top: 12px; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 6px; font-size: 14px; }
.learn-ai p { margin: 4px 0 0; }
.learn-rating { margin-top: 16px; }
/* Focused after checking only so keys 1-3 reach the page - no frame for that. */
.learn-rating:focus { outline: none; }
.learn-rating-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.learn-rate {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 2px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; font-size: 15px; font-weight: 600; color: var(--text);
  border-bottom-width: 3px;
}
.learn-rate small { color: var(--text-muted); font-size: 11px; font-weight: 400; }
.learn-rate-0 { border-bottom-color: var(--locked); }
.learn-rate-50 { border-bottom-color: var(--planned); }
.learn-rate-100 { border-bottom-color: var(--completed); }
.learn-rate.suggested { outline: 2px solid var(--accent); outline-offset: 1px; background: var(--accent-soft); }

/* Study Helper title wrapper, and Lernen's own header. */
.topbar-title { display: flex; align-items: center; gap: 10px; }
.learn-topbar .page-nav { margin-left: 8px; }
.learn-topbar .page-nav a { text-decoration: none; }
/* The bell before the profile icon; its badge counts unread notifications. */
.learn-bell { position: relative; margin-left: auto; display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); text-decoration: none; }
.learn-bell.active { color: var(--accent); }
.learn-bell .icon-badge { position: absolute; top: -2px; right: -4px; }
.learn-bell + .profile-menu-wrap { margin-left: 8px; }
.learn-notifications { max-width: 760px; margin: 0 auto; }
.learn-notifications-clear { margin: 0 0 0 auto; }
.learn-notification-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.learn-notification a {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.learn-notification a:hover { border-color: var(--accent); }
.learn-notification.unread a { border-left: 4px solid var(--accent); }
.learn-notification small { font-size: 12px; }
.learn-flash-ok { color: var(--completed); }
.learn-hero-stats { display: flex; gap: 28px; }
.learn-hero-stats > div { display: flex; flex-direction: column; }
.learn-start-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.learn-hero > .learn-muted { flex-basis: 100%; margin: 0; }
/* Start buttons, with how many cards each has. */
.learn-mode { display: inline-flex; align-items: center; gap: 8px; }
.learn-mode:disabled { opacity: .45; cursor: default; }
.learn-mode-count {
  min-width: 22px; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 700; text-align: center;
  background: rgba(255, 255, 255, .25);
}
/* "Lernmodus" and "Prüfungsmodus" side by side on the overview (one under
   the other on a phone). */
.learn-mode-cards { flex-basis: 100%; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.learn-mode-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.learn-mode-card h2 { margin: 0; font-size: 17px; }
.learn-mode-card > .learn-muted { margin: 0; font-size: 13px; flex: 1; }
.learn-mode-card .learn-start-row .learn-mode { flex: 1; justify-content: center; padding: 10px 8px; }
.learn-options .learn-focus-pick { margin-top: 6px; display: flex; }
.learn-options .learn-focus-pick button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.learn-seg .learn-mode-count { background: var(--border); }
.learn-session-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.learn-due-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.learn-due-track { flex: 1; height: 10px; border-radius: 5px; background: var(--border); overflow: hidden; }
.learn-due-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }
.learn-due-progress.done .learn-due-fill { background: var(--completed); }
.learn-due-label { font-size: 13px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.learn-due-progress.done .learn-due-label { color: var(--completed); }
/* Their display: flex would otherwise win over .hidden. */
.learn-hero.hidden, .learn-due-progress.hidden { display: none; }

/* Difficulty (leicht / mittel / schwer): muted section colours, a stronger
   tone of each for what's done, chips and anchor points. */
:root {
  --diff-leicht: #e3f2e6; --diff-leicht-strong: #7fbf92; --diff-leicht-text: #2f7a49;
  --diff-mittel: #f8f0cf; --diff-mittel-strong: #d9bd52; --diff-mittel-text: #866b12;
  --diff-schwer: #fbe4d3; --diff-schwer-strong: #e5a170; --diff-schwer-text: #9a5218;
}
.diff-leicht { --diff-bg: var(--diff-leicht); --diff-strong: var(--diff-leicht-strong); --diff-text: var(--diff-leicht-text); }
.diff-mittel { --diff-bg: var(--diff-mittel); --diff-strong: var(--diff-mittel-strong); --diff-text: var(--diff-mittel-text); }
.diff-schwer { --diff-bg: var(--diff-schwer); --diff-strong: var(--diff-schwer-strong); --diff-text: var(--diff-schwer-text); }
.learn-diff-chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--diff-bg); color: var(--diff-text); white-space: nowrap; }
.ed-difficulty { display: flex; }
.ed-difficulty button { flex: 1; }
.ed-difficulty button.active.diff-leicht, .ed-difficulty button.active.diff-mittel, .ed-difficulty button.active.diff-schwer { background: var(--diff-bg); color: var(--diff-text); }

.exam-progress { align-items: flex-start; }
.exam-progress .learn-due-label { line-height: 10px; }
.exam-bar { position: relative; flex: 1; min-width: 0; }
.exam-bar > .learn-due-track { display: flex; gap: 3px; }
.learn-due-track.sectioned { background: transparent; overflow: visible; }
.learn-due-track.sectioned .learn-due-fill { display: none; }
.exam-seg { flex: 1 1 0; min-width: 6px; height: 100%; border-radius: 5px; background: var(--diff-bg); overflow: hidden; }
.exam-seg.active { box-shadow: 0 0 0 1.5px var(--diff-strong) inset; }
.exam-seg-fill { height: 100%; width: 0; background: var(--diff-strong); transition: width .3s ease; }
.exam-anchor {
  position: absolute; top: 5px; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--diff-strong); box-sizing: border-box; pointer-events: auto;
}
.exam-anchor.reached { background: var(--diff-strong); }
.exam-legend { display: flex; gap: 3px; margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.exam-legend.hidden { display: none; }
.exam-legend-item { flex: 1 0 auto; display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.exam-legend-item.active { color: var(--diff-text); font-weight: 600; }
.exam-legend-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--diff-strong); }
/* The Lernmodus goal bar (learn.js) uses the exam bar's sections: fällig,
   neu, or the whole round - in tones of the accent; all green once reached. */
.goal-due, .goal-rest { --diff-bg: color-mix(in srgb, var(--accent) 18%, transparent); --diff-strong: var(--accent); --diff-text: var(--accent); }
.goal-new { --goal-new: color-mix(in srgb, var(--accent) 50%, var(--completed)); --diff-bg: color-mix(in srgb, var(--goal-new) 18%, transparent); --diff-strong: var(--goal-new); --diff-text: var(--goal-new); }
.learn-due-progress.done .exam-seg-fill { background: var(--completed); }
/* Lernmodus sections by exam: nearest exam in the accent, later ones warmer,
   decks without an exam grey (learn.js buildGoal). */
.goal-exam-0 { --diff-bg: color-mix(in srgb, var(--accent) 18%, transparent); --diff-strong: var(--accent); --diff-text: var(--accent); }
.goal-exam-1 { --diff-bg: color-mix(in srgb, var(--planned) 20%, transparent); --diff-strong: var(--planned); --diff-text: var(--planned); }
.goal-exam-2 { --goal-later: color-mix(in srgb, var(--planned) 50%, var(--locked)); --diff-bg: color-mix(in srgb, var(--goal-later) 18%, transparent); --diff-strong: var(--goal-later); --diff-text: var(--goal-later); }
.goal-none { --diff-bg: color-mix(in srgb, var(--notoffered) 25%, transparent); --diff-strong: var(--notoffered); --diff-text: var(--text-muted); }
#learnGoalLegend .exam-legend-item { flex-shrink: 1; min-width: 0; }
#learnGoalLegend .exam-legend-text { overflow: hidden; text-overflow: ellipsis; }
.learn-congrats { text-align: center; }
.learn-congrats-icon { font-size: 48px; line-height: 1; }
.learn-congrats .learn-start-row { justify-content: center; }
.learn-practice-note { font-size: 12px; color: var(--text-muted); margin: 6px 0 0; }
/* "Zeichnen": the drawing pad, the solution image, and the editor's image field. */
.learn-pad { display: flex; flex-direction: column; gap: 6px; }
.learn-pad-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.learn-pad-gap { flex: 1; }
.learn-pad-tool {
  min-width: 34px; height: 34px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 13px; cursor: pointer;
}
.learn-pad-tool[data-color] { padding: 0; background: var(--pad-color); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.learn-pad-tool.active { box-shadow: 0 0 0 2px var(--accent); }
.learn-pad-tool:not([data-color]).active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.learn-pad-tool:disabled { opacity: .4; cursor: default; }
.learn-pad-canvas {
  display: block; width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 8px;
  touch-action: none; cursor: crosshair;
}
.learn-pad.locked .learn-pad-canvas { cursor: default; }
.learn-solution-image { display: block; max-width: 100%; max-height: 70vh; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.learn-md img { max-width: 100%; }
.ed-image-drop {
  display: flex; align-items: center; justify-content: center; min-height: 120px; padding: 10px;
  border: 2px dashed var(--border); border-radius: 8px; background: var(--bg);
}
.ed-image-drop.over, .ed-image-drop:focus { border-color: var(--accent); outline: none; }
.ed-image-drop img { max-width: 100%; max-height: 260px; border-radius: 6px; }
/* "Prüfung": list of exam sessions, new-session form, session header. */
.learn-exam-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.learn-exam-top h2 { margin: 0; }
.learn-exam-item.done .learn-deck-name { color: var(--completed); }
.learn-exam-new { margin-top: 16px; }
.learn-exam-new .learn-picker-body { padding-top: 4px; display: flex; flex-direction: column; gap: 10px; }
.learn-exam-new .learn-picker-tools { margin: 4px 0 0; }
.learn-exam-new .learn-picker-title { margin-right: auto; }
.learn-exam-submit { margin-top: 6px; }
.learn-exam-submit .btn-primary:disabled { opacity: .45; cursor: default; }
.learn-exam-edit > summary { list-style: none; }
.learn-exam-edit > summary::-webkit-details-marker { display: none; }
.learn-exam-edit-hint { font-size: 13px; color: var(--accent); }
.learn-exam-edit[open] .learn-exam-edit-hint { visibility: hidden; }
.learn-exam-edit .learn-picker-body { display: flex; flex-direction: column; gap: 8px; }
.learn-request-error { margin-top: 12px; padding: 10px 14px; border-left: 3px solid var(--locked); border-radius: 6px; background: var(--bg); }
.learn-request-error p { margin: 0 0 8px; }
.learn-actions-row .learn-skip { margin-left: 8px; }

@media (max-width: 768px) {
  /* Left in the header row, opposite the profile icon. */
  .learn-bell { grid-area: actions; justify-self: start; align-self: center; margin-left: 0; }
}

@media (max-width: 768px) {
  .topbar-title { grid-area: title; justify-content: center; gap: 8px; }
  .learn-hero-stats { gap: 18px; }
  .learn-modes { width: 100%; }
  .learn-modes .learn-mode { flex: 1; justify-content: center; padding: 10px 8px; }
  .learn-card { padding: 14px; }
  .learn-prompt { font-size: 18px; }
  .learn-deck-actions { margin-left: 0; }
  .learn-picker-tools .learn-select { margin-left: 0; flex: 1; font-size: 16px; }
  .learn-groups-title h2 { flex-basis: 100%; margin-bottom: 0; }
  .learn-groups-fold { margin-left: 0; }
  .learn-groups-fold { width: 100%; }
  .learn-groups-fold .btn-secondary { flex: 1; min-height: 38px; white-space: nowrap; }
  .learn-group-head { padding: 6px 10px 8px 4px; }
  /* Name and deck count on the first line, the numbers with the icons below. */
  .learn-group-head {
    display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 2px 8px;
    grid-template-areas: "toggle name count" ". meta icons";
  }
  .learn-group-head > .learn-group-toggle { grid-area: toggle; }
  .learn-group-head > .learn-group-rename { grid-area: name; }
  .learn-group-head > .learn-group-count { grid-area: count; }
  .learn-group-head > .learn-muted { grid-area: meta; }
  .learn-group-head > .learn-icon-actions { grid-area: icons; margin-left: 0; justify-self: end; }
  .learn-group-rename { flex: 1; min-width: 0; }
  input.learn-group-name { flex: 1; width: 100%; }
  .learn-group-body { padding: 8px; }
  .learn-group-add input[type=text] { max-width: none; }
  .learn-group-add .btn-secondary { min-height: 36px; }
  .learn-deck[data-deck] { padding: 8px 10px; gap: 2px 6px; grid-template-areas: "handle main history" "handle actions actions"; }
  .learn-deck[data-deck]:has(> .sort-handle) { padding-left: 2px; }
  .learn-deck-history { align-self: start; }
  .learn-deck-icons { justify-self: start; margin-top: 4px; }
  .icon-btn { width: 40px; height: 40px; }
  .learn-modal { width: 100%; max-width: 100%; margin: auto auto 0; border-radius: 16px 16px 0 0; max-height: 92vh; max-height: 92dvh; overflow-x: hidden; overscroll-behavior: contain; }
  .learn-modal-head { padding: 10px 8px 8px 16px; }
  .learn-modal-head::before { content: ""; position: absolute; top: 5px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--border); }
  .learn-modal-body { padding: 4px 16px calc(16px + env(safe-area-inset-bottom)); min-width: 0; }
  .learn-modal .share-combo { min-width: 0; flex-basis: 100%; }
  .learn-modal .share-combo input[type=text] { font-size: 16px; min-height: 44px; }
  .learn-modal .learn-share-form { flex-direction: column; align-items: stretch; }
  .learn-modal .learn-share-form .btn-primary { width: 100%; min-height: 44px; }
  .learn-share-who { align-items: flex-start; }
  .learn-share-email { flex: 1 1 100%; min-width: 0; }
  .learn-modal .learn-share-rights { display: flex; flex-direction: column; align-items: stretch; gap: 2px; }
  .learn-modal .learn-share-rights label { min-height: 36px; font-size: 14px; }
  .learn-modal .learn-share-rights .btn-secondary { min-height: 40px; margin-top: 4px; }
  .sort-handle { width: 32px; height: 40px; font-size: 20px; }
  .learn-actions .learn-inline-form { width: 100%; }
  .learn-actions .learn-inline-form input[type=text] { flex-basis: 100%; min-width: 0; font-size: 16px; box-sizing: border-box; }
  .learn-actions .learn-inline-form .btn-secondary { min-height: 38px; }
  .learn-group-add input[type=text], input.learn-group-name { font-size: 16px; }
  .learn-pick-label { font-size: 15px; }
  .learn-field-row { flex-direction: column; gap: 12px; }
}

/* ---- Lernen editor (card forms, /lernen/inhalte/<id>/, deck-editor.js) ---- */
/* Desktop: a two-column modal (form | preview). Mobile: a full-screen sheet
   with a sticky Abbrechen/Übernehmen bar; inputs at 16px so iOS doesn't zoom
   in, tap targets >= 40px. */
.ed-tabs { margin: 4px 0 12px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.ed-save-state { font-size: 13px; color: var(--text-muted); min-width: 110px; }
.ed-save-state.saved { color: var(--completed); }
.ed-save-state.error { color: var(--locked); font-weight: 600; }
.ed-empty { padding: 14px; margin: 0; }
.ed-add { width: auto; margin-top: 12px; padding: 12px 22px; font-size: 15px; }
.ed-source-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; }

.ed-row { padding: 4px 6px 4px 4px; flex-wrap: wrap; gap: 4px; }
.ed-row.invalid { background: var(--locked-soft); }
.ed-row.selected { background: var(--accent-soft); }
.ed-select-box { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.ed-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.ed-toolbar .btn-secondary { min-height: 36px; }
.ed-toolbar #edSelInfo { flex: 1; }
.ed-toolbar .hidden { display: none; }
.ed-toolbar .learn-btn-inline:disabled { opacity: .45; cursor: default; }
.ed-row-main {
  flex: 1; min-width: 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  border: none; background: transparent; text-align: left; font: inherit; font-size: 13px; color: var(--text);
  padding: 8px; border-radius: 8px; cursor: pointer; min-height: 44px;
}
.ed-row-main:hover { background: var(--bg); }
.ed-row-main .learn-card-prompt { overflow-wrap: anywhere; }
.ed-row-actions { display: flex; gap: 2px; }
.ed-row-error { flex-basis: 100%; margin: 0 8px 6px; font-size: 12px; color: var(--locked); }
.ed-icon-btn {
  min-width: 40px; min-height: 40px; border: 1px solid transparent; border-radius: 8px; background: transparent;
  font-size: 16px; color: var(--text-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.ed-icon-btn:hover:not(:disabled) { background: var(--bg); border-color: var(--border); color: var(--text); }
.ed-icon-btn:disabled { opacity: .3; cursor: default; }

.ed-locked { overflow: hidden; }
.ed-overlay {
  position: fixed; inset: 0; z-index: 400; background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.ed-sheet {
  background: var(--surface); border-radius: var(--radius); box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
  display: flex; flex-direction: column; width: 100%; max-height: 100%; overflow: hidden;
}
.ed-picker { max-width: 620px; }
.ed-card-sheet { max-width: 1120px; height: min(92vh, 960px); }
.ed-sheet-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--border); }
.ed-sheet-head h2 { font-size: 16px; margin: 0; flex: 1; }
.ed-type-select { max-width: 50%; }
.ed-sheet-body { flex: 1; overflow-y: auto; padding: 16px 18px; -webkit-overflow-scrolling: touch; }
.ed-card-sheet .ed-sheet-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; padding: 0; overflow: hidden; }
.ed-card-sheet .ed-form, .ed-card-sheet .ed-preview { overflow-y: auto; padding: 16px 18px 24px; }
.ed-preview { background: var(--bg); border-left: 1px solid var(--border); }
.ed-sheet-foot {
  display: flex; gap: 10px; align-items: center; justify-content: flex-end;
  padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface);
}
.ed-foot-status {
  flex: 1; min-width: 0; text-align: left; border: none; background: none; padding: 4px 0; cursor: pointer;
  font-size: 13px; color: var(--locked); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ed-foot-status.hidden { display: block; visibility: hidden; }
.ed-sheet-foot .btn-secondary, .ed-apply { width: auto; min-height: 42px; padding: 10px 18px; font-size: 15px; }
.ed-apply:disabled { opacity: .45; cursor: default; }
.ed-sheet-foot .ed-delete { color: var(--locked); }
.ed-sheet-foot .ed-delete:hover { background: var(--locked-soft); border-color: var(--locked); }

.ed-type-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ed-type-btn {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left; min-height: 76px;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  cursor: pointer; font: inherit; color: var(--text);
}
.ed-type-btn strong { font-size: 15px; }
.ed-type-btn span { font-size: 13px; color: var(--text-muted); }
.ed-type-btn:hover, .ed-type-btn:focus-visible { border-color: var(--accent); background: var(--accent-soft); }

.ed-form { display: flex; flex-direction: column; gap: 16px; }
.ed-field { display: flex; flex-direction: column; gap: 6px; }
.ed-label { font-size: 13px; font-weight: 600; color: var(--text); }
.ed-hint { margin: 0; font-size: 12px; color: var(--text-muted); }
.ed-field-error { margin: 0; font-size: 13px; color: var(--locked); font-weight: 600; }
.ed-field-error:empty { display: none; }
.ed-field.has-error > .ed-input, .ed-field.has-error .ed-option-row .ed-input,
.ed-field.has-error .ed-var-row .ed-input, .ed-field.has-error .ed-pair-row .ed-input,
.ed-field.has-error .ed-group .ed-input { border-color: var(--locked); }
.ed-input {
  width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; font-size: 15px; background: var(--surface); color: var(--text);
}
.ed-input:focus, .ed-sheet .learn-select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.ed-textarea { resize: vertical; line-height: 1.45; min-height: 64px; }
.ed-prompt { min-height: 40px; resize: none; overflow: hidden; }
.ed-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ed-table { white-space: pre; overflow-x: auto; font-size: 13px; }
.ed-sheet .learn-select { min-height: 40px; }
.ed-details > summary { cursor: pointer; font-size: 13px; color: var(--text-muted); padding: 4px 0; }
.ed-details[open] > summary { margin-bottom: 6px; }
.ed-add-row { align-self: flex-start; min-height: 40px; padding: 8px 14px; font-size: 14px; }
.ed-inline { display: flex; gap: 8px; align-items: center; }
.ed-sep { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

.ed-option-row, .ed-pair-row { display: flex; gap: 6px; align-items: center; }
.ed-option-row .ed-input, .ed-pair-row .ed-input { flex: 1; min-width: 0; }
.ed-check {
  flex: none; width: 40px; height: 40px; border-radius: 8px; border: 2px solid var(--border); background: var(--surface);
  color: transparent; font-size: 18px; font-weight: 700; cursor: pointer;
}
.ed-check.on { border-color: var(--completed); background: var(--completed-soft); color: var(--completed); }
.ed-var-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 6px; border: 1px solid var(--border); border-radius: 8px; }
.ed-var-name { width: 90px; flex: none; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ed-var-kind { flex: none; }
.ed-var-spec { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 200px; }
.ed-var-spec .ed-input { min-width: 0; }
.ed-num { width: 90px; flex: 1; }
.ed-inline .ed-num { flex: none; width: 130px; }
.ed-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: -8px; }
.ed-chips:empty { display: none; }
.ed-chip {
  min-height: 34px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent-soft);
  color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; cursor: pointer;
}
.ed-entry-side { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
.ed-entry-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ed-entry-row .ed-entry-konto { flex: 2 1 220px; min-width: 0; }
.ed-entry-row .ed-entry-betrag { flex: 1 1 120px; min-width: 0; text-align: right; }
.ed-field.has-error .ed-entry-row .ed-input, .ed-field.has-error .ed-entry-row .learn-select { border-color: var(--locked); }
.ed-group { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
.ed-group-head { display: flex; gap: 4px; align-items: center; }
.ed-group-head .ed-input { flex: 1; min-width: 0; font-weight: 600; }

.ed-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.ed-preview-head h3 { margin: 0; font-size: 14px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.ed-preview-card { padding: 16px; }
.ed-preview-card.stale { opacity: .55; }
.ed-samples { margin-top: 12px; font-size: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.ed-samples h4 { margin: 0 0 6px; font-size: 13px; color: var(--text-muted); }
.ed-samples ul { margin: 0; padding-left: 18px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.ed-sample-result { font-weight: 700; }
.ed-md { margin-top: 12px; }
.ed-md pre {
  margin: 0; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere;
}

@media (max-width: 768px) {
  .ed-overlay { padding: 0; align-items: stretch; }
  .ed-sheet, .ed-card-sheet {
    max-width: none; height: 100vh; height: 100dvh; max-height: none; border-radius: 0;
    padding-top: env(safe-area-inset-top);
  }
  .ed-card-sheet .ed-sheet-body { display: block; overflow-y: auto; }
  .ed-card-sheet .ed-form, .ed-card-sheet .ed-preview { overflow: visible; padding: 14px; }
  .ed-preview { border-left: none; border-top: 1px solid var(--border); }
  .ed-sheet-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .ed-foot-status { flex-basis: 100%; white-space: normal; }
  .ed-foot-status.hidden { display: none; }
  .ed-sheet-foot .btn-secondary, .ed-apply { flex: 1; }
  .ed-type-grid { grid-template-columns: minmax(0, 1fr); }
  .ed-input, .ed-sheet .learn-select, .ed-sheet .learn-input, .ed-sheet .learn-textarea,
  .learn-editor .learn-deck-title, .learn-editor .learn-source { font-size: 16px; }
  .ed-row-main { flex-basis: 100%; }
  .ed-row .sort-handle { order: 2; }
  .ed-row-actions { margin-left: auto; order: 3; }
  .ed-row-error { order: 4; }
  .ed-var-spec { flex-basis: 100%; order: 3; }
  .ed-var-row > .ed-icon-btn { order: 2; margin-left: auto; }
  .ed-add { width: 100%; }
}

/* ---- Lernen statistics (/lernen/statistik/, learn-stats.js) ---- */
/* One blue hue for single values (meter, line, columns); the learning phases
   use a one-hue ordinal ramp (validated: monotone, light end >= 2:1). Text
   stays in text colors, never the series color. */
.stats { max-width: 900px; margin: 0 auto; }
.stats-filters { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.stats-filter { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-muted); }
.stats-filter .learn-select { min-height: 38px; min-width: 200px; }
.stats-body { transition: opacity .15s; }
.stats-body.loading { opacity: .5; }
.stats-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 16px;
}
.stats-section h2 { font-size: 16px; margin: 0 0 4px; }
.stats-section h3 { font-size: 14px; margin: 0; }
.stats-sub { margin: 0 0 12px; font-size: 13px; color: var(--text-muted); }
.stats-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }

.stats-hero {
  display: flex; gap: 24px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}
.stats-hero-main { display: flex; flex-direction: column; gap: 2px; min-width: 200px; }
.stats-hero-value { font-size: 52px; font-weight: 700; line-height: 1.05; color: var(--text); }
.stats-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; flex: 1; min-width: 280px; }
.stats-tile { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--bg); border-radius: 8px; }
.stats-tile-label { font-size: 12px; color: var(--text-muted); }
.stats-tile-value { font-size: 24px; font-weight: 600; color: var(--text); }
.stats-tile-sub { font-size: 11px; color: var(--text-muted); }

.stats-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; color: var(--text); }
.stats-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.stats-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.stats-stack { display: flex; gap: 2px; height: 24px; border-radius: 4px; overflow: hidden; background: var(--surface); }
.stats-seg-part { position: relative; min-width: 3px; display: flex; align-items: center; justify-content: center; cursor: default; outline-offset: 2px; }
.stats-seg-part:hover, .stats-seg-part:focus-visible { filter: brightness(1.12); }
.stats-seg-label { font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; }
.stats-seg-label.dark { color: #0d366b; }

.stats-rows { display: flex; flex-direction: column; }
.stats-row {
  display: grid; grid-template-columns: minmax(140px, 1.2fr) minmax(100px, 2fr) 48px auto; gap: 14px; align-items: center;
  padding: 10px 0; border-top: 1px solid var(--border);
}
.stats-row:first-child { border-top: none; }
.stats-row-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stats-row-name strong { font-size: 14px; overflow-wrap: anywhere; }
.stats-meter { height: 12px; border-radius: 4px; background: #cde2fb; overflow: hidden; cursor: default; outline-offset: 3px; }
.stats-meter-fill { height: 100%; background: #2a78d6; border-radius: 0 4px 4px 0; }
.stats-meter:hover .stats-meter-fill, .stats-meter:focus-visible .stats-meter-fill { filter: brightness(1.12); }
.stats-row-value { font-size: 14px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.stats-practice { text-decoration: none; color: var(--text); min-height: 34px; display: inline-flex; align-items: center; }

.learn-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.learn-seg button { border: none; background: var(--surface); padding: 8px 14px; font-size: 13px; cursor: pointer; color: var(--text-muted); min-height: 36px; }
.learn-seg button + button { border-left: 1px solid var(--border); }
.learn-seg button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.stats-chart { margin: 8px 0 16px; }
.stats-chart figcaption { margin-bottom: 4px; }
.stats-plot { width: 100%; }
.stats-svg { display: block; max-width: 100%; overflow: visible; }
.stats-grid { stroke: #e1e0d9; stroke-width: 1; }
.stats-axis { stroke: #c3c2b7; stroke-width: 1; }
.stats-tick { font-size: 11px; fill: #898781; font-variant-numeric: tabular-nums; }
.stats-line { fill: none; stroke: #2a78d6; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.stats-area { fill: #2a78d6; opacity: .1; }
.stats-dot { fill: #2a78d6; stroke: var(--surface); stroke-width: 2; }
.stats-end-label { font-size: 12px; font-weight: 600; fill: var(--text); }
.stats-crosshair { stroke: #898781; stroke-width: 1; }
.stats-bar { fill: #2a78d6; }
.stats-bar-group { cursor: default; outline: none; }
.stats-bar-group:hover .stats-bar, .stats-bar-group:focus .stats-bar { fill: #3987e5; }
.stats-empty { font-size: 13px; fill: #898781; }

.stats-table-toggle { margin-top: 10px; font-size: 13px; }
.stats-table-toggle summary { cursor: pointer; color: var(--text-muted); }
.stats-table { border-collapse: collapse; width: 100%; margin-top: 8px; font-size: 13px; font-variant-numeric: tabular-nums; }
.stats-table th, .stats-table td { text-align: right; padding: 5px 8px; border-top: 1px solid var(--border); white-space: nowrap; }
.stats-table th:first-child { text-align: left; white-space: normal; }
.stats-table thead th { color: var(--text-muted); font-weight: 600; border-top: none; }

.stats-tooltip {
  position: fixed; z-index: 500; pointer-events: none; min-width: 140px; max-width: 260px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
  padding: 8px 10px; font-size: 12px; color: var(--text-muted);
}
.stats-tip-title { font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.stats-tip-row { display: flex; align-items: center; gap: 6px; }
.stats-tip-row strong { color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
.stats-tip-key { width: 10px; height: 3px; border-radius: 2px; flex: none; }

@media (max-width: 768px) {
  .stats-section, .stats-hero { padding: 14px; }
  .stats-hero-value { font-size: 48px; }
  .stats-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-row { grid-template-columns: minmax(0, 1fr) 48px auto; row-gap: 6px; }
  .stats-row-name { grid-column: 1 / -1; }
  .stats-filter { flex: 1; }
  .stats-filter .learn-select { flex: 1; min-width: 0; font-size: 16px; }
}

/* "Fragen mit KI erstellen" prompt box on the Inhalte page */
.prompt-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 24px; }
.prompt-controls { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.prompt-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.prompt-field input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; min-height: 36px; min-width: 220px; }
.prompt-count input { min-width: 0; width: 90px; }
.prompt-box #promptAudience { margin: 10px 0 8px; }
.prompt-text { min-height: 260px; font-size: 12px; }
.prompt-actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; }
@media (max-width: 768px) {
  .prompt-field { flex: 1; }
  .prompt-field input { min-width: 0; font-size: 16px; }
  .prompt-actions .learn-btn-inline { flex: 1; }
  /* Five prompts don't fit one row on a phone: a grid of tiles instead, so
     "Nur Format" isn't cut off at the edge. */
  .prompt-box .learn-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; width: 100%; background: var(--border); }
  .prompt-box .learn-seg button + button { border-left: none; }
  .prompt-box .learn-seg button { padding: 8px 6px; }
}

/* "Karten aus Lernmaterial erzeugen" (Inhalte page + job page) */
.gen-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 12px; }
.gen-box .learn-muted { margin: 0; }
.gen-box .prompt-actions { margin: 0; }
.gen-box .btn-primary:disabled { opacity: .45; cursor: default; }
.gen-file input { font-size: 14px; }
.gen-jobs { display: flex; flex-direction: column; gap: 4px; margin-bottom: 24px; }
.gen-job { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--text); font-size: 14px; }
.gen-page { max-width: 760px; }
.gen-progress { height: 10px; border-radius: 4px; background: #cde2fb; overflow: hidden; margin: 16px 0 8px; }
.gen-progress-fill { height: 100%; background: #2a78d6; border-radius: 0 4px 4px 0; transition: width .4s; }
.gen-status { font-size: 14px; }
.gen-status.failed { color: var(--locked); font-weight: 600; }
.gen-status.done { color: var(--completed); font-weight: 600; }
.gen-actions { display: flex; gap: 10px; align-items: center; margin: 12px 0 20px; }
.gen-log { font-size: 13px; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.gen-panel { display: flex; flex-direction: column; gap: 12px; }
.gen-provider { gap: 6px; }
.gen-panel.hidden, .prompt-field.hidden, .gen-actions .hidden { display: none; }

/* Reminder times on the Lernen settings page */
.notify-times { display: flex; flex-direction: column; gap: 6px; }
.notify-row { display: flex; align-items: center; gap: 6px; max-width: 420px; }
.notify-label { font-size: 14px; color: var(--text); flex: none; }
.notify-row > .notify-label:first-child { min-width: 30px; }
.notify-time { flex: 1 1 0; min-width: 0; padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 16px; min-height: 40px; background: var(--surface); color: var(--text); }
.notify-add { display: flex; gap: 8px; flex-wrap: wrap; }
.notify-add .btn-secondary { min-height: 38px; }
.ladder-preview { margin: -4px 0 0; }
.learn-hero-sub { display: block; font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* Card on/off switch in the deck editor */
.ed-switch {
  position: relative; flex: none; width: 40px; height: 24px; margin: 8px 4px; border-radius: 999px; border: none; cursor: pointer;
  background: var(--border); transition: background .15s;
}
.ed-switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s;
}
.ed-switch[aria-checked="true"] { background: var(--accent); }
.ed-switch[aria-checked="true"]::after { transform: translateX(16px); }
.ed-switch:disabled { opacity: .4; cursor: default; }
.ed-switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ed-row.off .ed-row-main .learn-card-prompt, .ed-row.off .ed-row-main .learn-type-chip { opacity: .5; }
.ed-off-chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--notoffered-soft); color: var(--text-muted); white-space: nowrap; }

/* ---- User list (accounts.views.user_list) ---- */
.user-table-wrap { overflow-x: auto; }
.user-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; }
.user-table th, .user-table td { text-align: left; padding: 8px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.user-table th { border-top: none; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.user-inactive td { color: var(--text-muted); }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.user-actions form { margin: 0; }
.user-actions a.btn-secondary { text-decoration: none; color: var(--text); }
.btn-delete:hover { background: var(--locked-soft); border-color: var(--locked); color: var(--locked); }
.role-badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--notoffered-soft); color: var(--text-muted); white-space: nowrap; }
.role-badge.role-admin { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.role-badge.role-off { background: var(--locked-soft); color: var(--locked); }
.user-edit-form { max-width: 420px; }
.user-edit-form select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }

/* Links that look like buttons: no link colour or underline. */
a.btn-secondary { color: var(--text); text-decoration: none; }
a.btn-primary { color: #fff; text-decoration: none; text-align: center; }
/* Explanations that fold away, so the actions stay near the top. */
.learn-hint { flex-basis: 100%; font-size: 13px; color: var(--text-muted); }
.learn-hint summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.learn-hint p { margin: 4px 0 0; }
.learn-field code { align-self: flex-start; }

/* ---- Lernen on phones ---- */
@media (max-width: 768px) {
  /* The Lernen header has no second row (ECTS counts), so centre the title
     over both grid rows instead of leaving it in the upper one. */
  .learn-topbar h1 { grid-row: 1 / -1; align-self: center; }

  /* Touch targets of at least 40px, and 16px text in every field - below
     that, iOS zooms into the page on focus. */
  .learn-topbar ~ main .btn-secondary { min-height: 40px; }
  .learn-topbar ~ main :is(input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea) { font-size: 16px; }

  /* Answering: check/skip side by side over the full width. */
  .learn-actions-row { display: flex; gap: 8px; margin-top: 12px; }
  .learn-actions-row .btn-primary { flex: 1; min-height: 46px; font-size: 16px; }
  .learn-actions-row .learn-skip { margin-left: 0; min-height: 46px; padding: 6px 14px; }

  /* The rating stays in reach of the thumb: pinned above the bottom nav
     while the solution scrolls behind it. */
  .learn-rating {
    position: sticky; bottom: calc(62px + env(safe-area-inset-bottom)); z-index: 5;
    margin: 16px -14px -14px; padding: 8px 14px 12px;
    background: var(--surface); border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 -6px 12px -8px rgba(0, 0, 0, .18);
  }
  .learn-rating > .learn-muted { margin: 0 0 6px; font-size: 12px; }
  .learn-rating-row { gap: 8px; }
  .learn-rate { min-height: 52px; justify-content: center; font-size: 16px; }

  /* Exam session: back link and name in one compact row. */
  .learn-exam-top { flex-wrap: nowrap; gap: 10px; }
  .learn-exam-top .learn-btn-inline { flex: none; padding: 8px 12px; }
  .learn-exam-top h2 { font-size: 18px; min-width: 0; overflow-wrap: anywhere; }
  .learn-session-bar { gap: 10px; }
  .learn-session-bar > :last-child { flex: none; }
}

/* ---- Prüfungstermine (learn/exam_dates.html) ---- */
.exam-range { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0 0; }
.exam-range-btn {
  padding: 5px 12px; border-radius: 999px; font-size: 13px; text-decoration: none;
  color: var(--text-muted); border: 1px solid var(--border); background: var(--surface);
}
.exam-range-btn:hover { color: var(--text); }
.exam-range-btn.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.exam-outside { margin: -6px 0 12px; font-size: 13px; }
.exam-card-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 16px; }
.exam-card {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  scroll-margin-top: 80px;
}
.exam-head { display: flex; align-items: flex-start; gap: 10px; }
.exam-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
/* Small countdown badge in the card's top right corner. */
.exam-countdown {
  flex: none; min-width: 50px; max-width: 76px; padding: 4px 6px; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  background: var(--accent-soft); color: var(--accent); line-height: 1.15;
}
.exam-days { font-size: 18px; font-weight: 700; }
.exam-days.exam-days-word { font-size: 13px; }
.exam-days-label { font-size: 11px; }
.exam-card.soon .exam-countdown { background: var(--planned-soft); color: var(--planned); }
.exam-card.today .exam-countdown { background: var(--locked-soft); color: var(--locked); }
.exam-card.past .exam-countdown, .exam-card.is-hidden .exam-countdown { background: var(--notoffered-soft); color: var(--notoffered); }
.exam-card.past, .exam-card.is-hidden { opacity: .75; }
.exam-title { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
/* .learn-paused-chip is display: none outside paused decks. */
.exam-card .exam-source { display: inline-block; color: var(--text-muted); margin-left: auto; }
.exam-course { font-size: 14px; color: var(--text); overflow-wrap: anywhere; }
/* One row per date of the exam: date, time and rooms in shared columns, so
   which time goes with which room lines up. */
.exam-slots {
  display: grid; grid-template-columns: auto auto 1fr auto; column-gap: 14px;
  font-size: 13px; color: var(--text-muted);
}
.exam-slot {
  display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: center;
  padding: 3px 0; scroll-margin-top: 80px;
}
.exam-slot + .exam-slot { border-top: 1px dashed var(--border); }
.exam-slot-date { white-space: nowrap; }
.exam-slot-time { white-space: nowrap; color: var(--text); font-weight: 600; }
.exam-slot-rooms { display: flex; flex-wrap: wrap; gap: 2px 10px; color: var(--text); min-width: 0; }
.exam-slot-actions form { margin: 0; }
.exam-slot-btn { padding: 4px; }
.exam-slot-btn .icon { width: 15px; height: 15px; }
.exam-notes { margin: 2px 0 0; font-size: 13px; }
.exam-decks { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; font-size: 13px; }
.exam-deck-chip {
  font-size: 12px; padding: 2px 8px; border-radius: 999px; text-decoration: none;
  background: var(--accent-soft); color: var(--accent); border: 1px solid transparent;
}
.exam-deck-chip:hover { border-color: var(--accent); }
.exam-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.exam-actions form { margin: 0; }
.exam-edit { font-size: 13px; }
.exam-edit > summary { cursor: pointer; color: var(--accent); padding: 4px 0; }
.exam-edit form { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.exam-edit-form textarea, .exam-new textarea { font: inherit; padding: 8px; border: 1px solid var(--border); border-radius: 8px; resize: vertical; }
.exam-section { margin-top: 8px; }
.exam-section > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text-muted); padding: 6px 0; }
.exam-empty { margin: 12px 0; }
.exam-new { margin-top: 8px; }
.deck-exam-dates { margin-top: 24px; }
.deck-exam-dates .learn-picker-body { display: flex; flex-direction: column; gap: 6px; }
.learn-focus {
  margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; font-size: 13px;
  background: var(--planned-soft); color: var(--planned);
}
.learn-focus a { color: inherit; font-weight: 600; }
@media (max-width: 560px) {
  .exam-card { padding: 10px 12px; }
  .exam-range { gap: 3px; }
  .exam-range-btn { padding: 4px 9px; font-size: 12px; }
  .exam-slots { grid-template-columns: auto 1fr auto; }
  .exam-slot-date { grid-column: 1 / 3; }
  .exam-slot-actions { grid-column: 3; grid-row: 1 / 3; }
  .exam-slot-time { grid-column: 1; }
  .exam-slot-rooms { grid-column: 2; }
  .exam-card .learn-field-row { flex-direction: column; gap: 8px; }
}

/* ==== Dark theme ==== */
/* Palette. Light values for the new variables live here too, so the answer
   highlighting / charts / course colours work in both themes. Dark applies
   for data-theme="dark", or - without an explicit "light" choice - when the
   OS prefers dark (mode "System" = no data-theme attribute at all). */
:root {
  color-scheme: light;
  --on-accent: #ffffff;
  --answer-ok-bg: #c9ecd9; --answer-ok-text: #0b5f40; --answer-ok-solid: #0f7a53;
  --answer-bad-bg: #fbd0d6; --answer-bad-text: #9b1c2e; --answer-bad-solid: #c8283f;
  --on-solid: #ffffff;
  --state-new: #86b6ef; --state-learning: #3987e5; --state-young: #1c5cab; --state-mature: #0d366b;
  --stat-line: #2a78d6; --stat-line-hover: #3987e5; --stat-meter-bg: #cde2fb; --stat-grid: #e1e0d9; --stat-axis: #c3c2b7; --stat-tick: #6f6d68;
  --course-bg-l: 94%; --course-fg-l: 40%;
  --paper: #ffffff;
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1218;
    --surface: #181c24;
    --border: #323a47;
    --text: #e6e9ee;
    --text-muted: #a3adbb;
    --accent: #929eff;
    --accent-soft: #252c55;
    --completed: #3dd29a;
    --completed-soft: #123629;
    --planned: #f2ad55;
    --planned-soft: #3a2b14;
    --locked: #ff8392;
    --locked-soft: #402029;
    --notoffered: #8f98a6;
    --notoffered-soft: #242932;
    --on-accent: #0f1218;
    --diff-leicht: #1c3a2a; --diff-leicht-strong: #4fa56d; --diff-leicht-text: #8fdaa6;
    --diff-mittel: #3b3417; --diff-mittel-strong: #c4a638; --diff-mittel-text: #ebd16f;
    --diff-schwer: #43291a; --diff-schwer-strong: #d38a54; --diff-schwer-text: #f3b68a;
    --answer-ok-bg: #14503b; --answer-ok-text: #7cecbf; --answer-ok-solid: #3dd29a;
    --answer-bad-bg: #5a1f2a; --answer-bad-text: #ffb0ba; --answer-bad-solid: #ff8392;
    --on-solid: #0f1218;
    --state-new: #9cc3f2; --state-learning: #6ba3e8; --state-young: #4a86d6; --state-mature: #3a73c4;
    --stat-line: #6aa6f0; --stat-line-hover: #92bff6; --stat-meter-bg: #1f3350; --stat-grid: #2c333f; --stat-axis: #475061; --stat-tick: #a3adbb;
    --course-bg-l: 20%; --course-fg-l: 78%;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --paper: #e9ebf0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
      color-scheme: dark;
      --bg: #0f1218;
      --surface: #181c24;
      --border: #323a47;
      --text: #e6e9ee;
      --text-muted: #a3adbb;
      --accent: #929eff;
      --accent-soft: #252c55;
      --completed: #3dd29a;
      --completed-soft: #123629;
      --planned: #f2ad55;
      --planned-soft: #3a2b14;
      --locked: #ff8392;
      --locked-soft: #402029;
      --notoffered: #8f98a6;
      --notoffered-soft: #242932;
      --on-accent: #0f1218;
      --diff-leicht: #1c3a2a; --diff-leicht-strong: #4fa56d; --diff-leicht-text: #8fdaa6;
      --diff-mittel: #3b3417; --diff-mittel-strong: #c4a638; --diff-mittel-text: #ebd16f;
      --diff-schwer: #43291a; --diff-schwer-strong: #d38a54; --diff-schwer-text: #f3b68a;
      --answer-ok-bg: #14503b; --answer-ok-text: #7cecbf; --answer-ok-solid: #3dd29a;
      --answer-bad-bg: #5a1f2a; --answer-bad-text: #ffb0ba; --answer-bad-solid: #ff8392;
      --on-solid: #0f1218;
      --state-new: #9cc3f2; --state-learning: #6ba3e8; --state-young: #4a86d6; --state-mature: #3a73c4;
      --stat-line: #6aa6f0; --stat-line-hover: #92bff6; --stat-meter-bg: #1f3350; --stat-grid: #2c333f; --stat-axis: #475061; --stat-tick: #a3adbb;
      --course-bg-l: 20%; --course-fg-l: 78%;
      --shadow-color: rgba(0, 0, 0, 0.5);
      --paper: #e9ebf0;
  }
}

/* Theme toggle button (profile menu item + floating on login/signup). */
.theme-toggle { display: flex; align-items: center; gap: 8px; font-family: inherit; }
.theme-toggle .theme-ico { flex: none; }
.theme-toggle[data-mode="system"] .theme-ico:not(.theme-ico-system),
.theme-toggle[data-mode="light"] .theme-ico:not(.theme-ico-light),
.theme-toggle[data-mode="dark"] .theme-ico:not(.theme-ico-dark) { display: none; }
.theme-toggle-floating {
  position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; z-index: 20;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text);
  font-size: 13px; cursor: pointer;
}
.theme-toggle-floating:hover { border-color: var(--accent); color: var(--accent); }

/* Light theme: the old thin dashed/soft answer marks were hard to spot. The
   markers also carry a symbol + text, so they don't rely on colour alone. */
.learn-option.ok, .learn-option.wrong, .learn-option.missed {
  position: relative; align-items: center; font-weight: 600;
}
.learn-option.ok { border-color: var(--answer-ok-solid); box-shadow: inset 0 0 0 1px var(--answer-ok-solid); background: var(--answer-ok-bg); }
.learn-option.wrong { border-color: var(--answer-bad-solid); box-shadow: inset 0 0 0 1px var(--answer-bad-solid); background: var(--answer-bad-bg); }
/* Right answer that was not ticked: dashed 2px frame, soft green. */
.learn-option.missed {
  border: 2px dashed var(--answer-ok-solid); padding: 9px 11px; background: var(--completed-soft);
}
.learn-option.ok::after, .learn-option.wrong::after, .learn-option.missed::after {
  flex: none; margin-left: auto; padding-left: 10px; font-size: 13px; font-weight: 700; white-space: nowrap;
}
.learn-option.ok::after { content: "\2713  Richtig"; color: var(--answer-ok-text); }
.learn-option.missed::after { content: "\2713  Richtig (nicht gewählt)"; color: var(--answer-ok-text); }
.learn-option.wrong::after { content: "\2717  Falsch"; color: var(--answer-bad-text); }
@media (max-width: 480px) {
  .learn-option.ok::after, .learn-option.wrong::after, .learn-option.missed::after { font-size: 12px; white-space: normal; text-align: right; max-width: 38%; }
}

/* Assign / Buchungssatz rows: stronger frame + round badge in the corner. */
.learn-assign-row, .learn-buchung-row { position: relative; }
.learn-assign-row.ok, .learn-buchung-row.ok { border-color: var(--answer-ok-solid); box-shadow: inset 0 0 0 1px var(--answer-ok-solid); background: var(--answer-ok-bg); }
.learn-assign-row.wrong, .learn-buchung-row.wrong, .learn-buchung-row.amount { border-color: var(--answer-bad-solid); box-shadow: inset 0 0 0 1px var(--answer-bad-solid); }
.learn-assign-row.wrong, .learn-buchung-row.wrong { background: var(--answer-bad-bg); }
.learn-buchung-row.amount { background: var(--locked-soft); }
.learn-assign-row.ok::after, .learn-assign-row.wrong::after, .learn-buchung-row.ok::after, .learn-buchung-row.wrong::after, .learn-buchung-row.amount::after {
  position: absolute; top: -9px; right: -7px; width: 20px; height: 20px; border-radius: 50%; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; line-height: 1;
  color: var(--on-solid); border: 2px solid var(--surface);
}
.learn-assign-row.ok::after, .learn-buchung-row.ok::after { content: "\2713"; background: var(--answer-ok-solid); }
.learn-assign-row.wrong::after, .learn-buchung-row.wrong::after, .learn-buchung-row.amount::after { content: "\2717"; background: var(--answer-bad-solid); }
.learn-assign-expected { color: var(--answer-ok-text); font-weight: 700; }

/* Single fields (Freitext, Selects, amounts): 2px frame + ✓/✗ inside the field. */
.learn-input.ok, .learn-select.ok, .learn-input.wrong, .learn-select.wrong {
  background-repeat: no-repeat; background-size: 16px 16px; background-position: right 8px center; padding-right: 30px;
}
.learn-select.ok, .learn-select.wrong { background-position: right 26px center; padding-right: 44px; }
.learn-input.ok, .learn-select.ok { border-color: var(--answer-ok-solid); box-shadow: inset 0 0 0 1px var(--answer-ok-solid); background-color: var(--answer-ok-bg); color: var(--text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='8' fill='%230f7a53'/%3E%3Cpath d='M4.5 8.3l2.4 2.4 4.6-5' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.learn-input.wrong, .learn-select.wrong { border-color: var(--answer-bad-solid); box-shadow: inset 0 0 0 1px var(--answer-bad-solid); background-color: var(--answer-bad-bg); color: var(--text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='8' fill='%23c8283f'/%3E%3Cpath d='M5.3 5.3l5.4 5.4M10.7 5.3l-5.4 5.4' fill='none' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.learn-ok, .learn-wrong { display: inline-block; padding: 4px 10px; border-radius: 6px; }
.learn-ok { color: var(--answer-ok-text); background: var(--answer-ok-bg); }
.learn-wrong { color: var(--answer-bad-text); background: var(--answer-bad-bg); }
.learn-ok::before { content: "\2713  "; font-weight: 800; }
.learn-wrong::before { content: "\2717  "; font-weight: 800; }

/* Stats charts: colours from variables. */
.stats-grid { stroke: var(--stat-grid); }
.stats-axis { stroke: var(--stat-axis); }
.stats-tick, .stats-empty { fill: var(--stat-tick); }
.stats-crosshair { stroke: var(--stat-tick); }
.stats-line { stroke: var(--stat-line); }
.stats-area, .stats-dot, .stats-bar { fill: var(--stat-line); }
.stats-bar-group:hover .stats-bar, .stats-bar-group:focus .stats-bar { fill: var(--stat-line-hover); }
.stats-meter, .gen-progress { background: var(--stat-meter-bg); }
.stats-meter-fill, .gen-progress-fill { background: var(--stat-line); }

/* Dark-only fixes for hard-coded colours above. */
:root[data-theme="dark"] .btn-secondary { color: var(--text); }
:root[data-theme="dark"] .btn-primary, :root[data-theme="dark"] a.btn-primary,
:root[data-theme="dark"] .ev-room.changed, :root[data-theme="dark"] .ev-options-marker,
:root[data-theme="dark"] .cal-month-cell.today .cal-month-date, :root[data-theme="dark"] .ev-changed-badge,
:root[data-theme="dark"] .cal-shares-badge, :root[data-theme="dark"] .session-changed,
:root[data-theme="dark"] .icon-badge, :root[data-theme="dark"] .app-toast,
:root[data-theme="dark"] .stats-seg-label { color: var(--on-accent); }
:root[data-theme="dark"] .stats-seg-label.dark, :root[data-theme="dark"] .stats-seg-label.dark-on-dark-theme { color: #0b2a52; }
:root[data-theme="dark"] .stats-seg-label { color: #fff; }
:root[data-theme="dark"] .learn-pad-canvas, :root[data-theme="dark"] .learn-solution-image { background: var(--paper); }
:root[data-theme="dark"] .learn-change.add, :root[data-theme="dark"] .diff-line.ins { background: #143d29; color: #8ae6b0; }
:root[data-theme="dark"] .learn-change.delete, :root[data-theme="dark"] .diff-line.del { background: #4a1f28; color: #ffadb8; }
:root[data-theme="dark"] .learn-change.edit { background: #44360f; color: #f4d27a; }
:root[data-theme="dark"] .learn-diff pre { background: var(--bg); }
:root[data-theme="dark"] .profile-menu, :root[data-theme="dark"] .app-toast { box-shadow: 0 8px 24px var(--shadow-color); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-secondary { color: var(--text); }
  :root:not([data-theme="light"]) .btn-primary, :root:not([data-theme="light"]) a.btn-primary,
  :root:not([data-theme="light"]) .ev-room.changed, :root:not([data-theme="light"]) .ev-options-marker,
  :root:not([data-theme="light"]) .cal-month-cell.today .cal-month-date, :root:not([data-theme="light"]) .ev-changed-badge,
  :root:not([data-theme="light"]) .cal-shares-badge, :root:not([data-theme="light"]) .session-changed,
  :root:not([data-theme="light"]) .icon-badge, :root:not([data-theme="light"]) .app-toast { color: var(--on-accent); }
  :root:not([data-theme="light"]) .stats-seg-label { color: #fff; }
  :root:not([data-theme="light"]) .stats-seg-label.dark, :root:not([data-theme="light"]) .stats-seg-label.dark-on-dark-theme { color: #0b2a52; }
  :root:not([data-theme="light"]) .learn-pad-canvas, :root:not([data-theme="light"]) .learn-solution-image { background: var(--paper); }
  :root:not([data-theme="light"]) .learn-change.add, :root:not([data-theme="light"]) .diff-line.ins { background: #143d29; color: #8ae6b0; }
  :root:not([data-theme="light"]) .learn-change.delete, :root:not([data-theme="light"]) .diff-line.del { background: #4a1f28; color: #ffadb8; }
  :root:not([data-theme="light"]) .learn-change.edit { background: #44360f; color: #f4d27a; }
  :root:not([data-theme="light"]) .learn-diff pre { background: var(--bg); }
}

/* ==== Fragen-Navigation ==== */
.learn-qnav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 12px; }
.learn-qnav-btn { min-height: 40px; padding: 6px 14px; white-space: nowrap; }
.learn-qnav-gap { min-width: 1px; }
.learn-qnav-label { flex: 1; text-align: center; font-size: 13px; }
.learn-reviewed-chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.learn-review-note { margin-top: 8px; font-size: 13px; }
.learn-review-note p { margin: 0; }
.learn-rating-review .learn-rate:disabled { opacity: .6; cursor: default; }
@media (max-width: 720px) {
  .learn-qnav-btn { min-height: 46px; padding: 6px 12px; font-size: 15px; }
  .learn-qnav-label { font-size: 12px; }
  /* In a review the rating is part of the page, not pinned over the nav below it. */
  .learn-rating.learn-rating-review { position: static; margin: 16px 0 12px; padding: 0; border: 0; box-shadow: none; background: none; }
}

/* ---- Start page: choose Kalender or Lernen (templates/home.html) ---- */
.home-choice { width: 640px; max-width: 100%; text-align: center; }
.home-choice h1 { font-size: 20px; margin: 0 0 20px; }
.home-choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.home-choice-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 28px 20px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); text-decoration: none;
  transition: border-color .15s, transform .15s;
}
.home-choice-card:hover, .home-choice-card:focus-visible { border-color: var(--accent); transform: translateY(-2px); }
.home-choice-card img { border-radius: 14px; }
.home-choice-card strong { font-size: 17px; }
.home-choice-card span { font-size: 13px; color: var(--text-muted); line-height: 1.4; }
.home-choice-hint { margin: 20px 0 0; font-size: 13px; color: var(--text-muted); line-height: 1.4; }
