/* ═══════════════════════════════════════════════════
   SEIZURRE — style.css
   © 2026 Stephanie Adams. Personal use only.
═══════════════════════════════════════════════════ */

:root {
  --bg:           #e8f4fd;
  --surface:      #ffffff;
  --surface2:     #f0f7ff;
  --border:       #b0d4f1;
  --text:         #111111;
  --text2:        #444444;
  --text3:        #666666;
  --blue:         #1565c0;
  --blue-light:   #42a5f5;
  --blue-pale:    #deedfb;
  --red:          #c62828;
  --red-deep:     #b71c1c;
  --red-pale:     #fdecea;
  --red-border:   #ef9a9a;
  --purple:       #6a1b9a;
  --purple-light: #ab47bc;
  --green:        #2e7d32;
  --shadow:       rgba(0,0,0,0.10);
  --shadow-md:    rgba(0,0,0,0.18);
  --nav-bg:       #ffffff;
  --nav-border:   #b0d4f1;
  --header-bg:    #6a1b9a;
  --header-text:  #ffffff;
  --input-bg:     #ffffff;
  --input-border: #90caf9;
  --modal-bg:     #ffffff;
  --clock-bg:     #4a148c;
  --footer-bg:    rgba(0,0,0,0.04);
  --heat0: #e8f4fd;
  --heat1: #b3d4f8;
  --heat2: #7c3aed44;
  --heat3: #ef444480;
  --heat4: #c62828;
}

body.dark-mode {
  --bg:           #0d1117;
  --surface:      #1c2433;
  --surface2:     #1a2235;
  --border:       #2d3f55;
  --text:         #e6edf3;
  --text2:        #b0bec5;
  --text3:        #78909c;
  --blue:         #58a6ff;
  --blue-light:   #79c0ff;
  --blue-pale:    #1c2d42;
  --red:          #f85149;
  --red-deep:     #ff6b6b;
  --red-pale:     #2a1010;
  --red-border:   #6b2020;
  --purple:       #ce93d8;
  --purple-light: #e040fb;
  --green:        #66bb6a;
  --shadow:       rgba(0,0,0,0.4);
  --shadow-md:    rgba(0,0,0,0.6);
  --nav-bg:       #161b22;
  --nav-border:   #2d3f55;
  --header-bg:    #2d0045;
  --header-text:  #e6edf3;
  --input-bg:     #1c2433;
  --input-border: #2d3f55;
  --modal-bg:     #1c2433;
  --clock-bg:     #1a0030;
  --footer-bg:    #0f1117;
  --heat0: #1a2235;
  --heat1: #1c3a5c;
  --heat2: #7c3aed55;
  --heat3: #ef444455;
  --heat4: #f85149;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 1rem;
  padding-bottom: 80px;
  min-height: 100dvh;
}

/* ─── SW UPDATE BAR ─────────────────────────────── */
.sw-update-bar {
  background: #7c3aed;
  color: #fff;
  text-align: center;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 999;
  position: sticky;
  top: 0;
}
.sw-update-bar button {
  background: rgba(255,255,255,0.25);
  border: none;
  color: #fff;
  padding: 3px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  margin-left: 8px;
}

/* ─── ONBOARDING BANNER ─────────────────────────── */
.onboarding-banner {
  background: linear-gradient(135deg, #1565c0, #6a1b9a);
  color: #fff;
  padding: 10px 14px;
  font-size: 0.84rem;
}
.onboarding-inner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 680px;
  margin: 0 auto;
}
.onboard-icon { font-size: 1.5rem; flex-shrink: 0; }
.onboard-text { flex: 1; line-height: 1.5; }
.onboard-text strong { display: block; margin-bottom: 2px; }
.onboard-close {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 24px; height: 24px;
  cursor: pointer;
  font-size: 0.85rem;
  flex-shrink: 0;
  line-height: 1;
}

