/* ===== Kopf ===== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head > div:first-child { flex: 1 1 260px; min-width: 0; }
.page-head .back { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.page-head .back:hover { color: var(--accent); }
.page-head p { margin-top: 6px; color: var(--text-2); max-width: 60ch; }

/* ===== Karte ===== */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 20px;
  position: relative;
}
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.card.tight { padding: 14px 16px; }
.card.hero { padding: 22px; overflow: hidden; }
.card-link { text-decoration: none; color: inherit; display: block; transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.card-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.card-link:active { transform: translateY(0) scale(.995); }
.card h3 + p { margin-top: 4px; }
.card-sep { height: 1px; background: var(--line); margin: 16px -20px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px;
  border: 0; border-radius: var(--r-md);
  font-weight: 650; font-size: 15px; letter-spacing: -0.005em;
  background: var(--surface-3); color: var(--text);
  text-decoration: none;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), opacity var(--t-fast);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:hover { background: var(--line-strong); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--accent-strong); color: #fff; box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .55); }
.btn-primary:hover { background: #4338CA; }
.btn-success { background: var(--success); color: #fff; }
:root[data-theme="dark"] .btn-success { background: #0F766E; }
.btn-success:hover { filter: brightness(1.08); background: var(--success); }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover { background: var(--danger-soft); filter: brightness(.97); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-soft:hover { background: var(--accent-soft); filter: brightness(.97); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.icon-btn { width: 42px; height: 42px; padding: 0; border-radius: var(--r-sm); }

/* ===== Chips ===== */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 30px; padding: 0 11px;
  border-radius: var(--r-pill);
  background: var(--surface-3); color: var(--text-2);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  border: 0; text-decoration: none;
}
.chip svg { width: 14px; height: 14px; }
button.chip { cursor: pointer; transition: background var(--t-fast), color var(--t-fast); }
button.chip:hover { color: var(--text); }
.chip[aria-pressed="true"], .chip.on { background: var(--accent-strong); color: #fff; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.success { background: var(--success-soft); color: var(--success); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.streak { background: var(--streak-soft); color: var(--streak); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
@media (min-width: 760px) { .chips.scroll { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; } }

/* Wert-Chip: Signatur – Variable + Zahl + Einheit */
.vchip {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 7px 12px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--line);
  font-variant-numeric: tabular-nums; font-size: 15px;
}
.vchip .k { font-weight: 700; color: var(--accent); font-size: 13px; }
.vchip .v { font-weight: 700; }
.vchip .u { color: var(--text-3); font-size: 12px; }

/* ===== Fortschritt ===== */
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--accent-strong); transform-origin: left; transition: width 600ms var(--ease); }
.bar.grad > i { background: var(--grad); }
.bar.success > i { background: var(--success); }
.bar.thin { height: 4px; }
.ring { display: block; }
.ring circle { fill: none; }
.ring .track { stroke: var(--surface-3); }
.ring .val { transition: stroke-dashoffset 900ms var(--ease); }
.ring-wrap { position: relative; display: inline-grid; place-items: center; }
.ring-wrap .ring-label { position: absolute; text-align: center; line-height: 1.05; }
.ring-wrap .ring-label b { display: block; font-size: 22px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.ring-wrap .ring-label span { font-size: 11px; color: var(--text-3); font-weight: 600; }

/* ===== Listen ===== */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 4px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
  transition: background var(--t-fast);
}
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-2); border-radius: 12px; }
.list-item .meta { flex: 1; min-width: 0; }
.list-item .meta b { display: block; font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
.list-item .meta span { display: block; font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nr {
  width: 36px; height: 36px; flex: none; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 750; font-size: 14px; font-variant-numeric: tabular-nums;
}
.nr.q2 { background: var(--success-soft); color: var(--success); }
.pct { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; min-width: 42px; text-align: right; }

/* ===== Icon-Kachel ===== */
.ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.ico svg { width: 20px; height: 20px; }
.ico.success { background: var(--success-soft); color: var(--success); }
.ico.streak { background: var(--streak-soft); color: var(--streak); }
.ico.danger { background: var(--danger-soft); color: var(--danger); }
.ico.warn { background: var(--warn-soft); color: var(--warn); }

/* ===== Segment ===== */
.seg { display: inline-flex; padding: 4px; gap: 2px; background: var(--surface-3); border-radius: 14px; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 650; font-size: 14px; color: var(--text-2); transition: background var(--t-fast), color var(--t-fast); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ===== Formulare ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 650; color: var(--text-2); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border-radius: var(--r-sm); border: 1.5px solid var(--line-strong);
  background: var(--surface); font-size: 16px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input { font-variant-numeric: tabular-nums; font-weight: 600; }
.textarea { min-height: 160px; line-height: 1.55; resize: vertical; font-weight: 450; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); outline: none; }
.input.ok { border-color: var(--success); background: var(--success-soft); }
.input.bad { border-color: var(--danger); background: var(--danger-soft); }
.input-unit { position: relative; }
.input-unit .u { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 13px; pointer-events: none; }
.input-unit .input { padding-right: 64px; }

/* ===== Hinweise ===== */
.note { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; }
.note svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--text-3); }
.note.success { background: var(--success-soft); border-color: transparent; color: var(--text); }
.note.success svg { color: var(--success); }
.note.danger { background: var(--danger-soft); border-color: transparent; }
.note.danger svg { color: var(--danger); }
.note.warn { background: var(--warn-soft); border-color: transparent; }
.note.warn svg { color: var(--warn); }
.tag-uebung { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--warn); background: var(--warn-soft); padding: 4px 10px; border-radius: 99px; }

