/* ═══════════ VibeyBall Theme: «Volleyball-warm» ═══════════
   Sand- und Orangetöne auf dunklem Blau; hell + dunkel über
   [data-theme] auf <html>. */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #ea580c;
  --accent-hover: #c2410c;
  --accent-grad: linear-gradient(135deg, #f97316, #ea580c);
  --accent-soft: rgba(234, 88, 12, .12);
  --accent-text: #c2410c;

  --bg: #f6f1e7;
  --bg-grad: radial-gradient(1200px 500px at 80% -10%, rgba(249, 115, 22, .07), transparent 60%);
  --panel: #fffdf8;
  --panel-soft: #faf6ee;
  --border: #e7ddcc;
  --text: #1e2433;
  --muted: #79715f;

  --header-grad: linear-gradient(120deg, #16203c 0%, #24345e 70%, #2d3f6e 100%);
  --header-line: #ea580c;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(30, 36, 51, .07), 0 4px 14px rgba(30, 36, 51, .05);
  --shadow-lift: 0 4px 10px rgba(30, 36, 51, .1), 0 10px 28px rgba(30, 36, 51, .08);
  --focus-ring: 0 0 0 3px rgba(234, 88, 12, .25);
}

:root[data-theme="dark"] {
  --accent: #f97316;
  --accent-hover: #fb8a3c;
  --accent-grad: linear-gradient(135deg, #f97316, #e04e08);
  --accent-soft: rgba(249, 115, 22, .16);
  --accent-text: #fb923c;

  --bg: #10131c;
  --bg-grad: radial-gradient(1200px 500px at 80% -10%, rgba(249, 115, 22, .08), transparent 60%);
  --panel: #1a1f2e;
  --panel-soft: #212739;
  --border: #2c3348;
  --text: #ece7dd;
  --muted: #98a0b3;

  --header-grad: linear-gradient(120deg, #0d1322 0%, #16203c 70%, #1b2849 100%);
  --header-line: #f97316;

  --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 4px 14px rgba(0, 0, 0, .25);
  --shadow-lift: 0 4px 10px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .35);
  --focus-ring: 0 0 0 3px rgba(249, 115, 22, .35);
}

html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-grad), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  transition: background-color .25s, color .25s;
}

.hidden { display: none !important; }

/* ═══════════ Header ═══════════ */
.app-header {
  background: var(--header-grad);
  border-bottom: 3px solid var(--header-line);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.app-header h1 { font-size: 1.3rem; font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.logo-icon { width: 1.2em; height: 1.2em; flex-shrink: 0; color: var(--accent); }
.app-header .subtitle { font-size: .85rem; font-weight: 400; opacity: .75; margin-left: 8px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.user-box { display: flex; align-items: center; gap: 12px; font-size: .9rem; }
.btn-header {
  background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .3);
  color: #fff; box-shadow: none;
}
.btn-header:hover { background: rgba(255, 255, 255, .22); }
.btn-theme { padding: 8px 10px; }

.view { max-width: 1240px; margin: 0 auto; padding: 24px 24px 60px; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar h2 { font-weight: 800; letter-spacing: -.01em; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ═══════════ Buttons ═══════════ */
.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s, background-color .12s;
}
.btn:hover { background: var(--panel-soft); transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--accent-grad);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-grad); filter: brightness(1.08); }
.btn-icon {
  border: none; background: none; cursor: pointer;
  font-size: .95rem; padding: 2px 6px; border-radius: 8px; color: var(--muted);
  box-shadow: none;
}
.btn-icon:hover { background: var(--accent-soft); color: var(--text); }
.btn-icon.danger:hover { color: #ef4444; }

/* ═══════════ Login / Registrierung ═══════════ */
.view-auth { display: flex; justify-content: center; padding-top: 7vh; }
.auth-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lift); padding: 28px; width: 100%; max-width: 390px;
  border-top: 4px solid var(--accent);
}
.auth-tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--panel-soft); border-radius: var(--radius-sm); padding: 4px; }
.auth-tab {
  flex: 1; border: none; background: none; padding: 8px; border-radius: 8px;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
}
.auth-tab.active { background: var(--panel); color: var(--accent-text); box-shadow: var(--shadow); }
#auth-form { display: flex; flex-direction: column; gap: 12px; }
#auth-form label { font-size: .8rem; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.auth-error { color: #ef4444; font-size: .85rem; }
.btn-block { width: 100%; padding: 11px; font-size: .95rem; }

