/* =================================================================
   KLIMAX DASHBOARD - Design-Token-System
   Bereichsfarben: Violett=Gym/Marke, Koralle=Kalorien, Grün=Habits,
   Bernstein=Kalender/Skip, Blau=Info. Hell-/Dunkel-Modus über Tokens.
   ================================================================= */

:root {
  /* DUNKEL (Default, auch bei System-Dunkelmodus) */
  --bg: #0F1017;
  --surface: #191B24;
  --surface-2: #20222E;
  --inset: #0E0F14;
  --border: #2A2D3B;
  --border-strong: #3A3F52;
  --text: #ECEDF3;
  --text-dim: #9BA0B2;
  --text-faint: #6A6F80;

  --violet: #7C5CFC;
  --coral: #FF6B57;
  --teal: #22C58B;
  --amber: #FFB020;
  --blue: #3B9EFF;
  --violet-soft: rgba(124, 92, 252, 0.17);
  --coral-soft: rgba(255, 107, 87, 0.17);
  --teal-soft: rgba(34, 197, 139, 0.17);
  --amber-soft: rgba(255, 176, 32, 0.17);
  --blue-soft: rgba(59, 158, 255, 0.17);
  --on-accent: #ffffff;

  --danger: #ff6b6b;
  --star: #E3C65F;

  --ring-track: #282B39;
  --glow-violet: rgba(124, 92, 252, 0.16);
  --glow-teal: rgba(34, 197, 139, 0.09);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 34px rgba(0, 0, 0, 0.45);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.30), 0 8px 22px rgba(0, 0, 0, 0.40);
}

