* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0f1419;
  --panel: #1a2028;
  --panel-2: #232b36;
  --border: #2d3744;
  --text: #e8eef5;
  --muted: #a3afc1;
  --accent: #4ade80;
  --accent-2: #22d3ee;
  --warn: #fbbf24;
  --danger: #f87171;
  --purple: #a78bfa;
  --water: #38bdf8;
}
/* Light theme — toned-down accents so the bright bg doesn't fight
   the colored UI elements.  Activated by data-theme="light" on
   <html>.  All component colors are CSS-var driven so this is the
   only place light overrides need to live. */
html[data-theme="light"] {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #eef2f7;
  --border: #dde4ec;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #16a34a;
  --accent-2: #0891b2;
  --warn: #d97706;
  --danger: #dc2626;
  --purple: #7c3aed;
  --water: #0284c7;
}
html[data-theme="light"] body { background: var(--bg); }
html[data-theme="light"] .toast { box-shadow: 0 4px 14px rgba(0,0,0,0.10); }
html[data-theme="light"] .modal { box-shadow: 0 12px 40px rgba(0,0,0,0.15); }
html[data-theme="light"] .panel { box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
/* Sleep chips */
.sleep-chip {
  padding: 3px 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; font-size: 12px; cursor: pointer; user-select: none;
  transition: all 0.1s; color: var(--muted);
}
.sleep-chip.on { background: rgba(167,139,250,0.15); color: var(--purple); border-color: rgba(167,139,250,0.4); }
.sleep-chip:active { transform: scale(0.95); }
.sleep-spark { display: flex; align-items: flex-end; gap: 3px; height: 32px; }
.sleep-spark-bar {
  flex: 1; min-width: 0; border-radius: 3px 3px 0 0;
  background: var(--accent-2); position: relative;
  transition: opacity 0.15s;
}
.sleep-spark-bar.warn { background: var(--warn); }
.sleep-spark-bar.danger { background: var(--danger); }
.sleep-spark-bar.no-data { background: var(--panel-2); height: 4px !important; }
/* Multi-period state v2: compact tabs + single collapsible body */
.state-tabs {
  display: flex; gap: 4px; margin-bottom: 8px;
}
.state-tab {
  flex: 1; padding: 8px 4px; text-align: center;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; user-select: none;
  transition: all 0.12s; font-size: 12px;
  position: relative;
}
.state-tab:active { transform: scale(0.97); }
.state-tab .emoji { font-size: 16px; line-height: 1; }
.state-tab .label { font-size: 11px; color: var(--muted); margin-top: 2px; }
.state-tab .score { font-size: 13px; font-weight: 700; margin-top: 2px; color: var(--muted); font-variant-numeric: tabular-nums; }
.state-tab.filled .score { color: var(--accent); }
.state-tab.current { border-color: var(--accent); }
.state-tab.active { background: var(--accent); border-color: var(--accent); }
.state-tab.active .label, .state-tab.active .score { color: #0a0f1a; }
.state-tab.active .emoji { filter: brightness(1.2); }
.state-tab .badge { position: absolute; top: 2px; right: 4px; font-size: 9px; color: var(--danger); font-weight: 700; }
.state-body {
  background: var(--panel-2); border-radius: 10px; padding: 10px;
  transition: max-height 0.2s;
}
.state-body.collapsed { display: none; }
.state-rating-line {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px;
}
.state-rating-line .lbl { min-width: 22px; color: var(--muted); font-size: 12px; text-align: center; }
.state-rating-line .pills { display: flex; gap: 3px; flex: 1; }
.state-rating-pill {
  flex: 1; text-align: center; padding: 5px 0;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  color: var(--muted); cursor: pointer; font-size: 12px;
  transition: all 0.1s; user-select: none;
}
.state-rating-pill:active { transform: scale(0.95); }
/* 3-color palette (red / warn / green) with color-mix interpolations at
   vals 2 and 4. Reads as a smooth ramp but stays within 3 hues — much
   less visual noise than the previous 5 hardcoded shades. */
.state-rating-pill[data-good="1"].active[data-val="1"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.state-rating-pill[data-good="1"].active[data-val="2"] { background: color-mix(in srgb, var(--danger) 50%, var(--warn)); border-color: color-mix(in srgb, var(--danger) 50%, var(--warn)); color: #fff; }
.state-rating-pill[data-good="1"].active[data-val="3"] { background: var(--warn); border-color: var(--warn); color: #0a0f1a; }
.state-rating-pill[data-good="1"].active[data-val="4"] { background: color-mix(in srgb, var(--warn) 50%, var(--accent)); border-color: color-mix(in srgb, var(--warn) 50%, var(--accent)); color: #0a0f1a; }
.state-rating-pill[data-good="1"].active[data-val="5"] { background: var(--accent); border-color: var(--accent); color: #0a0f1a; font-weight: 700; }
.state-rating-pill[data-good="0"].active[data-val="1"] { background: var(--accent); border-color: var(--accent); color: #0a0f1a; font-weight: 700; }
.state-rating-pill[data-good="0"].active[data-val="2"] { background: color-mix(in srgb, var(--accent) 50%, var(--warn)); border-color: color-mix(in srgb, var(--accent) 50%, var(--warn)); color: #0a0f1a; }
.state-rating-pill[data-good="0"].active[data-val="3"] { background: var(--warn); border-color: var(--warn); color: #0a0f1a; }
.state-rating-pill[data-good="0"].active[data-val="4"] { background: color-mix(in srgb, var(--warn) 50%, var(--danger)); border-color: color-mix(in srgb, var(--warn) 50%, var(--danger)); color: #fff; }
.state-rating-pill[data-good="0"].active[data-val="5"] { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 700; }
.state-chip-group { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.state-chip {
  padding: 3px 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; font-size: 12px; cursor: pointer; user-select: none;
  transition: all 0.1s; color: var(--muted);
}
.state-chip.on { background: rgba(248,113,113,0.18); color: var(--danger); border-color: rgba(248,113,113,0.4); }
.state-chip.craving.on { background: rgba(245,158,11,0.18); color: var(--warn); border-color: rgba(245,158,11,0.4); }
.state-chip:active { transform: scale(0.95); }
.state-extras-toggle {
  margin-top: 8px; padding: 5px 4px; font-size: 12px; color: var(--muted);
  cursor: pointer; user-select: none; border-top: 1px dashed var(--border);
  text-align: center;
}
.state-extras-toggle:hover { color: var(--text); }
.state-extras { display: none; margin-top: 4px; }
.state-extras.show { display: block; }
.state-day-chart {
  margin: 4px 0 8px; background: var(--panel-2); border-radius: 8px; padding: 6px 8px;
}
.persona-card {
  text-align: center; padding: 10px 4px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; font-size: 12px; color: var(--muted);
  transition: all 0.12s;
}
.persona-card > :first-child { font-size: 22px; line-height: 1; }
.persona-card .lbl { margin-top: 4px; }
.persona-card.selected {
  border-color: var(--accent); border-width: 2px;
  padding: 9px 3px; color: var(--text);
  background: rgba(74,222,128,0.10);
}
.persona-card:active { transform: scale(0.96); }
.theme-card { transition: border-color 0.15s, transform 0.1s; }
.theme-card.selected { border-color: var(--accent); border-width: 2px; padding: 9px 7px; }
.theme-card:active { transform: scale(0.96); }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 12px;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
.container { max-width: 900px; margin: 0 auto; }
h1 { font-size: 20px; margin-bottom: 2px; }
.subtitle { color: var(--muted); font-size: 13px; margin-bottom: 10px; }

.tabs {
  display: flex;
  gap: 3px;
  margin-bottom: 10px;
  background: rgba(26, 32, 40, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow-x: auto;
  position: sticky;
  top: max(0px, env(safe-area-inset-top));
  z-index: 50;
}
.tab {
  flex: 1;
  min-width: 52px;
  padding: 8px 6px;
  text-align: center;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  transition: all 0.15s;
  user-select: none;
  white-space: nowrap;
}
.tab.active {
  background: color-mix(in srgb, var(--accent) 14%, var(--panel-2));
  color: var(--text);
  font-weight: 600;
  /* tiny accent underline anchors the active tab without shifting layout */
  box-shadow: inset 0 -2px 0 var(--accent);
}
.tab:hover { color: var(--text); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  /* Skip layout + paint for off-screen panels until they scroll near.
     Massive cold-start win on this 16k-line single-HTML structure. */
  content-visibility: auto;
  contain-intrinsic-size: auto 300px;
}
.panel.panel-user-hidden { display: none !important; }

/* Quiet panels for non-actionable views — settings (configuration) and
   knowledge (reading material). Tighter padding + softer border so they
   recede behind the homepage primary content. */
#view-settings .panel,
#view-knowledge .panel {
  padding: 12px 14px;
  border-color: color-mix(in srgb, var(--border) 55%, transparent);
}

/* Hidden view tabs shouldn't even attempt visibility computation */
.view:not(.active) { content-visibility: hidden; }
/* Splash overlay shown until first JS init completes. Ambient radial glow
   echoes the timer halo so the first paint and the homepage feel related. */
#appSplash {
  position: fixed; inset: 0; z-index: 9999;
  background:
    radial-gradient(ellipse 50% 35% at 50% 45%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; transition: opacity 0.3s; pointer-events: none;
}
#appSplash.hidden { opacity: 0; }
#appSplash .dot {
  width: 40px; height: 40px;
  border: 3px solid color-mix(in srgb, var(--accent) 18%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 50%, transparent));
  animation: splashSpin 0.9s linear infinite;
}
#appSplash .label { color: var(--muted); font-size: 13px; letter-spacing: 0.04em; }
@keyframes splashSpin { to { transform: rotate(360deg); } }
/* Compact vitals layout */
.vitals-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.vital-cell label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.vital-cell input {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 8px 10px; border-radius: 6px; font-size: 14px; box-sizing: border-box;
}
.rating-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 0;
}
.rating-label { font-size: 13px; color: var(--muted); min-width: 30px; }
.rating-pills { display: flex; gap: 4px; flex: 1; }
.rating-pill {
  flex: 1; text-align: center; padding: 6px 0; font-size: 13px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); cursor: pointer; transition: all 0.1s;
}
.rating-pill.active {
  background: var(--accent); color: #0a0f1a; border-color: var(--accent); font-weight: 600;
}
.panel-hide-btn {
  margin-left: auto; background: transparent; border: none;
  color: var(--muted); font-size: 18px; cursor: pointer;
  padding: 0 4px; line-height: 1;
}
.panel-hide-btn:hover { color: var(--text); }
.panel h2 { font-size: 14.5px; margin-bottom: 8px; color: var(--text); display:flex; align-items:center; gap:6px; line-height: 1.4; }
.panel h3 { font-size: 13px; margin: 10px 0 6px; color: var(--accent-2); }

/* Sprite-based line icon (lucide). Inherits color from text via currentColor
   so it adapts to the parent's color (e.g. .panel h3 uses --accent-2).
   inline-block + vertical-align makes it work in both flex parents (.panel h2)
   and inline contexts (.modal h2, button text). */
.icon {
  width: 1.1em; height: 1.1em;
  vertical-align: -0.18em;
  display: inline-block;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
}
.icon-lg { width: 1.4em; height: 1.4em; vertical-align: -0.28em; }
.icon-sm { width: 0.95em; height: 0.95em; vertical-align: -0.1em; }

.view { display: none; }
.view.active {
  display: block;
  /* fade + small upward lift on activation; old view just disappears
     (no fade-out so the swap stays snappy) */
  animation: viewFadeIn 0.22s ease-out;
}
@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Timer — homepage centerpiece. Subtle radial ambient under the ring +
   glow on the active arc + slow breathing pulse so it feels alive. */
.timer-wrap {
  text-align: center;
  padding: 24px 0 22px;
  border-color: transparent;
  border-radius: 18px;
  position: relative;
  /* halo lives in ::before so it can pulse without re-rendering the SVG */
  isolation: isolate;
}
/* Pulsing ambient halo behind the timer — the "breathing" is here, not on
   the SVG, so the countdown text never has to repaint with the animation. */
.timer-wrap::before {
  content: '';
  position: absolute;
  left: 50%; top: 36%;
  width: 320px; height: 320px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 22%, transparent) 0%, transparent 60%);
  border-radius: 50%;
  z-index: -1;
  pointer-events: none;
  animation: timerHalo 4.5s ease-in-out infinite;
}
@keyframes timerHalo {
  0%, 100% { transform: translate(-50%, -50%) scale(0.85); opacity: 0.55; }
  50%      { transform: translate(-50%, -50%) scale(1.1);  opacity: 1; }
}
.timer-circle {
  position: relative;
  width: 240px;
  height: 240px;
  margin: 0 auto 20px;
}
.timer-svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.timer-bg { fill: none; stroke: color-mix(in srgb, var(--text) 8%, transparent); stroke-width: 12; }
.timer-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 12;
  stroke-linecap: round;
  /* Static glow only — animating filter caused iOS to stutter the JS
     countdown because drop-shadow re-rasterizes every frame. */
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 60%, transparent));
  transition: stroke-dashoffset 0.5s, stroke 0.8s;
}
.timer-text {
  position: absolute; top: 50%; left: 50%;
  /* translate-then-scale, both composed in one transform so :active
     doesn't accidentally drop the centering when it adds scale. */
  transform: translate(-50%, -50%) scale(1);
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.08s ease-out;
}
.timer-text:active { transform: translate(-50%, -50%) scale(0.97); }
.timer-time { font-size: 36px; font-weight: 600; font-variant-numeric: tabular-nums; }
.timer-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.timer-goal { color: var(--accent-2); font-size: 13px; margin-top: 6px; }

.stage-badge {
  display: inline-block;
  padding: 6px 14px;
  background: var(--panel-2);
  border-radius: 20px;
  font-size: 13px;
  margin-bottom: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
}
/* Stage info card — directional gradient (cool corner → warm accent corner)
   gives it dimension without being loud. Tiny shadow lifts it off panel-2. */
.stage-info {
  background: linear-gradient(135deg, var(--panel-2) 0%, color-mix(in srgb, var(--panel-2) 88%, var(--accent) 12%) 100%);
  border-radius: 10px;
  padding: 14px;
  margin: 12px 0;
  text-align: left;
  border-left: 3px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.stage-info strong { color: var(--accent); }

/* --btn-tint drives the gradient + glow color; variants just override the
   tint, no need to redefine the gradient each time. */
.btn {
  --btn-tint: var(--accent);
  --btn-fg: #0a0f1a;
  display: inline-block;
  padding: 12px 24px;
  border-radius: 10px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease-out, box-shadow 0.12s ease-out;
  background: linear-gradient(180deg, color-mix(in srgb, var(--btn-tint) 92%, white 8%), color-mix(in srgb, var(--btn-tint) 92%, black 8%));
  color: var(--btn-fg);
  margin: 4px;
  font-family: inherit;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 2px 5px rgba(0, 0, 0, 0.22);
}
.btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 1px 2px rgba(0, 0, 0, 0.22);
}
/* Secondary opts out of the gradient/shadow — it's a flat utility button. */
.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn-secondary:active { box-shadow: none; }
.btn-danger { --btn-tint: var(--danger); --btn-fg: #1a0a0a; }
.btn-warn  { --btn-tint: var(--warn);   --btn-fg: #1a0f0a; }
.btn-water { --btn-tint: var(--water);  --btn-fg: #0a1a26; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-block { display: block; width: 100%; margin: 6px 0; }

.goal-select {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  margin: 12px 0;
}
.goal-chip {
  padding: 8px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  transition: transform 0.08s ease-out, box-shadow 0.12s ease-out;
}
.goal-chip:active { transform: scale(0.96); }
.goal-chip.active {
  /* match the .btn vocabulary: subtle gradient + glow */
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, white 8%), color-mix(in srgb, var(--accent) 92%, black 8%));
  color: #0a0f1a;
  border-color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* Stats grid */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 12px 0; }
.stat {
  /* subtle directional sheen + 1px accent highlight along the top edge
     via inset box-shadow — adds dimension without a heavy border. */
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel-2) 85%, var(--text) 4%), var(--panel-2));
  padding: 12px;
  border-radius: 10px;
  text-align: center;
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--accent-2) 28%, transparent);
}
.stat-value { font-size: 20px; font-weight: 600; color: var(--accent-2); }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* History */
.history-item {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.history-meta { font-size: 13px; color: var(--muted); }
.history-duration { font-weight: 600; color: var(--accent); font-size: 15px; }
.history-actions { display: flex; gap: 4px; }

/* Plan */
.week-card {
  background: var(--panel-2);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}
.week-card h4 { color: var(--accent-2); font-size: 14px; margin-bottom: 6px; }
.week-card .schedule { font-size: 13px; color: var(--text); }
.week-card .note { font-size: 13px; color: var(--muted); margin-top: 6px; font-style: italic; }
.week-card.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.week-tag {
  display: inline-block;
  background: var(--accent);
  color: #0a0f1a;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 6px;
}

/* Input */
.input-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.input-row label { font-size: 13px; color: var(--muted); min-width: 80px; }
input, select, textarea {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  flex: 1;
  min-width: 100px;
  transition: border-color 0.12s ease-out, box-shadow 0.12s ease-out;
}
textarea { resize: vertical; min-height: 60px; }
/* Focus halo: 3px accent ring around the input so the eye snaps to it.
   transition on the parent makes the ring slide in instead of popping. */
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* Water */
.water-hero {
  display: flex; gap: 16px; align-items: stretch;
  padding: 14px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(56,189,248,0.06), rgba(56,189,248,0.16));
  border: 1px solid rgba(56,189,248,0.22);
  margin-bottom: 10px;
}
.water-bottle {
  position: relative; width: 76px; height: 120px; flex-shrink: 0;
  border: 2px solid rgba(56,189,248,0.55);
  border-top: none;
  border-radius: 6px 6px 20px 20px / 6px 6px 28px 28px;
  background: rgba(56,189,248,0.04);
  overflow: hidden;
}
.water-bottle::before {
  /* bottle cap */
  content: '';
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  width: 30px; height: 10px;
  background: rgba(56,189,248,0.55);
  border-radius: 4px 4px 0 0;
}
.water-bottle-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(56,189,248,0.7), rgba(56,189,248,0.95));
  transition: height 0.6s cubic-bezier(0.34, 1.5, 0.64, 1);
  overflow: hidden;
}
.water-bottle-fill::before, .water-bottle-fill::after {
  content: '';
  position: absolute; left: -50%; top: -8px;
  width: 200%; height: 14px;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.4) 0%, transparent 60%);
  background-size: 30% 100%;
  background-repeat: repeat-x;
  animation: waterWave 3.2s linear infinite;
}
.water-bottle-fill::after {
  animation-duration: 4.5s;
  animation-direction: reverse;
  opacity: 0.5;
  top: -4px;
}
@keyframes waterWave {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-30%); }
}
.water-bottle-marks {
  position: absolute; inset: 0; pointer-events: none;
}
.water-bottle-marks span {
  position: absolute; right: 4px; width: 8px; height: 1px;
  background: rgba(255,255,255,0.25);
}
.water-bottle.goal-hit { animation: bottleCelebrate 0.6s ease-out; }
.water-bottle.goal-hit { border-color: var(--accent); }
.water-bottle.goal-hit .water-bottle-fill {
  background: linear-gradient(180deg, rgba(74,222,128,0.7), rgba(74,222,128,0.95));
}
@keyframes bottleCelebrate {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.08); }
  70%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}