/* ═══════════ Session-Übersicht ═══════════ */
.session-list { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.session-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  border-left: 4px solid var(--accent);
}
.session-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.session-card h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }
.session-card .meta { color: var(--muted); font-size: .85rem; }
.session-card .card-footer {
  display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 8px;
}
.card-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; white-space: nowrap; }

.badge {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: .8rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

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

/* ═══════════ Editor ═══════════ */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 900px) { .editor-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel h3 { margin-bottom: 12px; font-size: 1.05rem; font-weight: 700; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin-bottom: 22px;
}
.form-grid label { font-size: .8rem; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.form-grid .span-2 { grid-column: span 2; }

input, select, textarea {
  font: inherit;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
::placeholder { color: var(--muted); opacity: .65; }

.plan-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }

/* ═══════════ Trainingsablauf ═══════════ */
.plan-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.plan-item {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--panel-soft);
}
.plan-item .drag-handle {
  color: var(--muted); cursor: grab; font-size: 1rem; padding: 2px;
  user-select: none; touch-action: none;
}
.plan-item .drag-handle:active { cursor: grabbing; }
.plan-item.dragging { opacity: .45; }
.plan-item.drag-over { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.plan-item .order { color: var(--accent-text); font-weight: 800; font-size: .85rem; width: 20px; text-align: center; }
.plan-item .name { font-weight: 700; font-size: .92rem; }
.plan-item .cat { color: var(--muted); font-size: .78rem; }
.plan-item .item-actions { display: flex; align-items: center; gap: 4px; }
.plan-item .duration-input {
  width: 62px; text-align: right; padding: 5px 6px; font-size: .88rem;
}
.plan-item .unit { color: var(--muted); font-size: .8rem; margin-right: 6px; }
.plan-item .item-note { grid-column: 3 / -1; }
.plan-item .item-note input { font-size: .82rem; padding: 5px 8px; }

.time-range {
  color: var(--accent-text); font-weight: 700; font-size: .78rem; margin-left: 8px;
  background: var(--accent-soft); padding: 1px 8px; border-radius: 999px;
}

/* ═══════════ Übungsbibliothek ═══════════ */
.library-filters { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-bottom: 12px; }
@media (max-width: 600px) { .library-filters { grid-template-columns: 1fr; } }

.exercise-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 70vh; overflow-y: auto; padding-right: 4px;
}

.exercise-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--panel);
  transition: border-color .12s;
}
.exercise-card:hover { border-color: var(--accent); }
.exercise-card.custom { border-left: 3px solid var(--accent); background: var(--panel-soft); }
.exercise-card .ex-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.exercise-card .ex-name { font-weight: 700; font-size: .92rem; }
.ex-head-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.exercise-card .ex-tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.tag {
  font-size: .72rem; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-soft); color: var(--muted); border: 1px solid var(--border);
}
.tag.cat { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.tag.own { background: var(--accent-grad); color: #fff; border-color: transparent; font-weight: 600; }
.exercise-card .ex-desc { font-size: .82rem; color: var(--muted); }
.btn-add {
  background: var(--accent-grad); color: #fff; border: none;
  border-radius: 8px; padding: 6px 12px; font-size: .85rem; font-weight: 600;
  cursor: pointer; flex-shrink: 0;
  transition: filter .12s, transform .12s;
}
.btn-add:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* ═══════════ Dialoge ═══════════ */
dialog {
  margin: auto; /* zentrieren – der globale Reset (* { margin: 0 }) überschreibt sonst das Browser-Standardverhalten */
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 14px 50px rgba(0, 0, 0, .35);
  padding: 24px; width: min(440px, calc(100vw - 40px));
  background: var(--panel); color: var(--text);
  border-top: 4px solid var(--accent);
}
dialog::backdrop { background: rgba(13, 17, 28, .55); backdrop-filter: blur(2px); }
dialog h3 { margin-bottom: 12px; font-weight: 700; }
dialog form, dialog { font-size: .92rem; }
dialog label {
  font-size: .8rem; font-weight: 600; color: var(--muted);
  display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px;
}
.dlg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dlg-hint { color: var(--muted); font-size: .85rem; margin-bottom: 12px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.share-row { display: flex; gap: 8px; }
.share-row input { flex: 1; font-size: .85rem; color: var(--muted); }

/* ═══════════ Reiter (Trainings | Statistik) ═══════════ */
.tabs {
  display: flex; gap: 4px; background: var(--panel-soft);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px;
}
.tab {
  border: none; background: none; padding: 8px 20px; border-radius: 8px;
  font: inherit; font-weight: 700; color: var(--muted); cursor: pointer;
}
.tab.active { background: var(--panel); color: var(--accent-text); box-shadow: var(--shadow); }

/* ═══════════ Fokus-Tags & Ausgeführt ═══════════ */
.field-label { font-size: .8rem; font-weight: 600; color: var(--muted); display: block; margin-bottom: 4px; }
.tag-select { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 13px;
  font-size: .85rem; cursor: pointer; user-select: none; background: var(--panel);
  color: var(--text); font-weight: 500;
  transition: background-color .12s, border-color .12s, color .12s;
}
.tag-chip:hover { border-color: var(--accent); }
.tag-chip input { display: none; }
.tag-chip:has(input:checked) {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent-text); font-weight: 700;
}

.check-row {
  flex-direction: row !important; align-items: center; gap: 8px;
  align-self: end; padding-bottom: 8px; cursor: pointer;
}
.check-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: #16a34a; cursor: pointer; }
.check-row span { font-size: .88rem; color: var(--text); font-weight: 500; }

.done-toggle {
  border: 1px solid var(--border); border-radius: 999px;
  width: 26px; height: 26px; line-height: 1; font-weight: 700;
}
.done-toggle.is-done { background: #16a34a; border-color: #16a34a; color: #fff; }
.done-toggle.is-done:hover { background: #15803d; color: #fff; }
.session-card.is-done { border-left-color: #16a34a; }

/* ═══════════ Statistik (Spider Chart) ═══════════ */
.stats-sub { color: var(--muted); font-size: .85rem; margin: -6px 0 14px; }
.stats-grid {
  display: grid; grid-template-columns: minmax(280px, 440px) auto;
  gap: 28px; align-items: center; justify-content: start;
}
@media (max-width: 700px) { .stats-grid { grid-template-columns: 1fr; } }
.radar { width: 100%; max-width: 440px; height: auto; display: block; }
.radar-ring { fill: none; stroke: var(--border); stroke-width: 1; }
.radar-axis { stroke: var(--border); stroke-width: 1; }
.radar-ringlabel { fill: var(--muted); font-size: 9px; }
.radar-label { fill: var(--text); font-size: 13px; font-weight: 600; }
.radar-area {
  fill: var(--accent); fill-opacity: .22;
  stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round;
}
.radar-dot { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.stats-list { list-style: none; display: flex; flex-direction: column; gap: 10px; min-width: 190px; }
.stats-list li {
  display: flex; align-items: center; gap: 10px;
  font-size: .92rem; border-bottom: 1px solid var(--border); padding-bottom: 8px;
}
.stats-list .stats-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.stats-list .stats-label { flex: 1; color: var(--muted); }
.stats-list strong { font-weight: 800; }

/* ═══════════ Geteilte Ansicht ═══════════ */
.share-meta { color: var(--muted); font-size: .9rem; margin-bottom: 18px; }
.share-meta strong { color: var(--text); }
.plan-item-static { grid-template-columns: auto 1fr; }
.share-notes { margin-top: 16px; font-size: .9rem; color: var(--muted); }
.share-notes strong { color: var(--text); }

/* ═══════════ Fertig-Knopf im Editor ═══════════ */
.btn-done { border-color: #16a34a; color: #16a34a; font-weight: 700; }
.btn-done:hover { background: rgba(22, 163, 74, .1); }
:root[data-theme="dark"] .btn-done { border-color: #4ade80; color: #4ade80; }

/* ═══════════ Speicher-Indikator ═══════════ */
.toolbar-left { display: flex; align-items: center; gap: 12px; }
.save-status { font-size: .82rem; border: none; background: none; padding: 0; font-family: inherit; }
.save-status.saving { color: var(--muted); }
.save-status.saved { color: #16a34a; }
:root[data-theme="dark"] .save-status.saved { color: #4ade80; }
.save-status.error { color: #ef4444; cursor: pointer; text-decoration: underline; }

/* ═══════════ Toasts ═══════════ */
.toasts {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center;
}
.toast {
  display: flex; align-items: center; gap: 14px;
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px;
  font-size: .88rem; box-shadow: var(--shadow-lift);
  animation: toast-in .2s ease-out;
}
.toast button {
  border: none; background: none; color: var(--accent-hover); font: inherit;
  font-weight: 700; cursor: pointer; padding: 0;
}
:root[data-theme="dark"] .toast button { color: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ═══════════ Favoriten-Stern ═══════════ */
.btn-icon.star { font-size: 1.05rem; color: var(--muted); }
.btn-icon.star.is-fav { color: var(--accent); }
.btn-icon.star:hover { color: var(--accent-text); }

/* ═══════════ Vorlagen-Dialog ═══════════ */
.tpl-hint { margin-top: 14px; }
.tpl-list { display: flex; flex-direction: column; gap: 6px; max-height: 45vh; overflow-y: auto; }
.tpl-row { display: flex; align-items: center; gap: 6px; }
.tpl-pick {
  flex: 1; text-align: left; border: 1px solid var(--border); background: var(--panel-soft);
  border-radius: var(--radius-sm); padding: 9px 13px; cursor: pointer; font: inherit; color: var(--text);
  transition: border-color .12s;
}
.tpl-pick:hover { border-color: var(--accent); }
.tpl-pick .tpl-name { font-weight: 700; display: block; font-size: .92rem; }
.tpl-pick .tpl-meta { color: var(--muted); font-size: .78rem; }

/* ═══════════ Statistik-Filter ═══════════ */
.stats-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.seg {
  display: inline-flex; gap: 2px; background: var(--panel-soft);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px;
}
.seg button {
  border: none; background: none; font: inherit; font-size: .82rem; font-weight: 600;
  color: var(--muted); padding: 5px 13px; border-radius: 999px; cursor: pointer;
}
.seg button.active { background: var(--panel); color: var(--accent-text); box-shadow: var(--shadow); }
.stats-filters select { width: auto; font-size: .85rem; padding: 6px 10px; }

/* ═══════════ Editor auf Mobilgeräten ═══════════ */
.editor-tabs { display: none; gap: 4px; margin-bottom: 14px; background: var(--panel-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; }
.editor-tabs .tab { flex: 1; }
@media (max-width: 900px) {
  .editor-tabs { display: flex; }
  .editor-grid .panel-lib { display: none; }
  .editor-grid.show-lib .panel-lib { display: block; }
  .editor-grid.show-lib .panel-plan { display: none; }
  /* grössere Touch-Ziele */
  .btn-icon { padding: 8px 10px; font-size: 1.05rem; }
  .done-toggle { width: 34px; height: 34px; }
  .plan-item .duration-input { width: 70px; padding: 8px 6px; }
  .tag-chip { padding: 8px 15px; }
  .exercise-list { max-height: none; }
}
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .check-row { align-self: start; padding-bottom: 0; }
}

/* ═══════════ Nur-Lese-Modus (Trainerteam mit Rolle «Lesen») ═══════════ */
body.read-only .write-only { display: none !important; }
body.read-only #view-editor input,
body.read-only #view-editor select,
body.read-only #view-editor textarea { pointer-events: none; opacity: .7; }
body.read-only .plan-item .item-actions,
body.read-only .plan-item .drag-handle,
body.read-only .tag-select,
body.read-only #f-done,
body.read-only .btn-add,
body.read-only .btn-icon.star { pointer-events: none; opacity: .5; }

/* ═══════════ Header: Workspace & Konto ═══════════ */
.workspace-select {
  width: auto; font-size: .82rem; padding: 6px 8px;
  background: rgba(255, 255, 255, .12); color: #fff;
  border-color: rgba(255, 255, 255, .3); border-radius: var(--radius-sm);
}
.workspace-select option { color: var(--text); background: var(--panel); }

/* ═══════════ Matchtage ═══════════ */
.match-card { border-left-color: #b08d2f; }
.badge.match-badge { background: rgba(176, 141, 47, .16); color: #a1802a; }
:root[data-theme="dark"] .badge.match-badge { color: #e5c56b; background: rgba(229, 197, 107, .14); }

/* ═══════════ Nachbereitung ═══════════ */
.review-line { color: var(--muted); font-size: .82rem; margin-top: 6px; }
.review-summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .88rem; }
.star-row { display: flex; gap: 2px; margin: 4px 0 12px; }
.star-row button {
  border: none; background: none; font-size: 1.7rem; cursor: pointer;
  color: var(--border); padding: 0 2px; transition: color .1s, transform .1s;
}
.star-row button.active { color: var(--accent); }
.star-row button:hover { transform: scale(1.15); }

/* ═══════════ Saisonblöcke ═══════════ */
.tag.block-tag { background: rgba(37, 99, 235, .1); color: #2563eb; border-color: transparent; }
:root[data-theme="dark"] .tag.block-tag { color: #93b4f8; background: rgba(147, 180, 248, .12); }
.block-form { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; }
.block-row { cursor: default; }

/* ═══════════ Trainerteam ═══════════ */
.team-form { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; margin-bottom: 12px; }
.team-role-select { width: auto; font-size: .85rem; padding: 6px 8px; }

/* ═══════════ Übungs-Skizzen ═══════════ */
.ex-body { display: flex; gap: 10px; align-items: flex-start; }
.ex-thumb {
  width: 64px; max-height: 110px; object-fit: contain; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer;
}
.dlg-sketch { width: min(430px, calc(100vw - 40px)); }
.sketch-tools { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.sketch-tools button {
  border: 1px solid var(--border); background: var(--panel-soft); border-radius: 8px;
  font-size: 1rem; padding: 6px 10px; cursor: pointer;
}
.sketch-tools button.active { border-color: var(--accent); background: var(--accent-soft); }
.sketch-canvas {
  width: 100%; max-height: 52vh; display: block; border: 1px solid var(--border);
  border-radius: 8px; touch-action: none; background: #f8f5ee;
}
.sketch-upload-row { font-size: .82rem; color: var(--muted); margin-top: 10px; display: block; }
.sketch-upload-row input { margin-top: 4px; }
.sketch-existing { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.sketch-existing img { width: 90px; max-height: 120px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.danger-text { color: #ef4444; }

/* ═══════════ Varianten ═══════════ */
.ex-variants { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.variant-link {
  border: none; background: none; padding: 0; font-size: .78rem; font-weight: 600;
  color: var(--accent-text); cursor: pointer; text-decoration: underline dotted;
}
.variant-link:hover { text-decoration: underline; }
.tag.shared-tag { background: rgba(13, 148, 136, .12); color: #0d9488; border-color: transparent; }
:root[data-theme="dark"] .tag.shared-tag { color: #5eead4; background: rgba(94, 234, 212, .12); }
.dlg-check { margin-top: 4px; }

/* ═══════════ Teilen-Gültigkeit / Einladungscodes / Konflikt ═══════════ */
.share-expiry-row {
  display: flex; align-items: center; gap: 10px; margin-top: 12px;
  font-size: .85rem; font-weight: 600; color: var(--muted);
}
.share-expiry-row select { width: auto; }
.invite-code { font-family: ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .04em; }
.invites-list { margin-top: 12px; }
#btn-invite-create { width: 100%; }

/* ═══════════ Scrollbar (dezent, thematisch, global) ═══════════ */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }

/* ═══════════ Animationen ═══════════ */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes dlg-in {
  from { opacity: 0; transform: scale(.95) translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes sheet-in {
  from { transform: translateY(100%); }
  to { transform: none; }
}
@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes radar-in {
  from { opacity: 0; transform: scale(.6); }
  to { opacity: 1; transform: none; }
}
@keyframes pop {
  0% { transform: scale(.6); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* Ansichtswechsel: display none→block triggert die Animation automatisch neu */
.view { animation: fade-up .28s ease-out; }

/* Karten gestaffelt einblenden – aber nur direkt nach einem Ansichtswechsel
   (body.view-entering wird von switchView kurz gesetzt). So flackern
   Re-Renders (Suche tippen, Dauer ändern, Toggles) nicht. */
body.view-entering .session-card,
body.view-entering .exercise-card,
body.view-entering .plan-item { animation: fade-up .3s ease-out both; }
body.view-entering :is(.session-card, .exercise-card, .plan-item):nth-child(2) { animation-delay: .04s; }
body.view-entering :is(.session-card, .exercise-card, .plan-item):nth-child(3) { animation-delay: .08s; }
body.view-entering :is(.session-card, .exercise-card, .plan-item):nth-child(4) { animation-delay: .12s; }
body.view-entering :is(.session-card, .exercise-card, .plan-item):nth-child(5) { animation-delay: .16s; }
body.view-entering :is(.session-card, .exercise-card, .plan-item):nth-child(6) { animation-delay: .2s; }
.plan-item.dragging, .plan-item.drag-over { animation: none !important; }

/* Dialoge: sanft öffnen, Backdrop einblenden */
dialog[open] { animation: dlg-in .22s ease-out; }
dialog[open]::backdrop { animation: backdrop-in .22s ease-out; }

/* Spider Chart wächst aus dem Zentrum */
.radar-area, .radar-dot {
  transform-box: fill-box;
  transform-origin: center;
  animation: radar-in .45s cubic-bezier(.2, .8, .3, 1.1) both;
}
.radar-dot { animation-delay: .15s; animation-duration: .35s; }

/* Mikro-Interaktionen (Stern nur per Transition – die Bibliothek rendert beim
   Suchen ständig neu, eine Keyframe-Animation würde dort dauerpulsieren) */
.btn-icon.star { transition: transform .15s, color .15s; }
.btn-icon.star:hover { transform: scale(1.2); }
.done-toggle.is-done { animation: pop .3s ease-out; }
.logo-icon { transition: transform .5s cubic-bezier(.3, 1.4, .4, 1); }
.app-header h1:hover .logo-icon { transform: rotate(180deg); }
.btn:active, .btn-add:active, .tab:active { transform: scale(.97); }
.save-status { transition: color .25s, opacity .25s; }
.toast { animation: toast-in .25s cubic-bezier(.2, .9, .3, 1.15); }
.tag-chip:has(input:checked) { animation: pop .25s ease-out; }

/* Barrierefreiheit: Bewegungen respektvoll abschalten */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
  }
}

/* ═══════════ Auth-Hero & Empty States ═══════════ */
.auth-wrap { display: flex; flex-direction: column; align-items: center; gap: 22px; width: 100%; max-width: 390px; }
.auth-hero { text-align: center; color: var(--text); }
.auth-hero .auth-logo {
  width: 64px; height: 64px; color: var(--accent);
  filter: drop-shadow(0 4px 12px rgba(234, 88, 12, .3));
}
.auth-hero h2 { font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; margin-top: 6px; }
.auth-hero p { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.auth-card { width: 100%; }

.empty-hint { display: block; }
.empty-logo {
  display: block; width: 84px; height: 84px; margin: 0 auto 14px;
  color: var(--muted); opacity: .3;
}

/* ═══════════ Mobile-Feinschliff ═══════════ */
/* Safe-Area für Notch/Home-Indicator (installierte PWA) */
.app-header {
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  padding-top: max(14px, env(safe-area-inset-top));
}
.toasts { bottom: max(20px, env(safe-area-inset-bottom)); }

@media (max-width: 700px) {
  /* Kompakter Header: Untertitel weg, Konto-Knopf als Symbol */
  .app-header { padding-bottom: 10px; gap: 6px; }
  .app-header .subtitle { display: none; }
  .app-header h1 { font-size: 1.15rem; }
  #btn-account #user-name { display: none; }
  #btn-account::before { content: "👤"; }
  .user-box { gap: 6px; }
  .btn-header { padding: 8px 10px; }
  .workspace-select { max-width: 130px; }

  /* Übersichts-Toolbar: horizontal scrollbar statt Umbruch-Chaos */
  .toolbar { align-items: stretch; }
  .toolbar-actions {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding-bottom: 4px;
    max-width: 100%;
    scrollbar-width: none;
  }
  .toolbar-actions::-webkit-scrollbar { display: none; }
  .toolbar-actions .btn { flex-shrink: 0; scroll-snap-align: start; }
  #btn-new-session { order: -1; } /* wichtigster Knopf zuerst sichtbar */

  .view { padding: 16px 14px 60px; }
  .panel { padding: 16px 14px; }
}

@media (max-width: 600px) {
  /* Dialoge als Bottom-Sheets */
  dialog {
    position: fixed;
    margin: 0;
    top: auto; bottom: 0; left: 0; right: 0;
    width: 100%; max-width: 100%;
    border-radius: 18px 18px 0 0;
    border-left: none; border-right: none; border-bottom: none;
    max-height: 92dvh;
    overflow-y: auto;
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }
  dialog[open] { animation: sheet-in .28s cubic-bezier(.2, .9, .3, 1); }
  .dlg-sketch { width: 100%; }
  .sketch-canvas { max-height: 46dvh; }
}

@media (max-width: 900px) {
  /* Editor-Tabs bleiben beim Scrollen erreichbar */
  .editor-tabs {
    position: sticky;
    top: 8px;
    z-index: 20;
    box-shadow: var(--shadow-lift);
  }
}
