/* v2-refresh.css — Komponenten-Library für den Claude-Design-Refresh
 * ------------------------------------------------------------------
 * Portiert aus staging/v2claudedesign/design_handoff_classcards_v2/app.css
 * plus A11y-Erweiterungen (Skip-Link, Focus-Ring, v2-pct-bar).
 * Tokens kommen aus v2-refresh-tokens.css (muss VOR dieser Datei geladen werden).
 */

/* ========== BASE ========== */
* { box-sizing: border-box; }
/* overflow-x: hidden bricht position: sticky bei Kindern. Stattdessen clip (bricht sticky nicht). */
html, body { margin: 0; padding: 0; max-width: 100vw; }
html { overflow-x: clip; }
body { overflow-x: clip; }
body.v2-refresh {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02","cv11","ss01";
}
body.v2-refresh .num { font-variant-numeric: tabular-nums; }
body.v2-refresh .wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

body.v2-refresh h1,
body.v2-refresh h2,
body.v2-refresh h3,
body.v2-refresh h4 {
  color: var(--ink); margin: 0;
  letter-spacing: -0.015em; font-weight: 700;
}
body.v2-refresh h1 { font-size: 28px; line-height: 1.15; letter-spacing: -0.022em; font-weight: 800; }
@media (min-width: 768px) { body.v2-refresh h1 { font-size: 32px; } }
body.v2-refresh h2 { font-size: 20px; line-height: 1.25; }
body.v2-refresh h3 { font-size: 16px; line-height: 1.35; font-weight: 600; }
body.v2-refresh p  { margin: 0; color: var(--ink-2); }
body.v2-refresh a  { color: inherit; text-decoration: none; }

/* ========== A11Y FOUNDATION ========== */
body.v2-refresh .sr-only {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0,0,0,0) !important;
  white-space: nowrap !important; border: 0 !important;
}
.v2-skip-link {
  position: absolute; top: 0; left: 0;
  background: var(--amber); color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 var(--r-md) 0;
  font-weight: 600; font-size: 14px; text-decoration: none;
  z-index: 9999;
  transform: translateY(-100%);
  transition: transform var(--t-fast) var(--ease);
}
.v2-skip-link:focus,
.v2-skip-link:focus-visible {
  transform: translateY(0);
  outline: 2px solid #fff; outline-offset: 2px;
}
body.v2-refresh :focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
body.v2-refresh :focus:not(:focus-visible) { outline: none; }

/* ========== ICONS ========== */
body.v2-refresh .ic,
body.v2-refresh .ic-xs {
  width: 18px; height: 18px;
  stroke: currentColor; fill: none;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
body.v2-refresh .ic-xs { width: 14px; height: 14px; }

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--r-md);
  font-family: inherit; font-weight: 600; font-size: 14px;
  border: 1px solid transparent; cursor: pointer;
  min-height: 40px;
  transition: transform var(--t-fast) var(--ease),
              background var(--t-mid) var(--ease),
              box-shadow var(--t-mid) var(--ease),
              border-color var(--t-mid) var(--ease),
              color var(--t-mid) var(--ease);
  white-space: nowrap;
}
.btn-primary { background: var(--amber); color: #fff; box-shadow: 0 2px 6px rgba(217,119,6,.2); }
.btn-primary:hover:not(:disabled) { background: var(--amber-2); transform: translateY(-1px); box-shadow: 0 6px 14px rgba(217,119,6,.3); }
.btn-accent  { background: var(--amber); color: #fff; box-shadow: 0 2px 6px rgba(217,119,6,.2); }
.btn-accent:hover:not(:disabled)  { background: var(--amber-2); transform: translateY(-1px); box-shadow: 0 6px 14px rgba(217,119,6,.3); }
.btn-ghost   { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-ghost:hover:not(:disabled)   { border-color: var(--border-2); background: var(--surface-2); }
.btn-danger  { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger:hover:not(:disabled)  { background: rgba(255,94,126,0.08); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 13px; min-height: 32px; gap: 6px; }
.btn-sm .ic { width: 15px; height: 15px; }
.btn-icon { padding: 0; width: 36px; min-height: 36px; border-radius: var(--r-md); }
.btn-sm.btn-icon { width: 32px; min-height: 32px; }

/* Touch-Target-Härtung für coarse pointer */
@media (hover: none) and (pointer: coarse) {
  .btn, .btn-icon, .ctx-pick, .sb-item { min-height: 44px; }
  .btn-icon { min-width: 44px; }
}

/* ========== INPUTS ========== */
.field { display: flex; flex-direction: column; gap: 6px; }
.lbl {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--mute);
}
.inp {
  font-family: inherit; font-size: 14px; color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); outline: none;
  transition: border-color var(--t-mid) var(--ease), box-shadow var(--t-mid) var(--ease);
  min-height: 40px;
}
.inp:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(217,119,6,0.15); }
.inp::placeholder { color: var(--mute); }
.inp[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(255,94,126,0.15);
}

/* toggle */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.t-track {
  width: 34px; height: 20px; border-radius: 999px;
  background: rgba(10,11,16,0.18); position: relative;
  transition: background var(--t-mid) var(--ease);
}
.t-track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform var(--t-mid) var(--ease);
}
.toggle input:checked + .t-track { background: var(--success); }
.toggle input:checked + .t-track::after { transform: translateX(14px); }