/* Light-Tokens als wiederverwendbarer Block: greift automatisch bei
   System-Hell (sofern keine manuelle Wahl) UND bei manueller Wahl. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F1F1F8;
    --surface: #FFFFFF;
    --surface-2: #F4F4FA;
    --inset: #EDEDF5;
    --border: #E6E6EF;
    --border-strong: #D6D6E2;
    --text: #191A22;
    --text-dim: #5C6070;
    --text-faint: #9A9EAC;
    --violet-soft: rgba(124, 92, 252, 0.12);
    --coral-soft: rgba(255, 107, 87, 0.13);
    --teal-soft: rgba(34, 197, 139, 0.14);
    --amber-soft: rgba(255, 176, 32, 0.16);
    --blue-soft: rgba(59, 158, 255, 0.13);
    --danger: #E5484D;
    --ring-track: #ECECF4;
    --glow-violet: rgba(124, 92, 252, 0.10);
    --glow-teal: rgba(34, 197, 139, 0.06);
    --shadow: 0 1px 2px rgba(20, 20, 40, 0.04), 0 10px 30px rgba(30, 25, 70, 0.09);
    --shadow-card: 0 1px 2px rgba(20, 20, 40, 0.03), 0 6px 18px rgba(30, 25, 70, 0.07);
  }
}

:root[data-theme="light"] {
  --bg: #F1F1F8;
  --surface: #FFFFFF;
  --surface-2: #F4F4FA;
  --inset: #EDEDF5;
  --border: #E6E6EF;
  --border-strong: #D6D6E2;
  --text: #191A22;
  --text-dim: #5C6070;
  --text-faint: #9A9EAC;
  --violet-soft: rgba(124, 92, 252, 0.12);
  --coral-soft: rgba(255, 107, 87, 0.13);
  --teal-soft: rgba(34, 197, 139, 0.14);
  --amber-soft: rgba(255, 176, 32, 0.16);
  --blue-soft: rgba(59, 158, 255, 0.13);
  --danger: #E5484D;
  --ring-track: #ECECF4;
  --glow-violet: rgba(124, 92, 252, 0.10);
  --glow-teal: rgba(34, 197, 139, 0.06);
  --shadow: 0 1px 2px rgba(20, 20, 40, 0.04), 0 10px 30px rgba(30, 25, 70, 0.09);
  --shadow-card: 0 1px 2px rgba(20, 20, 40, 0.03), 0 6px 18px rgba(30, 25, 70, 0.07);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  min-height: 100%;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 900px 520px at 12% -5%, var(--glow-violet), transparent 60%),
    radial-gradient(ellipse 720px 500px at 100% 10%, var(--glow-teal), transparent 55%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}
.hidden { display: none !important; }
.screen { min-height: 100vh; min-height: 100dvh; }

/* LOGIN */
#login-screen { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 340px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 28px 24px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow);
}
.logo {
  width: 54px; height: 54px; border-radius: 16px; background: var(--violet); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; margin: 0 auto 4px;
  box-shadow: 0 8px 20px -6px var(--violet);
}
.login-card h1 { text-align: center; font-size: 19px; margin: 0 0 10px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
.login-card input {
  background: var(--inset); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; color: var(--text); font-size: 16px;
}
.login-card button[type="submit"] {
  margin-top: 6px; background: var(--violet); color: var(--on-accent); border: none;
  border-radius: 10px; padding: 13px; font-size: 15px; font-weight: 600;
  box-shadow: 0 6px 16px -6px var(--violet);
}
.error-text { color: var(--danger); font-size: 13px; min-height: 16px; margin: 0; text-align: center; }

/* APP SHELL */
#app-screen { display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 12px; position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.topbar-title { font-weight: 700; font-size: 18px; }
.topbar-date { font-size: 13px; color: var(--text-dim); text-transform: capitalize; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  width: 38px; height: 38px; border-radius: 11px; font-size: 16px; cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.icon-btn:active { border-color: var(--border-strong); }
.icon-btn.small { width: 32px; height: 32px; font-size: 15px; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn-spacer { display: inline-block; width: 38px; height: 38px; }

#main-content { flex: 1; padding: 6px 14px 90px; max-width: 640px; width: 100%; margin: 0 auto; }

/* EINSTELLUNGEN */
#settings-screen { display: flex; flex-direction: column; }
.settings-main { flex: 1; padding: 6px 14px 40px; max-width: 640px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.tab-panel { display: flex; flex-direction: column; gap: 14px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 16px; box-shadow: var(--shadow-card); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; gap: 8px; }
.card-header h2 { font-size: 15px; margin: 0; color: var(--text); }
.small-btn { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 9px; padding: 6px 12px; font-size: 12px; cursor: pointer; }
.primary-btn { background: var(--violet); color: var(--on-accent); border: none; border-radius: 9px; padding: 9px 18px; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: 0 5px 14px -6px var(--violet); }
.link-btn { background: none; border: none; color: var(--violet); font-size: 13px; padding: 8px 2px; text-align: left; cursor: pointer; }

/* THEME-UMSCHALTER (Einstellungen) */
.theme-toggle-row { display: flex; gap: 8px; margin-top: 4px; }
.theme-opt {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--inset); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 11px; padding: 11px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.theme-opt.active { background: var(--violet-soft); border-color: var(--violet); color: var(--violet); }

/* STAT TILES - je Kachel eine Bereichsfarbe */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px; text-align: center; cursor: pointer; box-shadow: var(--shadow-card);
  --tile: var(--violet);
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.stat-tile:active { transform: scale(0.97); border-color: var(--border-strong); }
.stat-value { font-size: 22px; font-weight: 800; color: var(--tile); letter-spacing: -0.02em; }
.stat-label { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.stat-grid .stat-tile:nth-child(1) { --tile: var(--blue); }
.stat-grid .stat-tile:nth-child(2) { --tile: var(--teal); }
.stat-grid .stat-tile:nth-child(3) { --tile: var(--violet); }
.stat-grid .stat-tile:nth-child(4) { --tile: var(--amber); }
.stat-grid .stat-tile:nth-child(5) { --tile: var(--coral); }

.item-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.item-list li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.item-list li:last-child { border-bottom: none; }
.item-list .empty-hint { color: var(--text-faint); font-style: italic; padding: 8px 4px; font-size: 13px; }

.checkbox {
  width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--border-strong);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: transparent; cursor: pointer;
}
.checkbox.done { background: var(--teal); border-color: var(--teal); color: var(--on-accent); }
.item-text { flex: 1; word-break: break-word; }
.item-text.done { text-decoration: line-through; color: var(--text-faint); }
.item-meta { font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.delete-btn { background: none; border: none; color: var(--text-faint); font-size: 17px; padding: 2px 6px; flex-shrink: 0; cursor: pointer; }
.star-btn { background: none; border: none; color: var(--star); font-size: 15px; padding: 2px 4px; flex-shrink: 0; cursor: pointer; }

.inline-form { display: flex; gap: 8px; margin-top: 10px; }
.inline-form input {
  flex: 1; background: var(--inset); border: 1px solid var(--border); border-radius: 11px;
  padding: 10px 12px; color: var(--text); font-size: 14.5px; min-width: 0;
}
.inline-form button { background: var(--violet); color: var(--on-accent); border: none; border-radius: 11px; width: 40px; font-size: 18px; flex-shrink: 0; cursor: pointer; }
.termin-form { flex-wrap: wrap; }
.termin-form input[type="date"] { flex: 1 1 130px; }
.termin-form input[type="time"] { flex: 0 1 90px; }
.termin-form input[type="text"] { flex: 1 1 100%; order: 3; }

/* HABIT CALENDAR */
.habit-cal-row { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.habit-cal-name { width: 90px; font-size: 12.5px; color: var(--text-dim); flex-shrink: 0; }
.habit-cal-days { display: flex; gap: 3px; flex: 1; }
.habit-cal-dot { width: 100%; aspect-ratio: 1; border-radius: 4px; background: var(--ring-track); }
.habit-cal-dot.done { background: var(--teal); }

/* HABIT RING */
.habit-ring-row { display: flex; gap: 16px; align-items: center; }
.habit-ring-wrap { position: relative; width: 84px; height: 84px; flex-shrink: 0; }
.habit-ring {
  position: relative; width: 84px; height: 84px; border-radius: 50%;
  background: conic-gradient(var(--teal) calc(var(--pct, 0) * 1%), var(--ring-track) 0);
}
.habit-ring::before { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.habit-ring-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: var(--text); z-index: 1;
}
.habit-ring-cal { flex: 1; min-width: 0; }

/* GYM: Tagesauswahl */
.gym-day-buttons { display: flex; flex-direction: column; gap: 8px; }
.gym-day-btn {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--inset); border: 1px solid var(--border); border-radius: 12px;
  padding: 13px 14px; color: var(--text); font-size: 14.5px; font-weight: 600;
}
.gym-day-badge { font-size: 11.5px; padding: 3px 9px; border-radius: 20px; font-weight: 600; flex-shrink: 0; }
.gym-day-badge.open { background: var(--surface-2); color: var(--text-dim); }
.gym-day-badge.done { background: var(--teal-soft); color: var(--teal); }
.gym-day-badge.skipped { background: var(--amber-soft); color: var(--amber); }
.gym-day-actions { display: flex; gap: 6px; margin-top: 4px; }
.gym-day-row {
  display: flex; flex-direction: column; gap: 10px; background: var(--inset);
  border: 1px solid var(--border); border-left: 3px solid var(--border-strong);
  border-radius: 12px; padding: 12px 14px;
}
.gym-day-row.done { border-left-color: var(--teal); }
.gym-day-row.skipped { border-left-color: var(--amber); }
.gym-day-row-top { display: flex; align-items: center; gap: 10px; }
.gym-day-ic {
  width: 32px; height: 32px; border-radius: 9px; background: var(--violet); color: #fff;
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.gym-day-ic svg { width: 17px; height: 17px; display: block; }
.gym-day-row-namecol { flex: 1; min-width: 0; }
.gym-day-row-name { font-size: 14.5px; font-weight: 600; }
.gym-day-row-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 1px; }
.gym-day-row-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.gym-day-row-btns button { font-size: 12.5px; padding: 8px 12px; border-radius: 9px; border: none; cursor: pointer; font-weight: 600; }
.gym-start-btn { background: var(--violet); color: var(--on-accent); }
.gym-skip-btn { background: var(--surface-2); color: var(--text-dim); }
.gym-view-btn { background: var(--surface-2); color: var(--violet); }
.gym-day-detail { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; margin-top: 2px; }
.gym-day-detail-row { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: 13px; }
.gym-day-detail-row .item-meta { white-space: nowrap; }

/* GYM: laufende Session */
.stopwatch { font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 700; color: var(--violet); }
.gym-ex-block { margin-bottom: 16px; }
.gym-ex-name { font-size: 14.5px; font-weight: 600; margin-bottom: 6px; }
.gym-ex-hint { font-size: 12.5px; color: var(--amber); margin: -3px 0 8px; }
.gym-set-row {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px;
  background: var(--inset); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
}
.gym-set-header { display: flex; justify-content: space-between; align-items: baseline; }
.gym-set-label { font-size: 12px; color: var(--text-dim); }
.gym-set-last { font-size: 11.5px; color: var(--text-faint); }
.gym-set-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gym-stepper {
  display: flex; align-items: center; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; flex-shrink: 0;
}
.gym-stepper-btn {
  width: 36px; height: 40px; border: none; background: none; color: var(--violet);
  font-size: 19px; font-weight: 700; cursor: pointer; flex-shrink: 0;
}
.gym-stepper-btn:active { background: var(--violet-soft); }
.gym-stepper input {
  width: 46px; min-width: 0; text-align: center; border: none; background: none;
  color: var(--text); font-size: 15.5px; font-weight: 600; padding: 8px 0;
}
.gym-stepper input::-webkit-outer-spin-button, .gym-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.gym-set-unit { font-size: 12.5px; color: var(--text-faint); flex-shrink: 0; }
.gym-set-check {
  width: 36px; height: 40px; border-radius: 10px; border: 1.5px solid var(--border-strong);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: transparent; font-size: 17px; cursor: pointer;
}
.gym-set-check.done { background: var(--teal); border-color: var(--teal); color: var(--on-accent); }
.gym-session-actions { display: flex; justify-content: space-between; margin-top: 8px; }
.gym-set-remove { background: none; border: none; color: var(--text-faint); font-size: 20px; padding: 4px 6px; flex-shrink: 0; margin-left: auto; cursor: pointer; }

/* GYM: Pause-Timer nach abgehaktem Satz */
.gym-rest-timer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--violet-soft); border: 1px solid var(--violet); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 12px;
}
.gym-rest-label { font-size: 14px; font-weight: 700; color: var(--violet); font-variant-numeric: tabular-nums; }
.gym-rest-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.gym-rest-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 12.5px; padding: 6px 9px; cursor: pointer;
}
.gym-rest-skip { color: var(--text-faint); font-size: 16px; padding: 6px 10px; }

/* FREIES TRAINING */
.uebung-chip-select { cursor: pointer; user-select: none; }
.uebung-chip-select.selected { background: var(--violet); border-color: var(--violet); color: var(--on-accent); }
.uebung-chip-select.selected .cat { color: rgba(255, 255, 255, 0.8); }

/* GYM: Plan editieren */
.plan-day-card { background: var(--inset); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.plan-day-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.plan-day-title { font-size: 14.5px; font-weight: 600; outline: none; border-bottom: 1px dashed transparent; flex: 1; }
.plan-day-title:focus { border-bottom-color: var(--violet); }
.plan-ex-row-structured { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.plan-ex-row-structured input {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 8px; color: var(--text); font-size: 13.5px; min-width: 0;
}
.plan-ex-name { flex: 1 1 auto; }
.plan-ex-sets { width: 38px; text-align: center; }
.plan-ex-reps { width: 58px; }
.plan-ex-weight { width: 52px; }
.plan-ex-x { color: var(--text-faint); font-size: 13px; flex-shrink: 0; }
.plan-add-ex-btn, .plan-del-day-btn { background: none; border: none; color: var(--violet); font-size: 12.5px; padding: 4px 2px; cursor: pointer; }
.plan-del-day-btn { color: var(--amber); }

.plan-add-controls { display: flex; align-items: center; gap: 6px; flex: 1 1 100%; flex-wrap: wrap; margin-top: 6px; }
.plan-add-controls input {
  background: var(--inset); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 8px; color: var(--text); font-size: 13.5px; min-width: 0;
}
.plan-add-controls .plan-ex-sets { width: 38px; text-align: center; }
.plan-add-controls .plan-ex-reps { width: 58px; }
.plan-add-controls .plan-ex-weight { width: 52px; }

.gym-history-day { margin-bottom: 14px; }
.gym-history-date { font-size: 12.5px; color: var(--text-dim); margin-bottom: 4px; font-weight: 600; }
.gym-history-entry { font-size: 13.5px; padding: 2px 0; color: var(--text); }
.gym-history-entry.skip { color: var(--amber); }
.gym-history-entry.duration { color: var(--text-faint); }

/* KALENDER */
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; color: var(--text-faint); margin-bottom: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-cell {
  aspect-ratio: 1; border-radius: 9px; background: var(--inset); border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 13px; color: var(--text); position: relative; cursor: pointer;
}
.cal-cell.outside { color: var(--text-faint); background: transparent; }
.cal-cell.today { border-color: var(--violet); }
.cal-cell.selected { background: var(--violet); color: var(--on-accent); }
.cal-dots { display: flex; gap: 2px; position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%); }
.cal-dot { width: 4px; height: 4px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }
.cal-gym-check {
  position: absolute; top: 3px; right: 4px; font-size: 9px; line-height: 1; color: var(--teal); font-weight: 700;
}
.cal-cell.selected .cal-gym-check { color: #d7fce9; }
.cal-day-detail { margin-top: 12px; }
.termin-color-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }

/* KALORIEN */
.kcal-total { text-align: center; font-size: 28px; font-weight: 800; color: var(--coral); margin: 6px 0 14px; letter-spacing: -0.02em; }
.kcal-total-unit { font-size: 14px; font-weight: 500; color: var(--text-dim); }
.macro-bars { display: flex; flex-direction: column; gap: 10px; }
.macro-bar { display: flex; align-items: center; gap: 8px; }
.macro-bar-label { width: 100px; font-size: 12.5px; color: var(--text-dim); flex-shrink: 0; }
.macro-bar-track { flex: 1; height: 8px; border-radius: 6px; background: var(--ring-track); overflow: hidden; }
.macro-bar-fill { height: 100%; background: var(--violet); border-radius: 6px; }
.macro-bar-value { width: 84px; text-align: right; font-size: 12px; color: var(--text); flex-shrink: 0; }

.kal-manual-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.kal-manual-form input {
  background: var(--inset); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font-size: 14px; flex: 1 1 45%; min-width: 0;
}
.kal-manual-form input#kal-manual-name, .kal-manual-form input#kal-manual-amount { flex-basis: 100%; }
.kal-manual-form button { flex-basis: 100%; }

.kal-search-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 12px 4px; border-bottom: 1px solid var(--border);
}
.kal-search-row:last-child { border-bottom: none; }
.kal-search-info { flex: 1 1 100%; min-width: 0; }
.kal-grams-input {
  width: 56px; background: var(--inset); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 6px; color: var(--text); font-size: 14px; flex-shrink: 0; text-align: center;
}
.kal-qty-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
.kal-unit-select {
  background: var(--inset); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 6px; color: var(--text); font-size: 13px; flex-shrink: 0; max-width: 110px;
}
.kal-add-btn { min-width: 40px; min-height: 38px; font-size: 18px; font-weight: 700; }
.kal-added-label { flex: 1 1 100%; font-size: 12.5px; color: var(--teal); font-weight: 600; }

/* MUSKELDIAGRAMM */
.muscle-toggle-wrap { flex: 1 1 100%; }
.muscle-toggle-btn { padding: 4px 2px; }
.muscle-panel { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.muscle-group-label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.muscle-img-row { display: flex; flex-wrap: wrap; gap: 10px; }
.muscle-img-item { width: 56px; text-align: center; }
.muscle-img-item img {
  width: 56px; height: auto; background: var(--inset); border-radius: 8px; border: 1px solid var(--border);
}
.muscle-img-label { font-size: 10.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.2; }

/* GANZKOERPER-MUSKELBELASTUNG */
.muscle-body-row { display: flex; gap: 14px; }
.muscle-body-col { flex: 1; min-width: 0; }
.muscle-body-label { font-size: 12px; color: var(--text-dim); text-align: center; margin-bottom: 6px; }
.muscle-body-stack {
  position: relative; width: 100%; aspect-ratio: 200 / 362;
  background: var(--inset); border-radius: 10px; border: 1px solid var(--border); overflow: hidden;
}
.muscle-body-stack img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
}
/* Neutraler Ganzkoerper-Umriss unter den farbigen Belastungs-Overlays. Die
   Original-Graustufen der wger-Grafik sind fuer Dunkel-Modus zu dunkel -> invertieren. */
.muscle-body-outline { opacity: 0.85; filter: invert(1); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .muscle-body-outline { filter: none; opacity: 0.5; }
}
:root[data-theme="light"] .muscle-body-outline { filter: none; opacity: 0.5; }
.muscle-load-legend { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.muscle-legend-row { display: flex; align-items: center; gap: 8px; }
.muscle-legend-name { width: 130px; flex-shrink: 0; font-size: 12.5px; color: var(--text); }
.muscle-legend-bar-track { flex: 1; height: 8px; border-radius: 6px; background: var(--ring-track); overflow: hidden; }
.muscle-legend-bar-fill { height: 100%; background: var(--violet); border-radius: 6px; }

.kal-goal-display { font-size: 13.5px; color: var(--text); }

.kal-meal-builder {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.kal-meal-builder > input[type="text"]#kal-meal-name {
  background: var(--inset); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font-size: 14.5px;
}
.kal-meal-builder .card-header { margin-top: 4px; }
.kal-meal-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.kal-meal-info { flex: 1; min-width: 0; }
.kal-meal-info .item-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kal-meal-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }

.macro-donut-row { display: flex; align-items: center; gap: 18px; }
#macro-donut {
  flex-shrink: 0; width: 100px; height: 100px;
  /* CSS-Anzeigegroesse fest verankern - drawMacroDonut() setzt canvas.width/height
     in Geraete-Pixeln (Retina-Displays haben devicePixelRatio 2-3), ohne dieses
     Overwrite wuerde die Anzeigegroesse mit hochskalieren statt nur die Schaerfe. */
}
.macro-donut-legend { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--text); }
.macro-donut-legend-row { display: flex; align-items: center; gap: 8px; }
.macro-donut-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* FORTSCHRITT / CHART */
.progress-select { display: flex; gap: 8px; margin-bottom: 10px; }
.progress-select select {
  flex: 1; background: var(--inset); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; color: var(--text); font-size: 14px;
}
.progress-chart-wrap { width: 100%; }
#progress-chart, #kcal-trend-chart { width: 100%; height: 160px; display: block; }
.progress-empty { color: var(--text-faint); font-style: italic; font-size: 13px; padding: 8px 4px; }

