:root {
  /* Athea — light by default */
  --brand: #1C1C1E;
  --brand-hover: #2c2c2e;
  --brand-dark: #1C1C1E;
  --bg: #F7F7F8;
  --bg-elevated: #ffffff;
  --bg-hover: #E5E5E7;
  --border: rgba(28, 28, 30, 0.08);
  --text: #1C1C1E;
  --text-muted: #6e6e73;
  --accent: #1C1C1E;
  --accent-hover: #2c2c2e;
  --accent-dim: rgba(28, 28, 30, 0.08);
  --accent-lavender: #DCD6FF;
  --ki-stern: #9699F2;
  --accent-mint: #D6F5E3;
  --ai-surface: #F3F0FF;
  --ai-surface-text: #1C1C1E;
  --success: #1f9d63;
  --warning: #c47f17;
  --error: #d94b4b;
  --cycling: #7B6FE3;
  --strength: #7B6FE3;
  --rest: #9a9aa1;
  --ring-sleep: #7B9FE8;
  --ring-recovery: #3db88a;
  --ring-strain: #7B6FE3;
  --radius: 20px;
  --radius-sm: 14px;
  --radius-lg: 28px;
  --space-section: 1.25rem;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', ui-monospace, 'JetBrains Mono', Menlo, monospace;
  --text-display: clamp(2.2rem, 6.5vw, 3.2rem);
  --text-title: 1.35rem;
  --text-body: 0.95rem;
  --text-caption: 0.72rem;
  --bottom-nav-offset: 0px;
  --tap-min: 48px;
  --chart-grid: rgba(28, 28, 30, 0.06);
  --chart-tooltip-bg: #ffffff;
  --chart-tooltip-text: #6e6e73;
  --chart-tooltip-title: #1C1C1E;
  --today-bg: rgba(220, 214, 255, 0.45);
  --completed-bg: rgba(214, 245, 227, 0.65);
  --surface-shadow: 0 10px 30px rgba(28, 28, 30, 0.06);
}

[data-theme="dark"] {
  --brand: #F7F7F8;
  --brand-hover: #ffffff;
  --brand-dark: #0e0e10;
  --bg: #0e0e10;
  --bg-elevated: #1C1C1E;
  --bg-hover: #2c2c2e;
  --border: rgba(255, 255, 255, 0.08);
  --text: #F7F7F8;
  --text-muted: #98989f;
  --accent: #F7F7F8;
  --accent-hover: #ffffff;
  --accent-dim: rgba(255, 255, 255, 0.1);
  --accent-lavender: #5a528a;
  --accent-mint: #2d5a45;
  --ai-surface: #2a2640;
  --ai-surface-text: #F7F7F8;
  --success: #34d399;
  --warning: #fbbf24;
  --error: #f87171;
  --cycling: #DCD6FF;
  --strength: #DCD6FF;
  --rest: #6b7280;
  --ring-sleep: #93c5fd;
  --ring-recovery: #34d399;
  --ring-strain: #DCD6FF;
  --chart-grid: rgba(255, 255, 255, 0.06);
  --chart-tooltip-bg: #1C1C1E;
  --chart-tooltip-text: #98989f;
  --chart-tooltip-title: #F7F7F8;
  --today-bg: rgba(220, 214, 255, 0.14);
  --completed-bg: rgba(214, 245, 227, 0.12);
  --surface-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  /* legacy alias — Athea default is already light */
}