/* segmented */
.seg {
  display: inline-flex; padding: 3px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-md);
  gap: 2px;
}
.seg button {
  font: inherit; font-size: 13px; border: 0; background: transparent;
  padding: 6px 12px; border-radius: var(--r-sm); color: var(--ink-2);
  cursor: pointer; font-weight: 500;
  transition: all var(--t-fast) var(--ease);
  min-height: 32px;
}
.seg button.on { background: var(--ink); color: #fff; }
.seg button:not(.on):hover { color: var(--ink); background: rgba(10,11,16,0.04); }

/* Form-Error Text */
.form-err {
  margin: 4px 0 0;
  color: var(--danger);
  font-size: 12px; line-height: 1.4;
}
.form-err[hidden] { display: none; }

/* ========== CARDS ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: var(--sp-4);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .actions { display: flex; gap: 8px; }

/* ========== KPI ========== */
.kpi-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.kpi { padding: 16px; }
.kpi-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.kpi-head .lbl { font-size: 11px; }
.kpi-body { display: flex; align-items: center; gap: 14px; }
.kpi-num { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.kpi-unit { font-size: 14px; color: var(--mute); font-weight: 500; margin-left: 2px; }
.sub { font-size: 12px; color: var(--mute); margin-top: 2px; }

/* ========== DONUT ========== */
.donut { width: 52px; height: 52px; flex-shrink: 0; }
.donut .track { fill: none; stroke: rgba(10,11,16,0.08); stroke-width: 3.2; }
:root[data-theme="dark"] .donut .track { stroke: rgba(255,255,255,0.10); }
.donut .val   { fill: none; stroke-width: 3.2; stroke-linecap: round; transition: stroke-dasharray var(--t-slow) var(--ease); }

/* Larger donut variant */
.donut-lg { width: 96px; height: 96px; }
.donut-lg .track, .donut-lg .val { stroke-width: 2.6; }

/* ========== DYNAMIC PROGRESS (Phase 3 Pattern) ========== */
/* Nutzung: <div class="v2-pct-bar" style="--pct:80"><span class="v2-pct-fill"></span></div> */
.v2-pct-bar {
  --pct: 0;
  height: 6px; width: 100%;
  background: rgba(10,11,16,0.06);
  border-radius: 3px; overflow: hidden;
}
:root[data-theme="dark"] .v2-pct-bar { background: rgba(255,255,255,0.08); }
.v2-pct-bar--lg { height: 10px; border-radius: 5px; }
.v2-pct-fill {
  display: block; height: 100%;
  width: calc(var(--pct) * 1%);
  background: var(--success);
  transition: width var(--t-mid) var(--ease);
  border-radius: inherit;
}
.v2-pct-fill--warn  { background: var(--warning); }
.v2-pct-fill--danger{ background: var(--danger); }
.v2-pct-fill--accent{ background: var(--amber); }

/* ========== BADGE / PILL ========== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  background: rgba(10,11,16,0.06); color: var(--ink-2);
  border: 1px solid transparent;
  white-space: nowrap;
}
:root[data-theme="dark"] .badge { background: rgba(255,255,255,0.08); }
.badge-ok     { background: rgba(5,150,105,0.12); color: var(--success); }
.badge-warn   { background: rgba(202,138,4,0.16); color: #854d0e; }
:root[data-theme="dark"] .badge-warn { color: #fcd34d; }
.badge-danger { background: rgba(255,94,126,0.14); color: #c83054; }
:root[data-theme="dark"] .badge-danger { color: var(--danger); }
.badge-amber  { background: rgba(217,119,6,0.12); color: var(--amber); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--border);
  font-size: 12px; color: var(--ink-2); font-weight: 500;
}
.pill-dark { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ========== AVATAR ========== */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #fde4c0, #f3c98a);
  color: #5a3a0a; font-size: 12px; font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 48px; height: 48px; font-size: 15px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar {
  margin-right: -8px;
  border-color: var(--surface);
  box-shadow: 0 0 0 2px var(--surface);
}
.avatar-stack .avatar:last-child { margin-right: 0; }
.avatar.more { background: var(--ink); color: #fff; }

/* ========== TABLE ========== */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl thead th {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--mute); text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
.tbl th.num, .tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody td {
  padding: 12px; border-bottom: 1px solid var(--border);
  color: var(--ink); vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background var(--t-fast) var(--ease); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .actions { text-align: right; white-space: nowrap; }
.tbl .user { display: flex; align-items: center; gap: 10px; }
.tbl .user-row { display: flex; align-items: center; gap: 14px; justify-content: space-between; }
.tbl .user-link { text-decoration: none; color: inherit; flex: 1; min-width: 0; transition: opacity var(--t-fast) var(--ease); }
.tbl .user-link:hover { opacity: 0.75; }
.tbl .user-link:hover .u-name { color: var(--amber); }
.deck-icons { display: inline-flex; gap: 6px; flex-wrap: nowrap; flex-shrink: 0; }
.deck-icon {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 11px; font-weight: 700; color: var(--ink-2);
  text-decoration: none; cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  letter-spacing: 0.03em;
}
.deck-icon:hover { border-color: var(--amber); color: var(--amber); background: var(--amber-soft); transform: translateY(-1px); }
.deck-icon.active { background: var(--amber); color: #fff; border-color: var(--amber); }
.u-name { font-weight: 600; color: var(--ink); font-size: 14px; }
.u-sub  { font-size: 11.5px; color: var(--mute); }

/* Scroll wrapper for wide tables — IMMER scrollbar-fähig, damit auch Desktop
 * mit Sidebar bei breiten Tabellen (z. B. 8-Spalten Lernfortschritt) nicht
 * abschneidet. Margin/Padding-Trick nur auf Mobile, damit der Scroll-Bereich
 * bündig zum Card-Padding ist. */
.tbl-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 calc(-1 * var(--sp-5));
  padding: 0 var(--sp-5);
  /* Subtiler Hinweis-Schatten an den Rändern, wenn scrollbar */
  background:
    linear-gradient(to right, var(--surface) 0%, transparent 4%) left center/24px 100% no-repeat,
    linear-gradient(to left,  var(--surface) 0%, transparent 4%) right center/24px 100% no-repeat;
}
.tbl-scroll .tbl { min-width: 640px; }
@media (min-width: 768px) {
  .tbl-scroll { margin: 0; padding: 0; }
  .tbl-scroll .tbl { min-width: 0; }
}

/* ========== PROGRESS + MASTERY ========== */
.progress {
  width: 120px; height: 6px; border-radius: 999px;
  background: rgba(10,11,16,0.06);
  overflow: hidden;
}
:root[data-theme="dark"] .progress { background: rgba(255,255,255,0.08); }
.progress i { display: block; height: 100%; background: var(--success); border-radius: inherit; }

.mastery {
  display: flex; width: 100%; height: 6px; border-radius: 999px;
  overflow: hidden; background: rgba(10,11,16,0.06);
}
.mastery .m-ok   { background: var(--success); }
.mastery .m-warn { background: var(--warning); }
.mastery .m-bad  { background: var(--danger); }

/* ========== SIDEBAR ========== */
.sidebar {
  width: var(--sb-w);
  background: var(--purple);
  color: rgba(255,255,255,0.86);
  padding: 20px 14px 16px;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
}
.sb-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 6px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 14px;
  position: relative; z-index: 2;
}
.sb-logo {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--amber), var(--amber-2));
  color: #fff; font-size: 12px; font-weight: 800;
  box-shadow: 0 2px 6px rgba(217,119,6,.3);
}
.sb-logo-img {
  width: 38px; height: 38px; border-radius: 9px;
  flex-shrink: 0; display: block;
  box-shadow: 0 2px 8px rgba(124,58,237,0.3);
}
.sb-name { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: -0.015em; }
.sb-sub  { font-size: 11px; color: rgba(255,255,255,0.5); }
.sb-group { margin-bottom: 12px; position: relative; z-index: 2; }
.sb-group.sb-bottom { margin-top: auto; margin-bottom: 0; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.sb-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  padding: 0 8px 8px;
}
.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-md);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  color: rgba(255,255,255,0.74);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  position: relative; text-decoration: none;
  background: transparent; border: 0;
  text-align: left; font-family: inherit; width: 100%;
}
.sb-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sb-item.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  box-shadow: inset 2px 0 0 var(--amber);
}
.sb-item .ic { opacity: 0.9; }
.sb-count {
  margin-left: auto;
  font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.85);
  padding: 1px 7px; border-radius: 999px;
}

