/* ===================== ASCEND KPI APP ===================== */
:root {
  --bg: #f4f6fa;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f4f9;
  --surface-3: #e7ebf3;
  --border: #dee3ed;
  --border-soft: #eaeef5;
  --text: #10131c;
  --text-dim: #59627a;
  --text-mute: #8d95a8;
  --accent: #5b5bd6;
  --accent-2: #0fae89;
  --accent-3: #e08600;
  --grad: linear-gradient(135deg, #6366f1 0%, #22b8a6 100%);
  --grad-warm: linear-gradient(135deg, #ff7aa8 0%, #f5a623 100%);
  --grad-fire: linear-gradient(135deg, #ff6a3d 0%, #f5a623 100%);
  --success: #0fae89;
  --warning: #e08600;
  --danger: #e8384f;
  --accent-soft: rgba(91,91,214,.10);
  --success-soft: rgba(15,174,137,.12);
  --warning-soft: rgba(224,134,0,.12);
  --danger-soft: rgba(232,56,79,.10);
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 10px 30px rgba(16,24,40,.06);
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow-lg: 0 8px 20px rgba(16,24,40,.08), 0 24px 60px rgba(16,24,40,.10);
  /* Theme-abhängige Werte — im Dark-Block weiter unten überschrieben */
  --scheme: light;
  --glass: rgba(255,255,255,.82);
  --glass-strong: rgba(255,255,255,.88);
  --scrim: rgba(16,24,40,.38);
  --glow-1: rgba(99,102,241,.10);
  --glow-2: rgba(34,184,166,.09);
  --primary-glow: 0 4px 14px rgba(99,102,241,.30);
  --on-accent: #fff;
  --on-success: #fff;
  --on-warm: #fff;
  --warning-ink: #b06800;
  --accent-tint: rgba(91,91,214,.10);
  --accent-tint-soft: rgba(91,91,214,.05);
  --accent-line: rgba(91,91,214,.40);
  --accent-line-soft: rgba(91,91,214,.24);
  --success-tint: rgba(15,174,137,.07);
  --success-line: rgba(15,174,137,.40);
  --success-fill: linear-gradient(90deg, rgba(15,174,137,.20), rgba(15,174,137,.32));
  --warn-line: rgba(245,166,35,.35);
  --danger-line: rgba(232,56,79,.30);
  --radius: 18px;
  --radius-sm: 12px;
  --emoji: "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Emoji", "Twemoji Mozilla", sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}


/* ---- Dunkles Theme: manuell gewählt ---- */
:root[data-theme="dark"] {
  --bg: #07070d;
  --bg-2: #0f0f1a;
  --surface: #14141f;
  --surface-2: #1c1c2b;
  --surface-3: #252538;
  --border: #2a2a3d;
  --border-soft: #1f1f2e;
  --text: #f1f1f7;
  --text-dim: #a0a0b8;
  --text-mute: #6b6b85;
  --accent: #7c5cff;
  --accent-2: #46e1c5;
  --accent-3: #ffb547;
  --grad: linear-gradient(135deg, #7c5cff 0%, #46e1c5 100%);
  --grad-warm: linear-gradient(135deg, #ff6b9d 0%, #ffb547 100%);
  --grad-fire: linear-gradient(135deg, #ff5e3a 0%, #ffb547 100%);
  --success: #46e1c5;
  --warning: #ffb547;
  --danger: #ff5470;
  --accent-soft: rgba(124,92,255,.12);
  --success-soft: rgba(70,225,197,.12);
  --warning-soft: rgba(255,181,71,.12);
  --danger-soft: rgba(255,84,112,.12);
  --shadow: 0 6px 24px rgba(0,0,0,.45);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-lg: 0 10px 28px rgba(0,0,0,.5);
  --scheme: dark;
  --glass: rgba(7,7,13,.85);
  --glass-strong: rgba(15,15,26,.95);
  --scrim: rgba(0,0,0,.62);
  --glow-1: rgba(124,92,255,.18);
  --glow-2: rgba(70,225,197,.10);
  --primary-glow: 0 4px 14px rgba(124,92,255,.35);
  --on-accent: #fff;
  --on-success: #07261f;
  --on-warm: #1a0d00;
  --warning-ink: #ffb547;
  --accent-tint: rgba(124,92,255,.14);
  --accent-tint-soft: rgba(124,92,255,.06);
  --accent-line: rgba(124,92,255,.45);
  --accent-line-soft: rgba(124,92,255,.30);
  --success-tint: rgba(70,225,197,.06);
  --success-line: rgba(70,225,197,.35);
  --success-fill: linear-gradient(90deg, rgba(70,225,197,.55), rgba(70,225,197,.65));
  --warn-line: rgba(255,181,71,.40);
  --danger-line: rgba(255,84,112,.35);
}

/* ---- Dunkles Theme: Systemeinstellung (wenn nicht manuell auf hell gestellt) ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #07070d;
    --bg-2: #0f0f1a;
    --surface: #14141f;
    --surface-2: #1c1c2b;
    --surface-3: #252538;
    --border: #2a2a3d;
    --border-soft: #1f1f2e;
    --text: #f1f1f7;
    --text-dim: #a0a0b8;
    --text-mute: #6b6b85;
    --accent: #7c5cff;
    --accent-2: #46e1c5;
    --accent-3: #ffb547;
    --grad: linear-gradient(135deg, #7c5cff 0%, #46e1c5 100%);
    --grad-warm: linear-gradient(135deg, #ff6b9d 0%, #ffb547 100%);
    --grad-fire: linear-gradient(135deg, #ff5e3a 0%, #ffb547 100%);
    --success: #46e1c5;
    --warning: #ffb547;
    --danger: #ff5470;
    --accent-soft: rgba(124,92,255,.12);
    --success-soft: rgba(70,225,197,.12);
    --warning-soft: rgba(255,181,71,.12);
    --danger-soft: rgba(255,84,112,.12);
    --shadow: 0 6px 24px rgba(0,0,0,.45);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
    --shadow-lg: 0 10px 28px rgba(0,0,0,.5);
    --scheme: dark;
    --glass: rgba(7,7,13,.85);
    --glass-strong: rgba(15,15,26,.95);
    --scrim: rgba(0,0,0,.62);
    --glow-1: rgba(124,92,255,.18);
    --glow-2: rgba(70,225,197,.10);
    --primary-glow: 0 4px 14px rgba(124,92,255,.35);
    --on-accent: #fff;
    --on-success: #07261f;
    --on-warm: #1a0d00;
    --warning-ink: #ffb547;
    --accent-tint: rgba(124,92,255,.14);
    --accent-tint-soft: rgba(124,92,255,.06);
    --accent-line: rgba(124,92,255,.45);
    --accent-line-soft: rgba(124,92,255,.30);
    --success-tint: rgba(70,225,197,.06);
    --success-line: rgba(70,225,197,.35);
    --success-fill: linear-gradient(90deg, rgba(70,225,197,.55), rgba(70,225,197,.65));
    --warn-line: rgba(255,181,71,.40);
    --danger-line: rgba(255,84,112,.35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif,
               "Apple Color Emoji", "Noto Color Emoji", "Segoe UI Emoji";
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior: none; /* x: Wischen wechselt die Woche, nicht „Zurück“ */
  -webkit-font-smoothing: antialiased;
  color-scheme: var(--scheme);
}
body {
  min-height: 100vh;
  background:
    radial-gradient(900px 520px at 82% -12%, var(--glow-1), transparent 62%),
    radial-gradient(760px 440px at -12% 108%, var(--glow-2), transparent 62%),
    var(--bg);
  padding-top: calc(var(--safe-top) + 0px);
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  font-family: inherit; font-size: 15px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; width: 100%; outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--text-mute); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--bg-2);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.015em; }

/* ===================== ICONS ===================== */
/* Inline-SVG-Sprite (Lucide, ISC). Strichstärke und Farbe erben vom Text,
   dadurch passen die Icons in jedem Kontext und in beiden Themes. */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 1em; height: 1em;
  flex-shrink: 0;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -.15em;
}
svg.emo { display: inline-block; margin-right: .38em; }
svg.emo-solo { margin-right: 0; }
svg.tab-icon { width: 21px; height: 21px; vertical-align: 0; }
svg.mode-icon { width: 17px; height: 17px; }
svg.empty-icon {
  display: block; margin: 0 auto 10px;
  width: 40px; height: 40px;
  stroke-width: 1.5; opacity: .45;
}
/* In Fließtext etwas kräftiger, damit die feinen Linien nicht verschwinden */
.goal-meta .ic, .todo-banner .ic, .chip-count .ic { stroke-width: 2.25; }

/* ===================== EMOJI ===================== */
/* Farb-Emoji sauber und einheitlich rendern, statt als Text-Glyphe */
.emo, .tab-icon, .empty-icon, .kpi-today-icon, .mode-icon, .achievement-icon,
.kpi-week-table .kpi-head, .btn-emo {
  font-family: var(--emoji);
  font-variant-emoji: emoji;
  font-weight: 400;
  font-style: normal;
  line-height: 1;
  -webkit-font-smoothing: auto;
}
.emo {
  display: inline-block;
  vertical-align: -.08em;
  margin-right: .38em;
}
.emo-lg { font-size: 1.15em; }
.emo-solo { margin-right: 0; }

/* ===================== HEADER ===================== */
.mode-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: 99px;
  background: var(--bg-2); color: var(--text);
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  transition: all .15s;
}
.mode-toggle:active { transform: scale(.97); }
.mode-toggle .mode-icon { font-size: 14px; line-height: 1; }
.setting-mode-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.setting-text { flex: 1; min-width: 0; }
.setting-name { font-weight: 700; font-size: 15px; }
.setting-desc { font-size: 12px; color: var(--text-dim); margin-top: 3px; line-height: 1.4; }
body.mode-edit .mode-toggle {
  background: var(--grad-warm);
  color: var(--on-warm); border-color: transparent;
  box-shadow: 0 4px 14px var(--warn-line);
}
/* Einziger verbliebener Balken über dem Inhalt — nur im Bearbeitungsmodus. */
.mode-banner {
  display: none;
  position: sticky; top: 0; z-index: 30;
  padding: 8px 16px;
  background: var(--warning-soft);
  color: var(--warning-ink);
  font-size: 12px; font-weight: 700;
  text-align: center;
  border-bottom: 1px solid var(--warn-line);
}
body.mode-edit .mode-banner { display: block; }
body.mode-use .edit-only { display: none !important; }
body.mode-edit .kpi-card { border-color: var(--warn-line); }
body.mode-edit .routine-item { border-color: var(--warn-line); }

/* ===================== MAIN ===================== */
main { padding: 16px 16px 110px; max-width: 720px; margin: 0 auto; }
.tab-panel { display: none; animation: fadeIn .25s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 4px 0 16px;
}
.page-title h1 { font-size: 27px; letter-spacing: -.025em; display: flex; align-items: center; }
.page-title h1 { flex: 1; min-width: 0; }
/* Kalenderwoche für die ganze App. Bewusst zurückhaltend: nur Text mit
   Chevron, damit die Überschrift die Zeile führt und nicht die Navigation. */
.week-select {
  flex-shrink: 0; width: auto; max-width: 58%;
  padding: 5px 26px 5px 10px;
  background: transparent; border: 1px solid transparent;
  border-radius: 99px;
  color: var(--text-mute); font-size: 12px; font-weight: 700;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d95a8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  background-size: 11px;
}
.week-select:focus { border-color: var(--border); background-color: var(--surface-2); }
/* Nicht die laufende Woche: deutlich abheben, damit man es nicht übersieht. */
.week-select.off-current {
  color: var(--accent);
  border-color: var(--accent-line-soft);
  background-color: var(--accent-soft);
}
.sub-period {
  margin: -4px 0 12px; padding: 0 2px;
  color: var(--text-mute); font-size: 12px; font-weight: 700;
}
.date-display { color: var(--text-dim); font-size: 13px; }
.section-title { font-size: 14px; color: var(--text-dim); margin: 22px 0 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }


/* ===================== CARDS ===================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.card-head h3 { font-size: 15px; }
.muted { color: var(--text-mute); font-size: 12px; }

.hero-card {
  background: var(--grad);
  border: none;
  color: #fff;
  position: relative; overflow: hidden;
}
.hero-card::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 100% 0%, rgba(255,255,255,.18), transparent 50%);
  pointer-events: none;
}
.hero-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; position: relative; }
.hero-stat { text-align: center; }
.hero-num { font-size: 26px; font-weight: 800; line-height: 1.1; }
.hero-lbl { font-size: 11px; opacity: .85; margin-top: 4px; letter-spacing: .04em; }

/* ===================== BUTTONS ===================== */
.btn-primary {
  background: var(--grad); color: #fff;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 14px;
  box-shadow: var(--primary-glow);
  transition: transform .1s, box-shadow .15s;
}
.btn-primary:active { transform: scale(.96); }
.btn-secondary {
  background: var(--bg-2); color: var(--text);
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, border-color .15s;
}
.btn-secondary:active { background: var(--surface-2); }
.btn-danger {
  background: var(--danger-soft); color: var(--danger);
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px;
  border: 1px solid var(--danger-line);
}

/* ===================== KPI WEEK TABLE ===================== */
.kpi-week-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.kpi-week-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
.kpi-week-table th, .kpi-week-table td {
  border: 1px solid var(--border-soft);
  padding: 10px 4px;
  text-align: center;
  vertical-align: middle;
  height: 40px;
  box-sizing: border-box;
  overflow: hidden;
}
.kpi-week-table .kw-cell,
.kpi-week-table .date-cell,
.kpi-week-table .result-cell,
.kpi-week-table .kpi-head { width: auto; }
.routine-week .kpi-week-table { table-layout: fixed; }
.auto-routine-week { margin-top: 14px; }
.auto-routine-week .kpi-cell, .auto-routine-week .routine-head { cursor: default; }
.routine-week .kpi-week-table .kw-cell { width: 36%; }
.routine-week .kpi-week-table .result-cell { width: 9%; }
.routine-week .kpi-week-table .day-head {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  padding: 8px 2px;
  line-height: 1.15;
  white-space: nowrap;
}
.routine-week .kpi-week-table .day-head.today { color: var(--accent); }
.routine-week .kpi-week-table .today-col { background: var(--accent-tint-soft); }
.routine-week .kpi-week-table tbody .routine-head {
  text-align: center;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: normal;
  line-height: 1.25;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: manual;
  background: var(--surface);
  cursor: pointer;
}
.routine-week .kpi-week-table tbody .routine-head:active { background: var(--surface-2); }
.routine-week .kpi-week-table tbody tr.deactivated .routine-head {
  text-decoration: line-through;
  color: var(--text-mute);
}
.routine-week .kpi-week-table tbody tr.deactivated .result-val { color: var(--text-mute); }

@media (max-width: 600px) {
  .kpi-week-table th, .kpi-week-table td {
    height: 32px;
    padding: 4px 3px;
  }
  .kpi-week-table .date-cell { font-size: 11px; }
  .routine-week .kpi-week-table tbody .routine-head {
    padding: 5px 6px;
    font-size: 11px;
    line-height: 1.2;
  }
  .routine-week .kpi-week-table .day-head { padding: 5px 2px; font-size: 11px; }
}
.kpi-week-table thead th {
  background: var(--surface-2);
  font-weight: 700;
  color: var(--text-dim);
  position: sticky; top: 0; z-index: 1;
}
.kpi-week-table .kw-cell { font-size: 12px; letter-spacing: .04em; }
.kpi-week-table .kpi-head {
  font-size: 20px; cursor: default;
  min-width: 44px;
}
/* Strichicon statt Emoji: optisch auf dieselbe Höhe wie ein Emoji bringen. */
.kpi-week-table .kpi-head .ic { vertical-align: -.12em; }
body.mode-edit .kpi-week-table .kpi-head { cursor: pointer; }
body.mode-edit .kpi-week-table .kpi-head:active { background: var(--surface-3); }
.kpi-week-table .date-cell {
  font-size: 12px; color: var(--text-dim);
  white-space: nowrap; text-align: center;
  background: var(--surface);
}
.kpi-week-table tr.today .date-cell { color: var(--accent); font-weight: 700; }
.kpi-week-table tr.today td { background: var(--accent-tint-soft); }
.kpi-week-table tfoot td {
  background: var(--surface-2);
  font-weight: 800;
}
.kpi-week-table tfoot .result-cell { text-align: center; }
.kpi-week-table tfoot .result-val.hit { color: var(--success); }
.kpi-week-table tfoot .result-goal {
  color: var(--text-mute);
  font-weight: 600;
  margin-left: 2px;
  font-size: .82em;
}

.kpi-cell { cursor: pointer; transition: background .1s; }
.kpi-cell:active { background: var(--surface-3); }
.kpi-cell.off { cursor: default; }
/* Bearbeitungsmodus: Tage pro Woche an/aus schalten */
body.mode-edit .kpi-cell,
body.mode-edit .kpi-cell.off { cursor: pointer; }
body.mode-edit .kpi-cell:active { background: var(--surface-3); }
.kpi-cell.day-on { background: var(--accent-tint); box-shadow: inset 0 0 0 1px var(--accent-line); }
.kpi-cell.day-off { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-soft); }
.cell-active {
  display: inline-block; width: 18px; height: 18px; vertical-align: middle;
  position: relative; line-height: 18px;
}
.cell-active::after {
  content: '✓'; position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--accent); font-weight: 800; font-size: 13px; line-height: 1;
}
.kpi-edit-hint {
  background: var(--accent-soft);
  border: 1px solid var(--accent-line-soft);
  border-radius: 12px;
  padding: 8px 12px; margin-bottom: 10px;
  font-size: 12.5px; color: var(--text-dim); line-height: 1.4;
}
.kpi-edit-hint b { color: var(--text); }
.kpi-scope-hint {
  margin: 6px 2px 0; font-size: 11.5px; color: var(--text-dim); line-height: 1.4;
}
.cell-check, .cell-skip, .cell-fail, .cell-exclude {
  display: inline-block;
  width: 18px; height: 18px;
  vertical-align: middle;
  position: relative;
  line-height: 18px;
}
.cell-check {
  border: 1.5px solid var(--border);
  border-radius: 4px;
}
.cell-check.done { background: var(--success); border-color: var(--success); }
.cell-check.done::after {
  content: '✓'; position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--on-success); font-weight: 800; font-size: 13px; line-height: 1;
}
.cell-skip::after {
  content: '✕'; position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--text-mute);
  font-weight: 800; font-size: 14px; line-height: 1;
}
.cell-fail::after {
  content: '✕'; position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--danger);
  font-weight: 800; font-size: 14px; line-height: 1;
}
.cell-exclude::after {
  content: '✕'; position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--text-mute);
  font-weight: 800; font-size: 14px; line-height: 1;
}
.cell-num { font-weight: 700; }
.cell-num.hit { color: var(--success); }
.kpi-cell.editing { padding: 0; background: var(--accent-soft); }
.cell-input {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0 4px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  background: transparent;
  color: var(--text);
  border: 2px solid var(--accent);
  border-radius: 0;
  outline: none;
  box-sizing: border-box;
  -moz-appearance: textfield;
}
.cell-input::-webkit-outer-spin-button,
.cell-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Today KPI tap-row */
.kpi-today-list { display: flex; flex-direction: column; gap: 10px; }
.kpi-today-row {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 12px;
  transition: transform .1s;
}
.kpi-today-row:active { transform: scale(.99); }
.kpi-today-row.done { border-color: var(--success-line); background: linear-gradient(180deg, var(--success-tint), var(--surface)); }
.kpi-today-row.skipped .kpi-today-name,
.kpi-today-row.skipped .kpi-today-sub { text-decoration: line-through; color: var(--text-mute); }
.kpi-today-row.skipped { opacity: .7; }
.kpi-today-icon {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  display: grid; place-items: center; font-size: 20px;
  flex-shrink: 0;
}
.kpi-today-info { flex: 1; min-width: 0; }
.kpi-today-name { font-weight: 700; font-size: 14px; }
.kpi-today-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.kpi-today-value { font-weight: 700; font-size: 16px; }

