/* =========================================================
   Nightcap — Live BAC Tracker
   Palette: midnight navy surfaces, warm gold accent, cream text.
   Designed for late-night use; serif display, clean sans body.
   ========================================================= */

:root,
[data-theme='light'] {
  --color-bg: #f4efe5;
  --color-surface: #faf6ec;
  --color-surface-2: #ffffff;
  --color-surface-offset: #ece6d6;
  --color-border: #d6cdba;
  --color-divider: #e3dccb;

  --color-text: #14161f;
  --color-text-muted: #5b5e6c;
  --color-text-faint: #9b9ca8;
  --color-text-inverse: #faf6ec;

  --color-primary: #a87328;        /* warm gold, AA on cream */
  --color-primary-hover: #8a5b18;
  --color-primary-active: #6c4510;
  --color-primary-highlight: #f0e2c0;

  --color-accent: #1c2342;          /* deep midnight navy for headings */
  --color-accent-soft: #2a3358;

  --color-success: #2c6b4f;
  --color-success-tint: #d6e8de;
  --color-warning: #a86010;
  --color-warning-tint: #f3dcb4;
  --color-danger:  #962e2e;
  --color-danger-tint: #efcecb;
  --color-critical: #5e1f6e;
  --color-critical-tint: #e3d0e9;

  --color-water: #1f6680;
  --color-water-tint: #d2e2eb;
  --color-food: #6c7a3b;
  --color-food-tint: #e0e3cc;

  --shadow-sm: 0 1px 2px rgb(20 25 50 / .06);
  --shadow-md: 0 8px 24px rgb(20 25 50 / .10);
  --shadow-lg: 0 24px 56px rgb(20 25 50 / .16);
}

[data-theme='dark'] {
  /* Midnight navy, not pure black — feels expensive, dim-bar lit */
  --color-bg: #0b0f1c;
  --color-surface: #131a2c;
  --color-surface-2: #1a2238;
  --color-surface-offset: #202a44;
  --color-border: #2a3556;
  --color-divider: #1f2841;

  --color-text: #f1ead7;            /* warm cream — premium, not stark white */
  --color-text-muted: #9a9fb5;
  --color-text-faint: #5b6485;
  --color-text-inverse: #0b0f1c;

  --color-primary: #e2b864;          /* warm gold, sings on navy */
  --color-primary-hover: #efc878;
  --color-primary-active: #c79a48;
  --color-primary-highlight: #2a2718;

  --color-accent: #f1ead7;          /* on dark, accent = cream */
  --color-accent-soft: #d8d2bf;

  --color-success: #7bc28a;
  --color-success-tint: #1c2e26;
  --color-warning: #e0a85c;
  --color-warning-tint: #2e251a;
  --color-danger:  #e08484;
  --color-danger-tint: #2e1f24;
  --color-critical: #c697d6;
  --color-critical-tint: #2a213a;

  --color-water: #6fb0c8;
  --color-water-tint: #182a36;
  --color-food: #b3c870;
  --color-food-tint: #1d2418;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / .45);
  --shadow-md: 0 8px 24px rgb(0 0 0 / .55);
  --shadow-lg: 0 24px 56px rgb(0 0 0 / .65);
}

:root {
  --text-xs: clamp(.75rem, .7rem + .25vw, .875rem);
  --text-sm: clamp(.875rem, .8rem + .35vw, 1rem);
  --text-base: clamp(1rem, .95rem + .25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + .75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-display: clamp(3rem, 2rem + 5vw, 5.5rem);

  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem;
  --space-4: 1rem; --space-5: 1.25rem; --space-6: 1.5rem;
  --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem;
  --space-16: 4rem;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --transition: 200ms cubic-bezier(.16, 1, .3, 1);
  --font-display: 'Fraunces', 'Source Serif 4', 'Iowan Old Style', Georgia, serif;
  --font-body: 'Satoshi', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  color-scheme: light dark;
}
body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--color-text);
  background:
    radial-gradient(1200px 700px at 80% -10%, color-mix(in oklab, var(--color-primary) 10%, transparent), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, color-mix(in oklab, var(--color-primary) 7%, transparent), transparent 60%),
    var(--color-bg);
  background-attachment: fixed;
}
img, svg { display: block; max-width: 100%; }
button { background: none; border: none; cursor: pointer; font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; letter-spacing: -.01em; }
.muted { color: var(--color-text-muted); }
.small { font-size: var(--text-xs); }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; border-radius: var(--radius-sm); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

a, button, [role='button'], input, select {
  transition: color var(--transition), background var(--transition),
              border-color var(--transition), box-shadow var(--transition),
              transform var(--transition);
}

/* ---------- Layout ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) clamp(var(--space-4), 4vw, var(--space-8));
  max-width: 980px;
  margin: 0 auto;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--color-text);
}
.brand-mark { color: var(--color-primary); }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.015em;
  font-size: var(--text-lg);
  font-feature-settings: "ss01";
}
.brand-tag {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  border-left: 1px solid var(--color-border);
  padding-left: var(--space-3);
  text-transform: lowercase;
  letter-spacing: .04em;
  font-style: italic;
}
.top-actions { display: flex; gap: var(--space-2); }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.icon-btn:hover { color: var(--color-text); border-color: var(--color-primary); }

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 clamp(var(--space-4), 4vw, var(--space-8)) var(--space-12);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* ---------- Live BAC hero ---------- */
.live-hero {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 2px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: clamp(var(--space-6), 4vw, var(--space-10));
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.live-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(600px 200px at 80% -20%, color-mix(in oklab, var(--color-primary) 22%, transparent), transparent 70%);
  pointer-events: none;
}
.live-stack {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.live-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.status-pill {
  font-size: var(--text-xs);
  font-weight: 700;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.status-pill[data-state='safe']     { background: color-mix(in oklab, var(--color-success) 38%, transparent); color: color-mix(in oklab, var(--color-success) 35%, var(--color-text)); border-color: color-mix(in oklab, var(--color-success) 60%, transparent); }
.status-pill[data-state='caution']  { background: color-mix(in oklab, var(--color-warning) 38%, transparent); color: color-mix(in oklab, var(--color-warning) 35%, var(--color-text)); border-color: color-mix(in oklab, var(--color-warning) 60%, transparent); }
.status-pill[data-state='illegal']  { background: color-mix(in oklab, var(--color-danger) 38%, transparent);  color: color-mix(in oklab, var(--color-danger) 35%, var(--color-text));  border-color: color-mix(in oklab, var(--color-danger) 60%, transparent); }
.status-pill[data-state='danger']   { background: color-mix(in oklab, var(--color-critical) 42%, transparent);color: color-mix(in oklab, var(--color-critical) 30%, var(--color-text));border-color: color-mix(in oklab, var(--color-critical) 60%, transparent); }

#trend-label {
  font-family: var(--font-mono);
  letter-spacing: .02em;
}
#trend-label[data-trend='up']::before    { content: '▲ '; color: var(--color-warning); }
#trend-label[data-trend='down']::before  { content: '▼ '; color: var(--color-success); }
#trend-label[data-trend='flat']::before  { content: '— '; color: var(--color-text-muted); }

.dual-readout {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: var(--space-4);
  align-items: stretch;
  margin-top: var(--space-1);
}
.dual-readout::before {
  content: '';
  grid-column: 2;
  background: var(--color-divider);
  width: 1px;
  align-self: stretch;
}
.readout-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}
.readout-col.now { grid-column: 1; }
.readout-col.projected { grid-column: 3; }
.readout-label {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .22em;
  font-weight: 500;
  color: var(--color-text-muted);
  font-style: italic;
}
.readout-col.projected .readout-label { color: var(--color-primary); }
.readout-sub {
  font-family: var(--font-mono);
  letter-spacing: .02em;
}
@media (max-width: 540px) {
  .dual-readout {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  .dual-readout::before {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    height: 1px;
  }
  .readout-col.now { grid-column: 1; grid-row: 1; }
  .readout-col.projected { grid-column: 1; grid-row: 3; }
}

.big-number {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.big-number #bac,
.big-number #bac-projected {
  font-size: clamp(2.25rem, 1.5rem + 3vw, 3.75rem);
  font-weight: 700;
  letter-spacing: -.04em;
  color: var(--color-text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.readout-col.projected #bac-projected {
  color: var(--color-primary);
  opacity: .9;
}
.big-number .unit {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}
.effect { font-size: var(--text-sm); color: var(--color-text-muted); max-width: 60ch; }

.meter {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.meter-track {
  position: relative;
  height: 8px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  display: grid;
  grid-template-columns: 27% 27% 23% 23%;
  background: var(--color-surface-offset);
}
.meter-zone { display: block; height: 100%; opacity: .55; }
.meter-zone.z1 { background: var(--color-success); }
.meter-zone.z2 { background: var(--color-warning); }
.meter-zone.z3 { background: var(--color-danger); }
.meter-zone.z4 { background: var(--color-critical); }
.meter-fill {
  position: relative;
  height: 4px;
  margin-top: -6px;
  width: 0%;
  background: var(--color-text);
  border-radius: var(--radius-pill);
  transition: width 600ms cubic-bezier(.16, 1, .3, 1);
  box-shadow: 0 0 0 2px var(--color-surface);
  z-index: 2;
}
.meter-fill.projected {
  margin-top: -4px;
  height: 2px;
  background: repeating-linear-gradient(
    90deg,
    var(--color-primary) 0 6px,
    transparent 6px 10px
  );
  box-shadow: none;
  opacity: .8;
  z-index: 1;
}
.meter-legal {
  display: grid;
  grid-template-columns: 27% 27% 23% 23%;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}
.meter-legal span:nth-child(1) { text-align: left; }
.meter-legal span:nth-child(2),
.meter-legal span:nth-child(3),
.meter-legal span:nth-child(4) { text-align: center; transform: translateX(-50%); }
.meter-legal span:nth-child(5) { grid-column: 4; text-align: right; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-divider);
}
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .label { font-size: var(--text-xs); color: var(--color-text-muted); }
.stat .value {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -.01em;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 460px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:last-child { grid-column: 1 / -1; }
}

/* ---------- Card ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.card-head h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 500;
  letter-spacing: -.015em;
  color: var(--color-accent);
  font-feature-settings: "ss01";
}

#elapsed-label {
  font-family: var(--font-mono);
  letter-spacing: .02em;
}

/* ---------- Quick log grid ---------- */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}
@media (max-width: 720px) { .quick-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 460px) { .quick-grid { grid-template-columns: repeat(2, 1fr); } }

.qbtn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  position: relative;
}
.qbtn svg { color: var(--color-text-muted); margin-bottom: var(--space-2); }
.qbtn .q-name { font-weight: 600; font-size: var(--text-sm); color: var(--color-text); }
.qbtn .q-meta { font-size: var(--text-xs); color: var(--color-text-muted); }

