:root {
  --bg: #0a0b0e;
  --bg-elev: #14161b;
  --bg-card: #1a1d24;
  --bg-card-2: #232730;
  --fg: #ebedf0;
  --fg-dim: #9aa3ad;
  --fg-muted: #5f6770;
  --border: #2a2f38;
  --border-strong: #3a4250;
  --accent: #3ddc84;
  --accent-2: #2ec46b;
  --danger: #ed5247;
  --warn: #f4b400;
  --phase: #9aa3ad;
  --safe-bottom: env(safe-area-inset-bottom, 0);
  --safe-top: env(safe-area-inset-top, 0);
  --max-w: 720px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ====== HEADINGS ====== */
h2 {
  font-size: 1.55rem; margin: 0 0 14px; font-weight: 700;
  letter-spacing: -.01em;
}
h3 { font-size: 1rem; font-weight: 600; margin: 0 0 10px; color: var(--fg); }
h3.sub {
  font-size: .78rem; font-weight: 700; color: var(--fg-dim);
  text-transform: uppercase; letter-spacing: .08em;
  margin: 28px 0 12px;
}
.muted { color: var(--fg-dim); }
.small { font-size: .85rem; }

/* ====== TOPBAR ====== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: linear-gradient(180deg, rgba(10,11,14,.96) 0%, rgba(10,11,14,.85) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  max-width: var(--max-w);
  margin: 0 auto;
}
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); color: var(--fg);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 14px 6px 6px;
  font-weight: 600; font-size: .9rem;
  transition: background .15s;
}
.user-chip:hover { background: var(--bg-card-2); }
.user-emoji {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; background: var(--bg-card-2); border-radius: 50%;
  font-size: 1rem;
}
.mini-timer {
  display: flex; align-items: center; gap: 8px;
  font-size: .82rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.mini-pill {
  padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--phase) 18%, transparent);
  color: var(--phase);
  font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  border: 1px solid color-mix(in srgb, var(--phase) 35%, transparent);
}

/* ====== SECTION NAV (pills) ====== */
.section-nav {
  position: sticky; top: calc(60px + var(--safe-top)); z-index: 40;
  display: flex; gap: 4px;
  padding: 8px 16px;
  background: rgba(10,11,14,.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow-x: auto;
  scrollbar-width: none;
  max-width: var(--max-w); margin: 0 auto;
  border-bottom: 1px solid var(--border);
}
.section-nav::-webkit-scrollbar { display: none; }
.section-nav a {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: .82rem; font-weight: 600;
  color: var(--fg-muted);
  transition: all .15s;
}
.section-nav a.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* ====== MAIN ====== */
main {
  max-width: var(--max-w); margin: 0 auto;
  padding: 8px 16px calc(40px + var(--safe-bottom));
}
.section {
  padding: 20px 0 32px;
  scroll-margin-top: 124px;
}
.section.hero { padding-top: 8px; }

/* ====== RING / NOW ====== */
.ring-wrap {
  position: relative;
  aspect-ratio: 1/1;
  max-width: 380px;
  margin: 8px auto 24px;
}
.ring {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
  position: relative; z-index: 2;
  filter: drop-shadow(0 0 12px color-mix(in srgb, var(--phase) 40%, transparent));
}
.ring-bg { fill: none; stroke: var(--border); stroke-width: 6; }
.ring-fg {
  fill: none;
  stroke: var(--phase);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s cubic-bezier(.4,0,.2,1), stroke 1s ease;
}
.ring-center {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
}
.phase-pill {
  display: inline-block;
  padding: 5px 14px; border-radius: 999px;
  background: color-mix(in srgb, var(--phase) 16%, transparent);
  color: var(--phase);
  font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  border: 1px solid color-mix(in srgb, var(--phase) 35%, transparent);
  transition: all .8s ease;
}
.timer {
  font-size: clamp(2.6rem, 9vw, 3.6rem);
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  margin: 10px 0 6px;
  letter-spacing: -.025em;
}
.phase-sub { font-size: .92rem; color: var(--fg-dim); }
.goal-line { font-size: .82rem; color: var(--fg-muted); margin-top: 8px; }

/* ====== PHASE FX (per-phase animations) ====== */
.phase-fx {
  position: absolute; inset: 0; z-index: 1;
  pointer-events: none;
  overflow: hidden;
  border-radius: 50%;
}
.fx-particle {
  position: absolute;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--phase);
  opacity: 0;
}
/* idle / no fast */
.ring-wrap[data-phase="idle"] .fx-particle { display: none; }

/* postprandial — slow breathing pulse on ring glow */
.ring-wrap[data-phase="postprandial"] .ring {
  animation: breathe 5s ease-in-out infinite;
}
@keyframes breathe {
  0%,100% { filter: drop-shadow(0 0 8px color-mix(in srgb, var(--phase) 30%, transparent)); }
  50%     { filter: drop-shadow(0 0 18px color-mix(in srgb, var(--phase) 50%, transparent)); }
}

/* glucose drops — gentle horizontal blue wave behind ring */
.ring-wrap[data-phase="glucose_drop"] .phase-fx::before {
  content: ""; position: absolute; inset: -10%;
  background: radial-gradient(circle at 30% 50%,
    color-mix(in srgb, var(--phase) 22%, transparent) 0%,
    transparent 60%);
  animation: wave 4s ease-in-out infinite alternate;
}
@keyframes wave {
  0%   { transform: translateX(-15%) scale(1); opacity: .5; }
  100% { transform: translateX(15%)  scale(1.1); opacity: .9; }
}

/* glycogen depletion — quicker cyan pulse */
.ring-wrap[data-phase="glycogen_depletion"] .ring {
  animation: pulse-fast 2.4s ease-in-out infinite;
}
@keyframes pulse-fast {
  0%,100% { filter: drop-shadow(0 0 10px color-mix(in srgb, var(--phase) 40%, transparent)); }
  50%     { filter: drop-shadow(0 0 22px color-mix(in srgb, var(--phase) 70%, transparent)); }
}

/* ketosis begins — green sparks */
.ring-wrap[data-phase="ketosis_mild"] .fx-particle,
.ring-wrap[data-phase="ketosis_deep"] .fx-particle {
  background: var(--phase);
  box-shadow: 0 0 6px var(--phase);
  animation: spark 2.2s ease-out infinite;
}
.ring-wrap[data-phase="ketosis_mild"] .fx-particle:nth-child(1) { left: 20%; top: 70%; animation-delay: 0s; }
.ring-wrap[data-phase="ketosis_mild"] .fx-particle:nth-child(2) { left: 75%; top: 30%; animation-delay: .4s; }
.ring-wrap[data-phase="ketosis_mild"] .fx-particle:nth-child(3) { left: 50%; top: 85%; animation-delay: .8s; }
.ring-wrap[data-phase="ketosis_mild"] .fx-particle:nth-child(4) { left: 15%; top: 30%; animation-delay: 1.2s; }
.ring-wrap[data-phase="ketosis_mild"] .fx-particle:nth-child(5) { left: 80%; top: 75%; animation-delay: 1.6s; }
.ring-wrap[data-phase="ketosis_mild"] .fx-particle:nth-child(6) { left: 50%; top: 15%; animation-delay: 2.0s; }
@keyframes spark {
  0%   { opacity: 0; transform: scale(.4); }
  30%  { opacity: 1; transform: scale(1.5); }
  100% { opacity: 0; transform: scale(.4); }
}

/* deep ketosis — bright sustained pulse, brighter sparks */
.ring-wrap[data-phase="ketosis_deep"] .ring {
  animation: pulse-bright 2.8s ease-in-out infinite;
}
.ring-wrap[data-phase="ketosis_deep"] .fx-particle:nth-child(1) { left: 22%; top: 68%; animation-delay: 0s; }
.ring-wrap[data-phase="ketosis_deep"] .fx-particle:nth-child(2) { left: 73%; top: 28%; animation-delay: .3s; }
.ring-wrap[data-phase="ketosis_deep"] .fx-particle:nth-child(3) { left: 48%; top: 80%; animation-delay: .6s; }
.ring-wrap[data-phase="ketosis_deep"] .fx-particle:nth-child(4) { left: 18%; top: 32%; animation-delay: .9s; }
.ring-wrap[data-phase="ketosis_deep"] .fx-particle:nth-child(5) { left: 82%; top: 72%; animation-delay: 1.2s; }
.ring-wrap[data-phase="ketosis_deep"] .fx-particle:nth-child(6) { left: 50%; top: 18%; animation-delay: 1.5s; }
@keyframes pulse-bright {
  0%,100% { filter: drop-shadow(0 0 14px color-mix(in srgb, var(--phase) 50%, transparent)); }
  50%     { filter: drop-shadow(0 0 28px color-mix(in srgb, var(--phase) 90%, transparent)); }
}

/* autophagy begins — purple particles drifting up */
.ring-wrap[data-phase="autophagy_begins"] .fx-particle {
  background: var(--phase);
  box-shadow: 0 0 8px var(--phase);
  animation: drift 5s ease-in infinite;
  bottom: 0;
}
.ring-wrap[data-phase="autophagy_begins"] .fx-particle:nth-child(1) { left: 20%; animation-delay: 0s; }
.ring-wrap[data-phase="autophagy_begins"] .fx-particle:nth-child(2) { left: 35%; animation-delay: .8s; }
.ring-wrap[data-phase="autophagy_begins"] .fx-particle:nth-child(3) { left: 50%; animation-delay: 1.6s; }
.ring-wrap[data-phase="autophagy_begins"] .fx-particle:nth-child(4) { left: 65%; animation-delay: 2.4s; }
.ring-wrap[data-phase="autophagy_begins"] .fx-particle:nth-child(5) { left: 80%; animation-delay: 3.2s; }
.ring-wrap[data-phase="autophagy_begins"] .fx-particle:nth-child(6) { left: 30%; animation-delay: 4.0s; }
@keyframes drift {
  0%   { bottom: 5%;  opacity: 0; transform: scale(.6); }
  20%  { opacity: 1; }
  80%  { opacity: 1; transform: scale(1.2); }
  100% { bottom: 90%; opacity: 0; transform: scale(.6); }
}

/* peak autophagy — magenta orbital glow */
.ring-wrap[data-phase="autophagy_peak"] .phase-fx::before {
  content: ""; position: absolute;
  width: 70%; height: 70%; left: 15%; top: 15%;
  border-radius: 50%;
  background: radial-gradient(circle,
    color-mix(in srgb, var(--phase) 25%, transparent) 0%,
    transparent 70%);
  animation: orbital 8s linear infinite;
  transform-origin: center;
}
@keyframes orbital {
  0%   { transform: rotate(0deg)   translateX(8%); }
  100% { transform: rotate(360deg) translateX(8%); }
}

/* stem cell regen — gold sparkle shimmer */
.ring-wrap[data-phase="stem_cell_regen"] .fx-particle {
  background: var(--phase);
  box-shadow: 0 0 12px var(--phase);
  animation: sparkle 1.8s ease-in-out infinite;
}
.ring-wrap[data-phase="stem_cell_regen"] .fx-particle:nth-child(1) { left: 18%; top: 22%; animation-delay: 0s; }
.ring-wrap[data-phase="stem_cell_regen"] .fx-particle:nth-child(2) { left: 75%; top: 25%; animation-delay: .25s; }
.ring-wrap[data-phase="stem_cell_regen"] .fx-particle:nth-child(3) { left: 30%; top: 75%; animation-delay: .5s; }
.ring-wrap[data-phase="stem_cell_regen"] .fx-particle:nth-child(4) { left: 78%; top: 70%; animation-delay: .75s; }
.ring-wrap[data-phase="stem_cell_regen"] .fx-particle:nth-child(5) { left: 50%; top: 15%; animation-delay: 1.0s; }
.ring-wrap[data-phase="stem_cell_regen"] .fx-particle:nth-child(6) { left: 50%; top: 85%; animation-delay: 1.25s; }
@keyframes sparkle {
  0%,100% { opacity: 0; transform: scale(.3) rotate(0deg); }
  50%     { opacity: 1; transform: scale(1.4) rotate(180deg); }
}
.ring-wrap[data-phase="stem_cell_regen"] .ring {
  animation: pulse-bright 3s ease-in-out infinite;
}

.actions { display: flex; flex-direction: column; gap: 10px; }
.phase-card {
  margin-top: 24px;
  padding: 18px;
  border-radius: 16px;
  background: var(--bg-card);
  border-left: 3px solid var(--phase);
  transition: border-color .8s ease;
}
.phase-card h3 { margin: 0 0 6px; }
.phase-card p { margin: 0; line-height: 1.5; }
.phase-card-tech {
  color: var(--fg-muted); font-size: .82rem;
  margin-bottom: 10px !important; font-style: italic;
}
.phase-card-benefits {
  color: var(--fg); font-size: .96rem; line-height: 1.6 !important;
  padding: 10px 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--phase) 8%, transparent);
  border-left: 2px solid color-mix(in srgb, var(--phase) 55%, transparent);
}
.quiet-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0;
}
.quiet-row label { margin: 0; }
.quiet-row p { grid-column: 1 / -1; margin: 4px 0 0; }