/* ===================== TODOS ===================== */
.todo-form { display: flex; gap: 8px; margin-bottom: 14px; }
.todo-form input { flex: 1; }
.todo-tabs {
  display: flex; gap: 8px; margin-bottom: 14px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.todo-tabs .chip { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; }
/* Zahl der offenen Aufgaben je Liste bzw. Kategorie; ✓ wenn nichts offen ist. */
.chip-count {
  flex-shrink: 0; min-width: 17px; padding: 1px 5px;
  border-radius: 99px;
  background: var(--surface-3); color: var(--text-dim);
  font-size: 10px; font-weight: 800; line-height: 1.6; text-align: center;
}
.chip.active .chip-count { background: rgba(255, 255, 255, .28); color: var(--on-accent); }
.todo-groups .chip .chip-count { background: var(--bg-2); }
.todo-groups .chip.active .chip-count { background: var(--bg-2); color: var(--text-dim); }
.todo-tabs .todo-tab-add { gap: 0; }
.todo-tab-add {
  font-size: 18px; font-weight: 800;
  padding: 6px 15px;
  background: var(--bg-2);
  color: var(--text-mute);
  border: 1px dashed var(--border);
  box-shadow: none;
}
.chip {
  padding: 8px 15px; border-radius: 99px;
  background: var(--bg-2); color: var(--text-dim);
  font-size: 13px; font-weight: 600; border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: background .15s, color .15s, border-color .15s;
}
.chip.active {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent);
  box-shadow: var(--primary-glow);
}