.theme-toggle {
  line-height: 1;
  padding: 0.4rem 0.55rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle .hidden { display: none; }

.icon,
.icon-slot svg,
.tab-icon svg,
.btn-icon svg,
[data-icon] > svg {
  display: block;
  flex-shrink: 0;
}

.icon-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-inline {
  display: inline-block;
  vertical-align: -0.15em;
  margin-right: 0.15em;
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-left: 0.55rem;
  padding-right: 0.55rem;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

.hidden { display: none !important; }

/* Screens */
.screen {
  min-height: 100vh;
}

/* Onboarding */
.onboarding-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.onboarding-header {
  text-align: center;
  margin-bottom: 2rem;
}

.onboarding-header-top {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.onboarding-auth {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-right: auto;
}

.onboarding-auth-user {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.onboarding-theme {
  flex-shrink: 0;
}

.onboarding-header .brand {
  justify-content: center;
  margin-bottom: 0.25rem;
}

.onboarding-header .brand-wordmark {
  align-items: center;
  text-align: center;
}

.page-header .brand,
.app-header .brand {
  margin-right: auto;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand-logo-wrap {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: 12px;
  padding: 0;
  box-shadow: none;
  color: var(--text);
}

.brand-logo {
  display: block;
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.brand-logo--mark {
  width: 28px;
  height: 28px;
  display: block;
}

.brand--hero .brand-logo,
.brand--hero .brand-logo--mark {
  width: 44px;
  height: 44px;
}

.brand--hero .brand-logo-wrap {
  padding: 0;
  border-radius: 14px;
}

.brand-wordmark {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.15;
  color: var(--text);
}

.brand-accent {
  color: inherit;
  font-weight: inherit;
}

.brand-tagline {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--text-muted);
}

.brand--compact .brand-name {
  font-size: 1rem;
}

.brand--compact .brand-tagline {
  display: none;
}

.brand-page-title {
  display: none;
  font-size: var(--text-title);
  font-weight: 700;
  color: var(--text);
  margin-left: -0.15rem;
  letter-spacing: -0.02em;
}

.text-display {
  font-size: var(--text-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.text-caption {
  font-size: var(--text-caption);
  color: var(--text-muted);
  line-height: 1.4;
}

/* Floating primary action (above bottom tabs on mobile) */
.fab-primary {
  position: fixed;
  right: 1rem;
  bottom: calc(var(--bottom-nav-offset, 0px) + 0.85rem);
  z-index: 90;
  width: var(--tap-min);
  height: var(--tap-min);
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #041512;
  font: inherit;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.fab-primary:active {
  transform: scale(0.96);
}

@media (max-width: 768px) {
  body.has-bottom-tabs {
    --bottom-nav-offset: calc(78px + env(safe-area-inset-bottom, 0px));
  }

  body.has-bottom-tabs .fab-primary {
    display: inline-flex;
  }
}

/* Shared sheet / side panel */
.ui-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 230;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgba(0, 0, 0, 0.5);
  overscroll-behavior: contain;
  opacity: 0;
  animation: uiFadeIn 0.18s ease forwards;
}

@media (min-width: 769px) {
  .ui-sheet-overlay {
    align-items: stretch;
    justify-content: flex-end;
    background: rgba(0, 0, 0, 0.35);
  }
}

.ui-sheet {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: min(92dvh, 820px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  transform: translateY(12px);
  animation: uiSheetUp 0.22s ease forwards;
}

@media (min-width: 769px) {
  .ui-sheet {
    width: min(420px, 100%);
    max-height: 100%;
    height: 100%;
    border-radius: 0;
    border-left: 1px solid var(--border);
    transform: translateX(16px);
    animation: uiSheetIn 0.22s ease forwards;
  }
}

.ui-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.1rem 0.65rem;
  flex-shrink: 0;
}

.ui-sheet-head h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.ui-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.35rem 1.1rem 1rem;
}

.ui-sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 0.75rem 1.1rem calc(0.85rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

body.ui-sheet-open {
  overflow: hidden;
}

@keyframes uiFadeIn {
  to { opacity: 1; }
}

@keyframes uiSheetUp {
  to { transform: translateY(0); }
}

@keyframes uiSheetIn {
  to { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .ui-sheet-overlay,
  .ui-sheet,
  .fab-primary {
    animation: none !important;
    transition: none !important;
  }
}

.logo.compact h1 { font-size: 1.25rem; }

.logo-icon { font-size: 2rem; }
.logo h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 20%;
}

.step-indicator {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 2rem;
}

.onboarding-step {
  display: none;
  animation: fadeIn 0.3s ease;
}

.onboarding-step.active { display: block; }

.onboarding-step h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.onboarding-step p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (max-width: 500px) {
  .form-grid { grid-template-columns: 1fr; }
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

label.full-width { margin-bottom: 1rem; }

input, textarea, select {
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.2s;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 60px; }

select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

select:focus {
  outline: none;
  border-color: var(--accent);
}

.step-hint {
  margin: -0.25rem 0 1rem;
  font-size: 0.85rem;
}

fieldset.day-picker,
fieldset.onboarding-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin: 0 0 1rem;
}

fieldset.onboarding-fieldset .form-grid {
  margin-top: 0.25rem;
}

fieldset.day-picker {
  margin-top: 1rem;
}

fieldset legend {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0 0.25rem;
}

.day-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.day-checkboxes label {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-elevated);
  padding: 0.4rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text);
  transition: all 0.2s;
}

.day-checkboxes input:checked + span,
.day-checkboxes label:has(input:checked) {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Status cards */
.status-cards {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.status-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-card.ok .status-dot { background: var(--success); }
.status-card.warn .status-dot { background: var(--warning); }
.status-card.error .status-dot { background: var(--error); }

.info-box {
  background: var(--accent-dim);
  border: 1px solid rgba(79, 140, 255, 0.3);
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

.info-box code {
  font-family: var(--mono);
  background: var(--bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Buttons */
.btn {
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: #1C1C1E;
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #2c2c2e; color: #fff; }

[data-theme="dark"] .btn-primary {
  background: #F7F7F8;
  color: #1C1C1E;
}
[data-theme="dark"] .btn-primary:hover:not(:disabled) {
  background: #ffffff;
  color: #1C1C1E;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0.5rem;
}
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; }

.onboarding-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* Generating spinner */
.generating {
  text-align: center;
  padding: 2rem;
}

.setup-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--text-muted);
  text-align: center;
  gap: 0.75rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Main App Layout */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.main-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 57px);
  min-height: 0;
}

body.coach-page .main-layout.coach-layout {
  grid-template-columns: 1fr minmax(260px, 320px);
}

body.coach-page .plan-sidebar {
  border-right: none;
  border-left: 1px solid var(--border);
  order: 2;
}

body.coach-page .chat-area {
  order: 1;
  min-width: 0;
}

@media (max-width: 768px) {
  body.has-bottom-tabs {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  body.has-bottom-tabs .app-header,
  body.has-bottom-tabs .page-header {
    flex-shrink: 0;
  }

  body.has-bottom-tabs .main-layout {
    flex: 1;
    min-height: 0;
    height: auto;
    display: flex;
    flex-direction: column;
  }

  body.coach-page .plan-sidebar {
    display: none;
  }

  body.coach-page.coach-mode-plan .plan-sidebar,
  body.coach-page.plan-open .plan-sidebar {
    display: flex;
  }

  body.coach-page .coach-header {
    padding: 0.5rem 0.65rem;
    gap: 0.35rem;
    flex-wrap: nowrap;
  }

  body.coach-page .coach-header .main-nav {
    display: none;
  }

  body.coach-page .app-title-desktop {
    display: none;
  }

  body.coach-page .brand-tagline {
    display: none;
  }

  body.coach-page .brand-page-title {
    display: inline;
  }

  body.coach-page .brand-name {
    display: none;
  }

  body.coach-page .coach-mobile-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
  }

  body.coach-page .header-actions .btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0.45rem 0.55rem;
  }

  body.coach-page .sync-text {
    font-size: 0;
  }

  body.coach-page .btn-with-icon#btn-sync .sync-text {
    display: none;
  }

  body.coach-page .chat-messages {
    padding: 0.65rem 0.85rem 0.5rem;
    gap: 0.65rem;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    flex: 1 1 auto;
    min-height: 0;
  }

  body.coach-page .message {
    max-width: 92%;
    font-size: 0.92rem;
    padding: 0.7rem 0.85rem;
    line-height: 1.55;
  }

  body.coach-page .chat-composer {
    position: relative;
    z-index: 20;
    padding-bottom: 0;
    margin-bottom: var(--bottom-nav-offset, calc(78px + env(safe-area-inset-bottom, 0px)));
    transition: transform 0.15s ease-out;
    flex-shrink: 0;
    max-height: 42vh;
    overflow: visible;
  }

  body.coach-page .chat-input {
    padding: 0.55rem 0.7rem 0.65rem;
    gap: 0.5rem;
    flex-direction: row;
    align-items: flex-end;
    border-top: none;
    margin-bottom: 0;
  }

  body.coach-page .chat-input textarea {
    flex: 1;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    max-height: 140px;
    font-size: 16px;
    line-height: 1.45;
    padding: 0.7rem 0.8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
  }

  body.coach-page .chat-input .btn {
    width: auto;
    flex-shrink: 0;
    align-self: flex-end;
  }

  body.coach-page .plan-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(0, 0, 0, 0.45);
  }

  body.coach-page .plan-backdrop[hidden] {
    display: none;
  }

  body.coach-page .plan-sidebar {
    display: none;
    flex-direction: column;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    z-index: 95;
    max-height: min(78vh, 560px);
    margin: 0;
    border: 1px solid var(--border);
    border-left: none;
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
    transform: translateY(110%);
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.25s ease, visibility 0.25s;
    padding: 0;
    overflow: hidden;
    order: unset;
  }

  body.coach-page.plan-open .plan-sidebar {
    display: flex;
    transform: translateY(0);
    visibility: visible;
    pointer-events: auto;
  }

  body.coach-page .plan-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    flex-shrink: 0;
  }

  body.coach-page .plan-drawer-header h2 {
    margin: 0;
    font-size: 1rem;
  }

  body.coach-page .plan-sidebar-title {
    display: none;
  }

  body.coach-page .plan-sidebar .plan-meta,
  body.coach-page .plan-sidebar .plan-sessions {
    padding-inline: 0.85rem;
  }

  body.coach-page .plan-sidebar .plan-meta {
    padding-top: 0.75rem;
  }

  body.coach-page .plan-sidebar .plan-sessions {
    overflow-y: auto;
    flex: 1;
    padding-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
  }

  body.coach-page .toast {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  .main-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  body.coach-page .main-layout.coach-layout {
    grid-template-columns: 1fr;
  }

  .plan-sidebar {
    max-height: 200px;
    overflow-y: auto;
  }

  .chat-area {
    flex: 1;
    min-height: 0;
  }
}

/* Plan Sidebar */
.plan-sidebar {
  border-right: 1px solid var(--border);
  padding: 1.25rem;
  overflow-y: auto;
  background: var(--bg);
}

.plan-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.plan-drawer-header h2 {
  margin: 0;
  font-size: 1rem;
}

.plan-drawer-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.plan-sidebar h2 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.plan-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.session-card {
  padding: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  border-left: 3px solid var(--cycling);
}

.session-card.strength { border-left-color: var(--strength); }
.session-card.rest { border-left-color: var(--rest); opacity: 0.7; }

.session-card.is-today {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-elevated));
}

.session-card.plan-flash-card,
body.plan-flash .session-card.is-today {
  animation: planFlash 0.9s ease;
}

@keyframes planFlash {
  0%, 100% { box-shadow: none; }
  40% { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent); }
}

.session-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.session-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0.2rem 0;
}

