:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --warning: #f59e0b;
  --mom: #db2777;
  --mom-light: #fce7f3;
  --baby: #16a34a;
  --baby-light: #dcfce7;
  --you: #2563eb;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  min-height: 100vh;
  padding-bottom: 80px;
}

/* TOPBAR */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 0;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.brand > div:nth-child(2) { flex: 1; min-width: 0; }
.brand-icon {
  font-size: 28px; background: var(--surface-2);
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
}
.brand-title { font-weight: 700; font-size: 18px; }
.brand-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.refresh-btn {
  background: var(--surface-2); border: none;
  width: 44px; height: 44px; border-radius: 12px;
  font-size: 22px; cursor: pointer; color: var(--text);
  display: grid; place-items: center; flex-shrink: 0;
}
.refresh-btn:hover { background: var(--border); }
.refresh-btn:active { background: var(--primary); color: white; }
.refresh-btn.spinning #refreshIcon { animation: spin 0.6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabs {
  display: flex; gap: 2px; margin: 0 -4px;
  overflow-x: auto;
}
.tab {
  flex: 1; min-width: max-content;
  background: transparent; border: none;
  padding: 12px 8px;
  font-size: 14px; font-weight: 600;
  color: var(--muted); cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

main { padding: 16px; max-width: 1100px; margin: 0 auto; }
.tab-section { display: none; }
.tab-section.active { display: block; }

.section-h {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin: 24px 0 10px;
  font-weight: 700;
}

/* ===== NEXT-UP BANNER ===== */
.next-up-banner {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: white;
  border-radius: 18px;
  padding: 18px 18px 20px;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(15,23,42,.25);
  position: relative;
  overflow: hidden;
}
.next-up-banner.ready {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  animation: pulse-green 2.5s ease-in-out infinite;
}
.next-up-banner.urgent {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  animation: pulse-red 1.5s ease-in-out infinite;
}
@keyframes pulse-green {
  0%, 100% { box-shadow: 0 8px 24px rgba(22,163,74,.35); }
  50% { box-shadow: 0 8px 36px rgba(22,163,74,.6); }
}
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 8px 24px rgba(220,38,38,.4); }
  50% { box-shadow: 0 8px 40px rgba(220,38,38,.75); }
}
.next-up-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  opacity: .75;
  margin-bottom: 6px;
}
.next-up-med {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 8px;
}
.next-up-countdown {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  margin-bottom: 4px;
}
.next-up-at {
  font-size: 14px;
  opacity: .85;
  font-weight: 600;
}
.next-up-cta {
  margin-top: 12px;
  background: rgba(255,255,255,.18);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  width: 100%;
  backdrop-filter: blur(4px);
}
.next-up-cta:active { background: rgba(255,255,255,.32); }
.next-up-quiet {
  font-size: 14px;
  opacity: .85;
  font-weight: 500;
  line-height: 1.45;
  margin-top: 4px;
}
.next-up-quiet strong { font-weight: 700; opacity: 1; }