/* stars in sidebar */
.sb-stars { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.sb-stars .star {
  position: absolute;
  color: #fff3d6;
  text-shadow:
    0 0 4px rgba(255,220,150,0.7),
    0 0 10px rgba(255,180,80,0.4);
  animation: starTwinkle 4s var(--ease) infinite;
}
.sb-stars .star.sm { font-size: 8px; opacity: 0.6; }
.sb-stars .star.md { font-size: 12px; opacity: 0.8; }
.sb-stars .star:nth-child(2n) { animation-delay: 1.2s; }
.sb-stars .star:nth-child(3n) { animation-delay: 2.1s; }
@keyframes starTwinkle {
  0%, 100% { opacity: .55; transform: scale(1); }
  50%      { opacity: .95; transform: scale(1.1); }
}
@media (prefers-reduced-motion: reduce) {
  .sb-stars .star { animation: none !important; opacity: 0.5; }
}

/* ========== TOPBAR ========== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 16px;
  background: rgba(250,243,221,0.82);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}
:root[data-theme="dark"] .topbar { background: rgba(14,11,28,0.82); }
:root[data-theme="pool"] .topbar {
  background: rgba(238,245,249,0.82);
  /* Subtile sommerliche Sonnen-Reflexion am oberen Rand */
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(37,99,168,0.08);
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 10px; }
.tb-menu {
  display: none;
  align-items: center; justify-content: center;
  min-width: 40px; min-height: 40px;
  background: transparent; border: 1px solid var(--border); color: var(--ink);
  border-radius: var(--r-md); cursor: pointer;
}
.tb-menu:hover { background: var(--surface-2); }
/* Hamburger entfällt: Bottom-Nav auf Mobile übernimmt Navigation */
.ctx { display: flex; gap: 8px; }
.ctx-item { display: inline-flex; align-items: center; gap: 6px; }
.ctx-item .lbl { display: none; }
@media (min-width: 768px) { .ctx-item .lbl { display: inline; } }
.ctx-pick {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink);
  padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 32px;
  transition: border-color var(--t-mid) var(--ease);
}
.ctx-pick:hover { border-color: var(--border-2); }
.ctx-pick .ic-xs { color: var(--mute); }