.todo-list { display: flex; flex-direction: column; gap: 8px; }
.todo-list.todo-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.todo-list.todo-grid-2 .empty { grid-column: 1 / -1; }
@media (max-width: 420px) {
  .todo-list.todo-grid-2 { gap: 6px; }
  .todo-list.todo-grid-2 .todo-item { padding: 8px 10px; gap: 8px; }
  .todo-list.todo-grid-2 .todo-check { width: 18px; height: 18px; border-width: 2px; }
  .todo-list.todo-grid-2 .todo-check.done::after,
  .todo-list.todo-grid-2 .todo-check.failed::after,
  .todo-list.todo-grid-2 .todo-check.skipped::after { font-size: 12px; }
  .todo-list.todo-grid-2 .todo-text { font-size: 12px; }
}
.todo-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  animation: slideIn .25s ease;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.todo-item.dragging {
  background: var(--bg-2);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  transform: scale(1.02);
  z-index: 5;
  position: relative;
  touch-action: none;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.todo-check {
  width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid var(--border);
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
.todo-check.done {
  background: var(--success); border-color: var(--success);
  color: var(--on-success);
}
.todo-check.done::after { content: '✓'; font-weight: 800; font-size: 14px; }
.todo-check.skipped { border-color: var(--text-mute); }
.todo-check.skipped::after { content: '✕'; font-weight: 800; font-size: 14px; color: var(--text-mute); }
.todo-text { font-size: 14px; word-break: break-word; }
.todo-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.todo-item.state-skipped .todo-text { color: var(--text-mute); text-decoration: line-through; }
.todo-item.state-done { border-color: var(--success-line); background: linear-gradient(180deg, var(--success-tint), var(--surface)); }
#weeklyTaskList .todo-check.failed { border-color: var(--danger); }
#weeklyTaskList .todo-check.failed::after { content: '✕'; color: var(--danger); }
#weeklyTaskList .todo-item.state-failed { border-color: var(--danger-line); }
#weeklyTaskList .todo-item.state-failed .todo-text { color: var(--text); text-decoration: none; }
.todo-banner {
  padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px; font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}
.todo-banner.soon { color: var(--warning-ink); border-color: var(--warn-line); background: var(--warning-soft); }
.todo-banner.overdue { color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); }
.todo-del { color: var(--text-mute); padding: 4px 8px; font-size: 18px; }
.todo-del:active { color: var(--danger); }
.todo-deadline {
  display: inline-block;
  align-self: flex-start;
  padding: 3px 9px; border-radius: 99px;
  font-size: 11px; font-weight: 700;
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border);
}
.todo-deadline.soon { color: var(--warning-ink); border-color: var(--warn-line); background: var(--warning-soft); }
.todo-deadline.overdue { color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); }
.todo-deadline.unlimited { color: var(--text-mute); }
.inline-check {
  display: flex !important;
  flex-direction: row !important;
  align-items: center; gap: 8px;
  font-size: 14px !important; color: var(--text) !important;
  cursor: pointer;
}
.inline-check input { width: auto; }
.todo-deadline-wrap {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.todo-deadline-wrap input[type="date"],
.todo-deadline-wrap input[type="time"] { color-scheme: var(--scheme); }

/* ===================== ROUTINE SUB-TABS ===================== */
.routine-subtabs {
  display: flex; gap: 8px; margin-bottom: 14px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.routine-subtabs .chip { flex-shrink: 0; }
.routine-sub[hidden] { display: none; }

/* ===================== ROUTINES ===================== */
.routine-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.routine-item.done { border-color: var(--success-line); }
.routine-item.done .routine-text { color: var(--text-mute); text-decoration: line-through; }

.routine-edit {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text-mute); font-size: 14px;
}
.routine-edit:active { background: var(--surface-2); color: var(--text); }
.routine-days-hint {
  font-size: 11px; color: var(--text-mute);
  margin-top: 2px; letter-spacing: .04em;
}

.day-chips { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 4px; }
.day-chip {
  padding: 11px 0; border-radius: 10px;
  background: var(--bg-2); color: var(--text-dim);
  font-size: 12px; font-weight: 700;
  border: 1px solid var(--border);
  transition: background .15s, color .15s, border-color .15s;
}
.day-chip.active {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent);
  box-shadow: var(--primary-glow);
}
.day-shortcuts { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.day-shortcuts .chip { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); box-shadow: none; padding: 6px 11px; }

