/* Life Tracker styles. Colors are defined once as tokens, then swapped for dark mode. */

:root {
  color-scheme: light;
  --bg: #f3f2ee;
  --surface: #fcfcfb;
  --raised: #ffffff;
  --sunken: #ebeae5;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;
  --hair: rgba(11, 11, 11, 0.1);
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --wash: rgba(11, 11, 11, 0.05);
  --seg-on: #ffffff;
  --accent: #2a78d6;
  --primary: #0b0b0b;
  --primary-ink: #ffffff;
  --danger: #c23434;
  --good: #006300;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 -4px 40px rgba(0, 0, 0, 0.18);

  /* Chart / hobby colors (fixed order; a hobby keeps its color) */
  --c0: #9a9892;
  --c1: #2a78d6;
  --c2: #eb6834;
  --c3: #1baf7a;
  --c4: #eda100;
  --c5: #e87ba4;
  --c6: #008300;
  --c7: #4a3aa7;
  --c8: #e34948;

  --radius: 20px;
  --radius-sm: 14px;
  --gutter: 16px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --raised: #232322;
    --sunken: #2a2a28;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --ink-3: #898781;
    --hair: rgba(255, 255, 255, 0.1);
    --grid: #2c2c2a;
    --axis: #383835;
    --wash: rgba(255, 255, 255, 0.06);
    --seg-on: #46463f;
    --accent: #3987e5;
    --primary: #ffffff;
    --primary-ink: #0b0b0b;
    --danger: #e66767;
    --good: #0ca30c;
    --shadow: none;
    --shadow-lg: 0 -4px 40px rgba(0, 0, 0, 0.6);
    --c0: #6d6c67;
    --c1: #3987e5;
    --c2: #d95926;
    --c3: #199e70;
    --c4: #c98500;
    --c5: #d55181;
    --c6: #008300;
    --c7: #9085e9;
    --c8: #e66767;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --raised: #232322;
  --sunken: #2a2a28;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --ink-3: #898781;
  --hair: rgba(255, 255, 255, 0.1);
  --grid: #2c2c2a;
  --axis: #383835;
  --wash: rgba(255, 255, 255, 0.06);
  --seg-on: #46463f;
  --accent: #3987e5;
  --primary: #ffffff;
  --primary-ink: #0b0b0b;
  --danger: #e66767;
  --good: #0ca30c;
  --shadow: none;
  --shadow-lg: 0 -4px 40px rgba(0, 0, 0, 0.6);
  --c0: #6d6c67;
  --c1: #3987e5;
  --c2: #d95926;
  --c3: #199e70;
  --c4: #c98500;
  --c5: #d55181;
  --c6: #008300;
  --c7: #9085e9;
  --c8: #e66767;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  overflow-x: hidden;
}
body.no-scroll { overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.center { text-align: center; }
.icon { flex: none; display: block; }

#app { max-width: 560px; margin: 0 auto; }
.page {
  padding: max(12px, env(safe-area-inset-top)) var(--gutter) calc(40px + env(safe-area-inset-bottom));
}

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 0 18px; }
.topbar-text { flex: 1; min-width: 0; }
.topbar-title { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.topbar-sub { color: var(--ink-3); font-size: 14px; margin-top: 2px; }

.icon-btn {
  width: 44px; height: 44px; flex: none;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--ink);
}
.icon-btn:hover { background: var(--wash); }
.icon-btn:disabled { opacity: 0.3; background: transparent; }
.icon-btn.sm { width: 36px; height: 36px; }

/* ---------- Sections & cards ---------- */
.section { margin: 0 0 24px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-title {
  margin: 0 0 10px; font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-3);
}
.section-meta { font-size: 14px; color: var(--ink-2); }