/* ====== GLUCOSE CARD ====== */
.glucose-card {
  margin-top: 18px;
  padding: 20px 20px 18px;
  border-radius: 18px;
  background: linear-gradient(140deg,
    color-mix(in srgb, var(--gs-color, var(--accent)) 14%, var(--bg-card)),
    var(--bg-card) 60%);
  border: 1px solid color-mix(in srgb, var(--gs-color, var(--accent)) 30%, var(--border-strong));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--gs-color, var(--accent)) 18%, transparent),
              0 6px 18px -8px color-mix(in srgb, var(--gs-color, var(--accent)) 35%, transparent);
}
.glucose-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.glucose-title { font-weight: 700; font-size: 1.05rem; letter-spacing: .2px; }
.btn-mini {
  padding: 8px 16px;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  color: var(--accent);
  border-radius: 999px;
  font-weight: 600; font-size: .88rem;
  transition: background .15s;
}
.btn-mini:hover { background: color-mix(in srgb, var(--accent) 12%, var(--bg-card-2)); }
.glucose-empty { color: var(--fg-dim); font-size: .95rem; padding: 8px 0; }
.glucose-row {
  display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center;
}
.glucose-current {
  display: flex; flex-direction: column; align-items: flex-start;
}
.glucose-value {
  font-size: 3.6rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
  line-height: 1;
  color: var(--gs-color, var(--fg));
  text-shadow: 0 0 24px color-mix(in srgb, var(--gs-color, var(--accent)) 35%, transparent);
}
.glucose-unit {
  font-size: 1rem; color: var(--fg-dim);
  margin-left: 8px; font-weight: 500;
  letter-spacing: .3px;
}
.glucose-when {
  font-size: .9rem; color: var(--fg-muted);
  margin-top: 8px; font-weight: 500;
}
.glucose-spark {
  width: 100%; height: 70px;
  display: block;
}
.glucose-state {
  display: flex; align-items: flex-start; gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--gs-color, var(--accent)) 14%, transparent);
  border-left: 4px solid var(--gs-color, var(--accent));
  border-radius: 10px;
}
.glucose-state-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--gs-color);
  margin-top: 5px;
  box-shadow: 0 0 12px var(--gs-color);
  flex-shrink: 0;
}
.glucose-state-label { font-weight: 700; font-size: 1rem; color: var(--gs-color); }
.glucose-state-note { font-size: .87rem; color: var(--fg-dim); margin-top: 3px; line-height: 1.5; }