/* ===================== BODY ===================== */
.inline-form { display: flex; gap: 8px; margin-bottom: 14px; }
.inline-form input { flex: 1; }
.weight-form { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto; gap: 8px; margin-bottom: 6px; }
.weight-form input[type="date"] { color-scheme: var(--scheme); }
@media (max-width: 380px) {
  .weight-form { grid-template-columns: 1fr 1fr; }
  .weight-form button { grid-column: 1 / -1; }
}
.weight-list-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px; font-size: 13px; color: var(--text-dim); font-weight: 600;
}
.weight-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.weight-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
}
.weight-row .w-date { flex: 1; font-size: 13px; color: var(--text-dim); }
.weight-row .w-val { font-weight: 700; font-size: 15px; }
.weight-row button { color: var(--text-mute); font-size: 18px; padding: 4px 8px; }
.weight-row button:active { color: var(--danger); }
.chart-wrap { position: relative; height: 220px; margin-top: 8px; }
.range-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 4px 0 6px; }
.range-btn {
  padding: 8px 0; border-radius: 10px;
  background: var(--bg-2); color: var(--text-dim);
  font-size: 12px; font-weight: 700;
  border: 1px solid var(--border);
}
.range-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.photo-upload {
  display: block; padding: 18px; text-align: center;
  background: var(--bg-2); border: 2px dashed var(--border);
  border-radius: var(--radius-sm); color: var(--text-dim);
  font-weight: 600; font-size: 14px;
  cursor: pointer; margin-bottom: 12px;
  transition: border-color .15s, color .15s;
}
.photo-upload:active { border-color: var(--accent); color: var(--accent); }
.photo-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.photo-item {
  position: relative; aspect-ratio: 1;
  border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-2);
}
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-date {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 4px 6px; font-size: 10px;
  background: linear-gradient(transparent, rgba(16,24,40,.70));
  color: #fff; font-weight: 600;
}
.photo-del {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(16,24,40,.55); color: #fff;
  display: grid; place-items: center; font-size: 14px;
}