.search {
  display: none; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 0 10px; height: 34px; color: var(--mute);
  min-width: 220px;
  transition: border-color var(--t-mid) var(--ease);
}
@media (min-width: 768px) { .search { display: flex; } }
.search:focus-within { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(217,119,6,0.12); }
.search .ic { color: var(--mute); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; font-size: 13.5px; color: var(--ink); }
.search kbd {
  font: inherit; font-size: 10.5px; font-weight: 600;
  padding: 2px 6px; border: 1px solid var(--border); border-radius: 4px;
  color: var(--mute); background: var(--surface-2);
}
.user-chip {
  display: none; align-items: center; gap: 8px; cursor: pointer;
  padding: 4px 8px 4px 4px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface);
  transition: border-color var(--t-mid) var(--ease);
  font: inherit; color: var(--ink);
}
@media (min-width: 640px) { .user-chip { display: inline-flex; } }
.user-chip:hover { border-color: var(--border-2); }
.uc-name { font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.2; }
.uc-sub  { font-size: 10.5px; color: var(--mute); line-height: 1.2; }

/* ========== APP SHELL ========== */
.shell {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "topbar"
    "main";
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
}
/* Mobile (< 1024px): Sidebar wird zur fixierten Bottom-Nav (iOS-Style) */
.shell .sidebar {
  display: flex; flex-direction: row;
  position: fixed; bottom: 0; left: 0; right: 0;
  /* WICHTIG: width 100% override, sonst bleibt die Desktop-`width: var(--sb-w)` aktiv
     (z. 350 oben) und die Bar reicht nur ~70% der Viewport-Breite. */
  width: 100%; max-width: 100vw;
  box-sizing: border-box;
  height: 68px;
  border-radius: 0; border-right: 0;
  border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
  backdrop-filter: saturate(160%) blur(20px);
  color: var(--ink-2);
  padding: 6px 6px env(safe-area-inset-bottom, 0px);
  z-index: 50;
  align-items: stretch;
  box-shadow: 0 -8px 24px rgba(10,11,16,0.06);
}
/* Brand, Stars, Section-Labels und Bottom-Group auf Mobile ausblenden */
.shell .sidebar .sb-stars,
.shell .sidebar .sb-brand,
.shell .sidebar .sb-label,
.shell .sidebar .sb-bottom { display: none; }
.shell .sidebar .sb-group {
  display: contents; /* Items direkt ins flex-row */
}
.shell .sidebar .sb-item {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; gap: 3px;
  padding: 6px 2px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0;
  color: var(--mute); border-radius: 12px;
  text-decoration: none;
  position: relative;
  transition: color 0.18s ease, transform 0.18s ease;
}
.shell .sidebar .sb-item .sb-ic {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
  position: relative; z-index: 1;
  transition: transform 0.18s ease, stroke-width 0.18s ease;
}
.shell .sidebar .sb-item .sb-txt {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%; line-height: 1.1;
  position: relative; z-index: 1;
}
/* Schmale Mobile-Geräte: Schrift weiter verkleinern damit „Einstellungen" + „Dashboard"
   nicht abgeschnitten werden. Letter-spacing auf negativ für mehr Platz. */