/* ====== GLUCOSE MODAL ====== */
.modal-sub { font-size: .85rem; color: var(--fg-dim); margin: 0 0 10px; }
.glucose-input {
  text-align: center;
  font-size: 2.4rem; font-weight: 200;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  padding: 18px 14px;
}
.glucose-unit-label {
  text-align: center;
  color: var(--fg-dim);
  font-size: .9rem;
  margin-top: -4px;
}
.modal-actions-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ====== LIBRE CARD ====== */
.libre-card {
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.libre-status {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px; font-size: .92rem;
}
.libre-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--fg-muted);
  box-shadow: 0 0 8px var(--fg-muted);
}
.libre-dot.live { background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: livePulse 2s ease-in-out infinite; }
.libre-dot.error { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
@keyframes livePulse { 0%,100% { opacity: 1 } 50% { opacity: .5 } }
.libre-info { color: var(--fg-dim); font-size: .82rem; line-height: 1.5; }
.libre-info strong { color: var(--fg); font-weight: 600; }
.libre-info .err {
  display: block; margin-top: 6px; padding: 8px 10px;
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger); border-radius: 8px; font-size: .82rem;
}
.libre-actions { display: flex; gap: 8px; margin-top: 10px; }
.libre-test-result {
  font-size: .85rem; padding: 8px 10px; border-radius: 8px;
}
.libre-test-result.ok {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}
.libre-test-result.err {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger);
}