/* ===================== STATS ===================== */
.select-input { margin-bottom: 8px; }
.settings-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.settings-row .btn-secondary, .settings-row .btn-danger { flex: 1; justify-content: center; display: inline-flex; }

/* ===================== ACHIEVEMENTS ===================== */
.achievement-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.achievement {
  aspect-ratio: 1; border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 8px; text-align: center;
  opacity: .35;
  filter: grayscale(.8);
  transition: all .3s;
}
.achievement.unlocked {
  opacity: 1; filter: none;
  background: linear-gradient(135deg, var(--accent-soft), var(--success-soft));
  border-color: var(--accent-line);
}
.achievement-icon { font-size: 28px; margin-bottom: 4px; }
.achievement-name { font-size: 11px; font-weight: 700; }
.achievement-desc { font-size: 9px; color: var(--text-mute); margin-top: 2px; }

/* ===================== TABBAR ===================== */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--glass-strong);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + var(--safe-bottom));
}
.tab-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 1px; color: var(--text-mute);
  font-size: 10px; font-weight: 600;
  border-radius: 10px; transition: color .15s, background .15s;
}
.tab-btn.active { color: var(--accent); background: var(--accent-soft); }
.tab-icon { font-size: 19px; line-height: 1; }
.tab-label { letter-spacing: .02em; white-space: nowrap; }

/* ===================== MODAL ===================== */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: var(--scrim);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .2s;
}
.modal[hidden] { display: none !important; }
.toast[hidden] { display: none !important; }
.modal-content {
  width: 100%; max-width: 520px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow-lg);
  padding: 18px 18px calc(18px + var(--safe-bottom));
  max-height: 92vh; overflow-y: auto;
  animation: slideUp .25s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 600px) {
  .modal { align-items: center; padding: 20px; }
  .modal-content { border-radius: 20px; border: 1px solid var(--border); }
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { font-size: 18px; }
.modal-close {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-2); display: grid; place-items: center;
  font-size: 22px; line-height: 1; color: var(--text-dim);
  transition: background .15s, color .15s;
}
.modal-form { display: flex; flex-direction: column; gap: 12px; }
.modal-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--text-dim); font-weight: 600;
}
.modal-actions {
  display: flex; gap: 8px; margin-top: 6px;
  justify-content: space-between;
}
.modal-actions .btn-primary, .modal-actions .btn-secondary, .modal-actions .btn-danger {
  flex: 1; padding: 13px; justify-content: center; display: inline-flex; align-items: center;
}