.qbtn:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.qbtn:hover svg { color: var(--color-primary); }
.qbtn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }

.qbtn.water:hover { border-color: var(--color-water); }
.qbtn.water:hover svg { color: var(--color-water); }
.qbtn.food:hover  { border-color: var(--color-food); }
.qbtn.food:hover svg  { color: var(--color-food); }

@keyframes log-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(.96); box-shadow: 0 0 0 4px color-mix(in oklab, var(--color-primary) 30%, transparent); }
  100% { transform: scale(1); }
}
.qbtn.logged { animation: log-pulse 360ms cubic-bezier(.16,1,.3,1); }

/* ---------- Timeline ---------- */
.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.timeline .empty {
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--space-6) 0;
}

.t-item {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  animation: slide-in 280ms cubic-bezier(.16, 1, .3, 1);
}
@keyframes slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.t-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
}
.t-item[data-kind='drink'] .t-icon { background: var(--color-primary-highlight); color: var(--color-primary); }
.t-item[data-kind='water'] .t-icon { background: var(--color-water-tint); color: var(--color-water); }
.t-item[data-kind='food']  .t-icon { background: var(--color-food-tint);  color: var(--color-food); }

.t-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.t-title { font-weight: 600; font-size: var(--text-sm); color: var(--color-text); }
.t-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.t-meta .dot::before { content: '·'; padding: 0 4px; color: var(--color-text-faint); }
.t-time {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  margin: -2px 0;
  border-radius: 999px;
  border: 1px dashed var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}
.t-time:hover {
  color: var(--color-text);
  border-color: var(--color-primary);
  background: var(--color-primary-highlight);
}
.t-time svg { opacity: 0.65; }
.t-time:hover svg { opacity: 1; color: var(--color-primary); }
.t-bac {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.t-bac strong { display: block; color: var(--color-text); font-size: var(--text-sm); font-weight: 600; }
.t-remove {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: var(--color-text-faint);
  border: 1px solid transparent;
}
.t-remove:hover { color: var(--color-danger); border-color: var(--color-danger); }

@media (max-width: 460px) {
  .t-item {
    grid-template-columns: 32px 1fr auto;
    grid-template-areas:
      'icon body remove'
      'icon bac  remove';
  }
  .t-icon   { grid-area: icon; }
  .t-body   { grid-area: body; }
  .t-bac    { grid-area: bac; text-align: left; }
  .t-remove { grid-area: remove; align-self: center; }
  .t-item:not(:has(.t-bac:not(:empty))) {
    grid-template-areas: 'icon body remove';
  }
}

.ghost-btn {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 600;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
}
.ghost-btn:hover { color: var(--color-danger); border-color: var(--color-danger); }

/* ---------- Dialog ---------- */
.dialog {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 100vw;
  max-height: 100dvh;
  margin: auto;
  inset: 0;
}
.dialog::backdrop {
  background: rgb(10 8 4 / .55);
  backdrop-filter: blur(6px);
}
.dialog[open] { animation: dialog-in 220ms cubic-bezier(.16, 1, .3, 1); }
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.dialog-inner {
  width: min(420px, 92vw);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6) var(--space-3);
}
.dialog-head h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: -.015em;
  color: var(--color-accent);
  font-feature-settings: "ss01";
}
.dialog-body { padding: 0 var(--space-6) var(--space-5); display: flex; flex-direction: column; gap: var(--space-5); }
.dialog-body.scrollable { max-height: 70vh; overflow-y: auto; }
.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface-2);
  border-top: 1px solid var(--color-divider);
}

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field label { font-size: var(--text-sm); font-weight: 500; color: var(--color-text); }
.field .row-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.field input[type='text'],
.field input[type='number'] {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  width: 100%;
  font-size: var(--text-base);
  font-variant-numeric: tabular-nums;
}
.field input:focus { border-color: var(--color-primary); }
.field .hint { margin-top: 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }

.seg {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 4px;
  width: fit-content;
}
.seg.three { grid-template-columns: 1fr 1fr 1fr; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  position: relative;
  z-index: 1;
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-pill);
  cursor: pointer;
  text-align: center;
  color: var(--color-text-muted);
  white-space: nowrap;
}
.seg input:checked + label { color: var(--color-text); }
.seg-thumb {
  position: absolute;
  z-index: 0;
  top: 4px; bottom: 4px;
  background: var(--color-surface);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), width var(--transition);
}
.seg:not(.three) .seg-thumb { width: calc(50% - 4px); left: 4px; }
.seg:not(.three) input[value='female']:checked ~ .seg-thumb { transform: translateX(100%); }
.seg.three .seg-thumb { width: calc(33.333% - 4px); left: 4px; }
.seg.three input[value='light']:checked ~ .seg-thumb { transform: translateX(100%); }
.seg.three input[value='full']:checked  ~ .seg-thumb { transform: translateX(200%); }

.seg-mini {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 2px;
  font-size: var(--text-xs);
  position: relative;
}
.seg-mini input { position: absolute; opacity: 0; pointer-events: none; }
.seg-mini label {
  padding: 2px var(--space-3);
  border-radius: var(--radius-pill);
  cursor: pointer;
  color: var(--color-text-muted);
  font-weight: 500;
}
.seg-mini input:checked + label { background: var(--color-surface); color: var(--color-text); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: var(--text-sm);
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--color-primary); color: var(--color-text-inverse); }
.btn.primary:not(:disabled):hover { background: var(--color-primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn.ghost { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn.ghost:not(:disabled):hover { border-color: var(--color-primary); color: var(--color-primary); }

/* ---------- Legal & footer ---------- */
.legal {
  margin-top: var(--space-2);
  padding: var(--space-5);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: color-mix(in oklab, var(--color-warning) 5%, var(--color-surface));
}
.legal h3 {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--color-warning);
  margin-bottom: var(--space-2);
}
.legal p { font-size: var(--text-sm); color: var(--color-text-muted); }
.legal strong { color: var(--color-text); }

.foot {
  text-align: center;
  padding: var(--space-6) var(--space-4) var(--space-10);
}

/* ---------- Effect lists ---------- */
.effect-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--space-2);
  padding: 0;
}
.effect-list li {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text);
  background: color-mix(in oklab, var(--color-text) 6%, var(--color-surface-offset));
  padding: 3px var(--space-2);
  border-radius: var(--radius-pill);
  border: 1px solid color-mix(in oklab, var(--color-text) 10%, var(--color-divider));
  line-height: 1.4;
}
.readout-col.projected .effect-list li {
  background: color-mix(in oklab, var(--color-primary) 18%, var(--color-surface-offset));
  border-color: color-mix(in oklab, var(--color-primary) 40%, var(--color-divider));
  color: color-mix(in oklab, var(--color-primary) 35%, var(--color-text));
}
.effect-list:empty { display: none; }