@media (max-width: 400px) {
  .shell .sidebar .sb-item {
    font-size: 9.5px;
    letter-spacing: -0.01em;
    padding: 6px 1px;
  }
  .shell .sidebar .sb-item .sb-ic {
    width: 20px; height: 20px;
  }
}
/* Pille hinter dem Icon (für Hover/Active) */
.shell .sidebar .sb-item::before {
  content: ''; position: absolute;
  top: 4px; left: 50%; transform: translateX(-50%);
  width: 44px; height: 30px; border-radius: 15px;
  background: transparent;
  transition: background 0.22s ease;
  pointer-events: none;
  z-index: 0;
}
.shell .sidebar .sb-item:hover {
  color: var(--ink);
}
.shell .sidebar .sb-item:hover::before {
  background: color-mix(in srgb, var(--ink) 5%, transparent);
}
.shell .sidebar .sb-item.active {
  color: var(--amber);
}
.shell .sidebar .sb-item.active::before {
  background: color-mix(in srgb, var(--amber) 16%, transparent);
}
.shell .sidebar .sb-item.active .sb-ic {
  stroke-width: 2.2;
  transform: scale(1.04);
}
.shell .sidebar .sb-item:active {
  transform: scale(0.96);
}
.shell .sidebar .sb-item:active::before {
  background: color-mix(in srgb, var(--amber) 24%, transparent);
}

/* Dark- und Pool-Theme: glasiger Look mit dunkler Tönung */
:root[data-theme="dark"] .shell .sidebar,
:root[data-theme="pool"] .shell .sidebar {
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border-top-color: color-mix(in srgb, var(--border) 70%, transparent);
  box-shadow: 0 -10px 30px rgba(0,0,0,0.35);
}

/* Auf Mobile: Lehrer-Items „Lernfortschritt" und „Bibliothek" verstecken,
   damit max 4 Items in die Bottom-Nav passen. Erreichbar bleiben sie trotzdem
   ueber direkte Links (Dashboard verlinkt darauf). */
.shell .sidebar [data-nav="progress"],
.shell .sidebar [data-nav="library"] { display: none; }

/* Main bekommt Platz nach unten, damit Bottom-Nav nicht überdeckt */
.shell .topbar  { grid-area: topbar; position: sticky; top: 0; z-index: 40; }
.shell .main    { grid-area: main; padding: 20px 16px calc(80px + env(safe-area-inset-bottom, 0px)); max-width: 100%; min-width: 0; overflow-x: hidden; }

/* Drawer-Klasse auf Mobile bleibt no-op, da Sidebar permanent sichtbar ist */
.shell.drawer-open::before { display: none; }