.uebung-chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }

/* FAVORITEN-KATEGORIEN */
.fav-category { margin-bottom: 10px; }
.fav-category summary {
  display: flex; align-items: center; justify-content: space-between; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--text); padding: 6px 2px; list-style: none;
}
.fav-category summary::-webkit-details-marker { display: none; }
.fav-category summary::before { content: '▸'; margin-right: 6px; color: var(--text-dim); }
.fav-category[open] summary::before { content: '▾'; }
.fav-cat-delete { background: none; border: none; color: var(--text-faint); font-size: 13px; padding: 2px 6px; cursor: pointer; }

.fav-chip-wrap { display: flex; flex-direction: column; gap: 6px; }
.fav-qty-row {
  display: flex; align-items: center; gap: 6px; background: var(--inset); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px 8px;
}
.fav-category .uebung-chip-row { margin-top: 4px; padding-left: 4px; }
.uebung-chip {
  display: flex; align-items: center; gap: 6px; background: var(--inset); border: 1px solid var(--border);
  border-radius: 20px; padding: 6px 8px 6px 12px; font-size: 12.5px; color: var(--text);
}
.uebung-chip button { background: none; border: none; color: var(--text-faint); font-size: 15px; padding: 0 2px; cursor: pointer; }
.uebung-chip .cat { color: var(--text-faint); }