.session-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  max-height: 3em;
  overflow: hidden;
}

/* Chat */
.chat-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.chat-quick-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  padding: 0.55rem 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.review-btn-short {
  display: none;
}

.last-workout-hint {
  font-size: 0.75rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  max-width: 85%;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: #1C1C1E;
  color: #fff;
  border-bottom-right-radius: 4px;
}

[data-theme="dark"] .message.user {
  background: var(--accent-lavender);
  color: #1C1C1E;
}

.message.assistant {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message.typing {
  color: var(--text-muted);
  font-style: italic;
}

.message.typing.coach-status {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-style: normal;
}

.coach-status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--accent);
  animation: coachPulse 1s ease infinite;
}

@keyframes coachPulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

.chat-input {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.chat-input textarea {
  flex: 1;
  resize: none;
}

.chat-input .btn {
  align-self: flex-end;
}

/* Coach page */
.coach-mobile-only,
.app-title-mobile,
.plan-drawer-header {
  display: none;
}

.app-title-desktop {
  display: inline;
}

.chat-composer {
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
}

.chat-empty {
  text-align: center;
  margin: auto;
  padding: 2rem 1rem;
  max-width: 20rem;
  line-height: 1.5;
}

.plan-backdrop {
  display: none;
}

.plan-sidebar-title {
  display: block;
}

#btn-send {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding-inline: 0.85rem;
  font-size: 1.1rem;
  line-height: 1;
}