@media (min-width: 1024px) {
  .shell {
    grid-template-columns: var(--sb-w) 1fr;
    grid-template-areas:
      "sidebar topbar"
      "sidebar main";
    overflow-x: visible;
  }
  /* Desktop: Sidebar links als Spalte (lila Standard wiederherstellen) */
  .shell .sidebar {
    display: flex; flex-direction: column;
    position: sticky; top: 0; bottom: auto; left: auto; right: auto;
    height: 100vh; min-height: 0;
    padding: 20px 14px 16px;
    border-top: 0;
    overflow: hidden;
    grid-area: sidebar;
    background: var(--purple);
    color: rgba(255,255,255,0.86);
  }
  .shell .sidebar .sb-stars,
  .shell .sidebar .sb-brand,
  .shell .sidebar .sb-label,
  .shell .sidebar .sb-bottom { display: revert; }
  .shell .sidebar .sb-group { display: block; }
  .shell .sidebar .sb-item {
    flex: none; flex-direction: row; min-width: 0;
    padding: 10px 14px; margin: 0;
    font-size: 14px; gap: 12px;
    text-align: left; font-weight: 500;
    color: rgba(255,255,255,0.86);
    justify-content: flex-start;
  }
  .shell .sidebar .sb-item .sb-ic {
    width: 18px; height: 18px;
    stroke-width: 1.8;
  }
  .shell .sidebar .sb-item.active::before { display: none; }
  .shell .sidebar .sb-item.active {
    background: rgba(255,255,255,0.08);
    color: #fff;
  }
  /* Desktop: alle Items wieder anzeigen (auf Mobile sind progress/library versteckt) */
  .shell .sidebar [data-nav="progress"],
  .shell .sidebar [data-nav="library"] { display: flex; }
  .shell .main { padding: 28px 32px; }
}
body.v2-scroll-lock { overflow: hidden; }

/* ========== OCCLUSION EDITOR ========== */
.occ-editor { display: flex; flex-direction: column; gap: 8px; }
.occ-stage {
  position: relative; width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--r-md);
  overflow: hidden; min-height: 200px;
  user-select: none;
  touch-action: none;
}
.occ-stage .occ-img {
  display: block; width: 100%; height: auto;
  pointer-events: none;
}
.occ-stage .occ-svg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  cursor: crosshair;
}
.occ-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--mute); font-size: 13px; font-style: italic;
  pointer-events: none;
}
.occ-box {
  fill: rgba(217,119,6,0.45);
  stroke: var(--amber);
  stroke-width: 0.4;
  cursor: move;
}
.occ-box-g:hover .occ-box { fill: rgba(217,119,6,0.6); }
.occ-label-text {
  font: 600 3px/1 'Inter', sans-serif;
  fill: #fff;
  paint-order: stroke;
  stroke: rgba(0,0,0,0.5);
  stroke-width: 0.25;
  pointer-events: none;
}
.occ-del-bg {
  fill: var(--danger);
  cursor: pointer;
  transition: r 0.15s;
}
.occ-box-g:hover .occ-del-bg { r: 1.8; }
.occ-del-x {
  font: 700 2.5px/1 sans-serif;
  fill: #fff;
  pointer-events: none;
  dominant-baseline: middle;
}
.occ-label-edit-wrap {
  position: absolute;
  z-index: 5;
  margin-top: 4px;
}
.occ-label-edit {
  width: 100%; min-width: 140px;
  font: inherit; font-size: 13px;
  padding: 6px 10px; border: 2px solid var(--amber);
  border-radius: 6px; background: var(--surface);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.occ-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--ink-2); flex-wrap: wrap; gap: 8px;
}
.occ-count { font-weight: 600; color: var(--amber); }
.occ-hint { color: var(--mute); font-style: italic; }

/* ========== CLOZE GAP HELPER ========== */
.cloze-helper {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px dashed var(--border-2);
  border-radius: var(--r-sm);
}
.cloze-helper .btn { flex-shrink: 0; }
.cloze-help {
  font-size: 12px; color: var(--ink-2); line-height: 1.4;
  flex: 1 1 200px; min-width: 0;
}
.cloze-help code {
  font-size: 11.5px; padding: 1px 4px; border-radius: 3px;
  background: var(--surface); color: var(--amber);
}
.cloze-hint-msg {
  font-size: 11.5px; font-weight: 600;
  flex: 0 0 auto;
  margin-left: auto;
}

/* ========== CARD RICH TEXT TOOLBAR ========== */
/* Kompakte Toolbar rechts im Eingabefeld — subtil im Default, voll sichtbar bei Fokus */
.crt-wrap { position: relative; display: block; }
.crt-wrap > input[type="text"], .crt-wrap > textarea { padding-right: 102px; width: 100%; }
.crt-wrap-area > textarea { padding-right: 12px; padding-bottom: 38px; }