/* ÜBERSICHT: Begrüßung + Widget-Dashboard */
.greeting { padding: 2px 2px 6px; }
.greeting h2 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.greeting p { margin: 3px 0 0; font-size: 13px; color: var(--text-dim); text-transform: capitalize; }

.wgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.w {
  border-radius: 18px; padding: 14px; cursor: pointer; position: relative; overflow: hidden;
  box-shadow: var(--shadow-card); border: 1px solid transparent;
  transition: transform 0.12s ease;
}
.w:active { transform: scale(0.97); }
.w.big { grid-column: span 2; display: flex; align-items: center; gap: 14px; }
.w .wi {
  width: 34px; height: 34px; border-radius: 11px; color: #fff;
  display: flex; align-items: center; justify-content: center; margin-bottom: 10px;
}
.w.big .wi { margin-bottom: 0; flex-shrink: 0; }
.w .wv { font-size: 23px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; color: var(--text); }
.w .wv .wu { font-size: 13px; font-weight: 600; color: var(--text-dim); letter-spacing: 0; }
.w .wl { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }
.w svg { display: block; }

.w.coral  { background: var(--coral-soft); }  .w.coral  .wi { background: var(--coral); }
.w.violet { background: var(--violet-soft); } .w.violet .wi { background: var(--violet); }
.w.teal   { background: var(--teal-soft); }   .w.teal   .wi { background: var(--teal); }
.w.amber  { background: var(--amber-soft); }  .w.amber  .wi { background: var(--amber); }
.w.blue   { background: var(--blue-soft); }   .w.blue   .wi { background: var(--blue); }