/* ====== BUTTONS ====== */
.btn {
  padding: 13px 18px;
  border-radius: 12px;
  border: none;
  font-size: .98rem;
  font-weight: 600;
  transition: transform .08s, opacity .15s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #07140c; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost { background: var(--bg-card); color: var(--fg); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--bg-card-2); }
.btn.danger.ghost { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.btn.big { width: 100%; padding: 16px; font-size: 1.05rem; }
.btn.wide { width: 100%; padding: 14px; margin-top: 10px; }

/* ====== START SECTION ====== */
.protocol-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px; margin-bottom: 12px;
}
.proto {
  padding: 14px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
  transition: all .15s;
}
.proto:hover { background: var(--bg-card-2); }
.proto.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-card));
  box-shadow: 0 0 0 1px var(--accent);
}
.proto-label { font-weight: 600; font-size: 1rem; }
.proto-note { font-size: .73rem; color: var(--fg-dim); margin-top: 4px; }

.custom-row { margin: 10px 0; }
.eat-window { color: var(--fg-dim); font-size: .9rem; padding: 8px 0; }

input[type="number"], input[type="datetime-local"], input[type="time"], input[type="text"], input[type="tel"] {
  background: var(--bg-card); color: var(--fg);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 1rem; width: 100%;
  outline: none; transition: border-color .15s;
}
input:focus { border-color: var(--accent); }
label { display: block; color: var(--fg-dim); font-size: .82rem; margin-bottom: 14px; font-weight: 500; }
label > input, label > .emoji-row { margin-top: 6px; }

.when-options { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 10px;
  margin: 0; color: var(--fg); font-size: .95rem;
  cursor: pointer; transition: all .15s;
}
.opt:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-card));
}
.opt input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }

.when-detail { margin-top: 10px; }

.schedule-list { display: flex; flex-direction: column; gap: 8px; }
.sched-item {
  padding: 13px 14px; background: var(--bg-card); border-radius: 10px;
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid var(--border);
}
.sched-item-info { font-size: .9rem; }
.sched-item-info small { display: block; color: var(--fg-dim); margin-top: 3px; }
.sched-del { background: transparent; border: none; color: var(--danger); font-size: 1.5rem; line-height: 1; padding: 4px 8px; }

/* ====== PHASES SECTION ====== */
.phase-list { display: flex; flex-direction: column; gap: 10px; }
.phase-item {
  padding: 14px;
  background: var(--bg-card);
  border-radius: 12px;
  border-left: 4px solid var(--phase-color);
  display: grid; grid-template-columns: 80px 1fr; gap: 14px; align-items: center;
  transition: all .3s;
}
.phase-item.current {
  background: color-mix(in srgb, var(--phase-color) 10%, var(--bg-card));
  box-shadow: 0 0 0 1px var(--phase-color),
              0 0 24px color-mix(in srgb, var(--phase-color) 30%, transparent);
  transform: scale(1.01);
}
.phase-hours { font-weight: 700; font-size: .95rem; color: var(--phase-color); font-variant-numeric: tabular-nums; }
.phase-name { font-weight: 600; font-size: 1rem; }
.phase-desc { font-size: .85rem; color: var(--fg-dim); margin-top: 4px; line-height: 1.45; }