.water-stats {
  flex: 1; display: flex; flex-direction: column; justify-content: space-between; min-width: 0;
}
.water-big-num {
  font-size: 32px; font-weight: 700; color: var(--water); font-variant-numeric: tabular-nums;
  line-height: 1; letter-spacing: -0.02em;
}
.water-big-num small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.water-pct-label {
  font-size: 13px; color: var(--muted); margin-top: 4px;
}
.water-pct-label strong {
  font-size: 14px; padding: 1px 8px; border-radius: 10px;
  background: rgba(56,189,248,0.18); color: var(--water);
}
.water-pct-label strong.warn { background: rgba(245,158,11,0.18); color: var(--warn); }
.water-pct-label strong.ok { background: rgba(74,222,128,0.18); color: var(--accent); }
.water-hint {
  font-size: 12px; color: var(--muted); margin-top: 6px;
  line-height: 1.45;
}
.water-quick-row {
  display: flex; gap: 6px; margin-bottom: 8px;
}
.water-chip-quick {
  flex: 1; padding: 10px 4px; text-align: center;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  cursor: pointer; transition: all 0.1s; user-select: none;
}
.water-chip-quick:active { transform: scale(0.95); }
.water-chip-quick:hover { border-color: var(--water); }
.water-chip-quick .emoji { font-size: 20px; line-height: 1; }
.water-chip-quick .ml { font-size: 12px; color: var(--muted); margin-top: 3px; font-weight: 600; }
.water-timeline {
  display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px;
  padding: 6px 8px; background: var(--panel-2); border-radius: 8px;
  font-size: 12px;
}
.water-timeline-dot {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; background: var(--bg); border-radius: 10px;
  color: var(--muted); border: 1px solid var(--border);
}
.water-timeline-empty { color: var(--muted); padding: 2px 4px; }
.water-secondary {
  display: flex; gap: 6px; margin-top: 6px; justify-content: flex-end;
}
.water-secondary button {
  font-size: 12px; padding: 4px 10px;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); border-radius: 6px; cursor: pointer;
}
.water-secondary button:hover { color: var(--text); border-color: var(--text); }