/* ─── STATUS BAR ────────────────────────────────── */
.status-bar {
  display: flex;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  min-height: 28px;
  align-items: center;
  flex-wrap: wrap;
}
.status-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 10px;
}
.chip-offline { background: #c62828; color: #fff; }
.chip-db      { background: var(--surface); color: var(--text3); border: 1px solid var(--border); }
.chip-ok      { background: #2e7d32; color: #fff !important; border: none !important; }
.chip-err     { background: #c62828; color: #fff !important; border: none !important; }

/* ─── HEADER ─────────────────────────────────────── */
header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 12px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px var(--shadow-md);
}
.header-title { font-size: 1.25rem; font-weight: 800; line-height: 1.1; }
.header-sub   { font-size: 0.72rem; opacity: 0.75; }
.header-actions { display: flex; gap: 6px; }
.emergency-header-btn, .icon-action-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font-size: 1.3rem;
  border-radius: 8px;
  width: 38px; height: 38px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.emergency-header-btn:hover, .icon-action-btn:hover { background: rgba(255,255,255,0.3); }
.emergency-header-btn:focus, .icon-action-btn:focus {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ─── CLOCK ──────────────────────────────────────── */
#live-clock {
  background: var(--clock-bg);
  color: #fff;
  text-align: center;
  padding: 10px 16px 8px;
}
#clock-time {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
#live-clock-date { font-size: 0.78rem; opacity: 0.8; }

/* ─── LOG ZONE ───────────────────────────────────── */
.log-zone {
  padding: 16px 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
#log-now-btn {
  width: 100%;
  max-width: 420px;
  padding: 24px 20px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 16px;
  font-size: 1.4rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 5px 20px rgba(198,40,40,0.35);
  transition: transform 0.08s, box-shadow 0.08s, background 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
#log-now-btn:active  { transform: scale(0.96); box-shadow: 0 2px 8px rgba(198,40,40,0.25); background: var(--red-deep); }
#log-now-btn.saved   { background: var(--green); box-shadow: 0 5px 20px rgba(46,125,50,0.35); }
#log-now-btn:focus   { outline: 3px solid var(--blue-light); outline-offset: 3px; }
.log-btn-icon { font-size: 1.7rem; line-height: 1; }
.log-hint { font-size: 0.78rem; color: var(--text3); text-align: center; }

/* ─── DATA SOURCE BAR ───────────────────────────── */
.data-source-status {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  padding: 5px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.data-source-status span { color: var(--text2); }
.data-source-status button {
  background: none;
  border: none;
  color: var(--blue);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.75rem;
}

/* ─── TABS ───────────────────────────────────────── */
.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 98;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-btn {
  flex: 1;
  padding: 10px 6px;
  background: none;
  border: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text3);
  cursor: pointer;
  transition: color 0.15s;
  white-space: nowrap;
  min-width: 0;
  font-family: inherit;
}
.tab-btn.active { color: var(--blue); border-bottom: 3px solid var(--blue); }
.tab-btn:focus  { outline: 2px solid var(--blue-light); outline-offset: -2px; }

.tab-content { display: none; padding: 12px 14px 24px; }
.tab-content.active { display: block; }

/* ─── STATS ──────────────────────────────────────── */
.stats-row {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.stat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.78rem;
  color: var(--text2);
  font-weight: 600;
}
.stat-chip span { color: var(--red); }

/* ─── HEATMAP ─────────────────────────────────────── */
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
  margin: 8px 0 4px;
}
.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  cursor: default;
  transition: opacity 0.15s;
}
.heatmap-cell:hover { opacity: 0.75; }
.heatmap-cell.h0 { background: var(--heat0); }
.heatmap-cell.h1 { background: var(--heat1); }
.heatmap-cell.h2 { background: var(--heat2); }
.heatmap-cell.h3 { background: var(--heat3); }
.heatmap-cell.h4 { background: var(--heat4); }
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--text3);
  margin-top: 4px;
}
.heatmap-swatch {
  width: 12px; height: 12px;
  border-radius: 2px;
  display: inline-block;
}
.heatmap-swatch.h0 { background: var(--heat0); border: 1px solid var(--border); }
.heatmap-swatch.h1 { background: var(--heat1); }
.heatmap-swatch.h2 { background: var(--heat2); }
.heatmap-swatch.h3 { background: var(--heat3); }
.heatmap-swatch.h4 { background: var(--heat4); }

