:root {
  --bg: #12141a;
  --surface: #1b1e26;
  --surface-2: #232733;
  --line: #2f3442;
  --text: #eef0f5;
  --muted: #98a0b3;
  --accent: #e5322d;
  --accent-soft: rgba(229, 50, 45, 0.16);
  --ok: #3ecf8e;
  --radius: 14px;
  --tap: 46px;

  --cat-mobilisieren: #6aa9ff;
  --cat-aufwaermen: #ff9f43;
  --cat-pratze-kissen: #e5322d;
  --cat-technik: #a978ff;
  --cat-cooldown: #3ecf8e;
}

/* Kategoriefarbe wird über das Attribut gesetzt, nicht über Inline-Styles —
   so bleibt die Content-Security-Policy ohne 'unsafe-inline' streng. */
[data-cat="mobilisieren"]  { --cat: var(--cat-mobilisieren); }
[data-cat="aufwaermen"]    { --cat: var(--cat-aufwaermen); }
[data-cat="pratze-kissen"] { --cat: var(--cat-pratze-kissen); }
[data-cat="technik"]       { --cat: var(--cat-technik); }
[data-cat="cooldown"]      { --cat: var(--cat-cooldown); }

/* Kleine Abstands- und Zustandshelfer (ersetzen frühere Inline-Styles) */
.grow { flex: 1; }
.center { text-align: center; }
.static { cursor: default; }
.gap-top { margin-top: 12px; }
.gap-top-lg { margin-top: 16px; }
.gap-top-xl { margin-top: 26px; }
.gap-bottom { margin-bottom: 14px; }
.chiprow.flush { padding-left: 0; padding-right: 0; margin: 0; }
.hint-inline { padding: 8px 0; text-align: left; }

.toast {
  position: fixed;
  left: 14px; right: 14px; bottom: 76px;
  z-index: 40;
  max-width: 752px;
  margin: 0 auto;
  background: var(--surface-2);
  border-color: var(--line);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { padding-bottom: env(safe-area-inset-bottom); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.25; }
ul { margin: 0; padding: 0; list-style: none; }

.app { max-width: 780px; margin: 0 auto; padding: 0 14px 108px; }

/* ---------- Kopfzeile ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 -14px;
  padding: 14px 14px 10px;
  background: linear-gradient(var(--bg) 78%, transparent);
  backdrop-filter: blur(8px);
}

.topbar-row { display: flex; align-items: center; gap: 10px; }
.topbar h1 { font-size: 22px; letter-spacing: -0.01em; flex: 1; }

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13.5px;
}
.summary strong { color: var(--text); font-weight: 600; }

/* ---------- Chips ---------- */

.chiprow {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 14px;
  margin: 0 -14px;
  scrollbar-width: none;
}
.chiprow::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}
.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

/* ---------- Slots ---------- */

.slots { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }

.slot {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--cat, var(--line));
  border-radius: var(--radius);
  overflow: hidden;
}
.slot[data-locked="true"] { border-color: var(--accent); }

.slot-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
}
.slot-num {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--cat, var(--line));
  color: #0f1116;
  font-size: 13px;
  font-weight: 800;
}
.slot-cat {
  flex: 1;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--cat, var(--muted));
}
.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 9px;
  font-size: 17px;
  color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }

.slot-empty {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 16px 12px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  text-align: left;
  font-size: 15px;
}
.slot-empty:hover { background: var(--surface-2); color: var(--text); }

.slot-body { padding: 0 12px 12px; }
.slot-title {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 17px;
  font-weight: 700;
  padding: 2px 0 4px;
}
.slot-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12.5px;
}
.slot-note {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13.5px;
}

/* Übungsliste mit Abwählen */