/* Modal */
dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  background: var(--bg-elevated);
  color: var(--text);
  max-width: 480px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

dialog::backdrop {
  background: rgba(0,0,0,0.6);
}

.modal-content {
  padding: 1.5rem;
}

.modal-content h2 { margin-bottom: 1rem; }
.modal-content h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 1.25rem 0 0.75rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding: 0;
  border: none;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  z-index: 1000;
  animation: slideUp 0.3s ease;
}

.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }

@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (max-width: 768px) {
  .app-header {
    padding: 0.65rem 0.75rem;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .logo.compact h1 {
    font-size: 1.05rem;
  }

  .main-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .main-nav::-webkit-scrollbar {
    display: none;
  }

  .main-nav a {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .header-actions {
    margin-left: auto;
  }

  .plan-sidebar {
    max-height: 35vh;
    padding: 0.85rem;
  }

  .chat-quick-actions {
    padding: 0.5rem 0.7rem;
    gap: 0.4rem;
    flex-direction: column;
    align-items: stretch;
  }

  .chat-quick-actions .btn {
    width: 100%;
    min-height: 44px;
    font-size: 0.9rem;
  }

  .last-workout-hint {
    text-align: center;
    white-space: normal;
    line-height: 1.35;
  }

  body.coach-page .has-bottom-tabs .chat-input,
  body.coach-page .chat-input {
    margin-bottom: 0;
  }

  .chat-messages {
    padding: 0.9rem;
    gap: 0.65rem;
  }

  .message {
    max-width: 94%;
    font-size: 0.9rem;
    padding: 0.72rem 0.85rem;
  }

  .chat-input {
    padding: 0.7rem;
    gap: 0.55rem;
  }

  .chat-input textarea {
    min-height: 44px;
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .onboarding-container {
    padding: 1rem 0.8rem 2rem;
  }

  .onboarding-theme {
    top: -0.15rem;
    right: -0.25rem;
  }

  .status-cards {
    flex-direction: column;
    gap: 0.55rem;
  }

  .onboarding-nav {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    padding: 0.8rem 0 0;
    margin-top: 1rem;
  }

  .btn {
    min-height: 42px;
  }

  .btn-sm {
    min-height: 36px;
    padding: 0.35rem 0.65rem;
  }

  body.coach-page .chat-input {
    flex-direction: row;
    align-items: flex-end;
  }

  body.coach-page .chat-input textarea {
    min-height: 56px;
  }

  body.coach-page .chat-input .btn {
    width: auto;
    min-width: 48px;
    min-height: 48px;
    align-self: flex-end;
  }

  .chat-input {
    flex-direction: column;
  }

  .chat-input .btn {
    width: 100%;
    align-self: stretch;
  }

  .has-bottom-tabs .chat-input {
    margin-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  body.has-bottom-tabs .chat-input {
    margin-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  /* Coach: Offset sitzt am Composer, nicht nochmal am Input */
  body.coach-page.has-bottom-tabs .chat-input {
    margin-bottom: 0;
  }

  dialog {
    width: calc(100vw - 1rem);
    max-width: none;
    margin: 0.5rem;
  }

  .modal-content {
    padding: 1rem;
  }
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.75rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.login-brand {
  justify-content: center;
  margin-bottom: 1.5rem;
}

.login-brand .brand-wordmark {
  align-items: center;
  text-align: center;
}

.login-card h1 {
  font-size: 1.35rem;
  margin-bottom: 0.35rem;
  text-align: center;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.login-field input {
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.login-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.login-error {
  color: var(--danger, #ef4444);
  font-size: 0.85rem;
  text-align: center;
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 0.75rem 1rem;
}

/* === ATHEA SHELL & COMPONENTS === */
body.has-bottom-tabs .page-header,
body.has-bottom-tabs .app-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border-bottom: none;
}

body.has-bottom-tabs .header-left {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  z-index: 2;
  min-width: 0;
}

body.has-bottom-tabs .header-left .brand {
  margin-right: 0;
}

body.has-bottom-tabs .header-sync {
  flex-shrink: 0;
}

body.has-bottom-tabs .header-sync .sync-text {
  display: none;
}

body.has-bottom-tabs .header-actions {
  z-index: 2;
  margin-left: auto;
}

body.has-bottom-tabs .brand-name,
body.has-bottom-tabs .brand-tagline {
  display: none;
}

body.has-bottom-tabs .brand-page-title {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: var(--text);
  pointer-events: none;
  white-space: nowrap;
}

body.has-bottom-tabs .brand-page-title--stack {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.45rem;
}

body.has-bottom-tabs .brand-page-title-main {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

body.has-bottom-tabs .brand-page-title-sub {
  pointer-events: auto;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  opacity: 0.72;
}

body.has-bottom-tabs .brand-page-title-sub:active,
body.has-bottom-tabs .brand-page-title-sub:hover {
  opacity: 1;
  color: var(--text);
}

body.has-bottom-tabs .sync-text {
  display: none;
}

body.has-bottom-tabs .header-biologie-link {
  display: inline-flex;
}

body.has-bottom-tabs .main-nav {
  display: none;
}

@media (min-width: 900px) {
  body.has-bottom-tabs .page-header,
  body.has-bottom-tabs .app-header {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
  }

  body.has-bottom-tabs .main-nav {
    display: flex;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    gap: 0.25rem;
  }

  body.has-bottom-tabs .brand-page-title {
    display: none;
  }

  body.has-bottom-tabs .brand-name {
    display: inline;
  }

  body.has-bottom-tabs .header-biologie-link {
    display: inline-flex;
  }
}

.athea-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.athea-status-grid--flat {
  gap: 0.35rem 0.5rem;
}

.athea-status-ring {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 0.85rem 0.5rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid rgba(28, 28, 30, 0.06);
  border-radius: 20px;
  text-decoration: none;
  color: inherit;
}

.athea-status-grid--flat .athea-status-ring {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0.55rem 0.25rem 0.35rem;
  box-shadow: none;
}

.athea-status-ring-wrap {
  position: relative;
  width: 72px;
  height: 72px;
}

.athea-status-ring-svg {
  width: 72px;
  height: 72px;
  transform: rotate(-90deg);
}

.athea-status-ring-track,
.athea-status-ring-value {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
}

.athea-status-ring-track { stroke: var(--bg-hover); }
.athea-status-ring-value { stroke: #1C1C1E; }
.athea-status-ring--ready .athea-status-ring-value { stroke: #7B6FE3; }
.athea-status-ring--hrv .athea-status-ring-value { stroke: #7B9FE8; }
.athea-status-ring--rhr .athea-status-ring-value { stroke: #f2a39a; }
.athea-status-ring--recovery .athea-status-ring-value { stroke: #3db88a; }

[data-theme="dark"] .athea-status-ring-value { stroke: #F7F7F8; }
[data-theme="dark"] .athea-status-ring--ready .athea-status-ring-value { stroke: #DCD6FF; }
[data-theme="dark"] .athea-status-ring--hrv .athea-status-ring-value { stroke: #93c5fd; }
[data-theme="dark"] .athea-status-ring--rhr .athea-status-ring-value { stroke: #f2a39a; }
[data-theme="dark"] .athea-status-ring--recovery .athea-status-ring-value { stroke: #34d399; }

.athea-status-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.1;
}

.athea-status-ring-unit {
  font-size: 0.58rem;
  color: var(--text-muted);
  font-weight: 600;
  max-width: 4.8rem;
  line-height: 1.15;
}

.athea-status-ring-val {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.athea-status-grid--flat .athea-status-ring-val {
  font-size: 0.82rem;
}

.athea-status-ring-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.athea-reco-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1rem 1.05rem;
  border-radius: 20px;
  background: var(--ai-surface);
  color: var(--ai-surface-text);
  border: none;
}

.athea-reco-card--insight {
  padding: 1.05rem 1.1rem;
}

.athea-reco-layout {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.athea-reco-body {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 0;
  flex: 1;
}

.athea-reco-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.athea-reco-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(28, 28, 30, 0.06);
  flex-shrink: 0;
  color: var(--ki-stern);
}

.athea-reco-icon--bare {
  width: auto;
  height: auto;
  background: transparent;
  border-radius: 0;
  margin-top: 0.15rem;
}

.athea-reco-icon--bare .athea-ki-stern {
  width: 22px;
  height: 22px;
}

.athea-ki-stern {
  display: block;
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
  pointer-events: none;
  user-select: none;
}

.athea-reco-title {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 650;
}

.athea-reco-text {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.athea-reco-sub {
  margin: 0;
  font-size: 0.8rem;
  opacity: 0.75;
  line-height: 1.4;
}

.athea-session-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.athea-session-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.95rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid rgba(28, 28, 30, 0.06);
  border-radius: 18px;
}

.athea-session-rows {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.athea-session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.athea-session-row-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.athea-session-row-value {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  font-size: 0.88rem;
  font-weight: 650;
  text-align: right;
  color: var(--text);
  min-width: 0;
}

.overview-session-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  opacity: 0.85;
}

.athea-pill-toggle {
  display: inline-flex;
  padding: 0.2rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  gap: 0.15rem;
}

.athea-pill-toggle .page-view-btn,
.athea-pill-toggle .coach-mode-btn {
  border: none;
  border-radius: 999px;
  padding: 0.45rem 1.1rem;
  background: transparent;
  color: var(--text-muted);
  font-weight: 650;
  font-size: 0.88rem;
  cursor: pointer;
}

.athea-pill-toggle .page-view-btn.active,
.athea-pill-toggle .coach-mode-btn.active {
  background: #1C1C1E;
  color: #fff;
  box-shadow: none;
}

[data-theme="dark"] .athea-pill-toggle .page-view-btn.active,
[data-theme="dark"] .athea-pill-toggle .coach-mode-btn.active {
  background: #F7F7F8;
  color: #1C1C1E;
}

.athea-pill-composer {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.35rem 0.35rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--surface-shadow);
}

.athea-pill-composer textarea,
.athea-pill-composer #chat-input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  min-height: 24px;
  max-height: 88px;
  padding: 0.45rem 0.25rem;
  font: inherit;
  color: var(--text);
  outline: none;
}

.athea-pill-composer .btn-send-round,
.athea-pill-composer #btn-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: #1C1C1E;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

[data-theme="dark"] .athea-pill-composer #btn-send {
  background: #F7F7F8;
  color: #1C1C1E;
}

.athea-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  min-height: 52px;
  border: none;
  border-radius: 999px;
  background: #1C1C1E;
  color: #fff;
  font: inherit;
  font-weight: 650;
  font-size: 0.95rem;
  cursor: pointer;
}

.athea-cta:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

[data-theme="dark"] .athea-cta {
  background: #F7F7F8;
  color: #1C1C1E;
}

.athea-exercise-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem;
  background: var(--bg-elevated);
  border: 1px solid rgba(28, 28, 30, 0.06);
  border-radius: 16px;
}

.athea-exercise-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-hover);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 700;
}

.athea-exercise-body { min-width: 0; flex: 1; }
.athea-exercise-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}
.athea-exercise-meta {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}