/* ---------- Stopwatch ---------- */
button.stopwatch {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-3);
  background: color-mix(in oklab, var(--color-primary) 6%, var(--color-surface-2));
  border: 1px solid color-mix(in oklab, var(--color-primary) 25%, var(--color-divider));
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  position: relative;
}
button.stopwatch:hover {
  border-color: var(--color-primary);
  background: color-mix(in oklab, var(--color-primary) 10%, var(--color-surface-2));
}
button.stopwatch[hidden] { display: none; }
.sw-edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-left: var(--space-3);
  padding: 3px var(--space-2);
  border-radius: var(--radius-pill);
  background: color-mix(in oklab, var(--color-primary) 14%, transparent);
  border: 1px solid color-mix(in oklab, var(--color-primary) 30%, transparent);
}
.sw-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--color-primary);
  font-weight: 700;
}
.sw-time {
  font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.25rem);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.sw-started { margin-left: auto; }

/* ---------- Recap dialog ---------- */
.recap-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.recap-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.recap-cell .recap-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--color-text-muted);
  font-weight: 600;
}
.recap-cell .recap-value {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.recap-cell .recap-sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}
.dialog-foot.recap-foot {
  flex-wrap: wrap;
  gap: var(--space-2);
}
@media (max-width: 460px) {
  .recap-grid { grid-template-columns: 1fr; }
  .dialog-foot.recap-foot { justify-content: stretch; flex-direction: column-reverse; }
  .dialog-foot.recap-foot .btn { width: 100%; }
}

/* ---------- History dialog ---------- */
.history-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
}
.history-stats[hidden] { display: none; }
.history-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
}
.history-stat .hs-value {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}
.history-stat .hs-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--color-text-muted);
}
@media (max-width: 460px) {
  .history-stats { grid-template-columns: 1fr 1fr; }
}
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.history-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.history-row .h-when {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.history-row .h-date {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-accent);
  font-feature-settings: "ss01";
}
.history-row .h-time {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.history-row .h-metrics {
  display: flex;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}
.history-row .h-metric strong {
  color: var(--color-primary);
  font-weight: 600;
}
.history-row .h-delete {
  background: transparent;
  border: 0;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.history-row .h-delete:hover { color: var(--color-danger); background: color-mix(in oklab, var(--color-danger) 10%, transparent); }
@media (max-width: 540px) {
  .history-row { grid-template-columns: 1fr auto; }
  .history-row .h-metrics { grid-column: 1 / -1; }
}

/* ---------- BAC curve chart ---------- */
.bac-chart {
  margin: var(--space-3) 0 0;
  padding: var(--space-3) var(--space-4) var(--space-4);
  background: color-mix(in oklab, var(--color-surface-2) 70%, transparent);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
}
.bac-chart[hidden] { display: none; }
.bac-chart-cap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}
.bac-chart-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: -.005em;
  color: var(--color-accent);
  font-feature-settings: "ss01";
}
.bac-chart-legend {
  display: inline-flex;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  letter-spacing: .02em;
}
.bac-chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.bac-chart-legend .lg::before {
  content: '';
  display: inline-block;
  width: 10px; height: 2px;
  border-radius: 1px;
  background: var(--color-primary);
}
.bac-chart-legend .lg-future::before {
  background: repeating-linear-gradient(to right, var(--color-primary) 0 3px, transparent 3px 6px);
}
.bac-chart-legend .lg-thresh::before {
  background: var(--color-warning);
  opacity: .7;
}
#bac-curve-svg {
  display: block;
  width: 100%;
  height: 180px;
  overflow: visible;
}
#bac-curve-svg .grid-line {
  stroke: var(--color-divider);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  opacity: .55;
}
#bac-curve-svg .threshold-line {
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 3 4;
  opacity: .55;
}
#bac-curve-svg .threshold-line.t-caution { stroke: var(--color-warning); }
#bac-curve-svg .threshold-line.t-illegal { stroke: var(--color-danger); }
#bac-curve-svg .threshold-label {
  fill: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .04em;
}
#bac-curve-svg .axis-label {
  fill: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .04em;
}
#bac-curve-svg .drink-marker {
  fill: var(--color-primary);
  stroke: var(--color-surface);
  stroke-width: 1.5;
}
#bac-curve-svg .drink-stem {
  stroke: var(--color-primary);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  opacity: .35;
}
#bac-curve-svg .drink-cluster-badge {
  fill: var(--color-primary);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .02em;
}
#bac-curve-svg .grid-line.vline {
  opacity: .25;
  stroke-dasharray: 1 4;
}
#bac-curve-svg #curve-line-past,
#bac-curve-svg #curve-line-future {
  vector-effect: non-scaling-stroke;
}

/* ---------- Safety suggestions ---------- */
.suggestions {
  margin-top: var(--space-5);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-primary);
}
.suggestions[hidden] { display: none; }
.suggestions-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.suggestions-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -.005em;
  color: var(--color-text);
}
.suggestions-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.suggestion {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--color-text);
}
.suggestion + .suggestion {
  border-top: 1px solid var(--color-divider);
  padding-top: var(--space-3);
}
.suggestion-icon {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-top: 1px;
  color: var(--color-primary);
  background: rgba(226, 184, 100, 0.10);
}
.suggestion-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}
.suggestion-text { flex: 1 1 auto; }
.suggestion[data-tone="warn"] .suggestion-icon {
  color: var(--color-warning);
  background: rgba(255, 176, 87, 0.12);
}
.suggestion[data-tone="good"] .suggestion-icon {
  color: var(--color-success, #7ad19f);
  background: rgba(122, 209, 159, 0.12);
}
.suggestion[data-tone="info"] .suggestion-icon {
  color: var(--color-primary);
  background: rgba(226, 184, 100, 0.10);
}

/* Update stats grid for the 4th cell */
.stats { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:last-child { grid-column: auto; }
}

/* ---------- Category dialog ---------- */
.dialog-inner.wide { width: min(560px, 94vw); }
.dialog-sub {
  padding: 0 var(--space-6) var(--space-3);
  margin-top: -8px;
}
.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  padding-right: 4px;
}
.option-grid:empty { display: none; }
.option-grid .opt[hidden] { display: none !important; }

/* Search row */
.search-row {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: var(--space-3);
  color: var(--color-text-muted);
  pointer-events: none;
}
.search-input {
  flex: 1;
  width: 100%;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: var(--space-3) var(--space-4) var(--space-3) calc(var(--space-3) + 22px);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}
.search-input::placeholder { color: var(--color-text-muted); }
.search-input:focus { border-color: var(--color-primary); }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.option-section-label {
  text-transform: uppercase;
  letter-spacing: .15em;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: calc(-1 * var(--space-3));
}
.option-section-label[hidden] { display: none; }

.no-results {
  text-align: center;
  font-style: italic;
  padding: var(--space-4);
}

.opt-style {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: -1px;
  margin-bottom: 1px;
}
@media (max-width: 460px) { .option-grid { grid-template-columns: 1fr; } }
.opt {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  padding: 0;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: left;
  overflow: hidden;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.opt:has(.opt-main:hover) {
  border-color: var(--color-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.opt-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  flex: 1 1 auto;
  min-width: 0;
  color: inherit;
  font: inherit;
}
.opt-main:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}
.opt-step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3) 0 var(--space-2);
  border-left: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
  transition: transform .15s ease;
}
.opt-step.bumped { transform: scale(1.06); }
.step-minus, .step-plus {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color .12s ease, background .12s ease, transform .08s ease;
}
.step-minus:hover:not(:disabled),
.step-plus:hover:not(:disabled) {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.step-minus:active:not(:disabled),
.step-plus:active:not(:disabled) {
  transform: scale(0.92);
}
.step-minus:disabled, .step-plus:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.step-qty {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  min-width: 1.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 460px) {
  .opt-step { padding: 0 var(--space-2); gap: 4px; }
  .step-minus, .step-plus { width: 26px; height: 26px; font-size: 14px; }
}
.opt-name { font-weight: 600; font-size: var(--text-sm); color: var(--color-text); }
.opt-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  letter-spacing: .01em;
}
.opt-cal { color: var(--color-primary); }
.btn.full { width: 100%; margin-top: var(--space-3); }

/* Calorie pill on timeline drink rows */
.t-cal {
  font-size: var(--text-xs);
  color: var(--color-primary);
  font-family: var(--font-mono);
  letter-spacing: .02em;
}

/* ---------- Start-time dialog ---------- */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.chip {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  cursor: pointer;
  font-family: var(--font-body);
}
.chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.chip.active {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}
.or-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .14em;
}
.or-divider::before,
.or-divider::after {
  content: '';
  height: 1px;
  background: var(--color-divider);
}
.field input[type='time'] {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  width: 100%;
  font-size: var(--text-base);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color-scheme: dark;
}
[data-theme='light'] .field input[type='time'] { color-scheme: light; }
.field input[type='time']:focus { border-color: var(--color-primary); }

