/* ============================================================
   Apex — Dein Performance-OS · dunkles Premium-Theme
   ============================================================ */

:root {
  --bg: #0b0f14;
  --surface: #141a22;
  --surface-2: #1b2330;
  --surface-3: #222d3d;
  --border: #232d3a;
  --border-strong: #2f3b4b;
  --ink: #e8eef4;
  --ink-2: #9fb0c0;
  --muted: #64748b;
  --accent: #2dd4bf;
  --accent-soft: rgba(45, 212, 191, 0.14);
  --accent-strong: #14b8a6;
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.14);
  --green: #a3e635;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --sidebar-w: 248px;
  --font: "Inter", "Inter var", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -0.015em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: .84rem; }

::selection { background: rgba(45, 212, 191, .3); }

/* ---------- Shell-Layout ---------- */
.shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  z-index: 40;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 10px 18px;
}
.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #0ea5a0);
  color: #06211d;
  font-size: 15px;
  font-weight: 700;
  flex: 0 0 auto;
}
.brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.02em; }
.brand-sub { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }

.nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-section {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
  padding: 16px 10px 6px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-weight: 500;
  font-size: .92rem;
  transition: background .15s ease, color .15s ease;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-ico { width: 20px; text-align: center; font-size: .95rem; opacity: .9; }

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding: 12px 8px 2px;
  margin-top: 10px;
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  flex: 0 0 auto;
}
.user-meta { min-width: 0; }
.user-name { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main {
  margin-left: var(--sidebar-w);
  padding: 32px clamp(18px, 4vw, 44px) 60px;
  max-width: 1200px;
  outline: none;
}

/* Topbar (mobil) */
.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 35;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(11, 15, 20, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-brand { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.topbar-brand .logo-mark { width: 26px; height: 26px; font-size: 12px; border-radius: 8px; }
.nav-toggle { font-size: 1.1rem; padding: 6px 12px; }
.nav-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 39;
}

@media (max-width: 900px) {
  .topbar { display: flex; }
  .sidebar { transform: translateX(-105%); box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .nav-backdrop { display: block; }
  .main { margin-left: 0; padding: 20px 14px 60px; }
}

/* ---------- Karten & Grundbausteine ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card h2 { display: flex; align-items: center; gap: 8px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head p { margin: 2px 0 0; color: var(--ink-2); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1050px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: .9rem;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .1s ease, opacity .15s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  justify-content: center;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06211d;
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { color: var(--red); border-color: rgba(248,113,113,.35); background: transparent; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 5px 9px; line-height: 1; }

/* Formulare */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.input, select.input, textarea.input {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  font: inherit;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, .18);
}
textarea.input { resize: vertical; min-height: 70px; }
input[type="date"].input, input[type="time"].input { color-scheme: dark; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; align-items: end; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.check-row { display: flex; align-items: center; gap: 9px; font-size: .9rem; color: var(--ink-2); cursor: pointer; user-select: none; }
.check-row input { width: 17px; height: 17px; accent-color: var(--accent); }

/* Slider */
.slider-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.slider-row:last-of-type { border-bottom: none; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.slider-head .lab { font-weight: 600; }
.slider-val { font-size: 1.1rem; font-weight: 700; color: var(--accent); display: inline-flex; align-items: center; gap: 8px; }
.slider-val .emo { font-size: 1.25rem; }
input[type="range"] {
  width: 100%;
  appearance: none;
  height: 6px;
  border-radius: 4px;
  background: var(--surface-3);
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
}
input[type="range"]::-moz-range-thumb {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
}

/* Badges & Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-2);
  letter-spacing: .02em;
}
.badge-teal { background: var(--accent-soft); color: var(--accent); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.chip {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: .84rem;
  cursor: pointer;
  transition: all .15s ease;
}
.chip:hover { color: var(--ink); border-color: var(--accent); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Stat-Kacheln */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .stat-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.stat .stat-value { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.stat .stat-sub { font-size: .8rem; color: var(--ink-2); }
.stat-value .unit { font-size: .85rem; color: var(--muted); font-weight: 600; margin-left: 3px; }
.delta-up { color: var(--accent); }
.delta-down { color: var(--amber); }
.delta-neutral { color: var(--muted); }
.delta-bad { color: var(--red); }

/* Fortschrittsbalken */
.bar { height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .4s ease; }
.bar > i.warn { background: var(--amber); }

/* Tabellen / Listen */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th {
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num { font-variant-numeric: tabular-nums; }

.row-list { display: flex; flex-direction: column; }
.row-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.row-item:last-child { border-bottom: none; }
.row-item .grow { flex: 1; min-width: 0; }

/* Zustände */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 34px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  font-size: .92rem;
}
.error-state { text-align: center; color: var(--amber); padding: 30px; }

.skeleton { display: flex; flex-direction: column; gap: 16px; }
.sk {
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--surface) 40%, var(--surface-2) 50%, var(--surface) 60%);
  background-size: 220% 100%;
  animation: shimmer 1.3s infinite linear;
}
@keyframes shimmer { to { background-position: -120% 0; } }

.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toasts */
.toasts {
  position: fixed;
  bottom: 18px; right: 18px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 100;
  max-width: min(360px, calc(100vw - 30px));
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  color: var(--ink);
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: .88rem;
  animation: toast-in .25s ease;
}
.toast.error { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Auth ---------- */
.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(700px 400px at 20% -10%, rgba(45, 212, 191, .10), transparent 60%),
    radial-gradient(600px 350px at 95% 105%, rgba(245, 158, 11, .06), transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 400px; padding: 30px 28px; box-shadow: var(--shadow); }
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand .logo-mark { width: 46px; height: 46px; font-size: 20px; border-radius: 13px; margin-bottom: 10px; }
.auth-brand h1 { margin-bottom: 0; }
.auth-tagline { color: var(--muted); font-size: .86rem; margin: 0; }
.tabs { display: flex; background: var(--bg); border-radius: var(--radius-sm); padding: 4px; gap: 4px; margin-bottom: 18px; border: 1px solid var(--border); }
.tab {
  flex: 1; border: none; background: transparent; color: var(--ink-2);
  font: inherit; font-weight: 600; font-size: .88rem;
  padding: 8px; border-radius: 7px; cursor: pointer;
  transition: all .15s ease;
}
.tab.active { background: var(--surface-2); color: var(--ink); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.demo-hint {
  background: var(--accent-soft);
  border: 1px solid rgba(45, 212, 191, .3);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: .82rem;
  text-align: center;
}

/* ---------- Dashboard ---------- */
.dash-hero { display: grid; grid-template-columns: 320px 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .dash-hero { grid-template-columns: 1fr; } }

.ring-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
.ring-wrap { position: relative; width: 190px; height: 190px; margin: 8px 0 4px; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--surface-3); stroke-width: 13; }
.ring-value {
  fill: none;
  stroke-width: 13;
  stroke-linecap: round;
  transition: stroke-dashoffset .8s ease;
}
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-score { font-size: 2.6rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1; }
.ring-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); margin-top: 4px; }
.ring-reco { color: var(--ink-2); font-size: .9rem; max-width: 260px; }

.comp-card { padding: 14px 16px; }
.comp-head { display: flex; justify-content: space-between; align-items: baseline; }
.comp-name { font-size: .8rem; font-weight: 600; color: var(--ink-2); }
.comp-score { font-weight: 750; font-size: 1.25rem; }
.comp-detail { font-size: .78rem; color: var(--muted); margin-top: 3px; min-height: 2.2em; }

.brief-card { border-left: 3px solid var(--accent); }
.brief-bullets { margin: 8px 0 0; padding-left: 20px; color: var(--ink-2); }
.brief-bullets li { margin-bottom: 5px; }

.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 230px; }

/* ---------- Coach ---------- */
.coach-wrap { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 420px; }
.coach-log { flex: 1; overflow-y: auto; padding: 6px 4px; display: flex; flex-direction: column; gap: 12px; }
.bubble {
  max-width: 78%;
  padding: 11px 15px;
  border-radius: 16px;
  font-size: .92rem;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #06211d;
  border-bottom-right-radius: 5px;
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}
.bubble-meta { align-self: flex-start; margin: -6px 0 0 6px; }
.typing { display: inline-flex; gap: 5px; padding: 14px 16px; }
.typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.coach-composer { display: flex; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); margin-top: 12px; }
.coach-composer .input { flex: 1; }

