/* ============================================================
   Little Sprout — mobile-first styles + themes
   Themes are CSS custom properties scoped by [data-theme].
   ============================================================ */

/* ---------- Theme palettes ---------- */
:root,
[data-theme="spring"] {
  --bg: #f3faf1;
  --bg-grad: linear-gradient(160deg, #f3faf1 0%, #eaf7ff 100%);
  --surface: #ffffff;
  --surface-2: #f3f7f4;
  --text: #2f3b33;
  --muted: #7c8a82;
  --primary: #79c285;
  --primary-ink: #ffffff;
  --accent: #f7a8c4;
  --line: #e3ebe5;
  --shadow: 0 6px 20px rgba(60, 90, 70, .10);
  --danger: #e06a6a;
}
[data-theme="flowers"] {
  --bg: #fdf4f8;
  --bg-grad: linear-gradient(160deg, #fdeff6 0%, #f4f0ff 100%);
  --surface: #ffffff;
  --surface-2: #faf1f6;
  --text: #4a3340;
  --muted: #a4869a;
  --primary: #e98bb8;
  --primary-ink: #ffffff;
  --accent: #b58be9;
  --line: #f0e1ea;
  --shadow: 0 6px 20px rgba(150, 90, 130, .12);
  --danger: #e06a6a;
}
[data-theme="ocean"] {
  --bg: #eef7fb;
  --bg-grad: linear-gradient(160deg, #e8f4fb 0%, #eafaf4 100%);
  --surface: #ffffff;
  --surface-2: #eef5f8;
  --text: #21404c;
  --muted: #6f93a0;
  --primary: #4bb0c9;
  --primary-ink: #ffffff;
  --accent: #6fc7a8;
  --line: #dcebf1;
  --shadow: 0 6px 20px rgba(40, 100, 120, .12);
  --danger: #e06a6a;
}
/* "sunset" is now the dynamic "Auto (day/night)" theme. It has no palette of
   its own — js/ui.js resolves it to [data-theme="spring"] by day and
   [data-theme="chocolate"] at night, reusing those variables (no duplication). */
[data-theme="classic"] {
  --bg: #f5f6f8;
  --bg-grad: linear-gradient(160deg, #f6f7f9 0%, #eef0f4 100%);
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --text: #2b2f36;
  --muted: #828a96;
  --primary: #5b8def;
  --primary-ink: #ffffff;
  --accent: #7aa0f2;
  --line: #e4e7ed;
  --shadow: 0 6px 20px rgba(60, 70, 90, .10);
  --danger: #e06a6a;
}
/* Dark — clean, high-contrast dark mode (text ~16:1 on bg; AA+ for body text).
   (Registration id stays "chocolate" for backward compatibility.) */
[data-theme="chocolate"] {
  --bg: #0f1115;
  --bg-grad: linear-gradient(160deg, #0f1115 0%, #0b0d11 100%);
  --surface: #181b22;
  --surface-2: #232833;
  --text: #f3f5f8;
  --muted: #aab4c2;
  --primary: #7cb8ff;
  --primary-ink: #07121f;
  --accent: #ff9ec2;
  --line: #2c333f;
  --shadow: 0 6px 24px rgba(0, 0, 0, .55);
  --danger: #ff8a85;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.4;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
h1, h2, h3 { margin: 0; font-weight: 700; }
/* Native buttons don't inherit body color (UA sets buttontext=black), which made
   unstyled button labels render black on dark themes. Inherit the theme text;
   explicit button rules (primary ink, active states) still override this. */
button { font-family: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 1rem; color: var(--text); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }

/* ---------- App shell ---------- */
.app { min-height: 100%; display: flex; flex-direction: column; }
.appbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.appbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; max-width: 880px; margin: 0 auto; width: 100%;
}
.baby-chip { display: flex; align-items: center; gap: 10px; }
.baby-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.2rem;
  background: var(--surface-2);
}
.baby-meta { display: flex; flex-direction: column; line-height: 1.15; }
.baby-meta strong { font-size: 1rem; }
.baby-meta small { font-size: .76rem; }

.screens { flex: 1; max-width: 880px; margin: 0 auto; width: 100%;
  padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); }
.screen { display: none; animation: fade .18s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.section-title { font-size: .95rem; color: var(--muted); margin: 18px 2px 10px;
  text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
}

/* ---------- Quick actions ---------- */
.quick-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.quick-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 20px; padding: 16px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  box-shadow: var(--shadow); transition: transform .08s ease;
  min-height: 96px; justify-content: center;
}
.quick-btn:active { transform: scale(.96); }
.quick-btn .qico {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.5rem;
  background: var(--surface-2);
}
.quick-btn .qlabel { font-size: .82rem; font-weight: 600; }
.quick-btn .qsub { font-size: .68rem; color: var(--muted); }
.quick-btn.live { border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 40%, transparent); }
.quick-btn.live .qico { background: var(--primary); color: var(--primary-ink);
  animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* ---------- Predictions ---------- */
.predictions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.predict-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow);
}
.predict-card .pico { font-size: 1.5rem; }
.predict-card .ptext { flex: 1; }
.predict-card .ptitle { font-weight: 700; font-size: .92rem; }
.predict-card .pdetail { font-size: .82rem; color: var(--muted); }
.conf { font-size: .68rem; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.conf.high { background: color-mix(in srgb, var(--primary) 22%, transparent); color: var(--text); }
.conf.med  { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); }

/* ---------- Timeline ---------- */
.timeline-head { display: flex; align-items: baseline; justify-content: space-between; }
.timeline { display: flex; flex-direction: column; gap: 8px; }
.tl-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 12px;
}
.tl-item .tlico {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: 1.15rem; background: var(--surface-2);
}
.tl-main { flex: 1; min-width: 0; }
.tl-title { font-weight: 600; font-size: .9rem; }
.tl-sub { font-size: .78rem; color: var(--muted); }
.tl-time { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; font-size: .9rem; }