/* ─── CARDS ──────────────────────────────────────── */
.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin: 14px 0 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.seizure-card, .med-card, .appt-card, .refill-card {
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 5px var(--shadow);
  animation: card-in 0.2s ease;
  margin-bottom: 10px;
}
.seizure-card  { border-left: 5px solid var(--red);    border: 1.5px solid var(--red-border); border-left-width: 5px; }
.med-card      { border-left: 5px solid var(--blue);   border: 1.5px solid var(--border); border-left-width: 5px; }
.appt-card     { border-left: 5px solid var(--green);  border: 1.5px solid var(--border); border-left-width: 5px; }
.appt-card.past { opacity: 0.6; }
.refill-card   { border-left: 5px solid var(--purple); border: 1.5px solid var(--border); border-left-width: 5px; }
.refill-card.urgent { border-color: var(--red); border-left-color: var(--red); }

@keyframes card-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.card-top {
  padding: 12px 14px 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.card-datetime  { font-weight: 700; font-size: 1rem; color: var(--red); line-height: 1.2; }
.card-date-sub  { font-size: 0.76rem; color: var(--text3); margin-top: 2px; }
.card-details   { padding: 0 14px 12px; font-size: 0.88rem; color: var(--text2); }
.card-details p { margin: 3px 0; }

.detail-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.detail-tag {
  font-size: 0.72rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 8px;
  color: var(--text3);
}

/* ─── NOTES ──────────────────────────────────────── */
.card-notes-area {
  border-top: 1px solid var(--border);
  padding: 10px 14px 12px;
  background: var(--surface2);
}
.card-notes-text { font-size: 0.88rem; color: var(--text2); white-space: pre-wrap; word-break: break-word; margin-bottom: 6px; }
.card-notes-text.empty { color: var(--text3); font-style: italic; }
.notes-editor { display: none; flex-direction: column; gap: 8px; }
.notes-editor.open { display: flex; }
.notes-editor textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.93rem;
  padding: 9px 12px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  min-height: 80px;
}
.notes-editor textarea:focus { border-color: var(--blue-light); }
.notes-editor-btns { display: flex; gap: 8px; }
.save-notes-btn   { background: var(--blue); color: #fff; border: none; border-radius: 8px; padding: 9px 16px; font-size: 0.9rem; font-weight: 700; cursor: pointer; font-family: inherit; }
.cancel-notes-btn { background: none; color: var(--text3); border: 1.5px solid var(--border); border-radius: 8px; padding: 9px 16px; font-size: 0.9rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.add-notes-btn { font-size: 0.8rem; color: var(--blue); background: none; border: none; cursor: pointer; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* ─── NOTE CARDS ─────────────────────────────────── */
#notes-list { display: flex; flex-direction: column; gap: 12px; }
.note-card {
  background: var(--surface);
  border-radius: 12px;
  border: 1.5px solid var(--border);
  border-left: 5px solid var(--purple);
  box-shadow: 0 1px 5px var(--shadow);
  animation: card-in 0.2s ease;
  overflow: hidden;
}
.note-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 8px; gap: 8px;
}
.note-title-input {
  flex: 1; font-size: 0.96rem; font-weight: 700;
  background: transparent; border: none; color: var(--text);
  font-family: inherit; outline: none; min-width: 0;
}
.note-title-input::placeholder { color: var(--text3); font-weight: 400; }
.note-title-input:focus { border-bottom: 1.5px solid var(--blue-light); }
.note-meta { font-size: 0.7rem; color: var(--text3); margin: 0 14px 2px; font-style: italic; }
.note-body-textarea {
  width: 100%; min-height: 90px;
  background: var(--surface2); border: none; border-top: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 0.93rem;
  padding: 10px 14px; outline: none; resize: vertical; display: block;
}
.note-body-textarea:focus { background: var(--input-bg); }
.note-save-row {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; padding: 6px 12px 10px;
  background: var(--surface2); border-top: 1px solid var(--border);
}
.note-saved-label { font-size: 0.76rem; color: var(--green); font-style: italic; opacity: 0; transition: opacity 0.3s; }
.note-saved-label.show { opacity: 1; }
.note-save-btn    { background: var(--purple); color: #fff; border: none; border-radius: 8px; padding: 6px 16px; font-size: 0.86rem; font-weight: 700; cursor: pointer; font-family: inherit; }
.note-delete-btn  { background: none; border: none; font-size: 1.1rem; cursor: pointer; padding: 4px; }

/* ─── DOSE CHIPS ─────────────────────────────────── */
.dose-times { padding: 0 14px 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.dose-chip {
  font-size: 0.8rem; padding: 5px 12px;
  border-radius: 20px; border: 1.5px solid var(--border);
  background: var(--surface2); color: var(--text2);
  cursor: pointer; font-weight: 600; transition: all 0.15s;
}
.dose-chip.taken { background: var(--green); color: #fff; border-color: var(--green); }
.dose-chip:focus { outline: 2px solid var(--blue-light); outline-offset: 2px; }

/* ─── ADHERENCE SUMMARY ──────────────────────────── */
.adherence-summary {
  background: var(--surface);
  border-radius: 12px;
  border: 1.5px solid var(--border);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.adherence-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 8px; }
.adherence-pills { display: flex; flex-direction: column; gap: 8px; }
.adh-pill { display: flex; align-items: center; gap: 8px; }
.adh-name  { font-size: 0.82rem; color: var(--text2); min-width: 100px; flex-shrink: 0; }
.adh-bar   { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.adh-fill  { height: 100%; background: var(--green); border-radius: 4px; transition: width 0.4s; }
.adh-label { font-size: 0.76rem; color: var(--text3); min-width: 28px; text-align: right; }

/* ─── REFILL ─────────────────────────────────────── */
.refill-card.urgent .card-datetime { color: var(--red); }

/* ─── TRIGGERS ───────────────────────────────────── */
.trigger-chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.trigger-chip {
  font-size: 0.78rem;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s;
  font-family: inherit;
}
.trigger-chip.selected { background: var(--purple); color: #fff; border-color: var(--purple); }
.trigger-chip:focus { outline: 2px solid var(--blue-light); outline-offset: 2px; }

.trigger-freq-list { display: flex; flex-direction: column; gap: 8px; }
.freq-row  { display: flex; align-items: center; gap: 8px; }
.freq-label { font-size: 0.82rem; color: var(--text2); min-width: 120px; flex-shrink: 0; }
.freq-bar-wrap { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.freq-bar  { height: 100%; background: var(--red); border-radius: 4px; transition: width 0.4s; }
.freq-count { font-size: 0.76rem; color: var(--text3); min-width: 24px; text-align: right; }

/* ─── CHARTS ─────────────────────────────────────── */
canvas { display: block; max-width: 100%; }
.correlation-list, .corr-row { display: flex; flex-direction: column; gap: 8px; }
.corr-row { flex-direction: row; align-items: center; gap: 8px; }
.corr-label { font-size: 0.82rem; color: var(--text2); min-width: 130px; flex-shrink: 0; }
.corr-bar-wrap { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.corr-bar  { height: 100%; background: var(--purple); border-radius: 4px; transition: width 0.4s; }
.corr-pct  { font-size: 0.76rem; color: var(--text3); min-width: 32px; text-align: right; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.stat-item { background: var(--surface2); border-radius: 10px; padding: 10px 12px; text-align: center; }
.stat-val  { font-size: 1.4rem; font-weight: 800; color: var(--purple); }
.stat-lbl  { font-size: 0.72rem; color: var(--text3); margin-top: 2px; }

/* ─── CARD BOX ───────────────────────────────────── */
.card-box {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 14px;
  margin-bottom: 2px;
}
.card-box-title { font-weight: 700; margin-bottom: 8px; font-size: 0.92rem; }
.box-sub   { font-weight: 400; font-size: 0.78rem; color: var(--text3); }
.box-desc  { font-size: 0.82rem; color: var(--text3); margin-bottom: 10px; line-height: 1.5; }
.danger-box { border-color: var(--red-border); }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.primary-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
  flex: 1;
  min-width: 120px;
  text-align: center;
}
.primary-btn:hover { opacity: 0.88; }
.primary-btn:focus { outline: 2px solid var(--blue-light); outline-offset: 2px; }
.add-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.add-btn:focus { outline: 2px solid var(--blue-light); outline-offset: 2px; }

/* ─── PRIVACY CARD ───────────────────────────────── */
.privacy-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--text2);
  line-height: 1.5;
}
.privacy-icon { font-size: 1.4rem; flex-shrink: 0; }

/* ─── SETTINGS ───────────────────────────────────── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  font-size: 0.9rem;
}
.settings-row:last-of-type { border-bottom: none; }
.toggle-check { width: 20px; height: 20px; cursor: pointer; flex-shrink: 0; accent-color: var(--purple); }
.settings-input {
  flex: 1;
  max-width: 160px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
}

/* ─── FILTER / FORM ──────────────────────────────── */
.filter-select {
  font-size: 0.8rem;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  color: var(--text);
  font-family: inherit;
  outline: none;
}
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text2);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.93rem;
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--blue-light); }

.voice-btn {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  margin-left: 6px;
  vertical-align: middle;
}
.voice-btn:focus { outline: 2px solid var(--blue-light); }

/* ─── NO RECORDS ─────────────────────────────────── */
.no-records {
  text-align: center;
  color: var(--text3);
  font-size: 0.88rem;
  padding: 22px 10px;
  font-style: italic;
  line-height: 1.6;
}

/* ─── TOAST ──────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 86px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 380px;
}
.toast {
  background: #37474f;
  color: #fff;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  text-align: center;
  animation: toast-in 0.2s ease, toast-out 0.3s ease 2.4s forwards;
  box-shadow: 0 3px 14px rgba(0,0,0,0.35);
}
.toast.error   { background: #b71c1c; }
.toast.success { background: #1b5e20; }
@keyframes toast-in  { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
@keyframes toast-out { to   { opacity:0; transform:translateY(8px); } }

/* ─── MODAL ──────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-content {
  background: var(--modal-bg);
  border-radius: 16px;
  padding: 22px 20px 18px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px var(--shadow-md);
  max-height: 92dvh;
  overflow-y: auto;
}
.modal-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.modal-sub   { font-size: 0.86rem; color: var(--text3); margin-bottom: 16px; }
.modal-btns  { display: flex; gap: 10px; }
.btn-primary { background: var(--blue); color: #fff; border: none; border-radius: 8px; padding: 11px; font-size: 0.93rem; font-weight: 700; cursor: pointer; flex: 1; font-family: inherit; }
.btn-danger  { background: var(--red); color: #fff; border: none; border-radius: 8px; padding: 11px; font-size: 0.93rem; font-weight: 700; cursor: pointer; flex: 1; font-family: inherit; }
.btn-cancel  { background: var(--border); color: var(--text); border: none; border-radius: 8px; padding: 11px; font-size: 0.93rem; font-weight: 600; cursor: pointer; flex: 1; font-family: inherit; }
.btn-primary:focus, .btn-danger:focus, .btn-cancel:focus { outline: 2px solid var(--blue-light); outline-offset: 2px; }

/* ─── EMERGENCY MODAL ────────────────────────────── */
.emergency-modal .modal-content { max-width: 440px; }
.emergency-content { border: 3px solid var(--red); }
.emergency-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--red);
  margin-bottom: 12px;
}
.emergency-steps { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.estep {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text2);
  line-height: 1.45;
}
.estep-num {
  background: var(--purple);
  color: #fff;
  border-radius: 50%;
  min-width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 0.78rem;
  flex-shrink: 0;
}
.estep-call .estep-num { background: var(--red); }
.emergency-actions { display: flex; gap: 10px; }
.btn-999 {
  flex: 1;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 1rem;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  display: block;
}
.btn-contact {
  flex: 1;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  display: block;
}

/* ─── ICON BUTTONS ───────────────────────────────── */
.icon-btn {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 5px 6px;
  border-radius: 6px;
  line-height: 1;
}
.icon-btn:focus { outline: 2px solid var(--blue-light); outline-offset: 2px; }

/* ─── BOTTOM NAV ─────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--nav-bg);
  border-top: 1px solid var(--nav-border);
  display: flex;
  z-index: 200;
  box-shadow: 0 -2px 8px var(--shadow);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px 6px;
  font-size: 0.67rem;
  color: var(--text3);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  gap: 2px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}
.nav-btn.active { color: var(--blue); }
.nav-btn:focus  { outline: 2px solid var(--blue-light); outline-offset: -2px; }
.nav-icon { font-size: 1.25rem; line-height: 1; }

/* ─── FOOTER ─────────────────────────────────────── */
.app-footer {
  text-align: center;
  font-size: 0.68rem;
  padding: 14px 16px 10px;
  color: var(--text3);
  border-top: 1px solid var(--border);
  margin-top: 24px;
  background: var(--footer-bg);
  line-height: 1.6;
}

/* ─── BUY ME A COFFEE ────────────────────────────── */
.coffee-card {
  border-left: 4px solid #f5a623 !important;
  background: linear-gradient(135deg, rgba(245,166,35,0.08) 0%, transparent 100%);
}
.coffee-btn {
  display: inline-block;
  background: linear-gradient(135deg, #f5a623, #e8921a);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 10px 22px;
  border-radius: 24px;
  text-decoration: none;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(245,166,35,0.35);
  transition: opacity 0.2s, transform 0.15s;
}
.coffee-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.coffee-btn:active { transform: translateY(0); }
.coffee-note {
  font-size: 0.74rem;
  color: var(--text3);
  margin: 8px 0 0;
  font-style: italic;
}

/* ─── DOSE HISTORY ───────────────────────────────── */
.dose-history-table {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.dose-history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--surface1);
  border: 1.5px solid var(--border);
  font-size: 0.82rem;
  transition: background 0.2s;
}
.dose-history-row.today { border-color: var(--purple); background: rgba(106,27,154,0.08); }
.dose-history-row.all-taken { border-color: var(--green); }
.dose-history-row.none-taken { border-color: var(--red); background: rgba(211,47,47,0.05); }
.dh-date { flex: 1; color: var(--text2); font-size: 0.8rem; }
.dh-dots { display: flex; gap: 5px; align-items: center; }
.dh-status { font-size: 1rem; min-width: 22px; text-align: center; }
.dose-dot {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface2);
}
.dose-dot.taken  { background: var(--green); border-color: var(--green); }
.dose-dot.missed { background: var(--red);   border-color: var(--red); opacity: 0.7; }
.dh-legend {
  font-size: 0.74rem;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 0 4px;
}
.dh-legend .dose-dot { width: 9px; height: 9px; }

/* ─── SCROLLBAR ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── FOCUS VISIBLE GLOBAL ───────────────────────── */
:focus-visible { outline: 2px solid var(--blue-light); outline-offset: 2px; }