.bool-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bool-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 18px; border-radius: var(--radius-sm);
  background: var(--bg-2); color: var(--text);
  font-weight: 700; font-size: 15px;
  border: 2px solid var(--border);
  transition: all .15s;
}
.bool-btn.active[data-val="1"] { background: var(--success); color: var(--on-success); border-color: var(--success); }
.bool-btn.active[data-val="0"] { background: var(--surface-3); color: var(--text-dim); border-color: var(--border); }

/* ===================== TOAST ===================== */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px; border-radius: 99px;
  font-weight: 600; font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  animation: toastIn .3s cubic-bezier(.2,.8,.2,1);
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.warn { border-color: var(--warning); color: var(--warning); }
@keyframes toastIn {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ===================== CONFETTI ===================== */
.confetti-canvas {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 70;
}

/* ===================== EMPTY ===================== */
.empty {
  text-align: center; padding: 32px 20px;
  color: var(--text-mute); font-size: 13px;
}
.empty-icon { font-size: 36px; margin-bottom: 8px; opacity: .5; }

/* ============== LOGIN OVERLAY ============== */
#login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 600px at 50% -10%, var(--glow-1), transparent 60%),
    radial-gradient(700px 500px at 10% 110%, var(--glow-2), transparent 60%),
    var(--bg);
}
#login-form {
  width: 100%; max-width: 340px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 30px 24px;
  box-shadow: var(--shadow-lg);
}
#login-form h1 {
  margin: 0; font-size: 24px; font-weight: 800; text-align: center;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
#login-form .login-sub {
  margin: 0 0 8px; text-align: center; font-size: 13px; color: var(--text-dim);
}
#login-form input {
  width: 100%; box-sizing: border-box;
  padding: 12px 14px; font-size: 15px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
}
#login-form input:focus { border-color: var(--accent); outline: none; }
#login-form .login-error {
  font-size: 13px; color: var(--danger); text-align: center; margin: -2px 0 2px;
}
#login-form button {
  margin-top: 6px; padding: 12px; font-size: 15px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  color: #fff; cursor: pointer;
  background: var(--grad);
  border: none; border-radius: 12px;
  box-shadow: var(--primary-glow);
}
#login-form button:disabled { opacity: .6; cursor: default; }

/* ===================== POLISH (hell / clean) ===================== */
.section-title { color: var(--text-mute); }
.tab-btn { font-weight: 700; }
.tab-icon { font-size: 20px; }

/* Sanfte Scrollbars statt Browser-Default */
.kpi-week-wrap::-webkit-scrollbar,
.todo-tabs::-webkit-scrollbar,
.routine-subtabs::-webkit-scrollbar,
.modal-content::-webkit-scrollbar { height: 6px; width: 6px; }
.kpi-week-wrap::-webkit-scrollbar-thumb,
.todo-tabs::-webkit-scrollbar-thumb,
.routine-subtabs::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }
.kpi-week-wrap::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track { background: transparent; }

/* Tastatur-Fokus sichtbar halten (Maus-Klicks bleiben ruhig) */
button:focus-visible, .chip:focus-visible, .day-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Emoji im Fließtext von Labels/Überschriften */
.card-head h3, .modal-head h3, .setting-name { display: flex; align-items: center; }
/* Label als Block, damit Emoji + Text in einer Zeile stehen (flex-column würde sie trennen) */
.modal-form label { display: block; gap: 0; }
.modal-form label > input,
.modal-form label > select,
.modal-form label > textarea { margin-top: 6px; }
.modal-form label[hidden] { display: none !important; }
.modal-form label.inline-check { display: flex !important; }
.modal-form label.inline-check[hidden] { display: none !important; }
.modal-form label.inline-check > input { margin-top: 0; }
.btn-primary, .btn-secondary, .btn-danger { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.modal-actions .btn-primary .emo,
.modal-actions .btn-secondary .emo,
.modal-actions .btn-danger .emo,
.settings-row .btn-secondary .emo,
.settings-row .btn-danger .emo { margin-right: 0; }

/* Prefers-reduced-motion respektieren */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Kompakter Hinzufügen-Button: klares Plus statt grauem Emoji auf dem Farbverlauf */
.btn-plus {
  font-size: 22px; font-weight: 400; line-height: 1;
  display: block; margin-top: -2px;
}

/* ===================== THEME-UMSCHALTER ===================== */
.theme-seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 5px;
}
.theme-opt {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 6px; border-radius: 10px;
  font-size: 13px; font-weight: 700;
  color: var(--text-dim);
  transition: background .15s, color .15s, box-shadow .15s;
}
.theme-opt .emo { margin-right: 0; }
.theme-opt.active {
  background: var(--bg-2); color: var(--text);
  box-shadow: var(--shadow-sm);
}
@media (max-width: 380px) {
  .theme-opt { font-size: 12px; padding: 10px 2px; gap: 4px; }
}

/* ===================== BEI BEDARF ===================== */
.ondemand-summary {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line-soft);
  font-size: 13px; font-weight: 700; color: var(--text);
}
.ondemand-summary[hidden] { display: none !important; }
.ondemand-summary .od-sub { font-weight: 600; color: var(--text-dim); }

/* Markierte Aufgabe: normal. Nicht markierte: deaktiviert. */
.todo-item.od-off { background: var(--surface-2); border-style: dashed; box-shadow: none; }
.todo-item.od-off .todo-text { color: var(--text-mute); }
.todo-item.od-off .todo-check {
  border-color: var(--border); opacity: .45;
  cursor: default;
}
.od-mark {
  flex-shrink: 0;
  width: 46px; height: 27px; border-radius: 99px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  position: relative;
  transition: background .18s, border-color .18s;
}
.od-mark::after {
  content: '';
  position: absolute; top: 2px; left: 2px;
  width: 21px; height: 21px; border-radius: 50%;
  background: var(--bg-2);
  box-shadow: var(--shadow-sm);
  transition: transform .18s cubic-bezier(.2,.8,.2,1);
}
.od-mark.on { background: var(--accent); border-color: var(--accent); }
.od-mark.on::after { transform: translateX(19px); }
.od-mark:active { transform: scale(.96); }
.od-note {
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  color: var(--text-mute);
}
.todo-item.od-on .od-note { color: var(--warning-ink); }
.todo-item.od-done .od-note { color: var(--success); }