/* Supplements */
.supp-list { display: flex; flex-direction: column; gap: 6px; }
.supp-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
}
.supp-item.checked { border-color: var(--accent); background: rgba(74,222,128,0.08); }
.supp-check {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
}
.supp-item.checked .supp-check { background: var(--accent); border-color: var(--accent); color: #0a0f1a; }
.supp-info { flex: 1; }
.supp-name { font-size: 14px; font-weight: 500; }
.supp-dose { font-size: 12px; color: var(--muted); }
.supp-edit-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; font-size: 16px; }

/* Training */
.training-item {
  background: var(--panel-2);
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 6px;
  border-left: 3px solid var(--purple);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.training-info { flex: 1; }
.training-type { font-weight: 600; font-size: 14px; }
.training-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* Checklist */
.checklist { list-style: none; }
.checklist li {
  background: var(--panel-2);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border);
  font-size: 13px;
  transition: all 0.15s;
}
.checklist li.done { border-color: var(--accent); opacity: 0.7; text-decoration: line-through; }
.checklist .ck {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.checklist li.done .ck { background: var(--accent); border-color: var(--accent); color: #0a0f1a; }

/* Knowledge */
.stage-list { list-style: none; }
.stage-list li {
  padding: 8px 12px;
  background: var(--panel-2);
  border-radius: 7px;
  margin-bottom: 4px;
  border-left: 3px solid var(--accent-2);
  font-size: 13px;
}
.stage-list strong { color: var(--accent-2); }
.warn-box {
  background: rgba(251, 191, 36, 0.1);
  border-left: 3px solid var(--warn);
  padding: 10px 12px;
  border-radius: 7px;
  margin: 6px 0;
  font-size: 13px;
}
.danger-box {
  background: rgba(248, 113, 113, 0.1);
  border-left: 3px solid var(--danger);
  padding: 10px 12px;
  border-radius: 7px;
  margin: 6px 0;
  font-size: 13px;
}
.ok-box {
  background: rgba(74, 222, 128, 0.1);
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  border-radius: 7px;
  margin: 6px 0;
  font-size: 13px;
}
.info-box {
  background: rgba(34, 211, 238, 0.08);
  border-left: 3px solid var(--accent-2);
  padding: 10px 12px;
  border-radius: 7px;
  margin: 6px 0;
  font-size: 13px;
}

details { background: var(--panel-2); border-radius: 7px; padding: 8px 12px; margin: 4px 0; cursor: pointer; }
details summary { font-weight: 600; color: var(--accent-2); font-size: 13px; }
details[open] summary { margin-bottom: 6px; }
details p, details ul { margin-top: 4px; font-size: 12.5px; line-height: 1.6; }
details ul { padding-left: 20px; }
details li { margin-bottom: 3px; }

/* Chart */
.chart-wrap { background: var(--panel-2); border-radius: 10px; padding: 12px; margin: 10px 0; }
canvas { width: 100%; height: 180px; display: block; }

.empty { text-align: center; color: var(--muted); padding: 24px; font-size: 13px; }

/* Modal */
.modal-bg {
  position: fixed; inset: 0;
  /* lower alpha because the blur fills in some of the "darkness" itself */
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { margin-bottom: 12px; }
.modal-close-btn { float: right; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; }

.quick-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel-2); padding: 10px 14px; border-radius: 10px;
  margin-bottom: 6px; border: 1px solid var(--border);
}
.quick-row .label { font-size: 13px; color: var(--muted); }
.quick-row .value { font-weight: 600; color: var(--accent-2); }

/* Wizard */
.wizard { max-width: 540px; }
.wizard-progress { margin-bottom: 16px; }
.wizard-bar { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.wizard-bar > div { height: 100%; background: var(--accent); transition: width 0.3s; border-radius: 3px; }
#wizardStepLabel { color: var(--muted); font-size: 13px; text-align: right; }
.wizard-step h3 { color: var(--accent-2); margin-bottom: 10px; font-size: 16px; }
.wizard-step p.hint { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.wizard-nav { display: flex; gap: 8px; margin-top: 16px; }
.wizard-nav button { flex: 1; margin: 0; }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 10px 0; }
.opt {
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 12px; border-radius: 10px; cursor: pointer; text-align: center;
  font-size: 13px; transition: all 0.15s;
}
.opt.sel { background: var(--accent); color: #0a0f1a; border-color: var(--accent); font-weight: 600; }
.opt-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.opt-list .opt { text-align: left; padding: 10px 14px; }
.opt-list .opt strong { display: block; margin-bottom: 2px; }
.opt-list .opt span { font-size: 13px; color: var(--muted); }
.opt-list .opt.sel span { color: #0a0f1a; }

/* Plan summary */
.plan-tag {
  display: inline-block;
  background: var(--accent); color: #0a0f1a;
  padding: 4px 10px; border-radius: 6px; font-size: 13px; font-weight: 600;
  margin-right: 6px;
}
.plan-row {
  display: flex; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.plan-row:last-child { border-bottom: none; }
.plan-row .label { color: var(--muted); }

/* Shopping list */
.shop-item {
  background: var(--panel-2); padding: 10px 14px; border-radius: 8px;
  margin-bottom: 6px; display: flex; align-items: center; gap: 10px;
  font-size: 13px;
}
.shop-pri {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.shop-pri.must { background: var(--danger); }
.shop-pri.rec { background: var(--warn); }
.shop-pri.have { background: var(--accent); }

/* Refeed menu */
.refeed-block {
  /* same dimensional treatment as .stage-info, in purple — keeps the
     "feature card" pattern consistent across the app. */
  background: linear-gradient(135deg, var(--panel-2) 0%, color-mix(in srgb, var(--panel-2) 88%, var(--purple) 12%) 100%);
  border-radius: 10px; padding: 12px 14px;
  margin-bottom: 10px; border-left: 3px solid var(--purple);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.refeed-block h4 { color: var(--purple); font-size: 14px; margin-bottom: 6px; }
.refeed-meal { font-size: 13px; margin: 4px 0; }
.refeed-meal strong { color: var(--accent-2); }

/* Symptom grid */
.symptom-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px; margin-top: 8px;
}
.symp {
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 8px 10px; border-radius: 8px; font-size: 13px; cursor: pointer;
  text-align: center; transition: all 0.15s;
}
.symp.on { background: var(--danger); color: #fff; border-color: var(--danger); }

/* Protein */
.protein-display {
  background: linear-gradient(180deg, rgba(167,139,250,0.05), rgba(167,139,250,0.15));
  padding: 16px; border-radius: 12px; margin-bottom: 10px;
  border: 1px solid rgba(167,139,250,0.2); text-align: center;
}
.protein-amount { font-size: 28px; font-weight: 600; color: var(--purple); }
.protein-target { color: var(--muted); font-size: 13px; }
.food-item {
  background: var(--panel-2); padding: 8px 12px; border-radius: 8px;
  margin-bottom: 4px; display: flex; justify-content: space-between;
  align-items: center; font-size: 13px;
}

/* Calendar */
.cal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cal-header span { font-weight: 600; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.cal-dow {
  text-align: center; font-size: 12px; color: var(--muted); padding: 4px;
}
.cal-day {
  aspect-ratio: 1; background: var(--panel-2); border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 13px; position: relative; cursor: pointer;
}
.cal-day.empty { background: transparent; cursor: default; }
.cal-day.today { box-shadow: 0 0 0 2px var(--accent-2); }
.cal-day.f14 { background: rgba(74, 222, 128, 0.15); }
.cal-day.f18 { background: rgba(74, 222, 128, 0.35); }
.cal-day.f24 { background: rgba(74, 222, 128, 0.6); color: #0a0f1a; }
.cal-day.f36 { background: rgba(74, 222, 128, 0.9); color: #0a0f1a; font-weight: 600; }
.cal-train { position: absolute; top: 2px; right: 3px; font-size: 9px; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.cal-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 3px; vertical-align: middle; }
.dot-light { background: rgba(74,222,128,0.2); }
.dot-med { background: rgba(74,222,128,0.45); }
.dot-dark { background: rgba(74,222,128,0.7); }
.dot-darker { background: rgba(74,222,128,1); }

/* Achievements */
.achievements {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px;
}
.ach {
  background: var(--panel-2); border-radius: 10px; padding: 10px 6px;
  text-align: center; border: 1px solid var(--border); opacity: 0.4;
  transition: transform 0.15s ease-out;
}
/* Unlocked = "earned" — warm gradient + soft golden halo. Subtle scale
   makes earned achievements feel more present than locked ones. */
.ach.unlocked {
  opacity: 1;
  border-color: color-mix(in srgb, var(--warn) 70%, var(--accent));
  background: linear-gradient(160deg, color-mix(in srgb, var(--panel-2) 75%, var(--warn) 16%), var(--panel-2));
  box-shadow: 0 0 14px color-mix(in srgb, var(--warn) 22%, transparent), inset 0 1px 0 color-mix(in srgb, var(--warn) 30%, transparent);
}
.ach.unlocked .ach-icon { filter: drop-shadow(0 0 4px color-mix(in srgb, var(--warn) 60%, transparent)); }
.ach-icon { font-size: 22px; margin-bottom: 4px; transition: filter 0.15s; }
.ach-name { font-size: 12px; font-weight: 600; }
.ach-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Weekly report */
.report-stat {
  display: flex; justify-content: space-between; padding: 8px 12px;
  background: var(--panel-2); border-radius: 8px; margin-bottom: 6px;
  font-size: 13px;
}
.report-stat .trend.up { color: var(--accent); }
.report-stat .trend.down { color: var(--warn); }
.report-feedback {
  background: var(--panel-2); border-radius: 10px; padding: 12px 14px;
  margin-top: 10px; border-left: 3px solid var(--accent-2);
  font-size: 13px; line-height: 1.7;
}

/* Safety alert */
.alert-row {
  background: var(--panel-2); padding: 10px 14px; border-radius: 8px;
  margin-bottom: 6px; font-size: 13px; border-left: 3px solid var(--warn);
}
.alert-row.danger { border-left-color: var(--danger); background: rgba(248,113,113,0.08); }

/* Daily tip banner */
.tip-banner {
  background: linear-gradient(135deg, rgba(34,211,238,0.12), rgba(74,222,128,0.08));
  border: 1px solid rgba(34,211,238,0.25);
  border-radius: 12px; padding: 12px 14px; padding-right: 72px;
  margin-bottom: 14px;
  font-size: 13px; line-height: 1.6; position: relative;
}
.tip-banner .tip-label {
  display: inline-block; background: var(--accent-2); color: #0a0f1a;
  padding: 2px 8px; border-radius: 6px; font-size: 11px;
  font-weight: 700; margin-right: 6px; vertical-align: middle;
}
.tip-banner .tip-actions {
  position: absolute; top: 8px; right: 8px; display: flex; gap: 2px;
}
.tip-banner .tip-refresh {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 14px; padding: 4px 6px; line-height: 1;
}
.tip-banner .tip-refresh:hover { color: var(--text); }

/* Streak card */
.streak-card {
  display: flex; gap: 10px; margin-bottom: 12px;
}
.streak-stat {
  flex: 1; background: var(--panel-2); border-radius: 12px;
  padding: 14px 10px; text-align: center; border: 1px solid var(--border);
}
.streak-stat .num {
  font-size: 28px; font-weight: 700; color: var(--accent);
  line-height: 1;
}
.streak-stat .lbl {
  font-size: 12px; color: var(--muted); margin-top: 6px;
}
.streak-stat.gold .num { color: var(--warn); }
.streak-stat.purple .num { color: var(--purple); }

/* 30-day heatmap */
.heatmap {
  display: grid; grid-template-columns: repeat(15, 1fr); gap: 3px;
  background: var(--panel-2); padding: 12px; border-radius: 10px;
}
.heatmap-cell {
  aspect-ratio: 1; border-radius: 3px; background: rgba(74,222,128,0.06);
  position: relative; cursor: pointer; transition: transform 0.15s;
}
.heatmap-cell:hover { transform: scale(1.15); z-index: 2; }
.heatmap-cell.h1 { background: rgba(74,222,128,0.25); }
.heatmap-cell.h2 { background: rgba(74,222,128,0.5); }
.heatmap-cell.h3 { background: rgba(74,222,128,0.75); }
.heatmap-cell.h4 { background: rgba(74,222,128,1); }
.heatmap-cell.today { box-shadow: 0 0 0 2px var(--accent-2); }
.heatmap-cell.train::after {
  content: ''; position: absolute; top: 1px; right: 1px;
  width: 4px; height: 4px; background: var(--purple); border-radius: 50%;
}
.heatmap-legend {
  display: flex; align-items: center; gap: 4px; font-size: 12px;
  color: var(--muted); margin-top: 8px; justify-content: flex-end;
}
.heatmap-legend .swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
}

/* Goal progress card */
.goal-card {
  background: linear-gradient(135deg, rgba(167,139,250,0.08), rgba(34,211,238,0.05));
  border: 1px solid rgba(167,139,250,0.25);
  border-radius: 12px; padding: 16px; margin-bottom: 10px;
}
.goal-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 10px;
}
.goal-header .gw {
  font-size: 24px; font-weight: 700; color: var(--text);
}
.goal-header .gw small {
  font-size: 13px; color: var(--muted); font-weight: 400;
}
.goal-bar {
  height: 10px; background: var(--panel-2); border-radius: 5px;
  overflow: hidden; margin: 8px 0;
}
.goal-bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--accent-2));
  border-radius: 5px; transition: width 0.4s;
}
.goal-meta {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  font-size: 13px; color: var(--muted); margin-top: 8px;
}
.goal-meta strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 2px; }

/* Macro ring (mini progress rings) */
.macro-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-bottom: 10px;
}
.macro-cell {
  background: var(--panel-2); border-radius: 10px; padding: 10px 4px;
  text-align: center; border: 1px solid var(--border);
}
.macro-cell .v { font-size: 16px; font-weight: 700; }
.macro-cell .t { font-size: 11px; color: var(--muted); margin-top: 2px; }
.macro-cell .bar { height: 4px; background: var(--bg); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.macro-cell .bar > div { height: 100%; border-radius: 2px; transition: width 0.3s; }
.macro-cell.kcal .v { color: var(--accent); }
.macro-cell.kcal .bar > div { background: var(--accent); }
.macro-cell.protein .v { color: var(--purple); }
.macro-cell.protein .bar > div { background: var(--purple); }
.macro-cell.carb .v { color: var(--warn); }
.macro-cell.carb .bar > div { background: var(--warn); }
.macro-cell.fat .v { color: var(--accent-2); }
.macro-cell.fat .bar > div { background: var(--accent-2); }

/* Measurement grid */
.measure-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 10px;
}
.measure-cell {
  background: var(--panel-2); border-radius: 10px; padding: 10px;
  border: 1px solid var(--border);
}
.measure-cell label {
  display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px;
}
.measure-cell input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 6px 8px; border-radius: 6px; font-size: 14px;
  -moz-appearance: textfield;
}
.measure-cell input::-webkit-outer-spin-button,
.measure-cell input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.measure-cell .delta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.measure-cell .delta.down { color: var(--accent); }
.measure-cell .delta.up { color: var(--warn); }

/* Workout exercise items */
.exercise-list { margin-top: 10px; }
.exercise-item {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; margin-bottom: 4px;
  display: grid; grid-template-columns: 1fr auto auto;
  gap: 8px; align-items: center; font-size: 13px;
}
.exercise-item .ex-name { font-weight: 600; }
.exercise-item .ex-meta { color: var(--muted); font-size: 12px; }
.exercise-item .ex-sets {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.exercise-item .set-chip {
  background: var(--panel-2); padding: 2px 6px; border-radius: 4px;
  font-size: 12px;
}
.pr-badge {
  display: inline-block; background: var(--warn); color: #0a0f1a;
  padding: 1px 5px; border-radius: 4px; font-size: 9px;
  font-weight: 700; margin-left: 4px;
}
.split-tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 700; margin-right: 4px;
}
.split-tag.push { background: #f87171; color: #fff; }
.split-tag.pull { background: #38bdf8; color: #fff; }
.split-tag.legs { background: #a78bfa; color: #fff; }
.split-tag.cardio { background: #fbbf24; color: #0a0f1a; }
.split-tag.other { background: var(--panel-2); color: var(--muted); }

/* TDEE calculator */
.calc-result {
  background: linear-gradient(135deg, rgba(74,222,128,0.08), rgba(34,211,238,0.06));
  border: 1px solid rgba(74,222,128,0.2);
  border-radius: 10px; padding: 12px; margin-top: 10px;
}
.calc-result-row {
  display: flex; justify-content: space-between; padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 13px;
}
.calc-result-row:last-child { border-bottom: none; }
.calc-result-row strong { color: var(--accent); }

/* Toast */
.toast-stack {
  position: fixed; left: 50%; bottom: 30px;
  transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column-reverse;
  gap: 8px; pointer-events: none;
  width: calc(100% - 32px); max-width: 360px;
}
.toast {
  background: var(--panel); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 12px 14px;
  font-size: 13px; color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: toastIn 0.25s ease-out, toastOut 0.25s ease-in 2.5s forwards;
  pointer-events: auto;
}
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--accent-2); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-10px) scale(0.95); }
}

/* Year heatmap */
.yh-grid {
  display: inline-grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  grid-auto-columns: 11px;
  gap: 2px;
  margin-top: 4px;
}
.yh-cell {
  width: 11px; height: 11px;
  border-radius: 2px;
  background: var(--panel-2);
  cursor: pointer;
}
.yh-cell.empty { visibility: hidden; }
.yh-cell.f14 { background: rgba(74,222,128,0.2); }
.yh-cell.f18 { background: rgba(74,222,128,0.4); }
.yh-cell.f24 { background: rgba(74,222,128,0.7); }
.yh-cell.f36 { background: rgba(74,222,128,1); }
.yh-cell.today { box-shadow: 0 0 0 1.5px var(--accent-2); }
.yh-row { display: flex; gap: 6px; }
.yh-months {
  display: flex; gap: 2px;
  font-size: 11px; color: var(--muted);
  margin-bottom: 2px;
}
.yh-dow {
  display: grid; grid-template-rows: repeat(7, 1fr);
  grid-auto-columns: 11px; gap: 2px;
  font-size: 9px; color: var(--muted);
  align-items: center; line-height: 11px;
  margin-right: 4px;
}
/* Health score */
.hs-total {
  display: flex; align-items: center; justify-content: center;
  width: 96px; height: 96px; border-radius: 50%;
  margin: 0 auto 12px;
  background: conic-gradient(var(--accent) calc(var(--score)*1%), var(--panel-2) 0);
  position: relative;
}
.hs-total::after {
  content: '';
  position: absolute; inset: 6px;
  background: var(--panel); border-radius: 50%;
}
.hs-total .v {
  position: relative; z-index: 1;
  font-size: 28px; font-weight: 700;
}
.hs-bars { display: grid; grid-template-columns: 64px 1fr 36px; gap: 6px 8px; align-items: center; font-size: 13px; }
.hs-bar-bg { background: var(--panel-2); height: 8px; border-radius: 4px; overflow: hidden; }
.hs-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s; }
.hs-trend { font-size: 12px; color: var(--muted); margin-top: 8px; text-align: center; }

/* AI typing indicator + streaming cursor */
.typing-dots { display: inline-flex; align-items: center; gap: 4px; padding: 2px 0; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: typingBounce 1.2s infinite ease-in-out;
  opacity: 0.5;
}
.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}
.stream-cursor {
  display: inline-block; width: 7px; height: 14px;
  background: var(--accent); margin-left: 2px;
  vertical-align: text-bottom;
  animation: streamBlink 0.9s steps(2) infinite;
}
@keyframes streamBlink {
  50% { opacity: 0; }
}
/* Button loading skeleton */
.btn-thinking {
  position: relative;
  background-image: linear-gradient(90deg,
    transparent 0%, rgba(255,255,255,0.12) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Share card preview */
.share-card-wrap {
  background: var(--panel-2); border-radius: 10px; padding: 12px;
  text-align: center; margin-top: 10px;
}
.share-card-wrap canvas {
  width: 100%; max-width: 360px; height: auto;
  border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* Section subtitle */
.panel h2 small {
  font-size: 12px; color: var(--muted); font-weight: 400;
  margin-left: 6px;
}

/* Wellness sliders */
.wellness-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
.wellness-cell {
  background: var(--panel-2); border-radius: 10px; padding: 10px 12px;
}
.wellness-cell .wl-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; color: var(--muted); margin-bottom: 6px;
}
.wellness-cell .wl-label strong {
  color: var(--text); font-size: 13px;
}
.wellness-cell .wl-emoji {
  font-size: 18px;
}
.wellness-cell input[type=range] {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 6px; background: var(--bg); border-radius: 3px; outline: none;
}
.wellness-cell input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent-2); cursor: pointer;
}
.wellness-cell input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent-2); cursor: pointer; border: none;
}