/* ---------- Segmented control ---------- */
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg-btn { flex: 1; border: none; background: transparent; color: var(--muted);
  padding: 9px 6px; border-radius: 9px; font-weight: 600; font-size: .86rem; }
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Summary cards ---------- */
.summary-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; box-shadow: var(--shadow);
}
.stat .stat-ico { font-size: 1.2rem; }
.stat .stat-val { font-size: 1.5rem; font-weight: 800; margin-top: 4px; }
.stat .stat-label { font-size: .8rem; color: var(--muted); }
.stat .stat-sub { font-size: .72rem; color: var(--muted); margin-top: 2px; }

/* ---------- Growth ---------- */
.weight-latest { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.weight-latest .wv { font-size: 2.2rem; font-weight: 800; }
.chart-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px; box-shadow: var(--shadow); margin: 14px 0; overflow: hidden; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.weight-list { display: flex; flex-direction: column; gap: 8px; }
.weight-row { display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.weight-row .wr-date { color: var(--muted); font-size: .85rem; }
.weight-row .wr-val { font-weight: 700; }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: .82rem; color: var(--muted); font-weight: 600; }
.field-label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.field input, .field select, .modal-body input, .modal-body select, .modal-body textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface-2); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--primary); }

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary, .btn-danger {
  border-radius: 14px; border: 1px solid transparent; padding: 13px 16px;
  font-weight: 700; font-size: .95rem; width: 100%;
}
.btn-primary { background: var(--primary); color: var(--primary-ink); box-shadow: var(--shadow); }
.btn-primary.big { padding: 16px; font-size: 1.02rem; }
.btn-primary:active { filter: brightness(.96); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-danger.ghost { width: auto; padding: 13px 18px; }
.icon-btn { background: var(--surface-2); border: 1px solid var(--line); border-radius: 50%;
  width: 38px; height: 38px; font-size: 1rem; color: var(--text); display: grid; place-items: center; }

/* ---------- Theme grid / chips ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-swatch { border: 2px solid var(--line); border-radius: 14px; padding: 10px;
  display: flex; flex-direction: column; gap: 8px; align-items: center; background: var(--surface-2); }
.theme-swatch.selected { border-color: var(--primary); }
.theme-dots { display: flex; gap: 4px; }
.theme-dots i { width: 16px; height: 16px; border-radius: 50%; display: block; }
.theme-swatch span { font-size: .76rem; font-weight: 600; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  padding: 9px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600; }
.chip.selected { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(12px);
  border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
.tab { background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  flex: 1; padding: 4px; border-radius: 12px; }
.tab-ico { font-size: 1.35rem; line-height: 1; filter: grayscale(.4); opacity: .7; }
.tab-label { font-size: .68rem; font-weight: 600; }
.tab.active { color: var(--text); }
.tab.active .tab-ico { filter: none; opacity: 1; transform: translateY(-1px); }

/* ---------- Modal sheet ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 25, 30, .4); }
.modal-sheet {
  position: relative; width: 100%; max-width: 560px;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0,0,0,.2);
  animation: rise .22s ease; max-height: 90vh; overflow-y: auto;
}
@keyframes rise { from { transform: translateY(100%); } to { transform: none; } }
.modal-handle { width: 40px; height: 5px; border-radius: 999px; background: var(--line);
  margin: 6px auto 10px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-body { display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; gap: 10px; margin-top: 18px; align-items: center; }
.modal-foot .btn-primary { flex: 1; }

/* time input methods inside modal */
.ti-methods { display: flex; gap: 6px; flex-wrap: wrap; }
.ti-method { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: .8rem; font-weight: 600; color: var(--muted); }
.ti-method.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.ti-panel { margin-top: 4px; }
.ti-relrow, .ti-steprow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ti-chip { padding: 9px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); font-weight: 600; font-size: .86rem; }
.ti-chip.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.ti-display { font-size: 1.15rem; font-weight: 800; text-align: center; padding: 6px 0; }
.step-btn { width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 1.4rem; font-weight: 700; }