/* ===== QUICK GRID (home page big buttons) ===== */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.big-tap {
  background: var(--surface);
  border: none;
  border-radius: 16px;
  padding: 22px 12px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
  box-shadow: var(--shadow);
  position: relative;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  transition: transform .08s, box-shadow .15s;
}
.big-tap:active {
  transform: scale(0.96);
  box-shadow: 0 0 0 4px rgba(37,99,235,.2);
}
.big-tap-emoji { font-size: 32px; line-height: 1; }
.big-tap-sub {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.3;
}
.big-tap-time {
  font-size: 20px;
  font-weight: 800;
  margin-top: 6px;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.big-tap-time.urgent { color: var(--danger); }
.big-tap-time.ready  { color: var(--success); }
.big-tap-time.wait   { color: var(--primary); }
.big-tap-when {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 2px;
}
.big-tap-sub.urgent { color: var(--danger); font-weight: 700; }
.big-tap-sub.ready  { color: var(--success); font-weight: 700; }

.big-tap.med { background: linear-gradient(135deg, #fff 0%, #fef3c7 100%); }
.big-tap.med.ready  { background: linear-gradient(135deg, #fff 0%, var(--success-light) 100%); border: 2px solid var(--success); }
.big-tap.med.urgent { background: linear-gradient(135deg, #fff 0%, #fee2e2 100%); border: 2px solid var(--danger); animation: pulse-urgent 1.8s ease-in-out infinite; }
@keyframes pulse-urgent {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: 0 0 0 6px rgba(220,38,38,.18); }
}
.big-tap.baby { background: linear-gradient(135deg, #fff 0%, var(--baby-light) 100%); }
.big-tap.diaper-wet { background: linear-gradient(135deg, #fff 0%, #dbeafe 100%); }
.big-tap.diaper-dirty { background: linear-gradient(135deg, #fff 0%, #fef3c7 100%); }
.big-tap.diaper-both { background: linear-gradient(135deg, #dbeafe 0%, #fef3c7 100%); }

.big-tap-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 16px 0;
}
.big-tap-row .big-tap {
  min-height: 90px;
  padding: 14px 4px;
  font-size: 13px;
  border-radius: 14px;
}

/* ===== ACTIVITY FEED ===== */
.activity-feed { display: flex; flex-direction: column; gap: 6px; }
.activity-item {
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  font-size: 14px;
}
.activity-emoji { font-size: 22px; flex-shrink: 0; }
.activity-body { flex: 1; min-width: 0; }
.activity-title { font-weight: 600; }
.activity-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.activity-time { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.activity-undo {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.activity-undo:hover { background: var(--surface-2); color: var(--danger); border-color: var(--danger); }

/* ===== MOM TAB (medicine list) ===== */
.summary-row, .baby-summary-row {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}
.summary-row { grid-template-columns: repeat(3, 1fr); }
.baby-summary-row { grid-template-columns: repeat(4, 1fr); }
.summary-card {
  background: var(--surface);
  padding: 10px 8px;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow);
}
.summary-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}
.summary-lbl {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 2px;
}

.day-nav, .week-nav {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
  background: var(--surface); padding: 8px 12px;
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.day-heading { font-weight: 700; font-size: 15px; text-align: center; flex: 1; }
.iconbtn {
  background: var(--surface-2); border: none;
  width: 36px; height: 36px; border-radius: 8px;
  font-size: 20px; cursor: pointer; color: var(--text);
}

.sub-tabs {
  display: flex; gap: 4px; margin-bottom: 12px;
  background: var(--surface); border-radius: 10px;
  padding: 4px; box-shadow: var(--shadow);
}
.sub-tab {
  flex: 1; background: transparent; border: none;
  padding: 10px 4px; font-size: 14px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-radius: 7px;
}
.sub-tab.active { background: var(--mom); color: white; }
.sub-section { display: none; }
.sub-section.active { display: block; }

.meds-list { display: flex; flex-direction: column; gap: 8px; }
.med-row {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.med-check {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--border);
  display: grid; place-items: center;
  flex-shrink: 0; background: var(--surface);
  font-size: 18px; color: transparent;
  transition: all .15s;
}
.med-row.done .med-check { background: var(--success); border-color: var(--success); color: white; }
.med-row.partial .med-check { background: var(--warning); border-color: var(--warning); color: white; }

.med-body { flex: 1; min-width: 0; }
.med-title { font-weight: 600; font-size: 15px; }
.med-row.done .med-title { text-decoration: line-through; color: var(--muted); }
.med-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.dose-timer {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  line-height: 1.4;
  display: inline-block;
}
.dose-timer.wait { background: #eff6ff; color: #1d4ed8; }
.dose-timer.ready { background: var(--success-light); color: var(--success); }
.dose-timer.soon {
  background: #fee2e2; color: var(--danger);
  animation: pulse-soon 2s ease-in-out infinite;
}
@keyframes pulse-soon {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); }
  50% { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}
.med-row.urgency-soon {
  background: #fef2f2;
  border-left: 4px solid var(--danger);
  padding-left: 10px;
}
.med-row.urgency-ready {
  background: #f0fdf4;
  border-left: 4px solid var(--success);
  padding-left: 10px;
}

.alarm-btn {
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-block;
}
.partial-badge {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--warning);
  color: white;
  font-weight: 700;
}

/* ===== BABY LISTS ===== */
.feeds-list, .diapers-list { display: flex; flex-direction: column; gap: 6px; }
.feed-item, .diaper-item {
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
}
.feed-emoji, .diaper-emoji { font-size: 22px; }
.feed-body, .diaper-body { flex: 1; }
.feed-time, .diaper-time { font-weight: 700; font-size: 15px; }
.feed-meta, .diaper-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.empty-state {
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius);
  font-size: 14px;
}

/* ===== WEEKLY GRID ===== */
.weekly-grid {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.week-table { width: 100%; border-collapse: collapse; min-width: 540px; }
.week-table th, .week-table td {
  padding: 8px 6px; text-align: center; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.week-table th { font-weight: 600; color: var(--muted); }
.week-table th:first-child, .week-table td:first-child {
  text-align: left; min-width: 160px; padding-left: 4px;
}
.week-table th.today { color: var(--primary); }
.week-cell {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%; font-size: 14px;
}
.week-cell.done { background: var(--success-light); color: var(--success); }
.week-cell.partial { background: #fef3c7; color: #b45309; font-size: 11px; }
.week-cell.missed { background: #fee2e2; color: var(--danger); }
.week-cell.future { color: #cbd5e1; }
.week-cell.na { color: #e2e8f0; }

/* ===== MANAGE ===== */
.manage-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.manage-header h2 { margin: 0; font-size: 18px; }
.manage-list { display: flex; flex-direction: column; gap: 8px; }
.manage-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
.manage-section h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.manage-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 8px; cursor: pointer;
}
.manage-row:hover { background: var(--surface-2); }
.manage-row .med-title { font-weight: 600; }
.cadence-pill {
  font-size: 11px; padding: 4px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-weight: 600;
}

/* ===== BUTTONS ===== */
.primary {
  background: var(--primary); color: white; border: none;
  padding: 10px 16px; border-radius: 8px;
  font-weight: 600; font-size: 14px; cursor: pointer;
}
.danger {
  background: var(--danger); color: white; border: none;
  padding: 10px 16px; border-radius: 8px;
  font-weight: 600; font-size: 14px; cursor: pointer;
}

/* ===== TOAST (after-tap details) ===== */
.toast-backdrop {
  position: fixed;
  inset: auto 0 20px 0;
  display: grid;
  place-items: end center;
  z-index: 90;
  padding: 0 16px;
  pointer-events: none;
}
.toast-backdrop[hidden] { display: none !important; }
.toast {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  padding: 16px;
  box-shadow: 0 10px 40px rgba(15,23,42,.2);
  pointer-events: auto;
  border: 2px solid var(--success);
  animation: slideup .25s ease-out;
}
@keyframes slideup {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.toast-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.toast-header > div:first-child { font-weight: 700; font-size: 15px; }
.toast-body { font-size: 14px; }
.toast-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.toast-actions button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.toast-actions button:active { background: var(--primary); color: white; }
.toast-actions button.active { background: var(--primary); color: white; border-color: var(--primary); }
.toast-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 15px;
  width: 80px;
  font-family: inherit;
}

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  display: grid; place-items: center;
  z-index: 100; padding: 16px;
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 20px 50px rgba(15,23,42,.25);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { margin: 0; font-size: 18px; }
.modal label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  margin: 12px 0 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.modal input, .modal select {
  width: 100%; padding: 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  background: var(--surface); color: var(--text);
}
.modal input:focus, .modal select:focus { outline: none; border-color: var(--primary); }
.person-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.person-btn {
  background: var(--surface-2); border: 2px solid transparent;
  padding: 12px 4px; border-radius: 8px;
  font-weight: 600; cursor: pointer; font-size: 14px; color: var(--text);
}
.person-btn.active[data-person="You"]  { border-color: var(--you);  background: #dbeafe; color: var(--you); }
.person-btn.active[data-person="Wife"] { border-color: var(--mom);  background: var(--mom-light); color: var(--mom); }
.person-btn.active[data-person="Baby"] { border-color: var(--baby); background: var(--baby-light); color: var(--baby); }
.weekday-picker { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 6px; }
.weekday-picker button {
  background: var(--surface-2); border: 2px solid transparent;
  padding: 10px 0; border-radius: 6px;
  font-weight: 600; cursor: pointer; font-size: 12px; color: var(--text);
}
.weekday-picker button.active { background: #dbeafe; border-color: var(--primary); color: var(--primary); }

.scheduled-times-list {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 4px;
}
.scheduled-time-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--mom-light);
  color: var(--mom);
  border: 1px solid var(--mom);
  border-radius: 999px;
  padding: 6px 4px 6px 12px;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.scheduled-time-chip input {
  width: 90px !important;
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  font-size: 14px !important;
  font-weight: 700;
  color: var(--mom);
}
.scheduled-time-chip button {
  background: transparent;
  border: none;
  color: var(--mom);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  line-height: 1;
}
.add-time-btn {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  font-size: 13px;
}
.add-time-btn:hover { background: var(--border); color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal-actions button:not(.danger) { margin-left: auto; }


/* ===== AUTO DARK MODE (7pm-7am local) ===== */
html[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111827;
  --surface-2: #1f2937;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --mom-light: #4a1d36;
  --baby-light: #14532d;
  --success-light: #14532d;
}
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }
html[data-theme="dark"] .topbar { background: var(--surface); border-bottom-color: var(--border); }
html[data-theme="dark"] .big-tap.med {
  background: linear-gradient(135deg, var(--surface) 0%, #3a2a0c 100%);
  color: var(--text);
}
html[data-theme="dark"] .big-tap.med.ready {
  background: linear-gradient(135deg, var(--surface) 0%, #14532d 100%);
  border-color: #16a34a;
}
html[data-theme="dark"] .big-tap.med.urgent {
  background: linear-gradient(135deg, var(--surface) 0%, #4a1414 100%);
  border-color: #dc2626;
}
html[data-theme="dark"] .big-tap.baby {
  background: linear-gradient(135deg, var(--surface) 0%, #14532d 100%);
  color: var(--text);
}
html[data-theme="dark"] .big-tap.diaper-wet {
  background: linear-gradient(135deg, var(--surface) 0%, #1e3a8a 100%);
  color: var(--text);
}
html[data-theme="dark"] .big-tap.diaper-dirty {
  background: linear-gradient(135deg, var(--surface) 0%, #422006 100%);
  color: var(--text);
}
html[data-theme="dark"] .big-tap.diaper-both {
  background: linear-gradient(135deg, #1e3a8a 0%, #422006 100%);
  color: var(--text);
}
html[data-theme="dark"] .dose-timer { background: var(--surface-2); color: var(--muted); }
html[data-theme="dark"] .dose-timer.wait { background: #1e293b; color: #93c5fd; }
html[data-theme="dark"] .dose-timer.ready { background: #14532d; color: #86efac; }
html[data-theme="dark"] .dose-timer.soon { background: #4a1414; color: #fca5a5; }
html[data-theme="dark"] .med-row.urgency-soon { background: #2a0f0f; }
html[data-theme="dark"] .med-row.urgency-ready { background: #0f2a17; }
html[data-theme="dark"] .week-cell.done { background: #14532d; color: #86efac; }
html[data-theme="dark"] .week-cell.missed { background: #4a1414; color: #fca5a5; }
html[data-theme="dark"] .week-cell.partial { background: #422006; color: #fbbf24; }
html[data-theme="dark"] .modal { background: var(--surface); color: var(--text); }
html[data-theme="dark"] .modal input, html[data-theme="dark"] .modal select {
  background: var(--surface-2); color: var(--text); border-color: var(--border);
}
html[data-theme="dark"] .toast { background: var(--surface); color: var(--text); }
html[data-theme="dark"] .scheduled-time-chip { background: #3a1828; }
html[data-theme="dark"] .iconbtn { background: var(--surface-2); color: var(--text); }
html[data-theme="dark"] .refresh-btn { background: var(--surface-2); color: var(--text); }
html[data-theme="dark"] .brand-icon { background: var(--surface-2); }
html[data-theme="dark"] .sub-tabs { background: var(--surface); }
html[data-theme="dark"] .next-up-banner { background: linear-gradient(135deg, #0a0f1e 0%, #050810 100%); }
html[data-theme="dark"] .filter-btn { background: var(--surface); color: var(--muted); border-color: var(--border); }
html[data-theme="dark"] .activity-undo { background: transparent; border-color: var(--border); color: var(--muted); }

/* Manual override toggle in the header */
.theme-toggle {
  background: var(--surface-2);
  border: none;
  width: 44px; height: 44px; border-radius: 12px;
  font-size: 20px; cursor: pointer; color: var(--text);
  display: grid; place-items: center; flex-shrink: 0;
  margin-left: 4px;
}
.theme-toggle:hover { background: var(--border); }
html[data-theme="dark"] .theme-toggle { background: var(--surface-2); color: var(--text); }


/* ===== VOICE BUTTON ===== */
.voice-btn {
  background: var(--mom);
  border: none;
  width: 44px; height: 44px; border-radius: 12px;
  font-size: 22px; cursor: pointer; color: white;
  display: grid; place-items: center; flex-shrink: 0;
}
.voice-btn:active { transform: scale(0.92); }
.voice-btn.listening {
  animation: micPulse 1.2s ease-in-out infinite;
  background: var(--danger);
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.5); }
  50% { box-shadow: 0 0 0 14px rgba(220,38,38,0); }
}

/* ===== QUICK-TIME GRID ===== */
.quick-time-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}
.quick-time-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 4px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
}
.quick-time-btn:active { background: var(--primary); color: white; border-color: var(--primary); }
.quick-time-btn.selected { background: var(--primary); color: white; border-color: var(--primary); }
html[data-theme="dark"] .quick-time-btn { background: var(--surface); }
html[data-theme="dark"] .quick-time-btn.selected { background: var(--primary); }

/* Listening pulse animation for the big mic in the modal */
#voicePulse { animation: micPulseBig 1.5s ease-in-out infinite; }
@keyframes micPulseBig {
  0%, 100% { transform: scale(1); opacity: .85; }
  50% { transform: scale(1.15); opacity: 1; }
}


/* ===== SECONDARY BUTTON (used in popups for 'Pick time' etc) ===== */
.secondary-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}
.secondary-btn:active { background: var(--primary); color: white; border-color: var(--primary); }
html[data-theme="dark"] .secondary-btn { background: var(--surface); }

/* ===== MED INFO POPUP ===== */
#medInfoBody .info-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
#medInfoBody .info-row:last-child { border-bottom: none; }
#medInfoBody .info-label { color: var(--muted); font-weight: 600; }
#medInfoBody .info-value { color: var(--text); font-weight: 700; text-align: right; }
#medInfoBody .info-value.urgent { color: var(--danger); }
#medInfoBody .info-value.ready { color: var(--success); }
#medInfoBody .info-warning {
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-left: 4px solid var(--warning);
  padding: 10px 12px;
  border-radius: 8px;
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.4;
  color: #7c2d12;
}
#medInfoBody .info-warning.danger {
  background: #fef2f2;
  border-color: #fca5a5;
  border-left-color: var(--danger);
  color: #7f1d1d;
}
html[data-theme="dark"] #medInfoBody .info-warning { background: #422006; color: #fed7aa; }
html[data-theme="dark"] #medInfoBody .info-warning.danger { background: #4a1414; color: #fca5a5; }

/* ===== BP TILE & READINGS LIST ===== */
.big-tap.bp {
  background: linear-gradient(135deg, #fff 0%, #fce7f3 100%);
}
html[data-theme="dark"] .big-tap.bp {
  background: linear-gradient(135deg, var(--surface) 0%, #4a1d36 100%);
  color: var(--text);
}
.bp-summary-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.bp-item {
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
}
.bp-emoji { font-size: 22px; }
.bp-body { flex: 1; }
.bp-value { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.bp-value.flag-low { color: var(--danger); }
.bp-value.flag-high { color: var(--danger); }
.bp-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