.miniring { width: 62px; height: 62px; flex-shrink: 0; position: relative; }
.miniring .ml { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800; }

.wdots { display: flex; gap: 4px; margin-top: 9px; }
.wdots i { flex: 1; height: 7px; border-radius: 4px; background: var(--ring-track); }
.wdots i.f { background: var(--teal); }

.w-termin-text { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* KARTEN-ÜBERSCHRIFTEN MIT ICON-BADGE */
.card-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.card-title h2 { margin: 0; }
.card-ic {
  width: 28px; height: 28px; border-radius: 9px; color: #fff; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.card-ic svg { width: 16px; height: 16px; display: block; }
.card-ic.blue { background: var(--blue); }
.card-ic.teal { background: var(--teal); }
.card-ic.amber { background: var(--amber); }
.card-ic.violet { background: var(--violet); }
.card-ic.coral { background: var(--coral); }

/* KALORIEN: Ring-Hero */
.kcal-hero { display: flex; align-items: center; gap: 16px; }
.kcal-ring { position: relative; width: 128px; height: 128px; flex-shrink: 0; }
.kcal-ring .kr-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.kcal-ring .kr-val { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.kcal-ring .kr-lbl { font-size: 10.5px; color: var(--text-dim); margin-top: 3px; }
.kcal-side { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.kcal-side-row { display: flex; align-items: center; gap: 10px; }
.kcal-side-ic { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kcal-side-ic.coral { background: var(--coral-soft); color: var(--coral); }
.kcal-side-ic.violet { background: var(--violet-soft); color: var(--violet); }
.kcal-side-row b { font-size: 14.5px; display: block; line-height: 1.15; }
.kcal-side-row span { font-size: 10.5px; color: var(--text-dim); }

.macro-mini-row { display: flex; gap: 10px; margin-top: 16px; }
.macro-mini { flex: 1; }
.macro-mini-top { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 5px; }
.macro-mini-top b { font-weight: 600; }
.macro-mini-top span { color: var(--text-faint); }
.macro-mini-bar { height: 5px; border-radius: 4px; background: var(--ring-track); overflow: hidden; }
.macro-mini-bar i { display: block; height: 100%; border-radius: 4px; }

/* KALORIEN: Mahlzeiten-Blöcke (Frühstück/Mittag/Abend/Snacks) */
.meal-block { border-top: 1px solid var(--border); padding: 11px 0; }
.meal-block:first-child { border-top: none; padding-top: 2px; }
.meal-block-head { display: flex; align-items: center; gap: 11px; }
.meal-ic { width: 36px; height: 36px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.meal-ic svg { width: 18px; height: 18px; }
.meal-ic.b { background: var(--amber-soft); color: var(--amber); }
.meal-ic.l { background: var(--coral-soft); color: var(--coral); }
.meal-ic.d { background: var(--violet-soft); color: var(--violet); }
.meal-ic.s { background: var(--teal-soft); color: var(--teal); }
.meal-block-title { flex: 1; min-width: 0; }
.meal-block-title b { font-size: 13.5px; display: block; }
.meal-block-title span { font-size: 11.5px; color: var(--text-faint); }
.meal-kcal { font-size: 12.5px; color: var(--text-dim); font-weight: 600; margin-right: 2px; }
.meal-add {
  width: 28px; height: 28px; border-radius: 9px; background: var(--coral-soft); color: var(--coral);
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
  border: none; font-size: 17px; cursor: pointer; box-shadow: 0 4px 12px -4px var(--coral);
}
.meal-items { list-style: none; margin: 7px 0 0; padding: 0 0 0 47px; display: flex; flex-direction: column; gap: 3px; }
.meal-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); }
.meal-item .mi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal-item .mi-kcal { color: var(--text-faint); white-space: nowrap; }
.meal-item .mi-star { background: none; border: none; color: var(--star); font-size: 13px; padding: 0 2px; cursor: pointer; }
.meal-item .mi-del { background: none; border: none; color: var(--text-faint); font-size: 15px; padding: 0 3px; cursor: pointer; }

/* Schnellzugriff-Chips "Zuletzt & häufig" */
.quick-chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 3px; -webkit-overflow-scrolling: touch; }
.quick-chips::-webkit-scrollbar { display: none; }
.quick-chip {
  flex-shrink: 0; background: var(--inset); border: 1px solid var(--border); border-radius: 20px;
  padding: 8px 13px; font-size: 12px; color: var(--text); white-space: nowrap; cursor: pointer;
}
.quick-chip b { color: var(--text-faint); font-weight: 600; margin-left: 5px; }
.quick-chip:active { border-color: var(--coral); }

/* TAB BAR */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 5;
  box-shadow: 0 -6px 20px -12px rgba(0, 0, 0, 0.4);
}
.tab-btn { flex: 1; background: none; border: none; color: var(--text-faint); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; font-size: 11px; border-radius: 12px; cursor: pointer; transition: color 0.15s ease; }
.tab-btn.active { color: var(--violet); }
.tab-icon { font-size: 19px; }

/* BARCODE-SCANNER */
.scan-overlay {
  position: fixed; inset: 0; background: #000; z-index: 500;
  display: flex; align-items: center; justify-content: center;
}
.scan-overlay video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: relative; width: 78vw; max-width: 340px; height: 34vw; max-height: 150px;
  border: 3px solid var(--coral); border-radius: 14px; box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.45);
}
.scan-hint {
  position: absolute; bottom: 14%; left: 0; right: 0; text-align: center;
  color: #fff; font-size: 14px; font-weight: 600; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.scan-close {
  position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px;
  background: rgba(255, 255, 255, 0.15); color: #fff; width: 38px; height: 38px; font-size: 17px;
}