.card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.pad { padding: 16px; margin-bottom: 16px; }
.card.empty { padding: 22px 18px; color: var(--ink-3); text-align: center; margin-bottom: 16px; }
.card.stack { display: grid; gap: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.card-head .btn { white-space: nowrap; flex-shrink: 0; }
.card-title { margin: 0 0 12px; font-size: 16px; font-weight: 650; }
.card-head .card-title { margin: 0; }
.card-sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.sub-title { margin: 18px 0 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }

/* ---------- Activity tiles (front page) ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: 128px; padding: 16px;
  text-align: left;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--tone) 9%, var(--surface));
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
}
.tile:active { transform: scale(0.97); }
.tile .bubble { margin-bottom: auto; }
.tile-name { font-weight: 650; font-size: 17px; margin-top: 12px; }
.tile-sub { font-size: 13px; color: var(--ink-3); }
.tile-sub.done { color: var(--ink-2); font-weight: 600; }
.tile.add { background: transparent; border: 1.5px dashed var(--axis); box-shadow: none; }
.tile.add .bubble { background: var(--sunken); color: var(--ink-2); }

.bubble {
  width: 44px; height: 44px; flex: none;
  display: inline-grid; place-items: center;
  border-radius: 14px;
  font-size: 24px; line-height: 1;
  background: color-mix(in srgb, var(--tone, var(--c0)) 20%, var(--surface));
}
.bubble.sm { width: 36px; height: 36px; font-size: 19px; border-radius: 11px; }
.muted-bubble { filter: grayscale(1); opacity: 0.6; }

/* ---------- Do it again ---------- */
.repeat-row {
  display: flex; gap: 10px; overflow-x: auto;
  margin: 0 calc(var(--gutter) * -1); padding: 2px var(--gutter) 6px;
  scrollbar-width: none; scroll-snap-type: x proximity;
}
.repeat-row::-webkit-scrollbar { display: none; }
.repeat {
  flex: none; scroll-snap-align: start;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px 10px 10px;
  border: 1px solid var(--hair); border-radius: 999px;
  background: var(--surface);
}
.repeat:active { transform: scale(0.97); }
.repeat-icon {
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%;
  background: color-mix(in srgb, var(--tone) 20%, var(--surface)); font-size: 17px;
}
.repeat-text { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.repeat-text strong { font-size: 14px; font-weight: 650; }
.repeat-text span { font-size: 12px; color: var(--ink-3); }

/* ---------- Lists of entries ---------- */
.list { list-style: none; margin: 0 0 16px; padding: 4px 0; }
.list > li + li { border-top: 1px solid var(--hair); }
.row, .row-hit {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border: 0; background: transparent; text-align: left;
}
.row.static { padding: 6px 8px 6px 0; }
.row.static .row-hit { flex: 1; min-width: 0; padding: 4px 14px; }
.row:not(.static):active, .row-hit:active { background: var(--wash); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 600; }
.row-sub { font-size: 13px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.reorder { display: flex; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border-radius: 14px; border: 1px solid transparent;
  font-weight: 650; font-size: 16px;
  transition: transform 0.1s ease, opacity 0.15s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn.block { width: 100%; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.primary:disabled { opacity: 0.35; }
.btn.secondary { background: var(--sunken); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--hair); }
.btn.danger-ghost { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.secondary.block { margin-top: 4px; }
.link-btn { background: none; border: 0; color: var(--accent); padding: 10px; font-weight: 600; }

/* ---------- Choice chips ---------- */
.chips { display: flex; gap: 8px; }
.chips.wrap { flex-wrap: wrap; }
.chip {
  flex: none;
  min-height: 44px; padding: 0 16px;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; border: 1px solid var(--hair);
  background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 15px;
}
.chip[aria-checked='true'] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.chip-icon { font-size: 20px; }

.chips.big { display: grid; grid-template-columns: 1fr 1fr; }
.chips.big .chip {
  min-height: 72px; border-radius: 16px; justify-content: center; font-size: 17px;
}
.chips.scroller {
  overflow-x: auto; margin: 0 -20px; padding: 2px 20px 6px;
  scroll-snap-type: x proximity; scrollbar-width: none;
}
.chips.scroller::-webkit-scrollbar { display: none; }
.chips.scroller .chip { scroll-snap-align: center; min-width: 64px; justify-content: center; font-variant-numeric: tabular-nums; }

.chips.segmented {
  background: var(--sunken); padding: 4px; border-radius: 14px; gap: 4px;
}
.chips.segmented .chip {
  flex: 1; min-height: 38px; border: 0; background: transparent; border-radius: 10px; justify-content: center; padding: 0 8px;
}
.chips.segmented .chip[aria-checked='true'] { background: var(--seg-on); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ---------- Forms ---------- */
.field { margin: 0 0 20px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border-radius: 12px; border: 1px solid var(--hair);
  background: var(--raised); color: var(--ink);
  font-size: 16px; /* 16px stops iPhones zooming in */
}
textarea.input { resize: vertical; min-height: 64px; }
.input.small { width: auto; min-width: 120px; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.custom-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; }
.form-error {
  color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent);
  padding: 10px 12px; border-radius: 10px; font-size: 14px; margin: 0 0 14px;
}
.emoji-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.emoji-opt {
  aspect-ratio: 1; border-radius: 12px; border: 1px solid transparent; background: var(--sunken);
  font-size: 22px; display: grid; place-items: center;
}
.emoji-opt[aria-checked='true'] { border-color: var(--ink); background: var(--raised); box-shadow: 0 0 0 1px var(--ink); }
.input.emoji-input { width: 72px; min-width: 0; text-align: center; font-size: 20px; }
.custom-row .muted { white-space: nowrap; }

/* ---------- Sign in ---------- */
.auth {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding: 32px var(--gutter) calc(32px + env(safe-area-inset-bottom));
  max-width: 400px; margin: 0 auto;
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand h1 { margin: 14px 0 4px; font-size: 28px; letter-spacing: -0.02em; }
.auth-brand p { margin: 0; }
.auth-logo { border-radius: 16px; }
.auth-form { display: flex; flex-direction: column; }
.auth-form .field { margin-bottom: 14px; }
.auth-form .btn { margin-top: 6px; }
.auth-note { color: var(--ink-2); font-size: 15px; margin: 0 0 18px; text-align: center; }

/* ---------- Bottom sheet ---------- */
.sheet-backdrop, .drawer-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0; transition: opacity 0.25s ease;
}
.sheet-backdrop.open, .drawer-backdrop.open { opacity: 1; }
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0;
  max-width: 560px; margin: 0 auto;
  max-height: 92dvh;
  display: flex; flex-direction: column;
  background: var(--raised);
  border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.open { transform: none; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--axis); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 4px 20px; }
.sheet-title { margin: 0; font-size: 20px; font-weight: 700; }
.sheet-title-inner { display: inline-flex; align-items: center; gap: 10px; }
.sheet-body { overflow-y: auto; padding: 12px 20px 4px; overscroll-behavior: contain; }
.sheet-footer {
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--hair);
}
.footer-row { display: flex; gap: 10px; }
.footer-row .btn.primary { flex: 1; }

/* ---------- Menu drawer ---------- */
.drawer {
  position: fixed; z-index: 41; top: 0; bottom: 0; right: 0;
  width: min(320px, 86vw);
  display: flex; flex-direction: column;
  background: var(--raised);
  padding: max(12px, env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow-y: auto;
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px 16px 12px; }
.drawer-name { font-weight: 700; font-size: 18px; }
.drawer-sub { color: var(--ink-3); font-size: 14px; }
.drawer-list { list-style: none; margin: 0; padding: 0; }
.drawer-item {
  width: 100%; display: flex; align-items: center; gap: 14px;
  min-height: 48px; padding: 0 12px; border: 0; border-radius: 12px;
  background: transparent; font-size: 16px; font-weight: 550; text-align: left; color: var(--ink);
}
.drawer-item:hover:not(.disabled) { background: var(--wash); }
.drawer-item.active { background: var(--sunken); font-weight: 700; }
.drawer-item.disabled { color: var(--ink-3); cursor: default; }
.drawer-item .emoji { width: 22px; text-align: center; font-size: 18px; filter: grayscale(0.6); }
.drawer-section {
  margin: 18px 12px 6px; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-3);
}
.badge {
  margin-left: auto; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: var(--sunken); color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em;
}
.drawer-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--hair); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 60; left: 0; right: 0; margin: 0 auto; width: max-content;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateY(20px); opacity: 0;
  display: flex; align-items: center; gap: 14px;
  max-width: calc(100vw - 32px);
  padding: 12px 12px 12px 18px; border-radius: 14px;
  background: var(--primary); color: var(--primary-ink);
  font-size: 15px; font-weight: 550;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.toast.show { transform: none; opacity: 1; }
.toast.error { background: var(--danger); color: #fff; }
.toast-action {
  border: 0; background: color-mix(in srgb, var(--primary-ink) 16%, transparent); color: inherit;
  font-weight: 700; padding: 8px 12px; border-radius: 10px;
}

/* ---------- Overview ---------- */
.filters { display: grid; gap: 10px; margin-bottom: 18px; }
.period-nav { display: flex; align-items: center; justify-content: space-between; }
.period-label { font-weight: 650; font-size: 17px; }
.overview-body { transition: opacity 0.15s; }
.overview-body.loading { opacity: 0.5; }

.hero { padding: 6px 2px 20px; }
.hero-label { font-size: 14px; color: var(--ink-3); font-weight: 600; }
.hero-value { font-size: 52px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; margin: 2px 0 4px; }
.hero-caption { color: var(--ink-2); font-size: 15px; }

.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.hbars.compact { gap: 10px; }
.hbar-top { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; margin-bottom: 6px; }
.hbar-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.hbar-value { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar-track { height: 10px; }
.hbar-fill { height: 10px; border-radius: 0 4px 4px 0; background: var(--tone); }
.swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--tone); flex: none; display: inline-block; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.split-cell { background: var(--sunken); border-radius: 14px; padding: 12px 14px; }
.split-label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.split-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.split-sub { font-size: 13px; color: var(--ink-3); }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0; margin: 4px 0 10px; font-size: 13px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }

.chart { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart svg { display: block; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .tick.future { opacity: 0.45; }
.chart .band-wash { fill: var(--wash); opacity: 0; }
.chart .band-wash.on { opacity: 1; }
.chart-tip {
  position: absolute; top: -6px; z-index: 2;
  min-width: 130px; max-width: 220px;
  padding: 10px 12px; border-radius: 12px;
  background: var(--raised); border: 1px solid var(--hair);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  font-size: 13px; pointer-events: none;
  transform: translateY(-100%);
}
.tip-title { color: var(--ink-3); font-weight: 600; }
.tip-total { font-size: 17px; font-weight: 700; margin: 2px 0 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-name { flex: 1; color: var(--ink-2); }
.tip-val { font-weight: 600; font-variant-numeric: tabular-nums; }

.chart-table { overflow-x: auto; }
.chart-table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.chart-table th, .chart-table td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--hair); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chart-table th:first-child { text-align: left; font-weight: 600; }
.chart-table thead th { color: var(--ink-3); font-size: 12px; font-weight: 600; }
.chart-table th:first-child { position: sticky; left: 0; background: var(--surface); padding-right: 12px; }

/* ---------- Loading placeholder ---------- */
.boot { min-height: 100dvh; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* Roomier on a computer screen */
@media (min-width: 600px) {
  .page { padding-top: 28px; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Quick pills (weight, good night) ---------- */
.pill-row { display: flex; gap: 10px; margin: -6px 0 22px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 16px 0 12px;
  border-radius: 999px; border: 1px solid var(--hair);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 15px;
  box-shadow: var(--shadow);
}
.pill:active { transform: scale(0.97); }
.pill.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* ---------- Night card (front page, evenings) ---------- */
.night-card {
  margin: -4px 0 22px; padding: 18px 18px 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #1b1f4b, #0e1030);
  color: #fff;
  box-shadow: 0 10px 30px rgba(20, 24, 80, 0.25);
}
.night-title { font-size: 20px; font-weight: 700; }
.night-sub { color: rgba(255, 255, 255, 0.72); font-size: 14px; margin: 4px 0 14px; }
.btn.night { background: #f7e08a; color: #1b1f4b; font-size: 17px; min-height: 52px; }
.night-card .pill-row { margin: 12px 0 0; }
.night-card .pill { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.18); color: #fff; box-shadow: none; }

/* ---------- Sleeping screen ---------- */
.sleep-mode {
  min-height: 100dvh; display: flex; flex-direction: column;
  background: radial-gradient(120% 80% at 50% 0%, #1c2150 0%, #0b0e24 60%, #06081a 100%);
  color: #fff; position: relative;
  padding: max(12px, env(safe-area-inset-top)) var(--gutter) calc(32px + env(safe-area-inset-bottom));
}
.sleep-menu { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; color: rgba(255,255,255,0.7); }
.sleep-body { margin: auto 0; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding-top: 40px; }
.sleep-moon { font-size: 64px; line-height: 1; margin-bottom: 8px; filter: drop-shadow(0 0 24px rgba(247, 224, 138, 0.35)); }
.sleep-title { margin: 0; font-size: 26px; font-weight: 700; }
.sleep-since { color: rgba(255, 255, 255, 0.65); font-size: 15px; }
.sleep-elapsed { font-size: 56px; font-weight: 700; letter-spacing: -0.03em; margin: 18px 0 26px; font-variant-numeric: tabular-nums; }
.sleep-forgot { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; width: 100%; max-width: 360px; text-align: left; }
.sleep-forgot p { margin: 0 0 10px; font-size: 14px; color: rgba(255,255,255,0.85); }
.sleep-forgot .input { background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.2); color-scheme: dark; }
.btn.wake { background: #f7e08a; color: #1b1f4b; font-size: 19px; min-height: 60px; max-width: 360px; border-radius: 18px; }
.sleep-cancel { color: rgba(255, 255, 255, 0.55); margin-top: 6px; font-size: 14px; font-weight: 500; }

/* ---------- Morning check-in ---------- */
.checkin-summary { text-align: center; padding: 4px 0 18px; }
.checkin-big { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }

/* Faces: 5 equal choices with a big emoji and a tiny label */
.chips.faces { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.chips.faces .chip {
  flex-direction: column; gap: 2px; min-height: 68px; padding: 6px 2px; border-radius: 14px; font-size: 11px; font-weight: 600;
  justify-content: center;
}
.chips.faces .chip-icon { font-size: 26px; }

/* ---------- Weight stepper ---------- */
.stepper { display: flex; align-items: center; justify-content: center; gap: 10px; }
.step-btn {
  width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--hair);
  background: var(--sunken); color: var(--ink); font-size: 26px; font-weight: 500; line-height: 1;
}
.step-btn:active { transform: scale(0.94); }
.stepper-mid { display: flex; align-items: baseline; gap: 6px; }
.weight-input {
  width: 150px; text-align: right; border: 0; background: transparent; color: var(--ink);
  font-size: 44px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; padding: 0;
}
.weight-input:focus { outline: none; border-bottom: 2px solid var(--accent); }
.stepper-unit { font-size: 18px; color: var(--ink-3); font-weight: 600; }

/* ---------- Stats rows, glance tiles ---------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius-sm); padding: 12px 12px 10px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.stat-value { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; margin-top: 2px; white-space: nowrap; }

.glance-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.glance {
  text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 14px 16px;
  border-radius: var(--radius); border: 1px solid var(--hair);
  background: color-mix(in srgb, var(--tone) 9%, var(--surface)); box-shadow: var(--shadow);
}
.glance:active { transform: scale(0.98); }
.glance-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.glance-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.glance-sub { font-size: 12px; color: var(--ink-3); }

/* ---------- Line chart marks ---------- */
.chart .trend-line { stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart .focus-dot { stroke: var(--surface); stroke-width: 2; }
.swatch.dot { border-radius: 50%; }
.swatch.line { height: 3px; width: 14px; border-radius: 2px; }
.row-value.face { font-size: 22px; }

/* ---------- Calories in vs. out ---------- */
.balance { display: grid; gap: 8px; margin-bottom: 6px; }
.balance-row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "label kcal" "rate kcal"; align-items: center; column-gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--sunken); }
.balance-label { grid-area: label; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.balance-rate { grid-area: rate; font-size: 15px; font-weight: 600; }
.balance-kcal { grid-area: kcal; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.balance-row.strong { background: color-mix(in srgb, var(--c1) 12%, var(--surface)); }
.advice { list-style: none; margin: 0 0 12px; padding: 0; }
.advice li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--hair); font-size: 15px; }
.advice li:last-child { border-bottom: 0; }
.advice-goal { font-weight: 600; white-space: nowrap; }
.advice-change { color: var(--ink-2); text-align: right; font-size: 14px; white-space: nowrap; }
@media (max-width: 360px) { .advice li { flex-direction: column; align-items: flex-start; gap: 2px; } .advice-change { text-align: left; } }

/* ---------- Routine / "usually now" ---------- */
.time-pair { display: flex; align-items: center; gap: 10px; }
.time-pair .input { flex: 1; min-width: 0; }
.now-card {
  display: flex; flex-direction: column; gap: 12px; margin: -4px 0 22px; padding: 16px;
  border-radius: var(--radius); border: 1px solid var(--hair);
  background: color-mix(in srgb, var(--tone) 12%, var(--surface)); box-shadow: var(--shadow);
}
.now-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); }
.now-title { font-size: 20px; font-weight: 700; margin-top: 2px; }
.now-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile.now { border-color: color-mix(in srgb, var(--tone) 55%, transparent); }
.now-badge {
  position: absolute; top: 12px; right: 12px; font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 999px; background: var(--tone); color: #fff;
}
.glance-row.three { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.glance-row.three .glance { padding: 12px 10px; }
.glance-row.three .glance-value { font-size: 19px; }
.glance-row.three .glance-label { font-size: 12px; }
.glance-row.three .glance-sub { font-size: 11px; }

/* ---------- Heart / imports ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.progress { width: 100%; height: 8px; margin: 10px 0 6px; accent-color: var(--accent); }
.howto { margin-top: 10px; font-size: 14px; color: var(--ink-2); }
.howto summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.howto ol, .howto ul { margin: 8px 0 0; padding-left: 20px; }
.howto li { margin: 4px 0; }

/* ---------- Money ---------- */
.insights { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.insights li { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; line-height: 1.35; }
.insight-mark { flex: none; width: 18px; text-align: center; font-size: 12px; margin-top: 3px; color: var(--ink-3); }
.insights li.up .insight-mark { color: var(--c2); }
.insights li.down .insight-mark { color: var(--good); }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--hair); font-size: 15px; }
.plain-list li:last-child { border-bottom: 0; }
.plain-list li span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plain-list strong { font-variant-numeric: tabular-nums; }
.tx-day { margin-bottom: 14px; }
.tx-date { font-size: 13px; font-weight: 600; color: var(--ink-3); margin: 0 0 6px 4px; }
.row-value.in, strong.in { color: var(--good); }
.bubble.cat { background: var(--sunken); font-size: 17px; }
.tx-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 0 0 14px; font-size: 14px; }
.tx-head strong { font-size: 20px; white-space: nowrap; }
.chips.cats .chip { min-height: 38px; padding: 0 12px; font-size: 14px; }
.chips.cats .chip-icon { font-size: 16px; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; color: var(--ink-2); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.lines { display: grid; gap: 8px; margin: 8px 0; }
.rline { display: grid; grid-template-columns: 1fr 96px 36px; gap: 6px; align-items: center; padding: 8px; border-radius: 12px; background: var(--bg); }
.rline .input { min-height: 40px; padding: 6px 10px; font-size: 14px; }
.rline .amt { text-align: right; }
.rline .sel { grid-column: 1 / 3; }
.rline .icon-btn { justify-self: end; }

/* ---------- Email ---------- */
.btn-row { display: flex; gap: 10px; margin-bottom: 18px; }
.btn-row .btn { flex: 1; }
.card.notice { margin-bottom: 14px; font-size: 14px; color: var(--ink-2); border-left: 4px solid var(--c8); }
.bullets { margin: 0 0 16px; padding-left: 20px; color: var(--ink-2); font-size: 14px; line-height: 1.45; }
.bullets li + li { margin-top: 6px; }
.section-sub { margin: -4px 0 10px; }
.row.mail .row-sub.subject { color: var(--ink); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.mail .row-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.mail.seen .row-title, .row.mail.seen .row-sub.subject { font-weight: 400; color: var(--ink-2); }
.row-value.small { font-size: 12px; color: var(--ink-3); font-weight: 500; align-self: flex-start; padding-top: 3px; }
.mail-head { margin-bottom: 12px; }
.mail-subject { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.stack { display: grid; gap: 8px; }
.btn.two { flex-direction: column; align-items: flex-start; gap: 2px; height: auto; min-height: 48px; padding: 10px 14px; line-height: 1.25; text-align: left; }
.btn.two .btn-sub { font-size: 12px; font-weight: 500; color: var(--ink-3); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-head .btn.small { white-space: nowrap; flex-shrink: 0; }

/* ---------- Two-step sign-in ---------- */
.auth-note.left { text-align: left; }
.field-hint { margin: 6px 0 0; }
.stack-lg { display: grid; gap: 14px; }
.code-input {
  font-size: 24px;
  letter-spacing: 0.18em;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.code-input::placeholder { letter-spacing: 0.05em; font-size: 18px; }
.setup-steps { margin: 0 0 14px; padding-left: 20px; color: var(--ink-2); font-size: 15px; line-height: 1.45; }
.setup-steps strong { color: var(--ink); }
.qr-box {
  display: flex;
  justify-content: center;
  padding: 14px;
  margin: 0 auto 12px;
  background: #fff; /* scanners need dark-on-light, even in dark mode */
  border-radius: var(--radius-sm);
  border: 1px solid var(--hair);
  width: fit-content;
}
.qr { display: block; width: 208px; height: 208px; image-rendering: pixelated; }
.key-details { margin: 14px 0 18px; }
.key-details summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 15px; padding: 6px 0; }
.key-details .inline-form { align-items: center; }
.totp-key {
  flex: 1;
  font: 600 15px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
  background: var(--sunken);
  border-radius: 10px;
  padding: 10px 12px;
  word-break: break-all;
  user-select: all;
}
.recovery-codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin: 0;
  padding: 14px 14px 14px 36px;
  background: var(--sunken);
  border-radius: var(--radius-sm);
}
.recovery-codes code { font: 600 15px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; user-select: all; }
.check-row { display: flex; align-items: center; gap: 10px; font-size: 15px; padding: 4px 0; }
.check-row input { width: 20px; height: 20px; accent-color: var(--primary); }
.tfa-state { margin: 0; font-weight: 650; }
.tfa-state.on { color: var(--good); }
.tfa-state .muted { font-weight: 400; color: var(--ink-3); }
@media (max-width: 360px) {
  .recovery-codes { grid-template-columns: 1fr; }
}
a.btn { text-decoration: none; text-align: center; color: inherit; padding-top: 10px; padding-bottom: 10px; line-height: 1.25; }
a.btn.secondary { color: var(--ink); }