/* ====== HISTORY ====== */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.hist-item {
  padding: 13px 14px; background: var(--bg-card); border-radius: 10px;
  border: 1px solid var(--border);
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
}
.hist-protocol { font-weight: 600; }
.hist-when { color: var(--fg-dim); font-size: .82rem; margin-top: 2px; }
.hist-dur { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.hist-status { font-size: .73rem; text-align: right; margin-top: 3px; font-weight: 600; }
.hist-status.completed { color: var(--accent); }
.hist-status.broken { color: var(--warn); }

/* ====== STATS ====== */
.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
@media (min-width: 600px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
.stat-card {
  background: var(--bg-card); padding: 16px; border-radius: 14px;
  border: 1px solid var(--border);
}
.stat-num { font-size: 1.9rem; font-weight: 200; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-label { color: var(--fg-dim); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }

/* ====== CHART ====== */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 14px 12px;
}
.chart-wrap {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  height: 200px;
  position: relative;
}
.chart-yaxis {
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: .68rem; color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding: 2px 0;
}
.chart-plot {
  position: relative;
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.chart-grid {
  position: absolute; left: 0; right: 0; top: 0; bottom: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  pointer-events: none;
}
.chart-grid > div {
  border-top: 1px dashed var(--border);
  height: 0;
}
.chart-bars {
  position: absolute; left: 4px; right: 4px; top: 0; bottom: 0;
  display: flex; align-items: flex-end; gap: 4px;
}
.chart-bar {
  flex: 1; min-width: 6px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  transition: opacity .15s, transform .15s;
  cursor: pointer;
  position: relative;
  animation: barRise .5s cubic-bezier(.4,0,.2,1) backwards;
}
@keyframes barRise {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}
.chart-bar { transform-origin: bottom; }
.chart-bar.completed { background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%); }
.chart-bar.broken    { background: linear-gradient(180deg, var(--warn) 0%, color-mix(in srgb, var(--warn) 70%, black) 100%); }
.chart-bar:hover { opacity: .85; transform: scaleY(1.02); }
.chart-bar.selected { box-shadow: 0 0 0 2px var(--fg); opacity: 1; }
.chart-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; color: var(--fg-muted); font-size: .9rem;
  font-style: italic;
}
.chart-detail {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--fg-dim);
  font-size: .88rem;
  min-height: 20px;
  font-variant-numeric: tabular-nums;
}
.chart-detail strong { color: var(--fg); }
.chart-legend {
  display: flex; gap: 16px; margin-top: 10px;
  font-size: .78rem; color: var(--fg-dim);
}
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend .dot {
  width: 10px; height: 10px; border-radius: 2px;
  display: inline-block;
}

.toggle {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; background: var(--bg-card); border-radius: 12px;
  margin: 0 0 8px; color: var(--fg); font-size: .98rem; font-weight: 500;
  border: 1px solid var(--border);
}
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }

.ntfy-card {
  padding: 14px; background: var(--bg-card); border-radius: 12px;
  border: 1px solid var(--border);
}
.ntfy-label { font-size: .82rem; color: var(--fg-dim); margin-bottom: 6px; }
.ntfy-topic {
  display: block; padding: 8px 12px;
  background: var(--bg); border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
  color: var(--accent); font-size: 1rem; font-weight: 600;
  user-select: all;
}

/* ====== DRINKS ====== */
.drinks-list { display: flex; flex-direction: column; gap: 8px; }
.drink {
  padding: 13px 14px; background: var(--bg-card); border-radius: 10px;
  display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start;
  border-left: 3px solid var(--border);
}
.drink.ok   { border-left-color: var(--accent); }
.drink.soft { border-left-color: var(--warn); }
.drink.no   { border-left-color: var(--danger); }
.drink-icon {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .92rem;
}
.drink.ok   .drink-icon { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.drink.soft .drink-icon { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.drink.no   .drink-icon { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.drink-name { font-weight: 500; }
.drink-note { font-size: .82rem; color: var(--fg-dim); margin-top: 3px; }

/* ====== LOGIN OVERLAY ====== */
.overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(40px + var(--safe-top)) 24px calc(40px + var(--safe-bottom));
  overflow-y: auto;
}
.login-box {
  width: 100%; max-width: 480px;
  display: flex; flex-direction: column; align-items: center;
  gap: 8px;
}
.login-brand {
  font-size: 2.6rem; font-weight: 200; letter-spacing: -.04em;
  background: linear-gradient(135deg, var(--accent), #7ed957);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-sub {
  font-size: 1.1rem; color: var(--fg-dim); margin-bottom: 28px;
}
.login-tabs {
  display: flex; gap: 6px;
  width: 100%; margin: 12px 0 22px;
  background: var(--bg-card);
  padding: 4px; border-radius: 12px;
  border: 1px solid var(--border);
}
.login-tab {
  flex: 1; padding: 10px;
  background: transparent;
  border: none; color: var(--fg-dim);
  font-weight: 600; font-size: .92rem;
  border-radius: 8px;
  transition: background .15s, color .15s;
}
.login-tab.active {
  background: var(--bg-card-2);
  color: var(--accent);
}
.login-form {
  display: flex; flex-direction: column;
  gap: 14px;
  width: 100%;
  animation: fade .25s;
}
.login-form label { margin-bottom: 0; }

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
  width: 100%;
  margin-bottom: 14px;
}
.profile-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 18px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: all .2s;
}
.profile-card:hover {
  background: var(--bg-card-2);
  border-color: var(--accent);
  transform: translateY(-2px);
}
.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--bg-card-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  border: 2px solid var(--border);
  transition: border-color .2s;
}
.profile-card:hover .profile-avatar { border-color: var(--accent); }
.profile-name { font-weight: 600; font-size: .95rem; text-align: center; word-break: break-word; }
.profile-pin-icon { font-size: .7rem; color: var(--fg-muted); }

