/* ═══════════════════════════════════════════════
   CSS Variables & Reset
═══════════════════════════════════════════════ */
:root {
  --primary:       #2d9e6b;
  --primary-dark:  #1e7a50;
  --primary-light: #e8f5ee;
  --danger:        #e05252;
  --warning:       #e8a020;
  --info:          #3a8fd4;
  --success:       #2d9e6b;
  --text:          #1e2b24;
  --text-muted:    #6b7d74;
  --bg:            #f2f7f4;
  --card:          #ffffff;
  --border:        #dde8e3;
  --nav-height:    62px;
  --header-height: 52px;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-top: var(--header-height);
  padding-bottom: var(--nav-height);
  -webkit-tap-highlight-color: transparent;
}

/* ═══════════════════════════════════════════════
   Header
═══════════════════════════════════════════════ */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* ═══════════════════════════════════════════════
   Main / Sections
═══════════════════════════════════════════════ */
#main-content {
  padding: 12px 12px 0;
  max-width: 520px;
  margin: 0 auto;
}

.section { display: none; }
.section.active { display: block; }

/* ═══════════════════════════════════════════════
   Cards
═══════════════════════════════════════════════ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
}
.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.card-title-row .card-title { margin-bottom: 0; }

/* ═══════════════════════════════════════════════
   Buttons
═══════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.12s, transform 0.1s;
  line-height: 1.2;
  white-space: nowrap;
}
.btn:active { opacity: 0.75; transform: scale(0.97); }
.btn-primary  { background: var(--primary); color: white; border-color: var(--primary); }
.btn-danger   { background: var(--danger);  color: white; border-color: var(--danger); }
.btn-warning  { background: var(--warning); color: white; border-color: var(--warning); }
.btn-outline  { background: white; color: var(--primary); border-color: var(--primary); }
.btn-outline-danger { background: white; color: var(--danger); border-color: var(--danger); }
.btn-ghost    { background: transparent; color: var(--text-muted); border-color: transparent; font-weight: 500; }
.btn-block    { width: 100%; }
.btn-sm       { padding: 7px 12px; font-size: 13px; }
.btn-xs       { padding: 4px 8px; font-size: 12px; }
.btn-done     { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* ═══════════════════════════════════════════════
   Bottom Navigation
═══════════════════════════════════════════════ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 200;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px 4px;
  transition: color 0.15s;
}
.nav-item.active { color: var(--primary); }
.nav-icon  { font-size: 22px; line-height: 1; }
.nav-label { font-size: 10px; font-weight: 600; letter-spacing: 0.2px; }

/* ═══════════════════════════════════════════════
   Sub-Navigation (Sport tabs)
═══════════════════════════════════════════════ */
.sub-nav {
  display: flex;
  background: white;
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  gap: 2px;
}
.sub-nav-item {
  flex: 1;
  padding: 8px 4px;
  background: none;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sub-nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}

/* ═══════════════════════════════════════════════
   Forms
═══════════════════════════════════════════════ */
.form-group { margin-bottom: 10px; }
.form-label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; font-weight: 500; }
.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: white;
  color: var(--text);
  transition: border-color 0.15s;
  appearance: none;
}
.form-input:focus { outline: none; border-color: var(--primary); }
textarea.form-input { resize: vertical; min-height: 60px; }
.form-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.form-row .form-input { flex: 1; }

/* ═══════════════════════════════════════════════
   Grid helpers
═══════════════════════════════════════════════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }

/* ═══════════════════════════════════════════════
   Timer (abstinence + fasting)
═══════════════════════════════════════════════ */
.timer {
  font-size: 38px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  color: var(--primary);
  line-height: 1.1;
}
.timer.inactive { color: var(--text-muted); }
.abstinence-display { text-align: center; padding: 4px 0 8px; }
.abstinence-meta { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.highscore-val { font-weight: 700; color: var(--primary); }

/* ═══════════════════════════════════════════════
   Streak mini (Heute cards)
═══════════════════════════════════════════════ */
.streak-mini {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  padding: 4px 0;
}

/* ═══════════════════════════════════════════════
   Fasting Card
═══════════════════════════════════════════════ */
.fasting-display { text-align: center; }
.fasting-elapsed {
  font-size: 42px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  color: var(--primary);
}
.fasting-elapsed.past-goal { color: var(--success); }
.progress-bar {
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
  margin: 10px 0;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 5px;
  transition: width 0.5s;
}
.fasting-meta { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }

/* ═══════════════════════════════════════════════
   Water Display
═══════════════════════════════════════════════ */
.water-display { text-align: center; }
.water-amount {
  font-size: 36px;
  font-weight: 700;
  color: var(--info);
}
.water-glasses-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: 10px 0;
}
.water-glass {
  font-size: 26px;
  line-height: 1;
  filter: grayscale(1) opacity(0.25);
  transition: filter 0.2s;
}
.water-glass.filled { filter: none; }