/* ===========================================================
   Threshold alerts — toast host + cards
   =========================================================== */
.nc-toast-host {
  position: fixed;
  inset: auto 0 max(env(safe-area-inset-bottom, 0), var(--space-4)) 0;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
  z-index: 1000;
  padding: 0 var(--space-3);
}
.nc-toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 36px 1fr 28px;
  gap: var(--space-3);
  align-items: center;
  width: min(420px, 96vw);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-warning);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 240ms cubic-bezier(.16,1,.3,1), transform 240ms cubic-bezier(.16,1,.3,1);
}
.nc-toast.show { opacity: 1; transform: translateY(0); }
.nc-toast-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  background: var(--color-warning-tint);
  color: var(--color-warning);
}
.nc-toast-body {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.nc-toast-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--color-text);
  font-feature-settings: "ss01";
  line-height: 1.2;
}
.nc-toast-text {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
.nc-toast-close {
  width: 28px; height: 28px;
  border-radius: var(--radius-pill);
  display: grid; place-items: center;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid transparent;
}
.nc-toast-close:hover { color: var(--color-text); border-color: var(--color-border); }
.nc-toast-illegal {
  border-left-color: var(--color-danger);
}
.nc-toast-illegal .nc-toast-icon { background: var(--color-danger-tint); color: var(--color-danger); }
.nc-toast-danger {
  border-left-color: var(--color-critical);
}
.nc-toast-danger .nc-toast-icon { background: var(--color-critical-tint); color: var(--color-critical); }
.nc-toast-safe {
  border-left-color: var(--color-success);
}
.nc-toast-safe .nc-toast-icon { background: var(--color-success-tint); color: var(--color-success); }

/* Alerts section inside settings */
.alerts-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.alerts-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.alerts-row .alerts-text {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.alerts-row .alerts-text strong {
  font-size: var(--text-sm); font-weight: 600; color: var(--color-text);
}
.alerts-row .alerts-text span {
  font-size: var(--text-xs); color: var(--color-text-muted);
}
.alerts-status {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  border: 1px solid var(--color-divider);
}
.alerts-status[data-state='granted'] {
  color: color-mix(in oklab, var(--color-success) 35%, var(--color-text));
  border-color: color-mix(in oklab, var(--color-success) 60%, transparent);
  background: color-mix(in oklab, var(--color-success) 22%, transparent);
}
.alerts-status[data-state='denied'] {
  color: color-mix(in oklab, var(--color-danger) 35%, var(--color-text));
  border-color: color-mix(in oklab, var(--color-danger) 60%, transparent);
  background: color-mix(in oklab, var(--color-danger) 22%, transparent);
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%; height: 100%;
  margin: 0; cursor: pointer;
  z-index: 1;
}
.switch-slider {
  position: absolute; inset: 0;
  background: var(--color-surface-offset);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  transition: background var(--transition), border-color var(--transition);
}
.switch-slider::before {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: var(--color-text-muted);
  border-radius: 50%;
  transition: transform var(--transition), background var(--transition);
}
.switch input:checked + .switch-slider {
  background: color-mix(in oklab, var(--color-primary) 24%, var(--color-surface-offset));
  border-color: var(--color-primary);
}
.switch input:checked + .switch-slider::before {
  background: var(--color-primary);
  transform: translateX(20px);
}
.switch input:focus-visible + .switch-slider {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ===========================================================
   History row sparkline thumbnail
   =========================================================== */
.history-row {
  /* override grid: thumbnail + when + metrics + delete */
  grid-template-columns: 96px 1fr auto auto;
}
.h-spark {
  width: 96px;
  height: 44px;
  display: block;
  background: color-mix(in oklab, var(--color-primary) 6%, var(--color-surface-offset));
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
}
.h-spark .spark-line {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.h-spark .spark-fill {
  fill: color-mix(in oklab, var(--color-primary) 22%, transparent);
  stroke: none;
}
.h-spark .spark-thresh {
  stroke: var(--color-warning);
  stroke-width: 1;
  stroke-dasharray: 2 3;
  vector-effect: non-scaling-stroke;
  opacity: .55;
}
@media (max-width: 540px) {
  .history-row { grid-template-columns: 64px 1fr auto; }
  .h-spark { width: 64px; height: 36px; }
  .history-row .h-metrics { grid-column: 2 / -1; }
  .history-row .h-when { grid-column: 2; }
  .history-row .h-delete { grid-column: 3; grid-row: 1; }
  .history-row .h-spark { grid-column: 1; grid-row: 1 / span 2; align-self: center; }
}

/* ===========================================================
   Party mode — drinker bar
   =========================================================== */
.drinker-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-3) clamp(var(--space-4), 4vw, var(--space-8));
  max-width: 980px;
  margin: 0 auto;
  border-bottom: 1px solid var(--color-divider);
}
.drinker-bar[hidden] { display: none; }
.drinker-bar-label {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-style: italic;
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--color-text-muted);
  margin-right: var(--space-2);
  font-feature-settings: "ss01";
}
.drinker-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.drinker-chip:hover { border-color: var(--color-primary); }
.drinker-chip[data-active='true'] {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}
.drinker-chip-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--dot-color, var(--color-primary));
  box-shadow: 0 0 0 1.5px var(--color-surface);
}
.drinker-chip[data-active='true'] .drinker-chip-dot {
  box-shadow: 0 0 0 1.5px var(--color-primary);
}
.drinker-chip .bac-mini {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: -.01em;
  color: var(--color-text-muted);
  font-weight: 500;
}
.drinker-chip[data-active='true'] .bac-mini { color: var(--color-text-inverse); opacity: .85; }
.drinker-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
}
.drinker-add:hover { color: var(--color-primary); border-color: var(--color-primary); border-style: solid; }
.drinker-actions { margin-left: auto; display: inline-flex; gap: var(--space-2); }

/* Drinker manage dialog */
.drinkers-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.drinker-row {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.drinker-row .d-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
}
.drinker-row .d-info {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.drinker-row .d-name {
  font-weight: 600; font-size: var(--text-sm); color: var(--color-text);
}
.drinker-row .d-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  letter-spacing: .02em;
}
.drinker-row .d-bac {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}
.drinker-row .d-remove {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: var(--color-text-faint);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}
.drinker-row .d-remove:hover { color: var(--color-danger); border-color: var(--color-danger); }
.drinker-row .d-remove:disabled { opacity: .35; cursor: not-allowed; }

/* =========================================================
   NIGHTCAP NEON — visual facelift
   Inspired by Virtual Bar's neon-marquee aesthetic, but
   tuned to Nightcap's gold-on-navy identity. Dark-theme only.
   ========================================================= */

[data-theme='dark'] {
  /* Neon palette — gold primary, magenta and cyan accents */
  --neon-gold: #ffd277;
  --neon-gold-glow: rgba(226, 184, 100, 0.55);
  --neon-magenta: #d96bbf;
  --neon-magenta-glow: rgba(217, 107, 191, 0.45);
  --neon-cyan: #6fd0e0;
  --neon-cyan-glow: rgba(111, 208, 224, 0.4);
}

/* ------- Section headers: thin-outline "marquee" treatment ------- */
[data-theme='dark'] .card-head h2,
[data-theme='dark'] .bac-chart-title,
[data-theme='dark'] .suggestions-title {
  color: var(--neon-gold);
  text-shadow:
    0 0 1px var(--neon-gold-glow),
    0 0 8px var(--neon-gold-glow),
    0 0 18px rgba(226, 184, 100, 0.18);
  letter-spacing: -0.005em;
}

/* The small uppercase labels inside the BAC hero ("RIGHT NOW", "ONCE FULLY ABSORBED") */
[data-theme='dark'] .readout-label {
  color: var(--neon-gold);
  text-shadow: 0 0 6px var(--neon-gold-glow), 0 0 12px rgba(226, 184, 100, 0.18);
  letter-spacing: .18em;
}

/* ------- Hero BAC numbers: gold neon glow ------- */
[data-theme='dark'] .big-number #bac,
[data-theme='dark'] .big-number #bac-projected {
  color: var(--neon-gold);
  text-shadow:
    0 0 1px rgba(255, 210, 119, 0.9),
    0 0 6px var(--neon-gold-glow),
    0 0 22px rgba(226, 184, 100, 0.32),
    0 0 50px rgba(226, 184, 100, 0.18);
}
/* "Right now" stays slightly cooler/calmer than the projection */
[data-theme='dark'] .readout-col.now .big-number #bac {
  color: #f1ead7;
  text-shadow:
    0 0 1px rgba(241, 234, 215, 0.85),
    0 0 8px rgba(241, 234, 215, 0.30),
    0 0 22px rgba(241, 234, 215, 0.15);
}
[data-theme='dark'] .big-number .unit {
  color: var(--color-text-muted);
  text-shadow: 0 0 4px rgba(154, 159, 181, 0.20);
}