/* ====== MODAL ====== */
.modal {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade .2s;
}
.modal-box {
  width: 100%; max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 24px;
  display: flex; flex-direction: column; gap: 12px;
  animation: pop .2s;
}
@keyframes pop { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-emoji { font-size: 3rem; text-align: center; margin: 4px 0; }
.modal-name { font-size: 1.2rem; font-weight: 600; text-align: center; margin-bottom: 8px; }
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.modal-error { color: var(--danger); font-size: .85rem; text-align: center; }
.modal-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px;
}
.pin-input {
  text-align: center; font-size: 1.6rem; font-weight: 600;
  letter-spacing: 1rem; padding: 14px; padding-right: calc(14px - 1rem);
  font-variant-numeric: tabular-nums;
}
.pin-input.small { font-size: 1.1rem; letter-spacing: .4rem; padding-right: calc(14px - .4rem); }

.emoji-row {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.emoji-pick {
  width: 40px; height: 40px; font-size: 1.4rem;
  background: var(--bg-card-2); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.emoji-pick.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg-card-2)); }

/* ====== RESPONSIVE ====== */
@media (min-width: 720px) {
  main { padding: 8px 24px calc(40px + var(--safe-bottom)); }
  .topbar { padding-left: 24px; padding-right: 24px; }
  .section-nav { padding-left: 24px; padding-right: 24px; }
}