/* ---------- Habits ---------- */
.habit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.habit-card { display: flex; flex-direction: column; gap: 10px; }
.habit-head { display: flex; align-items: center; gap: 10px; }
.habit-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: 1.25rem;
  flex: 0 0 auto;
}
.habit-title { flex: 1; min-width: 0; }
.habit-title h3 { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.streak { font-size: .82rem; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.dots { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.dot {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--surface-3);
}
.dot.on { background: var(--accent); }
.dot.on.bad { background: var(--amber); }
.dot.today-marker { outline: 1px solid var(--border-strong); outline-offset: 1px; }
.habit-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.habit-edit { border-top: 1px solid var(--border); padding-top: 12px; }

/* ---------- Insights ---------- */
.corr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.corr-card { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.corr-pair { font-weight: 650; font-size: .95rem; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.corr-pair .x { color: var(--muted); font-weight: 400; }
.corr-insight { color: var(--ink-2); font-size: .86rem; margin: 0; }
.report-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 8px; }
.report-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.focus-box {
  background: var(--accent-soft);
  border: 1px solid rgba(45, 212, 191, .3);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 16px;
}
.focus-box h3 { color: var(--accent); }
.hl-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 7px; color: var(--ink-2); font-size: .9rem; }

/* ---------- Ernährung ---------- */
.macro-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 800px) { .macro-cards { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Einstellungen ---------- */
.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 6px 0 18px;
}
.provider-card {
  appearance: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--ink-2);
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.provider-card:hover { border-color: var(--accent); color: var(--ink); }
.provider-card:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(45, 212, 191, .25); }
.provider-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.provider-card .provider-ico { font-size: 1.15rem; line-height: 1.2; }
.provider-card .provider-title { font-weight: 650; font-size: .92rem; }
.provider-card.active .provider-title { color: var(--accent); }
.provider-card .provider-sub { font-size: .76rem; color: var(--muted); }

.model-row { display: flex; gap: 8px; align-items: stretch; }
.model-row .input { flex: 1; min-width: 0; }
.model-row .btn { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 480px) { .model-row { flex-wrap: wrap; } .model-row .btn { flex: 1 1 100%; } }

.test-result { display: inline-flex; align-items: center; gap: 7px; font-size: .84rem; color: var(--ink-2); min-height: 24px; flex-wrap: wrap; }
.badge-ok { background: var(--accent-soft); color: var(--accent); }
.badge-fail { background: var(--red-soft); color: var(--red); }

.spinner-inline {
  width: 13px; height: 13px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  display: inline-block;
  vertical-align: -2px;
}

/* Nummerierte Setup-Schritte */
.setup-steps { margin: 4px 0 16px; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 10px; }
.setup-steps li { counter-increment: step; position: relative; padding-left: 38px; color: var(--ink-2); font-size: .92rem; min-height: 26px; }
.setup-steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700; font-size: .82rem;
}