/* ------- Projected absorption: gradient backplate (Virtual Bar effects-card vibe) ------- */
[data-theme='dark'] .readout-col.projected {
  position: relative;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(217, 107, 191, 0.18), transparent 60%),
    radial-gradient(140% 100% at 0% 100%, rgba(226, 184, 100, 0.12), transparent 55%),
    rgba(26, 34, 56, 0.55);
  border: 1px solid rgba(217, 107, 191, 0.22);
  box-shadow:
    inset 0 0 0 1px rgba(255, 210, 119, 0.06),
    0 0 24px rgba(217, 107, 191, 0.10);
}
[data-theme='dark'] .readout-col.projected::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg,
    rgba(217, 107, 191, 0.05) 0%,
    transparent 40%);
}
[data-theme='dark'] .readout-col.projected .readout-label {
  /* Lighter pink + dark backstop so it reads cleanly on the magenta gradient */
  color: #fbe0f1;
  text-shadow:
    0 1px 2px rgba(11, 15, 28, 0.85),
    0 0 10px rgba(217, 107, 191, 0.55),
    0 0 22px rgba(217, 107, 191, 0.28);
  letter-spacing: .14em;
}
[data-theme='dark'] .readout-col.projected .big-number #bac-projected {
  color: var(--neon-gold);
  text-shadow:
    0 0 1px rgba(255, 210, 119, 0.9),
    0 0 8px var(--neon-gold-glow),
    0 0 28px rgba(226, 184, 100, 0.4),
    0 0 56px rgba(217, 107, 191, 0.25);
}
[data-theme='dark'] .readout-col.projected #projected-eta {
  color: #f1ead7;
}

/* ------- Status pill: glowing chip ------- */
[data-theme='dark'] .status-pill {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 0 12px color-mix(in oklab, currentColor 30%, transparent);
}

/* ------- Drink category tiles: bigger illustrated cards ------- */
[data-theme='dark'] .qbtn {
  padding: var(--space-5) var(--space-4);
  background: linear-gradient(180deg,
    rgba(26, 34, 56, 0.95) 0%,
    rgba(19, 26, 44, 0.95) 100%);
  border: 1px solid rgba(111, 208, 224, 0.18);
  border-radius: 14px;
  align-items: flex-start;
  gap: var(--space-2);
  min-height: 120px;
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
}
[data-theme='dark'] .qbtn svg {
  width: 32px;
  height: 32px;
  color: var(--neon-cyan);
  filter: drop-shadow(0 0 4px var(--neon-cyan-glow))
          drop-shadow(0 0 10px rgba(111, 208, 224, 0.20));
  margin-bottom: var(--space-2);
}
[data-theme='dark'] .qbtn .q-name {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -.005em;
  color: #f1ead7;
}
[data-theme='dark'] .qbtn .q-meta {
  color: var(--color-text-muted);
  letter-spacing: .005em;
}
[data-theme='dark'] .qbtn:hover {
  transform: translateY(-3px);
  border-color: var(--neon-cyan);
  box-shadow:
    0 0 0 1px rgba(111, 208, 224, 0.25),
    0 8px 24px rgba(111, 208, 224, 0.12),
    0 0 32px rgba(111, 208, 224, 0.10);
}
[data-theme='dark'] .qbtn:hover svg {
  color: var(--neon-cyan);
  filter: drop-shadow(0 0 6px var(--neon-cyan))
          drop-shadow(0 0 16px var(--neon-cyan-glow));
}
/* Water tile leans cyan, food tile leans amber-green */
[data-theme='dark'] .qbtn.water svg {
  color: var(--neon-cyan);
  filter: drop-shadow(0 0 6px var(--neon-cyan-glow));
}
[data-theme='dark'] .qbtn.food svg {
  color: #b3c870;
  filter: drop-shadow(0 0 6px rgba(179, 200, 112, 0.45));
}
[data-theme='dark'] .qbtn.water:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 1px rgba(111, 208, 224, 0.30), 0 8px 28px rgba(111, 208, 224, 0.14);
}
[data-theme='dark'] .qbtn.food:hover {
  border-color: #b3c870;
  box-shadow: 0 0 0 1px rgba(179, 200, 112, 0.30), 0 8px 28px rgba(179, 200, 112, 0.14);
}

/* ------- BAC curve: gold neon line ------- */
[data-theme='dark'] #bac-curve-svg #curve-line-past {
  filter: drop-shadow(0 0 3px var(--neon-gold-glow))
          drop-shadow(0 0 8px rgba(226, 184, 100, 0.18));
}
[data-theme='dark'] #bac-curve-svg #curve-line-future {
  filter: drop-shadow(0 0 2px var(--neon-gold-glow));
}
[data-theme='dark'] #bac-curve-svg .drink-marker {
  filter: drop-shadow(0 0 3px var(--neon-gold-glow));
}

/* ------- Suggestions card: glowing left rail ------- */
[data-theme='dark'] .suggestions {
  border-left-width: 3px;
  border-left-color: var(--neon-gold);
  box-shadow: -3px 0 18px rgba(226, 184, 100, 0.10);
}

/* ------- Stat values: subtle gold glow on the live numbers ------- */
[data-theme='dark'] .stat .value.mono {
  color: var(--neon-gold);
  text-shadow: 0 0 4px var(--neon-gold-glow), 0 0 10px rgba(226, 184, 100, 0.16);
}

/* ------- Section labels (the "STYLES" / "BRANDS" small caps in dialogs) ------- */
[data-theme='dark'] .option-section-label {
  color: var(--neon-cyan);
  text-shadow: 0 0 6px var(--neon-cyan-glow);
}

/* ------- Drink option rows: subtle cyan accent on hover ------- */
[data-theme='dark'] .opt:has(.opt-main:hover) {
  border-color: var(--neon-cyan);
  box-shadow:
    0 0 0 1px rgba(111, 208, 224, 0.18),
    0 6px 20px rgba(111, 208, 224, 0.10);
}

/* ------- Stopwatch session card: gold neon edge ------- */
[data-theme='dark'] .stopwatch {
  background: linear-gradient(180deg,
    rgba(26, 34, 56, 0.85),
    rgba(19, 26, 44, 0.85));
  border: 1px solid rgba(226, 184, 100, 0.25);
  box-shadow: 0 0 16px rgba(226, 184, 100, 0.06);
}
[data-theme='dark'] .stopwatch .sw-time {
  color: var(--neon-gold);
  text-shadow: 0 0 6px var(--neon-gold-glow), 0 0 14px rgba(226, 184, 100, 0.22);
}


/* ------- Suggestion warn icons: amber glow ------- */
[data-theme='dark'] .suggestion[data-tone="warn"] .suggestion-icon {
  background: radial-gradient(circle at 30% 30%,
    rgba(255, 176, 87, 0.32),
    rgba(255, 176, 87, 0.10) 70%);
  box-shadow:
    0 0 0 1px rgba(255, 176, 87, 0.35),
    0 0 14px rgba(255, 176, 87, 0.30);
}
[data-theme='dark'] .suggestion[data-tone="warn"] .suggestion-icon svg,
[data-theme='dark'] .suggestion[data-tone="warn"] .suggestion-icon {
  filter: drop-shadow(0 0 4px rgba(255, 176, 87, 0.55));
}
[data-theme='dark'] .suggestion[data-tone="ok"] .suggestion-icon {
  box-shadow:
    0 0 0 1px rgba(111, 208, 224, 0.30),
    0 0 12px rgba(111, 208, 224, 0.22);
}

/* =========================================================
   NIGHTCAP ENTRY FLOW
   Splash + onboarding + bar-door reveal.
   Always rendered above the app via fixed positioning.
   Hides app body via body[data-entry="active"].
   ========================================================= */

/* While entry is active, lock the app behind it */
body[data-entry="active"] {
  overflow: hidden;
}
body[data-entry="active"] .topbar,
body[data-entry="active"] main,
body[data-entry="active"] .drinker-bar,
body[data-entry="active"] footer {
  visibility: hidden;
}

.nc-entry {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #06080f;
  color: #f1ead7;
  font-family: var(--font-body, system-ui, sans-serif);
  overflow: hidden;
  isolation: isolate;
}
.nc-entry.is-fading {
  animation: ncFade 220ms ease-out forwards;
}
@keyframes ncFade {
  to { opacity: 0; }
}