/* ====== GLUCOSE STATS CARD (Stats tab) ====== */
.glucose-stats-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.g-headline {
  display: flex; align-items: center; gap: 16px;
  padding: 8px 4px 14px; border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.g-headline-num {
  font-size: 2.6rem; font-weight: 700; line-height: 1;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.g-headline-num small { font-size: 1.1rem; opacity: .65; margin-left: 2px; }
.g-headline-label { font-weight: 600; font-size: .95rem; margin-bottom: 2px; }
.muted.warn { color: var(--warn, #d97706); }
.g-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 12px;
}
.g-tile {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 10px 9px;
  text-align: center;
}
.g-num {
  font-size: 1.3rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.g-num small { font-size: .8rem; opacity: .65; margin-left: 1px; }
.g-lbl { font-size: .72rem; opacity: .65; margin-top: 2px; line-height: 1.15; }
.g-90day {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .85rem;
  margin-bottom: 10px;
}

/* ====== HISTORY EXPANDABLE ====== */
.hist-item.collapsible { cursor: pointer; }
.hist-item .hist-row { display: flex; justify-content: space-between; align-items: center; }
.hist-item.expanded { background: color-mix(in srgb, var(--accent) 6%, var(--bg-card)); }
.hist-glucose { padding-top: 10px; margin-top: 8px; border-top: 1px solid var(--border); }
.hist-glucose-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px;
  margin-bottom: 6px;
}
.hist-glucose-grid > div { text-align: center; padding: 4px 2px; }
.hg-num { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hg-lbl { font-size: .7rem; opacity: .6; }
@media (max-width: 480px) {
  .hist-glucose-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ====== EXTEND BANNER (goal reached) ====== */
.extend-banner {
  margin: 12px 0;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent) 18%, var(--bg-card)),
    color-mix(in srgb, var(--accent) 8%, var(--bg-card)));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border-strong));
  border-radius: 16px;
  padding: 14px 16px;
  animation: extendPulse 2.4s ease-in-out infinite;
}
@keyframes extendPulse {
  0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 22%, transparent); }
  50%     { box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 0%, transparent); }
}
.extend-banner-title { font-weight: 700; font-size: 1.05rem; margin-bottom: 2px; }
.extend-banner-sub   { opacity: .7; font-size: .85rem; margin-bottom: 12px; }
.extend-banner-actions {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.extend-banner-actions .btn { padding: 8px 12px; font-size: .85rem; }

/* ====== NEXT FAST CARD (idle state) ====== */
.next-fast-card {
  margin: 12px 0;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
}
.next-fast-icon { font-size: 1.5rem; }
.next-fast-title { font-weight: 600; font-size: .95rem; }
.next-fast-sub { font-size: .82rem; opacity: .8; margin-top: 2px; }

/* ====== CHEAT DAY VISUAL ====== */
.hist-status.cheat {
  color: #c084fc;
  font-style: italic;
}
.hist-item.is-cheat {
  opacity: .65;
  background: color-mix(in srgb, var(--bg-card) 92%, transparent);
}
.hist-actions {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end;
}
.btn.small { padding: 6px 10px; font-size: .8rem; }

/* ====== AUTO-FAST + SPIKE PATTERN STYLING ====== */
.hist-badge {
  display: inline-block;
  font-size: .68rem;
  padding: 2px 6px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: 1px;
  font-weight: 600;
}
.hist-badge.auto {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
}
.hist-item.is-auto:not(.is-cheat) {
  border-left: 3px solid var(--accent);
}

/* Spike pattern card */
.sp-headline {
  display: flex; align-items: center; gap: 14px;
  padding-bottom: 12px; margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.sp-num {
  font-size: 2.1rem; font-weight: 700; line-height: 1;
  color: #ed5247; font-variant-numeric: tabular-nums;
}
.sp-lbl { font-weight: 600; font-size: .9rem; }
.sp-row-label {
  font-size: .75rem; opacity: .65; margin: 8px 0 4px;
  text-transform: uppercase; letter-spacing: .5px;
}
.sp-bars {
  display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px;
  height: 64px; align-items: end;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 6px 16px;
  margin-bottom: 8px;
  position: relative;
}
.sp-bars.dow { grid-template-columns: repeat(7, 1fr); }
.sp-bar-wrap {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; gap: 0;
  position: relative;
}
.sp-bar {
  width: 100%;
  background: linear-gradient(180deg, #ed5247, #b91c1c);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
}
.sp-bar-lbl {
  position: absolute; bottom: -14px;
  font-size: .58rem; opacity: .55;
  font-variant-numeric: tabular-nums;
}

/* ====== EATING WINDOW CARD (Now screen, between fasts) ====== */
.eating-window-card {
  margin: 12px 0;
  background: linear-gradient(135deg,
    color-mix(in srgb, #f4b400 18%, var(--bg-card)),
    var(--bg-card) 70%);
  border: 1px solid color-mix(in srgb, #f4b400 30%, var(--border-strong));
  border-radius: 16px;
  padding: 14px 16px;
}
.ew-headline { display:flex; align-items:center; gap:12px; margin-bottom:10px; }
.ew-icon { font-size: 1.6rem; }
.ew-title { font-weight: 700; font-size: 1.05rem; }
.ew-sub { font-size: .85rem; opacity: .85; margin-top: 2px; }
.ew-progress {
  height: 6px; border-radius: 999px;
  background: color-mix(in srgb, #f4b400 12%, transparent);
  overflow: hidden; margin: 6px 0 6px;
}
.ew-progress-bar {
  height: 100%; background: linear-gradient(90deg, #f4b400, #f59e0b);
  transition: width .4s ease;
}
.ew-meta { margin-top: 4px; }

/* ====== PER-PROTOCOL TABLE ====== */
.pp-table {
  width: 100%; border-collapse: collapse; font-size: .9rem; margin-bottom: 8px;
}
.pp-table th {
  text-align: left; padding: 6px 4px; opacity: .65;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}
.pp-table td {
  padding: 8px 4px; border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.pp-table .num { text-align: right; }
.pp-table tbody tr:last-child td { border-bottom: none; }
.pp-table small { opacity: .55; font-size: .75rem; margin-left: 1px; }

/* ====== LAB A1C ====== */
.a1c-form {
  display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; margin: 10px 0;
}
.a1c-form input { padding: 8px 10px !important; font-size: .85rem !important; }
.a1c-form .btn { padding: 8px 14px; }
@media (max-width: 480px) {
  .a1c-form { grid-template-columns: 1fr 1fr; }
  .a1c-form > input:nth-child(3), .a1c-form > button { grid-column: span 2; }
}
.a1c-list { margin-top: 8px; }
.a1c-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  align-items: center;
}
.a1c-row:last-child { border-bottom: none; }
.a1c-row > div:nth-child(2) { grid-column: 1; }
.a1c-row .btn.small { padding: 4px 10px; font-size: .8rem; }

/* ====== SENSOR LIFECYCLE ====== */
.sl-warmup {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: .9rem;
}
.sl-row {
  display: flex; align-items: center; gap: 16px;
  padding-bottom: 10px; margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.sl-num { font-size: 2.2rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.sl-num small { font-size: 1rem; opacity: .65; margin-left: 2px; }
.sl-num.ok { color: #3ddc84; }
.sl-num.warn { color: #f4b400; }
.sl-num.danger { color: #ed5247; }
.sl-lbl { font-size: .72rem; opacity: .65; text-transform: uppercase; letter-spacing: .5px; }
.sl-meta { flex: 1; }
.sl-progress {
  height: 8px; border-radius: 999px;
  background: var(--bg-card-2);
  overflow: hidden; margin-bottom: 8px;
}
.sl-progress-bar {
  height: 100%; transition: width .4s ease;
  background: linear-gradient(90deg, #3ddc84, #3ddc84);
}
.sl-progress-bar.warn { background: linear-gradient(90deg, #3ddc84 0%, #f4b400 80%); }
.sl-progress-bar.danger { background: linear-gradient(90deg, #f4b400 0%, #ed5247 70%); }

/* ====== 24H GLUCOSE CHART ====== */
.g24-svg { width: 100%; height: 130px; display: block; margin: 4px 0 6px; }

/* ====== STREAKS HEATMAP ====== */
.sk-summary { font-size: .9rem; margin-bottom: 12px; }
.sk-grid {
  display: grid;
  grid-template-rows: repeat(7, 12px);
  grid-auto-flow: column;
  grid-auto-columns: 12px;
  gap: 3px;
  padding: 4px 0 12px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.sk-cell {
  width: 12px; height: 12px; border-radius: 2px;
  background: color-mix(in srgb, var(--bg-card-2) 90%, var(--accent) 10%);
  border: 1px solid var(--border);
}
.sk-cell[data-score="1"] {
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-card-2));
}
.sk-cell[data-score="2"] {
  background: color-mix(in srgb, var(--accent) 55%, var(--bg-card-2));
}
.sk-cell[data-score="3"] {
  background: var(--accent);
  box-shadow: 0 0 4px color-mix(in srgb, var(--accent) 50%, transparent);
}
.sk-grid .sk-cell { grid-row: calc(var(--row, 0) + 1); }
.sk-cell[data-row="0"] { grid-row: 1; }
.sk-cell[data-row="1"] { grid-row: 2; }
.sk-cell[data-row="2"] { grid-row: 3; }
.sk-cell[data-row="3"] { grid-row: 4; }
.sk-cell[data-row="4"] { grid-row: 5; }
.sk-cell[data-row="5"] { grid-row: 6; }
.sk-cell[data-row="6"] { grid-row: 7; }
.sk-legend {
  display: flex; align-items: center; gap: 4px;
  font-size: .72rem; opacity: .65;
  margin-top: 6px;
}
.sk-legend .sk-cell { width: 10px; height: 10px; }

/* ====== EATING WINDOW ACTIONS ====== */
.ew-actions { margin-top: 10px; }
.ew-actions .btn.small { padding: 6px 12px; font-size: .82rem; }

/* ====== MEAL MODAL — uses existing .modal styles ====== */
#mealModal select,
#mealModal input {
  background: var(--bg-card-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .95rem;
  width: 100%;
}

/* ====== PUSH SUBSCRIPTION CARD ====== */
.push-card {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.push-row {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px;
}
.push-row > div:first-child { flex: 1; min-width: 0; }
.push-row .btn { flex-shrink: 0; }

/* ====== ENDO REPORT CARD ====== */
.btn.wide { display: block; width: 100%; text-align: center; padding: 12px; margin-top: 4px; }

/* ====== LEADERBOARD ====== */
.lb-self {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.lb-self td { font-weight: 600; }

/* ====== COACH CARD ====== */
.coach-card { border-color: color-mix(in srgb, var(--accent) 35%, var(--border-strong)); }
.coach-insight {
  padding: 12px 14px;
  background: var(--bg-card-2);
  border-radius: 12px;
  border-left: 4px solid var(--accent);
  margin-bottom: 10px;
}
.coach-insight.concern { border-left-color: var(--warn); }
.coach-insight.milestone {
  border-left-color: var(--accent);
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent) 14%, var(--bg-card-2)),
    var(--bg-card-2) 70%);
}
.coach-insight.safety { border-left-color: var(--danger); }
.coach-insight.lesson { border-left-color: #c084fc; }
.coach-insight-kind {
  font-size: .7rem; font-weight: 700;
  opacity: .7; text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 4px;
}
.coach-insight-title { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.coach-insight-body { font-size: .88rem; line-height: 1.5; opacity: .9; }
.coach-insight-actions { display: flex; gap: 8px; margin-top: 10px; }
.coach-history-toggle { text-align: center; margin: 8px 0; }
.coach-history-item {
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
}
.coach-history-item:last-child { border-bottom: none; }
.coach-history-item.resolved { opacity: .65; }
.coach-history-item.dismissed { opacity: .45; text-decoration: line-through; }
.coach-history-item.stubborn { border-left: 2px solid var(--warn); padding-left: 8px; }

/* ====== PROFILE CARD ====== */
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.profile-card select,
.profile-card input[type=date] {
  background: var(--bg-card-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: .9rem;
  width: 100%;
}
.meds-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 4px 10px;
  margin-bottom: 12px;
}
.meds-grid label {
  display: flex; align-items: center; gap: 6px;
  font-size: .85rem; color: var(--fg);
  margin: 2px 0;
}
.meds-grid input[type=checkbox] { width: 16px; height: 16px; margin: 0; }