/* ===== Rechenweg ===== */
.steps { counter-reset: s; display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.steps li { counter-increment: s; display: flex; gap: 12px; font-variant-numeric: tabular-nums; font-size: 14.5px; }
.steps li::before { content: counter(s); width: 22px; height: 22px; flex: none; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 750; display: grid; place-items: center; margin-top: 1px; }

/* ===== Checkliste ===== */
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast); }
.check input { appearance: none; width: 22px; height: 22px; flex: none; border-radius: 7px; border: 2px solid var(--line-strong); margin: 1px 0 0; display: grid; place-items: center; transition: background var(--t-fast), border-color var(--t-fast); cursor: pointer; }
.check input:checked { background: var(--success); border-color: var(--success); }
.check input:checked::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px, -1px); }
.check:has(input:checked) { background: var(--success-soft); border-color: transparent; }

/* ===== Tabelle ===== */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14.5px; }
table.data th, table.data td { padding: 10px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; white-space: normal; }
table.data thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 700; }
table.data td small { color: var(--text-3); display: block; font-size: 11.5px; }

/* ===== Tab-Leiste ===== */
.tabbar {
  position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 50; display: flex; gap: 2px; padding: 6px;
  width: min(460px, calc(100% - 24px));
  background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-bar);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px 7px; border-radius: 16px; text-decoration: none;
  color: var(--text-3); font-size: 11.5px; font-weight: 650;
  transition: color var(--t-fast), background var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.tab svg { width: 22px; height: 22px; }
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.tab.play[aria-current="page"] { color: #fff; background: linear-gradient(135deg, #4F46E5, #7C3AED); }

/* ===== Toast / XP ===== */
.toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; width: min(420px, calc(100% - 24px)); }
.toast { background: var(--text); color: var(--bg); border-radius: 14px; padding: 11px 16px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-2); animation: toast-in var(--t-norm) var(--ease); display: flex; align-items: center; gap: 10px; }
.toast svg { width: 18px; height: 18px; flex: none; }
.toast.xp { background: var(--grad); color: #fff; }
.toast.out { animation: toast-out var(--t-norm) var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* ===== Leer / Laden ===== */
.empty { text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty svg { width: 34px; height: 34px; color: var(--text-3); margin-bottom: 10px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.loading { display: grid; place-items: center; min-height: 60vh; color: var(--text-3); gap: 12px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent-strong); animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Modal ===== */
.modal-back { position: fixed; inset: 0; background: rgba(12, 14, 34, .45); z-index: 80; display: grid; place-items: end center; animation: fade var(--t-norm) var(--ease); }
@media (min-width: 640px) { .modal-back { place-items: center; } }
.modal { background: var(--surface); width: min(560px, 100%); max-height: 88vh; overflow: auto; border-radius: 24px 24px 0 0; padding: 22px; box-shadow: var(--shadow-2); animation: sheet var(--t-norm) var(--ease); }
@media (min-width: 640px) { .modal { border-radius: 24px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet { from { transform: translateY(24px); opacity: 0; } }

/* ===== Drop-Zone ===== */
.drop { border: 2px dashed var(--line-strong); border-radius: var(--r-lg); padding: 30px 18px; text-align: center; background: var(--surface); transition: border-color var(--t-fast), background var(--t-fast); cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop svg { width: 30px; height: 30px; color: var(--accent); }

/* ===== Switch ===== */
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { appearance: none; width: 100%; height: 100%; margin: 0; border-radius: 99px; background: var(--line-strong); cursor: pointer; transition: background var(--t-fast); }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform var(--t-fast) var(--ease); }
.switch input:checked { background: var(--success); }
.switch input:checked::after { transform: translateX(18px); }