.items li { border-top: 1px solid var(--line); }
.items button {
  display: flex;
  gap: 10px;
  width: 100%;
  min-height: var(--tap);
  padding: 9px 2px;
  text-align: left;
  align-items: flex-start;
  font-size: 14.5px;
  line-height: 1.45;
}
.items .box {
  flex: 0 0 auto;
  width: 19px; height: 19px;
  margin-top: 2px;
  border: 2px solid var(--muted);
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: transparent;
}
/* Planung: angehakt = gehört dazu, abgewählt = durchgestrichen */
.items [data-on="true"] .box { background: var(--ok); border-color: var(--ok); color: #0f1116; }
.items [data-on="false"] span:last-child { color: var(--muted); text-decoration: line-through; }

/* Trainingsmodus: angehakt = erledigt */
.items [data-done="true"] .box { background: var(--ok); border-color: var(--ok); color: #0f1116; }
.items [data-done="true"] span:last-child { color: var(--muted); text-decoration: line-through; }

/* ---------- Aktionsleiste ---------- */

.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  gap: 8px;
  max-width: 780px;
  margin: 0 auto;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(18, 20, 26, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.actionbar button {
  flex: 1;
  min-height: var(--tap);
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 15px;
  font-weight: 600;
}
.actionbar button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  flex: 1.3;
}
.actionbar button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Navigation ---------- */

.nav {
  display: flex;
  gap: 4px;
  margin: 0 -14px 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}
.nav button {
  padding: 10px 12px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.nav button[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- Listen ---------- */

.list { display: flex; flex-direction: column; gap: 9px; }

.row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--cat, var(--line));
  border-radius: var(--radius);
}
.row:hover { background: var(--surface-2); }
.row h3 { font-size: 16px; margin-bottom: 3px; }
.row .sub { display: flex; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: 12.5px; }
.row .preview {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.group-title {
  margin: 20px 0 8px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--cat, var(--muted));
}

.empty-hint { padding: 28px 8px; color: var(--muted); text-align: center; }

/* ---------- Overlay / Sheet ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { flex: 1; font-size: 18px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 12px 14px 24px; }
.sheet-foot {
  display: flex;
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.sheet-foot button {
  flex: 1;
  min-height: var(--tap);
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-weight: 600;
}
.sheet-foot button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.sheet-foot button.danger { flex: 0 0 auto; padding: 0 16px; color: var(--accent); }
.sheet-inner { max-width: 780px; width: 100%; margin: 0 auto; }

/* ---------- Formular ---------- */

.field { margin-bottom: 14px; }
.field > label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.input {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline-offset: 2px;
}
.input:focus { border-color: var(--accent); outline: none; }
textarea.input { min-height: 74px; resize: vertical; }

.item-edit { display: flex; gap: 8px; margin-bottom: 8px; align-items: flex-start; }
.item-edit .input { flex: 1; }
.item-edit .icon-btn { flex: 0 0 auto; height: var(--tap); }

.linkbtn {
  padding: 8px 0;
  color: var(--accent);
  font-weight: 600;
  font-size: 14.5px;
}

.error {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  font-size: 14px;
}

/* ---------- Anmeldung ---------- */

.login {
  max-width: 340px;
  margin: 0 auto;
  padding: 15vh 18px 40px;
  text-align: center;
}
.login .logo { font-size: 42px; margin-bottom: 10px; }
.login h1 { font-size: 24px; margin-bottom: 6px; }
.login p { color: var(--muted); margin: 0 0 22px; font-size: 14.5px; }
.login button {
  width: 100%;
  min-height: var(--tap);
  margin-top: 10px;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

/* ---------- Trainingsmodus ---------- */

.run { min-height: 100dvh; display: flex; flex-direction: column; }
.run-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.run-progress { display: flex; gap: 4px; margin-bottom: 12px; }
.run-progress i {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}
.run-progress i[data-state="done"] { background: var(--ok); }
.run-progress i[data-state="current"] { background: var(--accent); }

.run-cat {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--cat, var(--muted));
}
.run-title { font-size: 25px; margin: 4px 0 8px; letter-spacing: -0.01em; }

.timer {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}
.timer .clock { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.timer .plan { color: var(--muted); font-size: 14px; }
.timer.over .clock { color: var(--accent); }

.run-body { flex: 1; overflow-y: auto; padding: 8px 16px 20px; }
.run-body .items button { min-height: 54px; font-size: 16.5px; }
.run-body .items .box { width: 23px; height: 23px; font-size: 14px; }

@media (min-width: 700px) {
  .run-title { font-size: 30px; }
  .run-body .items button { font-size: 17.5px; }
}

/* ---------- Drucken ---------- */

@media print {
  .topbar, .actionbar, .nav, .chiprow, .icon-btn, .slot-actions { display: none !important; }
  html, body { background: #fff; color: #000; }
  .slot, .row { border: 1px solid #999; break-inside: avoid; }
  .items [data-on="false"] { display: none; }
}