/* Collapsible panel */
.panel.collapsible > h2 {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
  position: relative;
  padding-right: 28px;
}
.panel.collapsible > h2:hover { color: var(--accent-2); }
.panel.collapsible > h2::after {
  content: '▾';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--muted);
  transition: transform 0.2s;
}
.panel.collapsed > h2::after {
  transform: translateY(-50%) rotate(-90deg);
}
.panel.collapsed > *:not(h2) { display: none !important; }
.panel.collapsible > h2 .col-meta {
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}

/* Inline edit chip */
.edit-chip {
  display: inline-block;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 6px;
  transition: all 0.15s;
}
.edit-chip:hover { color: var(--accent-2); border-color: var(--accent-2); }

/* Editable week card */
.week-card .week-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.week-card .week-actions button {
  flex: 1;
  font-size: 12px;
  padding: 4px 8px;
}

/* Workout mode */
.wm-warmup {
  background: linear-gradient(135deg, rgba(251,191,36,0.10), rgba(251,191,36,0.03));
  border: 1px solid rgba(251,191,36,0.25);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 10px;
  cursor: pointer;
}
.wm-warmup summary {
  font-weight: 600; color: var(--warn);
  font-size: 13px;
  list-style: none;
}
.wm-warmup summary::-webkit-details-marker { display: none; }
.wm-warmup summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.2s;
}
.wm-warmup[open] summary::before { transform: rotate(90deg); }
.warmup-move {
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  margin-bottom: 4px;
}
.last-session {
  font-size: 12px;
  color: var(--muted);
  background: rgba(255,255,255,0.03);
  padding: 6px 10px;
  border-radius: 6px;
  margin: 6px 0;
  border-left: 2px solid var(--accent-2);
}
.warmup-ladder {
  background: rgba(251,191,36,0.06);
  border: 1px dashed rgba(251,191,36,0.3);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 6px 0;
}
.ladder-row {
  padding: 3px 0;
  font-size: 13px;
  font-weight: 500;
}
.wm-set-block {
  margin-bottom: 6px;
}
.wm-set-block.done { opacity: 0.7; }
.wm-rpe-row {
  display: flex; align-items: center; gap: 4px; margin-top: 4px; padding-left: 32px;
  font-size: 11px; color: var(--muted);
}
.wm-rpe-row .label { min-width: 32px; }
.wm-rpe-pill {
  flex: 0 0 auto; padding: 3px 8px; border-radius: 4px;
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 600;
  user-select: none; transition: all 0.1s;
}
.wm-rpe-pill:hover { color: var(--text); }
.wm-rpe-pill.active { background: var(--warn); color: #0a0f1a; border-color: var(--warn); }
.wm-rpe-pill.active[data-rpe="10"] { background: var(--danger); border-color: var(--danger); color:#fff; }
.wm-rpe-pill.active[data-rpe="6"] { background: var(--accent); border-color: var(--accent); }
.wm-rpe-pill.active[data-rpe="7"] { background: var(--accent-2); border-color: var(--accent-2); color:#0a0f1a; }
.wm-rpe-done {
  display: inline-block; padding: 2px 6px; border-radius: 4px;
  background: var(--panel-2); color: var(--muted); font-size: 12px;
  font-weight: 600; margin-left: 6px;
}
.overload-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 28px;
  text-align: center;
  background: transparent;
  color: transparent;
}
.overload-badge.up {
  background: rgba(74,222,128,0.15);
  color: var(--accent);
}
.overload-badge.down {
  background: rgba(248,113,113,0.15);
  color: var(--danger);
}
.overload-badge.same {
  background: rgba(255,255,255,0.06);
  color: var(--muted);
}
.weight-chips {
  display: flex;
  gap: 4px;
  padding: 2px 0 2px 30px;
}
.weight-chips button {
  flex: 1;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 3px 6px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  margin: 0;
  transition: all 0.15s;
}
.weight-chips button:hover { background: var(--panel-2); color: var(--text); }
.weight-chips button:active { transform: scale(0.95); }

.wm-exercise {
  background: var(--panel-2); border-radius: 10px;
  padding: 12px; margin-bottom: 8px;
  border-left: 3px solid var(--purple);
}
.wm-exercise.done { opacity: 0.55; border-left-color: var(--accent); }
.wm-ex-header {
  display: flex; justify-content: space-between;
  align-items: baseline; margin-bottom: 6px;
}
.wm-ex-name { font-weight: 600; font-size: 14px; }
.wm-ex-target { font-size: 12px; color: var(--muted); }
.wm-sets { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.wm-set-row {
  display: grid; grid-template-columns: 24px 1fr 1fr auto auto;
  gap: 6px; align-items: center; font-size: 13px;
}
.wm-set-row .set-num {
  background: var(--bg); border-radius: 50%;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: var(--muted);
}
.wm-set-row.done .set-num { background: var(--accent); color: #0a0f1a; }
.wm-set-row input {
  padding: 4px 8px; font-size: 13px; min-width: 60px;
  background: var(--bg);
}
.wm-set-row button {
  padding: 4px 10px; font-size: 12px; margin: 0;
}

/* Volume bars (MEV/MAV/MRV) */
.vol-row {
  background: var(--panel-2); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 6px;
}
.vol-row-head {
  display: flex; justify-content: space-between;
  font-size: 13px; margin-bottom: 6px;
}
.vol-row-head .name { font-weight: 600; }
.vol-row-head .val { color: var(--muted); font-variant-numeric: tabular-nums; }
.vol-bar {
  height: 8px; background: var(--bg);
  border-radius: 4px; overflow: hidden;
  position: relative;
}
.vol-bar > .fill {
  height: 100%; border-radius: 4px;
  transition: width 0.3s;
}
.vol-bar > .fill.under { background: #6b7280; }
.vol-bar > .fill.mav { background: var(--accent); }
.vol-bar > .fill.high { background: var(--warn); }
.vol-bar > .fill.over { background: var(--danger); }
.vol-bar > .marker {
  position: absolute; top: -2px; bottom: -2px;
  width: 1px; background: rgba(255,255,255,0.3);
}
.vol-zone-hint {
  font-size: 11px; color: var(--muted); margin-top: 4px;
}

/* 1RM card */
.rm-card {
  background: var(--panel-2); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 6px;
}
.rm-card-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
}
.rm-card-head .name { font-weight: 600; font-size: 14px; }
.rm-card-head .rm {
  font-size: 18px; font-weight: 700; color: var(--warn);
  font-variant-numeric: tabular-nums;
}
.rm-card-head .rm small { font-size: 11px; color: var(--muted); font-weight: 400; }
.rm-tier-bar {
  display: flex; gap: 2px; height: 6px; margin: 6px 0;
  border-radius: 3px; overflow: hidden;
}
.rm-tier-bar > div { flex: 1; }
.rm-tier-bar > .untrained { background: #6b7280; }
.rm-tier-bar > .novice { background: #94a3b8; }
.rm-tier-bar > .intermediate { background: var(--accent-2); }
.rm-tier-bar > .advanced { background: var(--accent); }
.rm-tier-bar > .elite { background: var(--warn); }
.rm-tier-bar > .below-current { opacity: 0.25; }
.rm-tier-label {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--muted);
}
.rm-tier-current {
  margin-top: 4px; font-size: 12px;
  color: var(--accent-2);
}
.rm-tier-current strong { color: var(--accent); }

/* Plate visualization */
.plate-vis {
  display: flex; align-items: center; justify-content: center;
  gap: 0; padding: 14px; background: var(--bg);
  border-radius: 8px; margin-bottom: 8px;
  overflow-x: auto;
}
.plate-disc {
  height: 50px; min-width: 6px;
  margin: 0 1px; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #000;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.3);
  writing-mode: vertical-rl;
}
.plate-bar {
  height: 8px; background: linear-gradient(180deg, #9ca3af, #4b5563);
  width: 40px; margin: 0 -2px; border-radius: 1px;
  flex-shrink: 0;
}
.plate-p25 { background: #ef4444; height: 56px; min-width: 12px; }
.plate-p20 { background: #3b82f6; height: 50px; min-width: 11px; }
.plate-p15 { background: #eab308; height: 46px; min-width: 10px; }
.plate-p10 { background: #22c55e; height: 42px; min-width: 9px; }
.plate-p5  { background: #f5f5f5; height: 36px; min-width: 7px; }
.plate-p2_5 { background: #1e293b; color: #fff; height: 30px; min-width: 6px; }
.plate-p1_25 { background: #64748b; color: #fff; height: 24px; min-width: 5px; }

/* Insight card */
.insight-row {
  background: linear-gradient(135deg, rgba(34,211,238,0.05), rgba(74,222,128,0.04));
  border: 1px solid rgba(34,211,238,0.2);
  border-radius: 10px; padding: 12px 14px;
  margin-bottom: 6px;
  font-size: 13px; line-height: 1.6;
  display: flex; gap: 10px; align-items: flex-start;
}
.insight-row .ic { font-size: 18px; flex-shrink: 0; line-height: 1.2; }
.insight-row.warn {
  background: linear-gradient(135deg, rgba(251,191,36,0.08), rgba(251,191,36,0.03));
  border-color: rgba(251,191,36,0.25);
}
.insight-row.success {
  background: linear-gradient(135deg, rgba(74,222,128,0.06), rgba(74,222,128,0.02));
  border-color: rgba(74,222,128,0.22);
}
.insight-row strong { color: var(--accent-2); }

/* Program card */
.program-row {
  background: var(--panel-2); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 6px;
  cursor: pointer; border: 1px solid var(--border);
  transition: all 0.15s;
}
.program-row:hover { border-color: var(--accent); background: var(--panel); }
.program-row.active {
  border-color: var(--accent);
  background: rgba(74,222,128,0.05);
}
.program-row h4 {
  color: var(--accent-2); font-size: 14px; margin: 0;
}
.program-row p {
  color: var(--muted); font-size: 13px; margin-top: 4px;
}
.program-meta {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--muted); margin-top: 6px;
}

/* PR list */
.pr-list { margin-top: 8px; }
.pr-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; background: var(--panel-2); border-radius: 8px;
  margin-bottom: 4px; font-size: 13px;
}
.pr-row .pr-weight { color: var(--warn); font-weight: 700; }

@media (max-width: 600px) {
  .timer-circle { width: 200px; height: 200px; }
  .timer-time { font-size: 28px; }
  .tab { font-size: 13px; padding: 8px 4px; min-width: 50px; }
  .symptom-grid { grid-template-columns: repeat(2, 1fr); }
  .measure-grid { grid-template-columns: repeat(2, 1fr); }
  .macro-row { grid-template-columns: repeat(2, 1fr); }
  .heatmap { grid-template-columns: repeat(10, 1fr); }
  .streak-card { flex-wrap: wrap; }
  .streak-stat { min-width: calc(50% - 5px); }
}