/* ═══════════════════════════════════════════════
   Workout Exercises
═══════════════════════════════════════════════ */
.exercise-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.exercise-item:last-child { border-bottom: none; }
.exercise-info { flex: 1; min-width: 0; }
.exercise-name { font-weight: 600; font-size: 15px; }
.exercise-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.exercise-action { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.sets-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}
.set-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.set-dot.done { background: var(--primary); }

/* ═══════════════════════════════════════════════
   Hygiene Grid
═══════════════════════════════════════════════ */
.hygiene-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.hygiene-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  text-align: center;
}
.hygiene-btn.done {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.hygiene-icon { font-size: 28px; }
.hygiene-label { font-size: 12px; }
.hygiene-check { font-size: 16px; }

/* ═══════════════════════════════════════════════
   Sleep
═══════════════════════════════════════════════ */
.sleep-display { text-align: center; padding: 6px 0; }
.sleep-state-label { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.sleep-duration { font-size: 36px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }

/* ═══════════════════════════════════════════════
   History Lists
═══════════════════════════════════════════════ */
.history-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.history-item:last-child { border-bottom: none; }
.history-value { font-weight: 700; font-size: 15px; white-space: nowrap; }
.history-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.history-right { text-align: right; flex-shrink: 0; }
.history-date { font-size: 12px; color: var(--text-muted); }

/* Blood pressure category badge */
.bp-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.bp-normal  { background: #e8f5ee; color: var(--primary); }
.bp-high    { background: #fdecea; color: var(--danger); }
.bp-low     { background: #fff3e0; color: var(--warning); }

/* ═══════════════════════════════════════════════
   Weight Chart (simple sparkline)
═══════════════════════════════════════════════ */
.weight-latest {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 8px;
}
.weight-value  { font-size: 40px; font-weight: 700; color: var(--primary); }
.weight-unit   { font-size: 18px; color: var(--text-muted); }
.weight-change { font-size: 14px; font-weight: 600; }
.weight-change.up   { color: var(--danger); }
.weight-change.down { color: var(--primary); }
.sparkline { display: block; width: 100%; height: 60px; margin: 4px 0; }

/* ═══════════════════════════════════════════════
   Modal
═══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  padding: 0;
  transition: opacity 0.2s;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: white;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px 16px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
}
.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 14px;
  padding-right: 30px;
}

/* ═══════════════════════════════════════════════
   Workout Timer Overlay
═══════════════════════════════════════════════ */
.timer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 40, 28, 0.97);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.timer-overlay.hidden { display: none; }
.timer-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px;
  width: 100%;
  max-width: 320px;
  position: relative;
}
.timer-exercise-name {
  font-size: 22px;
  font-weight: 700;
  color: white;
  text-align: center;
}
.timer-set-info {
  font-size: 15px;
  color: rgba(255,255,255,0.65);
}
.timer-countdown {
  font-size: 80px;
  font-weight: 800;
  color: white;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.timer-circle-wrap {
  position: relative;
  width: 200px;
  height: 200px;
}
.timer-circle {
  width: 200px;
  height: 200px;
  transform: rotate(-90deg);
}
.timer-circle-bg {
  fill: none;
  stroke: rgba(255,255,255,0.15);
  stroke-width: 8;
}
.timer-circle-progress {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 339.3;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.95s linear;
}
.timer-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-top: 8px;
}
.timer-buttons .btn { flex: 1; }

/* ═══════════════════════════════════════════════
   Sleep Settings (in modal)
═══════════════════════════════════════════════ */
.reminder-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.reminder-tag {
  padding: 6px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.reminder-tag.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

/* ═══════════════════════════════════════════════
   Manage Exercises (in modal)
═══════════════════════════════════════════════ */
.exercise-manage-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.exercise-manage-item:last-child { border-bottom: none; }
.exercise-manage-name { font-weight: 600; flex: 1; }
.exercise-manage-meta { font-size: 12px; color: var(--text-muted); }
.exercise-manage-btns { display: flex; gap: 6px; }
.exercise-inactive { opacity: 0.45; }

/* ═══════════════════════════════════════════════
   Utility
═══════════════════════════════════════════════ */
.text-muted   { color: var(--text-muted); }
.text-center  { text-align: center; }
.text-small   { font-size: 13px; }
.text-success { color: var(--primary); }
.text-danger  { color: var(--danger); }
.font-bold    { font-weight: 700; }
.empty-state  { text-align: center; color: var(--text-muted); padding: 16px 0; font-size: 14px; }
.divider      { height: 1px; background: var(--border); margin: 10px 0; }
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
}