/* Bei Bedarf im 2-Spalten-Raster: schmalerer Schalter, engere Zeile */
.todo-grid-2 .todo-item { gap: 8px; }
.todo-grid-2 .od-mark { width: 40px; height: 24px; }
.todo-grid-2 .od-mark::after { width: 18px; height: 18px; }
.todo-grid-2 .od-mark.on::after { transform: translateX(16px); }
.todo-grid-2 .od-note { font-size: 10px; }
@media (max-width: 420px) {
  .todo-grid-2 .od-mark { width: 34px; height: 20px; }
  .todo-grid-2 .od-mark::after { width: 15px; height: 15px; }
  .todo-grid-2 .od-mark.on::after { transform: translateX(13px); }
  .todo-grid-2 .od-note { font-size: 9.5px; padding-right: 38px; }
  /* In der schmalen Spalte den Schalter unten rechts absetzen: der Titel
     bekommt so die volle Kartenbreite statt auf zwei Zeilen zu brechen. */
  .todo-grid-2 .todo-item { position: relative; }
  .todo-grid-2 .od-mark { position: absolute; right: 10px; bottom: 8px; }
}

/* Fristbanner läuft über beide Spalten; den Abstand macht das Raster. */
.todo-list.todo-grid-2 .todo-banner { grid-column: 1 / -1; margin-bottom: 0; }
/* Todos im Raster: Löschen nach oben rechts, damit rechts unten Platz für den
   Wochen-Schalter der Schalter-Aufgaben bleibt. */
#todoList.todo-grid-2 .todo-item { position: relative; }
#todoList.todo-grid-2 .todo-body { padding-right: 20px; }
#todoList.todo-grid-2 .todo-del {
  position: absolute; top: 2px; right: 4px;
  padding: 2px 6px; font-size: 16px; line-height: 1;
}

/* ===================== KATEGORIEN INNERHALB EINER LISTE ===================== */
.todo-groups { margin-top: -8px; }
/* Flacher als die Listen-Chips darüber, damit die beiden Reihen als
   Hierarchie lesbar bleiben und nicht als zwei gleichrangige Leisten. */
.todo-groups .chip {
  font-size: 12px; padding: 6px 12px;
  background: transparent; box-shadow: none;
}
.todo-groups .chip.active {
  background: var(--accent-soft); color: var(--text);
  border-color: var(--accent-line-soft); box-shadow: none;
}
.todo-groups .todo-tab-add { font-size: 16px; padding: 4px 12px; }

/* Auf schmalen Schirmen tragen die Chips nur ihr Symbol — der Name steht im
   Tooltip und im aria-label. Ab der vollen Spaltenbreite (720px Container)
   kommt er sichtbar dazu, dort ist der Platz da. */
.chip-label-wide, .subtab-label { display: none; }
@media (min-width: 700px) {
  .chip-label-wide, .subtab-label { display: inline; }
}
/* Ohne sichtbaren Text hinterlässt der Innenabstand des Icons eine Lücke. */
@media (max-width: 699px) {
  .routine-subtab .emo { margin-right: 0; }
}

/* Icon statt Name: der Chip schrumpft auf Symbol + Zähler, damit die Leiste
   auch bei vielen Listen ohne Seitwärts-Scrollen auf den Schirm passt. */
.chip-icon { display: inline-flex; align-items: center; font-size: 16px; line-height: 1; }
.todo-groups .chip-icon { font-size: 14px; }
/* Strichicons erben Farbe und Strichstärke vom Chip — im aktiven Chip also
   weiß auf Akzent, sonst gedeckt wie die Nav-Leiste. */
.chip-icon .ic { width: 1.05em; height: 1.05em; vertical-align: 0; }

/* Icon-Feld im Modal: Eingabe bzw. Vorschau plus KI- und Rückgängig-Button. */
.icon-ai-row { display: flex; gap: 8px; align-items: stretch; }
.icon-ai-row > input { flex: 1; min-width: 0; text-align: center; font-size: 18px; }
/* Sitzt an der Stelle des Emoji-Feldes, sobald ein Strichicon gesetzt ist. */
.icon-ai-preview {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  color: var(--text);
}
.icon-ai-preview .ic { width: 22px; height: 22px; vertical-align: 0; }
.icon-ai-btn {
  flex-shrink: 0; gap: 6px; padding: 10px 12px; font-size: 13px;
  color: var(--text-dim);
}
.icon-ai-btn[disabled] { opacity: .55; }
/* .btn-secondary setzt display, das schlaegt sonst das hidden-Attribut. */
.icon-ai-btn[hidden], .icon-ai-preview[hidden], .icon-ai-row > input[hidden] { display: none !important; }
.icon-ai-btn.busy .ic { animation: icon-ai-spin 1s linear infinite; }
@keyframes icon-ai-spin { to { transform: rotate(360deg); } }