.crt-toolbar {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex; align-items: center; gap: 1px;
  background: transparent;
  opacity: 0.45;
  transition: opacity var(--t-fast) var(--ease);
}
.crt-wrap:hover .crt-toolbar,
.crt-wrap:focus-within .crt-toolbar { opacity: 1; }

/* Bei Textareas: Toolbar unten rechts */
.crt-wrap-area .crt-toolbar { top: auto; bottom: 6px; transform: none; }

.crt-btn {
  font: inherit; font-size: 11.5px; font-weight: 600;
  width: 22px; height: 22px;
  padding: 0; border: 0; background: transparent;
  color: var(--mute); cursor: pointer; border-radius: 4px;
  display: inline-grid; place-items: center;
  transition: all var(--t-fast) var(--ease);
}
.crt-btn:hover { background: var(--surface-2); color: var(--ink); }
.crt-btn.crt-bold   { font-weight: 800; }
.crt-btn.crt-italic { font-style: italic; }
.crt-btn.crt-under  { text-decoration: underline; }
.crt-btn.crt-clear  { font-size: 14px; line-height: 1; color: var(--mute); margin-left: 2px; }
.crt-btn.crt-clear:hover { color: var(--danger); }

.crt-color-trigger { padding: 0; }
.crt-color-dot {
  display: block; width: 12px; height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d97706 0%, #dc2626 33%, #16a34a 66%, #2563eb 100%);
  border: 1px solid var(--border-2);
}

.crt-palette {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  display: inline-flex; gap: 4px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 10;
}
.crt-palette[hidden] { display: none; }
.crt-color {
  width: 18px; height: 18px; padding: 0;
  border: 1px solid var(--border-2);
  border-radius: 50%; cursor: pointer;
  transition: transform var(--t-fast) var(--ease);
}
.crt-color:hover { transform: scale(1.2); }

/* ========== DESIGN-SYSTEM PAGE ========== */
.ds-page { padding-bottom: 60px; }
.ds-head { padding: 40px 0 24px; border-bottom: 1px solid var(--border); margin-bottom: 28px; background: var(--surface-2); }
.ds-sub { margin-top: 8px; color: var(--ink-2); }
.ds-main { display: flex; flex-direction: column; gap: 36px; }
.ds-block > h2 {
  font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--mute); margin-bottom: 16px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}