/* Große Link-Code-Anzeige */
.link-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(1.5rem, 6vw, 2.2rem);
  font-weight: 700;
  letter-spacing: .35em;
  text-indent: .35em; /* gleicht das Nachlauf-Spacing des letzten Zeichens aus */
  text-align: center;
  color: var(--accent);
  background: var(--bg);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  padding: 18px 10px;
  margin: 10px 0 12px;
  user-select: all;
}

/* Status-Hinweise */
.warn-note {
  background: var(--amber-soft);
  border: 1px solid rgba(245, 158, 11, .3);
  color: var(--amber);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: .84rem;
  margin-top: 10px;
  overflow-wrap: anywhere;
}
.ok-note {
  background: var(--accent-soft);
  border: 1px solid rgba(45, 212, 191, .3);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .92rem;
}
.tg-status-line, .status-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* V4: Apple-Health-Import — 32-Zeichen-API-Key in der Code-Box lesbar halten */
.link-code.key-code {
  font-size: clamp(.9rem, 2.8vw, 1.15rem);
  letter-spacing: .08em;
  text-indent: 0;
  overflow-wrap: anywhere;
  padding: 14px 12px;
}

/* Bot-Befehls-Referenz */
.cmd-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 7px; font-size: .88rem; color: var(--ink-2); }
code.cmd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
  color: var(--ink);
  white-space: nowrap;
}

/* Sonstiges */
.inline-actions { display: flex; gap: 6px; align-items: center; }
.section-gap { margin-top: 24px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.val-chip {
  display: inline-block;
  min-width: 26px;
  text-align: center;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: .82rem;
}

/* ---------- V3: API on demand ---------- */

/* Segmented Control (API-Modus in den Einstellungen) */
.api-mode-field { margin-top: 16px; }
.api-mode-field > span .badge { margin-left: 6px; vertical-align: 1px; }
.segmented {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  max-width: 560px;
}
.seg-btn {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--ink-2);
  font-family: inherit;
  font-size: .88rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.seg-btn:hover { background: var(--surface-2); color: var(--ink); }
.seg-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(45, 212, 191, .25); }
.seg-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.seg-btn .seg-sub { font-size: .74rem; font-weight: 400; color: var(--muted); }
.seg-btn.active .seg-sub { color: var(--ink-2); }
@media (max-width: 480px) { .segmented { flex-direction: column; } .seg-btn { flex: 1 1 auto; } }

/* Queue-Banner auf der Coach-Seite */
.queue-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--amber-soft);
  border: 1px solid rgba(245, 158, 11, .3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 12px;
  font-size: .88rem;
  color: var(--ink);
}
.queue-banner-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.queue-banner-text strong { color: var(--amber); }
.queue-banner-err { font-size: .8rem; color: var(--red); overflow-wrap: anywhere; }
.queue-banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* „wartet auf Senden“-Chip unter unbeantworteten User-Bubbles */
.queue-chip {
  align-self: flex-end;
  margin: -8px 6px 0 0;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: .74rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- V4.1: Einklappbare Einstellungs-Sektionen ---------- */

.card.collapsible { padding: 0; }
.collapsible-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius);
  transition: background .15s ease;
}
.collapsible-head:hover { background: var(--surface-2); }
.collapsible-head:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(45, 212, 191, .25); }
.collapsible-head h2 { margin: 0; }
.collapsible-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.collapsible .chevron {
  display: inline-block;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1;
  transition: transform .18s ease;
}
.collapsible:not(.collapsed) .chevron { transform: rotate(90deg); } /* ▸ → ▾ */
.collapsible:not(.collapsed) .collapsible-head { border-radius: var(--radius) var(--radius) 0 0; }
.collapsible-body { padding: 2px 20px 20px; }
.collapsible.collapsed .collapsible-body { display: none; }

/* Status-Badges im Collapsible-Header */
.badge-connected {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(45, 212, 191, .35);
}
.badge-off { background: var(--amber-soft); color: var(--amber); }