/* ---------- Splash ---------- */
.nc-entry [hidden] { display: none !important; }
.nc-splash {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
}
.nc-cover {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.nc-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  /* Subtle ken-burns drift on first paint for life */
  animation: ncKenburns 14s ease-out both;
}
@keyframes ncKenburns {
  from { transform: scale(1.08) translateY(8px); }
  to   { transform: scale(1.00) translateY(0); }
}
.nc-cover-veil {
  position: absolute;
  inset: 0;
  background:
    /* gold rim glow at top edge */
    radial-gradient(120% 60% at 50% -20%, rgba(255, 210, 119, 0.20), transparent 60%),
    /* magenta glow lower-left */
    radial-gradient(80% 60% at 0% 80%, rgba(217, 107, 191, 0.18), transparent 60%),
    /* deep navy bottom for legibility */
    linear-gradient(180deg, rgba(6, 8, 15, 0.10) 0%, rgba(6, 8, 15, 0.55) 45%, rgba(6, 8, 15, 0.92) 78%, #06080f 100%);
}

.nc-splash-content {
  position: relative;
  z-index: 1;
  padding: 32px 28px calc(40px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
/* Each splash element animates in on its own timeline so the mark draws,
   then the wordmark and copy cascade up underneath it. */
.nc-splash-content > * {
  opacity: 0;
  transform: translateY(20px);
  animation: ncRise 600ms cubic-bezier(.2,.8,.2,1) both;
}
.nc-splash-content > .nc-marquee   { animation-delay:  100ms; }
.nc-splash-content > .nc-tag       { animation-delay: 1500ms; }
.nc-splash-content > .nc-sub       { animation-delay: 1700ms; }
.nc-splash-content > .nc-cta       { animation-delay: 1900ms; }
.nc-splash-content > .nc-disclaimer{ animation-delay: 2100ms; }
@keyframes ncRise {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Monogram draw-on animation ----------
   1. Stem draws downward (stroke length ~ 28px)
   2. Arch draws across-and-down (stroke length ~ 64px)
   3. Crescent moon scales in from a point with a small bounce + glow flash
*/
.nc-mark-animated .nc-mark-stem {
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  animation: ncDraw 480ms cubic-bezier(.2,.8,.2,1) 200ms forwards;
}
.nc-mark-animated .nc-mark-arch {
  stroke-dasharray: 70;
  stroke-dashoffset: 70;
  animation: ncDraw 720ms cubic-bezier(.2,.8,.2,1) 600ms forwards;
}
.nc-mark-animated .nc-mark-moon {
  /* Pivot at the moon's own center (~38, 15) so it pops in place. */
  transform-box: fill-box;
  transform-origin: 60% 50%;
  transform: scale(0) rotate(-40deg);
  opacity: 0;
  animation: ncMoonPop 700ms cubic-bezier(.2,1.6,.4,1) 1240ms forwards;
}
@keyframes ncDraw {
  to { stroke-dashoffset: 0; }
}
@keyframes ncMoonPop {
  0%   { transform: scale(0)   rotate(-40deg); opacity: 0; }
  60%  { transform: scale(1.18) rotate(6deg);  opacity: 1; filter: drop-shadow(0 0 14px rgba(255,210,119,.85)); }
  100% { transform: scale(1)   rotate(0deg);   opacity: 1; filter: drop-shadow(0 0 0 rgba(255,210,119,0)); }
}

/* The wordmark sits inside .nc-marquee; we want IT to delay independently
   so the mark finishes drawing first. Override the default cascade. */
.nc-marquee .nc-wordmark {
  opacity: 0;
  transform: translateY(14px);
  animation: ncRise 600ms cubic-bezier(.2,.8,.2,1) 1100ms both;
}

/* Respect reduced motion: snap everything in, no draw, no cascade */
@media (prefers-reduced-motion: reduce) {
  .nc-splash-content > *,
  .nc-marquee .nc-wordmark { animation: none; opacity: 1; transform: none; }
  .nc-mark-animated .nc-mark-stem,
  .nc-mark-animated .nc-mark-arch { stroke-dashoffset: 0; animation: none; }
  .nc-mark-animated .nc-mark-moon { transform: none; opacity: 1; animation: none; }
}
.nc-marquee {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #ffd277;
  filter: drop-shadow(0 0 18px rgba(255, 210, 119, 0.45));
}
.nc-mark {
  color: currentColor;
}
.nc-wordmark {
  font-family: var(--font-display, 'Fraunces', serif);
  font-weight: 500;
  font-size: 56px;
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0;
  color: #ffd277;
  text-shadow:
    0 0 14px rgba(255, 210, 119, 0.55),
    0 0 32px rgba(255, 210, 119, 0.30);
}
.nc-tag {
  font-family: var(--font-display, 'Fraunces', serif);
  font-style: italic;
  font-size: 22px;
  margin: 0;
  color: #f5e7c5;
  letter-spacing: 0.01em;
}
.nc-sub {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  color: rgba(241, 234, 215, 0.70);
  max-width: 36ch;
}
.nc-cta {
  margin-top: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  border-radius: 999px;
  border: 1px solid rgba(255, 210, 119, 0.55);
  background: linear-gradient(180deg, #ffd277, #e2b864);
  color: #1a1408;
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(255, 210, 119, 0.35),
    0 12px 32px rgba(255, 210, 119, 0.30),
    0 0 22px rgba(255, 210, 119, 0.45);
  transition: transform 160ms ease, box-shadow 220ms ease, filter 160ms ease;
}
.nc-cta:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
  box-shadow:
    0 0 0 1px rgba(255, 210, 119, 0.55),
    0 16px 38px rgba(255, 210, 119, 0.40),
    0 0 30px rgba(255, 210, 119, 0.55);
}
.nc-cta:active { transform: translateY(0); }
.nc-disclaimer {
  margin: 8px 0 0;
  font-size: 12px;
  color: rgba(241, 234, 215, 0.45);
  letter-spacing: 0.01em;
}

/* ---------- Onboarding ---------- */
.nc-onboard {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(80% 50% at 50% 0%, rgba(217, 107, 191, 0.10), transparent 60%),
    radial-gradient(60% 50% at 100% 100%, rgba(111, 208, 224, 0.08), transparent 60%),
    linear-gradient(180deg, #0b0f1c 0%, #06080f 100%);
  animation: ncFadeIn 280ms ease-out both;
}
@keyframes ncFadeIn { from { opacity: 0; } to { opacity: 1; } }
.nc-onboard-head {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px 8px;
}
.nc-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(241, 234, 215, 0.12);
  background: rgba(19, 26, 44, 0.6);
  color: rgba(241, 234, 215, 0.85);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.nc-back:hover { border-color: rgba(255, 210, 119, 0.40); color: #ffd277; }
.nc-back-spacer { width: 40px; }
.nc-step-meter {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.nc-step-dot {
  width: 30px;
  height: 4px;
  border-radius: 999px;
  background: rgba(241, 234, 215, 0.14);
  transition: background 220ms ease, box-shadow 220ms ease;
}
.nc-step-dot[data-active] {
  background: #ffd277;
  box-shadow: 0 0 10px rgba(255, 210, 119, 0.55);
}

.nc-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 24px calc(32px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}
.nc-step {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: ncStepIn 320ms cubic-bezier(.2,.8,.2,1) both;
}
@keyframes ncStepIn {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}
.nc-step-title {
  font-family: var(--font-display, 'Fraunces', serif);
  font-weight: 500;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: #ffd277;
  margin: 12px 0 0;
  padding: 0;
  text-shadow: 0 0 12px rgba(255, 210, 119, 0.35);
}
.nc-step-sub {
  margin: 0 0 4px;
  color: rgba(241, 234, 215, 0.60);
  font-size: 14px;
  line-height: 1.45;
}
.nc-step-sub strong {
  color: rgba(241, 234, 215, 0.85);
  font-weight: 600;
}

.nc-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nc-label {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6fd0e0;
  font-weight: 600;
  text-shadow: 0 0 6px rgba(111, 208, 224, 0.35);
}
.nc-optional {
  margin-left: 6px;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(241, 234, 215, 0.40);
  font-weight: 400;
}
.nc-help {
  font-size: 12px;
  color: rgba(241, 234, 215, 0.45);
}

.nc-field input[type="text"],
.nc-field input[type="number"],
.nc-field select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  background: rgba(19, 26, 44, 0.85);
  border: 1px solid rgba(241, 234, 215, 0.10);
  border-radius: 14px;
  color: #f1ead7;
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 17px;
  padding: 14px 16px;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.nc-field input::placeholder { color: rgba(241, 234, 215, 0.32); }
.nc-field input:focus,
.nc-field select:focus {
  border-color: rgba(255, 210, 119, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 210, 119, 0.18);
}
.nc-field select {
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(241,234,215,.5) 50%),
    linear-gradient(135deg, rgba(241,234,215,.5) 50%, transparent 50%);
  background-position: calc(100% - 18px) 22px, calc(100% - 12px) 22px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.nc-shake { animation: ncShake 360ms cubic-bezier(.36,.07,.19,.97); border-color: #d96bbf !important; }
@keyframes ncShake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

/* Segmented choices */
.nc-segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(19, 26, 44, 0.6);
  padding: 6px;
  border-radius: 14px;
  border: 1px solid rgba(241, 234, 215, 0.08);
}
.nc-segment-sm {
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.nc-seg {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: rgba(241, 234, 215, 0.60);
  transition: color 160ms ease, background 160ms ease;
}
.nc-seg input { position: absolute; opacity: 0; pointer-events: none; }
.nc-seg:hover { color: #f1ead7; }
.nc-seg:has(input:checked) {
  background: linear-gradient(180deg, rgba(255, 210, 119, 0.20), rgba(226, 184, 100, 0.10));
  color: #ffd277;
  box-shadow:
    inset 0 0 0 1px rgba(255, 210, 119, 0.45),
    0 0 14px rgba(255, 210, 119, 0.20);
  text-shadow: 0 0 8px rgba(255, 210, 119, 0.45);
}

.nc-weight-row {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 10px;
  align-items: stretch;
}

.nc-checkbox {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 14px;
  background: rgba(19, 26, 44, 0.6);
  border: 1px solid rgba(241, 234, 215, 0.08);
  border-radius: 14px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
  color: rgba(241, 234, 215, 0.78);
}
.nc-checkbox input {
  width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px;
  accent-color: #ffd277;
}

.nc-form .nc-cta {
  margin-top: auto;
  margin-bottom: 4px;
}

/* ---------- Bar-door reveal ---------- */
.nc-doors {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  display: flex;
}
.nc-door {
  position: relative;
  flex: 1;
  background:
    /* metallic dark sheen */
    linear-gradient(135deg, #15182a 0%, #0a0d18 50%, #15182a 100%);
  transform: translateX(-100%);
  transition: transform 700ms cubic-bezier(.6, 0, .2, 1);
  will-change: transform;
}
.nc-door-right { transform: translateX(100%); }
.nc-door-edge {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg,
    rgba(255, 210, 119, 0) 0%,
    rgba(255, 210, 119, 0.7) 12%,
    rgba(217, 107, 191, 0.8) 50%,
    rgba(111, 208, 224, 0.7) 88%,
    rgba(111, 208, 224, 0) 100%);
  filter: blur(0.5px);
  box-shadow:
    0 0 16px rgba(255, 210, 119, 0.6),
    0 0 32px rgba(217, 107, 191, 0.4);
}
.nc-door-left .nc-door-edge { right: -1px; }
.nc-door-right .nc-door-edge { left: -1px; }
.nc-doors.closing .nc-door-left { transform: translateX(0); }
.nc-doors.closing .nc-door-right { transform: translateX(0); }
.nc-doors.opening .nc-door-left { transform: translateX(-100%); transition-duration: 1000ms; }
.nc-doors.opening .nc-door-right { transform: translateX(100%); transition-duration: 1000ms; }

/* ---------- Profile chip in header ---------- */
.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid rgba(255, 210, 119, 0.30);
  background: rgba(19, 26, 44, 0.6);
  color: #f1ead7;
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-left: auto;
  margin-right: var(--space-2, 8px);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.profile-chip:hover {
  border-color: rgba(255, 210, 119, 0.70);
  box-shadow: 0 0 14px rgba(255, 210, 119, 0.20);
}
.pc-initial {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ffd277, #e2b864);
  color: #1a1408;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0;
  box-shadow: 0 0 10px rgba(255, 210, 119, 0.45);
}
.pc-name {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Settings: danger-zone visual */
.danger-zone {
  border-top: 1px solid rgba(241, 234, 215, 0.06);
  padding-top: 12px;
  margin-top: 4px;
}

/* Light-theme tweaks for entry */
[data-theme='light'] .nc-entry { background: #f6efdc; color: #1a1408; }
[data-theme='light'] .nc-onboard {
  background:
    radial-gradient(80% 50% at 50% 0%, rgba(217, 107, 191, 0.06), transparent 60%),
    linear-gradient(180deg, #fbf6e6 0%, #f1ead7 100%);
}

/* When a profile chip is shown, the header gets crowded on mobile.
   Hide the italic "live bac tracker" tag below 480px so the chip + actions fit. */
@media (max-width: 480px) {
  .brand-tag { display: none; }
  .profile-chip { padding: 3px 8px 3px 3px; font-size: 12px; }
  .profile-chip .pc-name { max-width: 90px; }
  .pc-initial { width: 22px; height: 22px; font-size: 12px; }
  .topbar { gap: var(--space-2); }
}

/* Make sure the brand mark stays visible (it was missing on small viewports
   because of the brand-name's larger size pushing layout). */
.brand { flex-shrink: 0; min-width: 0; }
.brand-name { white-space: nowrap; }

/* Settings dialog: Onboarding (danger-zone) section */
#settings-dialog .danger-zone {
  padding: 14px 0 4px;
  margin-top: 4px;
  border-top: 1px solid rgba(241, 234, 215, 0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
#settings-dialog .danger-zone .section-title {
  font-family: var(--font-display);
  font-size: var(--text-sm, 13px);
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  letter-spacing: .02em;
}
#settings-dialog .danger-zone .hint {
  margin: 0;
}

/* ===========================================================
   Recap badges (achievements unlocked tonight)
   =========================================================== */
.recap-badges {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid color-mix(in srgb, var(--color-border) 70%, transparent);
}
.recap-badges-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}
.recap-badge-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.recap-badge {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, #ffd277 14%, transparent);
  border: 1px solid color-mix(in srgb, #ffd277 35%, transparent);
}
.recap-badge-icon {
  font-size: 22px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: color-mix(in srgb, #ffd277 22%, transparent);
}
.recap-badge-text { display: flex; flex-direction: column; gap: 2px; }
.recap-badge-label {
  font-weight: 600;
  font-size: 14px;
  color: #ffd277;
  letter-spacing: 0.01em;
}
.recap-badge-desc {
  font-size: 12px;
  color: var(--color-text-muted);
}

#recap-share { gap: 4px; }
#recap-share[disabled] { opacity: 0.7; cursor: progress; }

/* ===========================================================
   Plan dialog (pre-night planning mode)
   =========================================================== */
.plan-body { display: flex; flex-direction: column; gap: var(--space-4); }
.plan-intro {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 14px;
  line-height: 1.5;
}
.plan-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.plan-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.plan-hours {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
#plan-hours {
  flex: 1;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, color-mix(in srgb, #ffd277 60%, transparent), color-mix(in srgb, #ffd277 18%, transparent));
  outline: none;
  cursor: pointer;
}
#plan-hours::-webkit-slider-thumb {
  appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #ffd277;
  border: 3px solid #0b0f1c;
  box-shadow: 0 0 12px rgba(255,210,119,0.6);
  cursor: grab;
}
#plan-hours::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #ffd277;
  border: 3px solid #0b0f1c;
  box-shadow: 0 0 12px rgba(255,210,119,0.6);
  cursor: grab;
}
.plan-hours-val {
  min-width: 60px;
  text-align: right;
  font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 16px;
  font-weight: 600;
  color: #ffd277;
}
.plan-select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
}
.plan-select:focus {
  outline: 2px solid color-mix(in srgb, #ffd277 60%, transparent);
  outline-offset: 1px;
}

.plan-result {
  margin-top: var(--space-2);
  padding: var(--space-4);
  border-radius: 16px;
  background:
    radial-gradient(120% 120% at 100% 0%, color-mix(in srgb, #ffd277 8%, transparent), transparent 60%),
    color-mix(in srgb, var(--color-surface) 90%, #0b0f1c);
  border: 1px solid color-mix(in srgb, #ffd277 25%, transparent);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.plan-result-hero {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.plan-result-num {
  font-family: var(--font-display, 'Fraunces', serif);
  font-weight: 500;
  font-size: 72px;
  line-height: 1;
  color: #ffd277;
  text-shadow: 0 0 20px rgba(255,210,119,0.45);
  font-variant-numeric: tabular-nums;
  transition: color 200ms;
}
.plan-result-num[data-tone="warn"] {
  color: #ff8b6b;
  text-shadow: 0 0 20px rgba(255,139,107,0.45);
}
.plan-result-num[data-tone="caution"] {
  color: #f3c46a;
  text-shadow: 0 0 20px rgba(243,196,106,0.45);
}
.plan-result-label {
  font-size: 22px;
  color: var(--color-text-muted);
  font-weight: 500;
}
.plan-result-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.plan-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  padding: 6px 0;
  border-bottom: 1px dashed color-mix(in srgb, var(--color-border) 60%, transparent);
}
.plan-meta-row:last-child { border-bottom: none; }
.plan-meta-k { color: var(--color-text-muted); }
.plan-meta-v {
  color: var(--color-text);
  font-weight: 500;
}
.plan-meta-v.mono { font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace); }
.plan-advice {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, #ffd277 10%, transparent);
  color: #ffd277;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 500;
}
.plan-fineprint {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--color-text-muted);
}
.plan-fineprint strong {
  color: var(--color-text);
}

@media (max-width: 460px) {
  .plan-result-num { font-size: 56px; }
}

/* ========== Plan dialog disclaimer banner ========== */
.plan-disclaimer {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  margin: 0 var(--space-6) var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: 14px;
  background: color-mix(in srgb, #ff5d62 16%, transparent);
  border: 1px solid color-mix(in srgb, #ff5d62 38%, transparent);
  color: var(--color-text);
  font-size: 13px;
  line-height: 1.5;
}
.plan-disclaimer strong { color: #ff8a8e; font-weight: 600; }
.plan-disc-icon { color: #ff8a8e; flex: 0 0 auto; margin-top: 2px; }

/* ========== Tonight (open-app) dialog ========== */
.tonight-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.tonight-section-head {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}
.tonight-step-num {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, #ffd277 22%, transparent);
  border: 1px solid color-mix(in srgb, #ffd277 45%, transparent);
  color: #ffd277;
  font-weight: 600;
  font-size: 13px;
  font-feature-settings: "tnum";
  margin-top: 2px;
}
.tonight-q {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 19px;
  color: var(--color-text);
  line-height: 1.25;
}
.tonight-help {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.tonight-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}
.tonight-options.two { grid-template-columns: 1fr 1fr; }
.tonight-opt {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: var(--space-3) var(--space-3) var(--space-3);
  border-radius: 14px;
  background: color-mix(in srgb, #14182a 78%, transparent);
  border: 1px solid color-mix(in srgb, #ffd277 16%, transparent);
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
  min-height: 92px;
}
.tonight-opt:hover {
  background: color-mix(in srgb, #14182a 95%, transparent);
  border-color: color-mix(in srgb, #ffd277 32%, transparent);
}
.tonight-opt:active { transform: translateY(1px); }
.tonight-opt[data-selected] {
  background: color-mix(in srgb, #ffd277 18%, transparent);
  border-color: color-mix(in srgb, #ffd277 65%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, #ffd277 18%, transparent);
}
.tonight-opt-emoji { font-size: 22px; line-height: 1; margin-bottom: 2px; }
.tonight-opt-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text);
  line-height: 1.2;
}
.tonight-opt-sub {
  font-size: 11.5px;
  color: var(--color-text-muted);
  line-height: 1.3;
}
.tonight-opt.drive[data-selected] {
  /* Driving "yes" stays gold (positive: they're committing to plan), nothing
     else to override — keeps consistent with "I'm going to be responsible". */
}
.tonight-disclaimer {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: 14px;
  background: color-mix(in srgb, #ff5d62 14%, transparent);
  border: 1px solid color-mix(in srgb, #ff5d62 36%, transparent);
  color: var(--color-text);
  font-size: 12.5px;
  line-height: 1.5;
}
.tonight-disclaimer strong { color: #ff8a8e; font-weight: 600; }
.tonight-disclaimer svg { color: #ff8a8e; flex: 0 0 auto; margin-top: 2px; }

@media (max-width: 460px) {
  .tonight-options { grid-template-columns: 1fr; }
  .tonight-options.two { grid-template-columns: 1fr; }
  .tonight-opt { min-height: auto; flex-direction: row; align-items: center; gap: var(--space-3); }
  .tonight-opt-emoji { font-size: 26px; }
  .tonight-opt-label { font-size: 15px; }
}

/* ---------- v1.1 additions: privacy note, cover picker, about/legal, streak chip ---------- */

/* Privacy note pill on entry step 2 */
.nc-privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  margin: 0 0 var(--space-4);
  border-radius: 12px;
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-primary) 32%, transparent);
  color: var(--color-text);
  font-size: 12.5px;
  line-height: 1.45;
}
.nc-privacy-note svg {
  color: var(--color-primary);
  flex: 0 0 auto;
  margin-top: 2px;
  filter: drop-shadow(0 0 4px color-mix(in srgb, var(--color-primary) 50%, transparent));
}
.nc-privacy-note span { color: var(--color-text-muted); }

/* Cover picker — 4-tile grid in settings */
.cover-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.cover-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.cover-tile input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.cover-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
  border: 2px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.cover-tile-label {
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--color-text-muted);
  text-align: center;
  text-transform: uppercase;
}
.cover-tile:hover .cover-thumb { transform: translateY(-1px); border-color: color-mix(in srgb, var(--color-primary) 50%, var(--color-border)); }
.cover-tile input:checked ~ .cover-thumb {
  border-color: var(--color-primary);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--color-primary) 35%, transparent),
    0 6px 18px color-mix(in srgb, var(--color-primary) 22%, transparent);
}
.cover-tile input:checked ~ .cover-tile-label { color: var(--color-primary); }
.cover-tile input:focus-visible ~ .cover-thumb {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
@media (max-width: 460px) {
  .cover-picker { grid-template-columns: repeat(2, 1fr); }
}

/* About & legal — collapsible details */
.about-details {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
  overflow: hidden;
  margin-top: 8px;
}
.about-details + .about-details { margin-top: 8px; }
.about-details summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.about-details summary::-webkit-details-marker { display: none; }
.about-details summary::after {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
  transform: rotate(45deg);
  transition: transform var(--transition);
  flex: 0 0 auto;
  margin-right: 4px;
}
.about-details[open] summary::after { transform: rotate(-135deg); }
.about-details summary:hover { background: color-mix(in srgb, var(--color-primary) 6%, transparent); }
.about-body {
  padding: 4px 14px 14px;
  color: var(--color-text-muted);
  font-size: 12.5px;
  line-height: 1.55;
  border-top: 1px solid var(--color-divider);
}
.about-body p { margin: 8px 0; }
.about-body p:first-child { margin-top: 10px; }
.about-body p:last-child { margin-bottom: 0; }
.about-body strong { color: var(--color-text); font-weight: 600; }
.about-body a { color: var(--color-primary); text-decoration: underline; text-underline-offset: 2px; }
.about-version {
  margin-top: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--color-text-faint);
  text-transform: uppercase;
}

/* Streak chip on recap badge label (gold ×N suffix) */
.recap-badge-streak {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-primary) 40%, transparent);
  letter-spacing: .02em;
  vertical-align: 1px;
}
.recap-badge-streak:empty { display: none; }
[data-theme='dark'] .recap-badge-streak {
  text-shadow: 0 0 6px color-mix(in srgb, var(--color-primary) 50%, transparent);
}

/* ============================================================
   v1.1 driver danger-zone & tonight drive-time picker
   ============================================================ */

/* Tonight dialog: drive-home time picker (revealed when "Yes — driving" is chosen) */
.tonight-drive-time {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--color-primary) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-primary) 22%, transparent);
  border-radius: 10px;
}
.tonight-drive-time[hidden] { display: none; }
.tonight-drive-time-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: .02em;
  text-transform: uppercase;
}
.tonight-driveby-input {
  font: inherit;
  font-family: var(--font-mono);
  font-size: 15px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  width: max-content;
  min-width: 130px;
}
.tonight-driveby-input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}
.tonight-drive-time-help {
  margin: 0;
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.45;
}

/* Settings: drive-home summary row */
.settings-drive-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--color-primary) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-primary) 20%, transparent);
  border-radius: 10px;
  flex-wrap: wrap;
}
.settings-drive-row[hidden] { display: none; }
.settings-drive-label {
  font-size: 12px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
}
.settings-drive-value {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--color-text);
  font-weight: 600;
}
.btn.link {
  background: transparent;
  border: none;
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 2px 4px;
  cursor: pointer;
  margin-left: auto;
}
.btn.link:hover { color: var(--color-primary-hover); }
.btn.link:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: 4px; }

/* Danger-zone banner — pinned above the quick-grid on the main log card */
.danger-zone-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0 0 14px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--color-danger) 8%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--color-danger) 35%, transparent);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--color-danger) 14%, transparent) inset;
  position: relative;
}
.danger-zone-banner[hidden] { display: none; }
.danger-zone-banner::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-primary);
  border-radius: 12px 0 0 12px;
}
.dzb-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}
.dzb-icon svg { display: block; }
.dzb-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dzb-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-text);
  letter-spacing: -.005em;
}
.dzb-msg {
  font-size: 13px;
  line-height: 1.45;
  color: var(--color-text-muted);
}
.dzb-msg strong {
  color: var(--color-text);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 12.5px;
}
.dzb-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.btn.small {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1.2;
  border: 1px solid transparent;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.btn.small.primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}
.btn.small.primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
.btn.small.ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border);
}
.btn.small.ghost:hover { color: var(--color-text); border-color: var(--color-text-faint); }

[data-theme='dark'] .danger-zone-banner {
  background: color-mix(in srgb, var(--color-danger) 14%, var(--color-surface));
  border-color: color-mix(in srgb, var(--color-danger) 55%, transparent);
}
[data-theme='dark'] .dzb-icon {
  color: var(--color-primary);
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--color-primary) 50%, transparent));
}