.ds-preview-frame {
  padding: 16px; background: var(--bg-warm); border-radius: var(--r-lg);
  border: 1px solid var(--border);
}
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.sw { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.sw .chip { width: 100%; height: 36px; border-radius: var(--r-sm); }
.sw b { font-size: 12px; font-weight: 600; }
.sw code { font-size: 11px; color: var(--mute); font-family: 'SFMono-Regular', Menlo, monospace; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-3 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .row-3 { grid-template-columns: repeat(3, 1fr); } }

/* ========== RESPONSIVE SAFETY NET ==========
 * Diese Regeln sind die letzte Verteidigung gegen Layout-Bugs bei ungewöhnlichen
 * Viewport-Größen, hohen DPI/Zoom-Stufen oder schmalen Smartphone-Browsern.
 * Sie ändern keine bewussten Layout-Entscheidungen — sie verhindern nur, dass
 * Inhalte horizontal aus dem Viewport wachsen oder abgeschnitten werden.
 */

/* Bilder / Medien dürfen nie über ihren Container wachsen */
body.v2-refresh img,
body.v2-refresh svg:not(.ic):not(.ic-xs):not(.donut),
body.v2-refresh video,
body.v2-refresh canvas,
body.v2-refresh iframe,
body.v2-refresh embed,
body.v2-refresh object {
  max-width: 100%;
  height: auto;
}

/* Tabellen: max-width damit sie nie über den Container wachsen, plus
 * Wort-Bruch in Cells für lange Inhalte (URLs, Tokens, Schülernamen mit
 * extralangen Strings). Wrapper-basiertes Scrollen via .tbl-scroll bleibt
 * empfohlen für sehr breite Spalten. */
body.v2-refresh table {
  max-width: 100%;
  table-layout: auto;
}
body.v2-refresh table td,
body.v2-refresh table th {
  overflow-wrap: anywhere;
  word-break: normal;
}
/* Tabellen ohne expliziten Scroll-Wrapper: defensiver block-Fallback nur,
 * wenn Tabelle einen content-overflow auslöst. Erkennbar via container-query
 * (Container-Width vs Tabelle), aber das ist zu komplex — stattdessen ein
 * sanftes max-width plus break. */
body.v2-refresh .tbl-scroll {
  /* Existierender Wrapper bleibt das primäre Pattern */
}
/* Existierender .tbl-scroll: min-width-Regel auf Mobile lockern */
@media (max-width: 480px) {
  .tbl-scroll .tbl { min-width: 480px; }
}

/* Eingabefelder bleiben in ihrem Container */
body.v2-refresh input[type="text"],
body.v2-refresh input[type="email"],
body.v2-refresh input[type="password"],
body.v2-refresh input[type="search"],
body.v2-refresh input[type="url"],
body.v2-refresh input[type="number"],
body.v2-refresh input[type="tel"],
body.v2-refresh input[type="date"],
body.v2-refresh input[type="time"],
body.v2-refresh select,
body.v2-refresh textarea {
  max-width: 100%;
}

/* Code/Pre nicht aus dem Container brechen */
body.v2-refresh pre,
body.v2-refresh code:not(:where(pre code)) {
  max-width: 100%;
  overflow-x: auto;
  word-break: normal;
}

/* Sehr lange Wörter (URLs, Tokens, Kartennamen) brechen statt zu überlaufen.
 * Gilt nur für klassische Text-Content-Bereiche, nicht für UI-Komponenten,
 * wo unkontrollierter Bruch falsch wäre. */
body.v2-refresh p,
body.v2-refresh li,
body.v2-refresh dd,
body.v2-refresh blockquote {
  overflow-wrap: anywhere;
}

/* Flex/Grid-Kinder dürfen ohne min-width:0 nicht schrumpfen — typischer
 * Cause für Truncation-Bugs in Topbar/Card-Title. Defensiv setzen. */
body.v2-refresh .card,
body.v2-refresh .kpi,
body.v2-refresh .card > *,
body.v2-refresh .lt-left,
body.v2-refresh .lt-right,
body.v2-refresh .deck-title,
body.v2-refresh .u-name,
body.v2-refresh .u-sub,
body.v2-refresh .user-link,
body.v2-refresh .qa-chip,
body.v2-refresh .nav-link {
  min-width: 0;
}

/* Toolbars und Action-Reihen sollen wrappen statt abzuschneiden */
body.v2-refresh .card-toolbar,
body.v2-refresh .toolbar,
body.v2-refresh .action-row,
body.v2-refresh .filter-row,
body.v2-refresh .topbar-actions {
  flex-wrap: wrap;
}

/* Wrap-Container (typische Page-Wraps) müssen sich klein machen können */
body.v2-refresh .wrap,
body.v2-refresh .container,
body.v2-refresh main {
  min-width: 0;
}

/* Hauptseite mit Sidebar: shell-main muss flex-shrink können */
body.v2-refresh .v2-shell-main,
body.v2-refresh .v2-shell-content,
body.v2-refresh .v2-page,
body.v2-refresh .v2-page-content {
  min-width: 0;
}

/* High-DPI / Zoom: bei effective viewport <320px sind Standard-Komponenten
 * ohnehin grenzwertig — wir schrumpfen Padding und Font-Sizes leicht. */
@media (max-width: 360px) {
  body.v2-refresh .wrap { padding: 0 12px; }
  body.v2-refresh .card { padding: 14px; }
  body.v2-refresh .btn { padding: 8px 12px; font-size: 13px; }
  body.v2-refresh .tbl { font-size: 12.5px; }
  body.v2-refresh .tbl tbody td,
  body.v2-refresh .tbl thead th { padding: 8px 6px; }
}

/* Sehr hohe DPI (Retina + Zoom 200%) erzeugt manchmal viewports unter 320px.
 * Verhindert horizontales Scrollen der gesamten Seite durch starre Grids. */
@media (max-width: 320px) {
  body.v2-refresh .wrap { padding: 0 8px; }
  body.v2-refresh .card { padding: 12px; border-radius: var(--r-md); }
}

/* Sticky-Container mit absoluten Inhalten: sicherstellen dass z-index nicht
 * mit Modal-Overlays kollidiert und keine horizontale Scroll-Bar entsteht. */
body.v2-refresh [class*="sticky"],
body.v2-refresh .rate-wrap {
  max-width: 100%;
}

/* Print-View: alle Sticky-Header normal positionieren, alle Overflow auf
 * sichtbar — wichtig für „Karten drucken". */
@media print {
  body.v2-refresh .tbl-scroll,
  body.v2-refresh table { overflow: visible !important; display: table !important; }
  body.v2-refresh .v2-topbar,
  body.v2-refresh .v2-sidebar,
  body.v2-refresh .rate-wrap { position: static !important; }
}