/* ===================== STATISTIK ===================== */
.stat-range { display: flex; gap: 10px; margin-bottom: 14px; }
.stat-range label {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px;
  font-size: 11px; font-weight: 700; color: var(--text-dim); letter-spacing: .04em;
}
.stat-range select { font-size: 13px; padding: 10px 12px; }
.rating-cfg { display: flex; gap: 10px; }
.rating-cfg label {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-dim);
}
.stat-week-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.stat-week-title { font-size: 14px; font-weight: 700; min-width: 0; }
/* Punktzahl und Note als ein Block — die Note ist die Schlagzeile. */
.stat-grade {
  flex-shrink: 0; display: flex; align-items: baseline; gap: 10px;
  padding: 5px 12px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
}
.stat-points { font-size: 13px; font-weight: 700; color: var(--text-dim); }
.stat-points small { font-size: 9px; margin-left: 2px; letter-spacing: .04em; }
.stat-note { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.stat-grade.good { background: var(--success-fill); border-color: transparent; }
.stat-grade.good .stat-note { color: var(--success); }
.stat-grade.ok .stat-note { color: var(--accent); }
.stat-grade.weak .stat-note { color: var(--warning-ink); }
.stat-grade.bad { background: var(--danger-soft); border-color: transparent; }
.stat-grade.bad .stat-note { color: var(--danger); }

.stat-row {
  display: grid; grid-template-columns: 92px 1fr 44px 76px;
  align-items: center; gap: 8px;
  padding: 6px 0; font-size: 12px;
}
.stat-row-lbl { color: var(--text-dim); font-weight: 600; white-space: nowrap; }
.stat-bar {
  height: 7px; border-radius: 99px; background: var(--surface-3);
  overflow: hidden; min-width: 0;
}
.stat-bar-fill {
  display: block; height: 100%; border-radius: 99px;
  background: var(--grad);
  transition: width .5s cubic-bezier(.2,.8,.2,1);
}
.stat-row-pct { font-weight: 700; text-align: right; }
.stat-row-pts { color: var(--text-dim); text-align: right; font-size: 11px; white-space: nowrap; }
.stat-capped { margin: 8px 0 0; font-size: 11px; color: var(--text-dim); }

/* Gewicht eines ganzen Routine-Bereichs, direkt unter den Reitern. */
.group-weight {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 14px;
}
.group-weight label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-dim);
}
.group-weight .kpi-scope-hint { margin-bottom: 0; }
.group-weight-cap { display: block; }
/* Steht über jedem Konfigurations-Formular. */
.week-scope-notice {
  margin: 0; padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--text-dim);
  font-size: 11px; line-height: 1.45; font-weight: 600;
}
.routine-subtab .weight-badge { margin-left: 7px; }
/* Auf dem aktiven Reiter läge Orange auf Violett — hier hell auf der Füllung. */
.routine-subtab.active .weight-badge { background: rgba(255, 255, 255, .28); color: var(--on-accent); }

/* Relatives Gewicht am Eintrag — nur im Bearbeitungsmodus sichtbar. */
.weight-badge {
  display: inline-block; margin-left: 6px;
  padding: 1px 6px; border-radius: 99px;
  background: var(--warning-soft); color: var(--warning-ink);
  font-size: 10px; font-weight: 800; vertical-align: middle;
}
@media (max-width: 380px) {
  .stat-row { grid-template-columns: 78px 1fr 40px; }
  .stat-row-pts { display: none; }
}

/* ===================== ZIELE ===================== */
.goal-list { display: flex; flex-direction: column; gap: 10px; }
.goal-group { display: flex; flex-direction: column; gap: 10px; }
.goal-section {
  margin-top: 8px; padding: 0 2px;
  font-size: 12px; font-weight: 800; letter-spacing: .04em;
  color: var(--text-mute); text-transform: uppercase;
}
.goal-list > .goal-section:first-child { margin-top: 0; }
.goal-item {
  display: flex; align-items: center; gap: 14px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  animation: slideIn .25s ease;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.goal-item.dragging {
  background: var(--bg-2);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  transform: scale(1.02);
  position: relative; z-index: 5;
  touch-action: none;
}
.goal-check {
  flex-shrink: 0;
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--border);
  display: grid; place-items: center;
  font-size: 17px; line-height: 1;
  transition: background .15s, border-color .15s, transform .15s;
}
.goal-check:active { transform: scale(.92); }
.goal-body { flex: 1; min-width: 0; cursor: pointer; }
.goal-text { font-size: 15px; font-weight: 700; word-break: break-word; }
.goal-meta { margin-top: 4px; font-size: 11.5px; font-weight: 700; color: var(--success); }
/* Erreicht: Pokal im Erfolgsgrün, Karte leicht getönt. */
.goal-item.done {
  border-color: var(--success-line);
  background: linear-gradient(180deg, var(--success-tint), var(--surface));
}
.goal-item.done .goal-check { border-color: var(--success-line); background: var(--success-tint); }
.goal-item.done .goal-text { color: var(--text-dim); }

/* ===================== SORTIEREN PER LONGPRESS ===================== */
/* Tabellenzeilen (Täglich): transform auf <tr> ist unzuverlässig,
   deshalb nur Farbe und Rahmen als Rückmeldung. */
.routine-week tbody tr.dragging > th,
.routine-week tbody tr.dragging > td {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.routine-week .routine-head { cursor: grab; }
.routine-week tbody tr.dragging .routine-head { cursor: grabbing; }

/* Im 2-Spalten-Raster liegt die gezogene Karte über den Nachbarn */
.todo-grid-2 .todo-item.dragging { z-index: 5; }

/* KPI-Spalte beim Verschieben hervorheben */
.kpi-week-table .kpi-head { cursor: grab; }
.kpi-week-table .kpi-head.dragging {
  cursor: grabbing;
  background: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
  border-radius: 6px;
}

/* ===================== TAGEBUCH ===================== */
.diary-nav { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.diary-nav input[type="date"] { flex: 1; min-width: 0; color-scheme: var(--scheme); }
.diary-nav .btn-secondary, #diaryRegen { flex-shrink: 0; }
.diary-text { font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
.diary-text h2 { font-size: 17px; margin-bottom: 10px; }
.diary-text h3 { font-size: 15px; margin: 16px 0 6px; }
.diary-text h4 { font-size: 14px; margin: 12px 0 4px; color: var(--text-dim); }
.diary-text p { margin: 0 0 10px; }
.diary-text ul { margin: 0 0 10px; padding-left: 20px; }
.diary-text li { margin-bottom: 4px; }
.diary-scores { margin-bottom: 12px; }
.diary-scores:empty { display: none; }
.diary-score {
  width: 100%; display: flex; align-items: baseline; gap: 10px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); color: var(--text); text-align: left;
}
.diary-score b { font-size: 24px; font-weight: 800; line-height: 1.1; }
.diary-score small { font-size: 13px; color: var(--text-mute); }
.diary-score span { font-size: 12px; font-weight: 600; color: var(--text-mute); }
.diary-score.active { border-color: var(--accent); }
/* Seltene Tage (ab etwa 1 von 100) hervorheben. */
.diary-score.rar { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: var(--primary-glow); }
.diary-score.rar small, .diary-score.rar span { color: var(--on-accent); opacity: .85; }