.opt-row { display: flex; gap: 8px; flex-wrap: wrap; }
.opt { flex: 1; min-width: 80px; text-align: center; padding: 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); font-weight: 600; }
.opt.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* ---------- Onboarding ---------- */
.onboarding { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px;
  background: var(--bg); background-image: var(--bg-grad); z-index: 100; }
.onboarding-card { background: var(--surface); border: 1px solid var(--line);
  border-radius: 24px; padding: 28px 22px; width: 100%; max-width: 380px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; text-align: center; }
.onboarding-emoji { font-size: 3rem; }
.onboarding-emoji img { display: block; width: 64px; height: 64px; margin: 0 auto;
  border-radius: 16px; object-fit: cover; }
.onboarding-card h1 { font-size: 1.4rem; }
.onboarding-card .field { text-align: left; }
.login-error { color: var(--danger); font-size: .85rem; min-height: 1.2em; margin: 4px 0 0; }
.erase-warn { font-size: .9rem; line-height: 1.4; margin: 0; }
.erase-warn strong { color: var(--danger); }
#login-card .btn-primary:disabled { opacity: .6; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: var(--text); color: var(--surface);
  padding: 10px 16px; border-radius: 999px; font-size: .85rem; font-weight: 600;
  z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: fade .2s ease; }

/* ---------- Larger screens (Mac review) ---------- */
@media (min-width: 720px) {
  .quick-grid { grid-template-columns: repeat(6, 1fr); }
  .summary-cards { grid-template-columns: repeat(4, 1fr); }
  .modal { align-items: center; }
  .modal-sheet { border-radius: 22px; max-width: 520px; }
  .theme-grid { grid-template-columns: repeat(6, 1fr); }
}

.disclaimer { margin-top: 22px; text-align: center; }
.about-row { display: flex; align-items: center; justify-content: space-between; }

/* ---------- appbar undo/redo ---------- */
.appbar-actions { display: flex; gap: 8px; }
.icon-btn.disabled { opacity: .35; pointer-events: none; }

/* ---------- time editor: big buttons ---------- */
.ti-steprow { display: flex; gap: 8px; justify-content: center; flex-wrap: nowrap; }
.step-btn { flex: 1; min-width: 0; height: 50px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 1rem; font-weight: 700; color: var(--text); }
.step-btn.step-now.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.ti-ago-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ti-bigbtn { display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0; padding: 12px 4px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); }
.ti-bigbtn .big-num { font-size: 1.15rem; font-weight: 800; }
.ti-bigbtn .big-sub { font-size: .66rem; color: var(--muted); }
.ti-bigbtn.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.ti-bigbtn.active .big-sub { color: var(--primary-ink); opacity: .85; }

/* ---------- collapsible (optional time) ---------- */
.collapsible { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.disclosure { width: 100%; display: flex; justify-content: space-between; align-items: center;
  background: var(--surface-2); border: none; padding: 12px 14px; font-weight: 600; color: var(--muted); }
.disclosure .chev { transition: transform .15s ease; }
.disclosure.open .chev { transform: rotate(180deg); }
.collapsible-body { padding: 12px 14px; }

/* ---------- diaper emoji options ---------- */
.opt.opt-big { font-size: 1.7rem; padding: 14px 8px; }

/* ---------- measure field (Type keypad / Slide ruler) ---------- */
.field-head { display: flex; align-items: center; justify-content: space-between; }
.field-head > span { font-size: .82rem; color: var(--muted); font-weight: 600; }
.mini-toggle { background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: .76rem; font-weight: 600; }

.ruler { display: flex; flex-direction: column; gap: 6px; }
.ruler-value { text-align: center; font-size: 1.35rem; font-weight: 800; }
.ruler-track-wrap { position: relative; height: 56px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.ruler-pointer { position: absolute; left: 50%; top: 6px; bottom: 6px; width: 2px;
  background: var(--primary); transform: translateX(-50%); z-index: 2; border-radius: 2px; }
.ruler-pointer::after { content: ''; position: absolute; top: -1px; left: 50%; transform: translateX(-50%);
  border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid var(--primary); }
.ruler-scroll { position: absolute; inset: 0; display: flex; align-items: flex-end;
  overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; touch-action: pan-x; }
.ruler-scroll::-webkit-scrollbar { display: none; }
.ruler-scroll { scrollbar-width: none; }
.ruler-spacer { flex: 0 0 auto; }
/* The tick MARK and label are centred in the tick box, matching scroll-snap
   (center) and the JS scrollLeft math, so a value sits exactly under the pointer. */
.ruler-tick { flex: 0 0 auto; height: 16px; position: relative; scroll-snap-align: center;
  display: flex; align-items: flex-end; justify-content: center; }
.ruler-tick::before { content: ''; width: 1px; height: 16px; background: var(--line); }
.ruler-tick.major { height: 30px; }
.ruler-tick.major::before { width: 2px; height: 30px; background: var(--muted); }
.ruler-tlabel { position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%);
  font-size: .62rem; color: var(--muted); white-space: nowrap; }

/* Combined diaper glyph (💧💩) shrinks to the same box footprint as one emoji. */
.tlico .emoji-combo { font-size: .72rem; line-height: 1; letter-spacing: -1px; white-space: nowrap; }

/* ---------- metrics: age banner ---------- */
.age-banner { margin-top: 4px; }
.age-inner { display: flex; align-items: center; gap: 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); }
.age-emoji { font-size: 1.6rem; }
.age-big { font-weight: 800; font-size: 1.1rem; }
.age-sub { font-size: .8rem; }

/* ---------- metrics: window controls ---------- */
.win-controls { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.win-controls .seg { flex: 1; }
.win-custom { flex: 0 0 auto; padding: 9px 10px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); font-weight: 600; font-size: .82rem; max-width: 40%; }

/* ---------- metrics: KPI rings ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 12px; box-shadow: var(--shadow); display: flex; flex-direction: column;
  align-items: center; gap: 4px; text-align: center; }
.kpi-ring { width: 84px; }
.kpi .ring { width: 84px; height: 84px; display: block; }
.kpi-label { font-weight: 700; font-size: .9rem; margin-top: 4px; }
.kpi-sub { font-size: .72rem; }
.kpi { cursor: pointer; }
.kpi.open { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent); }
.kpi .spark-wrap { width: 100%; margin-top: 6px; }
.kpi .spark { width: 100%; height: 40px; display: block; }
.kpi-hint { font-size: .62rem; margin-top: 4px; opacity: .7; }
.kpi-detail { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.kpi-detail:empty { display: none; }
.kpi-detail-head { font-size: .76rem; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; }

/* ---------- home: day navigation ---------- */
.day-nav { display: flex; align-items: center; gap: 8px; margin: 18px 2px 10px; }
.nav-arrow { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 1.3rem; color: var(--text); flex: none; line-height: 1; }
.nav-arrow.disabled { opacity: .3; pointer-events: none; }
.day-nav-mid { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.home-range { border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 10px; padding: 7px 12px; font-weight: 700; font-size: .88rem; max-width: 100%; }
.day-label { font-size: .74rem; }
.home-custom { width: 100%; margin: 0 0 10px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 600; }

/* ---------- metrics: trend charts ---------- */
.trend-charts { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.trend-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 14px; box-shadow: var(--shadow); }
.trend-title { font-weight: 700; font-size: .9rem; margin-bottom: 6px; }
.trend-legend { display: flex; gap: 14px; margin-bottom: 6px; }
.trend-legend .leg { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; color: var(--muted); }
.trend-legend .leg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.trend-card .bars { width: 100%; height: auto; display: block; touch-action: none; }

/* ---------- weight chart interactivity ---------- */
.chart-inner { position: relative; }
.chart-tip { position: absolute; transform: translate(-50%, -130%); pointer-events: none;
  background: var(--text); color: var(--surface); border-radius: 10px; padding: 6px 10px;
  font-size: .78rem; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  display: flex; flex-direction: column; align-items: center; line-height: 1.25; z-index: 2; }
.chart-tip span { opacity: .8; font-size: .68rem; }

@media (min-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .ti-ago-grid { grid-template-columns: repeat(8, 1fr); }
  .trend-charts { display: grid; grid-template-columns: repeat(2, 1fr); }
}
