/* Medicine Tracker — calm, family-friendly styles */

:root, :root[data-theme="light"] {
  --cream: #FAF7F2;
  --cream-2: #F3EFE7;
  --card: #FFFFFF;
  --header-bg: rgba(250, 247, 242, 0.92);
  --nav-bg: #FFFFFF;
  --nav-border: #E8E2D7;
  --nav-active-bg: #F1F5F0;
  --icon-btn-bg: rgba(255, 255, 255, 0.6);
  --icon-btn-bg-hover: #FFFFFF;
  --icon-btn-color: #5A5550;
  --sage-50: #F1F5F0;
  --sage-100: #DDE7DA;
  --sage-200: #B9CCB4;
  --sage-300: #94B08F;
  --sage-500: #7A9B7E;
  --sage-600: #5F7E63;
  --sage-700: #4A6B4E;
  --sage-900: #1F3621;

  --terracotta-50: #FBF1EC;
  --terracotta-100: #F5D5C5;
  --terracotta-300: #E2A488;
  --terracotta-500: #C97B5A;
  --terracotta-700: #9B5A40;

  --amber-50: #FDF8EE;
  --amber-100: #FAEDD8;
  --amber-400: #E0B589;
  --amber-600: #B07A3F;

  --rose-50: #FBF2F2;
  --rose-200: #EBC9C9;
  --rose-500: #C97B7B;

  --text-900: #2D2A26;
  --text-700: #5A5550;
  --text-500: #87827A;
  --text-300: #C2BDB4;

  --line: #E8E2D7;
  --line-2: #F0EBE0;

  --shadow-sm: 0 1px 2px rgba(50, 40, 30, 0.04), 0 1px 3px rgba(50, 40, 30, 0.06);
  --shadow-md: 0 4px 14px rgba(50, 40, 30, 0.06), 0 2px 4px rgba(50, 40, 30, 0.04);
  --shadow-lg: 0 10px 30px rgba(50, 40, 30, 0.08), 0 4px 10px rgba(50, 40, 30, 0.05);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;

  --font-serif: 'Fraunces', 'Iowan Old Style', Georgia, 'Times New Roman', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* Dark theme — explicit choice */
:root[data-theme="dark"] {
  /* True-dark theme: near-black page bg with subtly-lifted cards.
     Cards stay distinct from bg via borders + shadows, not brightness. */
  --cream: #0C100E;
  --cream-2: #161B18;
  --card: #1A201D;
  --header-bg: rgba(12, 16, 14, 0.92);
  --nav-bg: #232A26;
  --nav-border: #3A4540;
  --nav-active-bg: #3E4944;
  --icon-btn-bg: #232A26;
  --icon-btn-bg-hover: #2E3530;
  --icon-btn-color: #E8E4DC;
  --sage-50: #2A332D;
  --sage-100: #364039;
  --sage-200: #4E5E50;
  --sage-300: #6B8170;
  --sage-500: #9CB69F;
  --sage-600: #B0C8B2;
  --sage-700: #C7DBC9;
  --sage-900: #E5EFE5;

  --terracotta-50: #2A211D;
  --terracotta-100: #3A2A22;
  --terracotta-300: #C18B72;
  --terracotta-500: #D9967A;
  --terracotta-700: #E8B49B;

  --amber-50: #2A2418;
  --amber-100: #3A3120;
  --amber-400: #D4A56F;
  --amber-600: #E5B985;

  --rose-50: #2A1F1F;
  --rose-200: #4A3030;
  --rose-500: #D89595;

  --text-900: #E8E4DC;
  --text-700: #B5B0A8;
  --text-500: #8A8479;
  --text-300: #5C574F;

  --line: #46504A;
  --line-2: #3A4540;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6), 0 4px 10px rgba(0, 0, 0, 0.45);
}

/* ---------- Color palette overrides ----------
   Sage is the default (defined in the root vars above). Ocean and Amber
   override --sage-* (the brand primary) and --terracotta-* (the warm accent).
   Each palette has both light and dark variants. */

/* LIGHT + OCEAN — cool background + blue accents */
:root[data-color="ocean"] {
  --cream: #F2F6F9;
  --cream-2: #E4ECF1;
  --header-bg: rgba(242, 246, 249, 0.92);
  --nav-bg: #FFFFFF;
  --nav-border: #D5E0E8;
  --nav-active-bg: #E2EDF3;
  --icon-btn-bg: rgba(255, 255, 255, 0.7);
  --line: #D5DEE5;
  --line-2: #E2EAF0;
  --sage-50: #ECF2F5;
  --sage-100: #D8E5EC;
  --sage-200: #B8CFDB;
  --sage-300: #8FB2C5;
  --sage-500: #5B8FA8;
  --sage-600: #4A7589;
  --sage-700: #3A5F75;
  --sage-900: #1F3F55;
  --terracotta-50: #FBF1EB;
  --terracotta-100: #F5D4C0;
  --terracotta-300: #E2B59E;
  --terracotta-500: #E89B7D;
  --terracotta-700: #B86E50;
}

/* LIGHT + AMBER — warm peach background + logo-orange accents */
:root[data-color="amber"] {
  --cream: #FCF5EE;
  --cream-2: #F5E3D2;
  --header-bg: rgba(252, 245, 238, 0.92);
  --nav-bg: #FFFFFF;
  --nav-border: #E8D0BB;
  --nav-active-bg: #F5DCC5;
  --icon-btn-bg: rgba(255, 255, 255, 0.7);
  --line: #E5CDB5;
  --line-2: #EFDBC6;
  --sage-50: #FBEFE8;
  --sage-100: #F5D4C0;
  --sage-200: #E2A488;
  --sage-300: #D08D6C;
  --sage-500: #C97B5A;   /* logo orange — primary */
  --sage-600: #A85F40;
  --sage-700: #8E4F32;
  --sage-900: #5A2F1E;
  --terracotta-50: #FDF6EB;
  --terracotta-100: #F8E0BA;
  --terracotta-300: #E6C282;
  --terracotta-500: #D9A663;   /* warm saffron — accent */
  --terracotta-700: #9F7A47;
}

/* DARK + OCEAN — bluish-black bg + bright blue accents */
:root[data-theme="dark"][data-color="ocean"] {
  --cream: #0A0E12;
  --cream-2: #141A1F;
  --card: #181F25;
  --header-bg: rgba(10, 14, 18, 0.92);
  --nav-bg: #1F2830;
  --nav-border: #364452;
  --nav-active-bg: #2F3E4A;
  --icon-btn-bg: #1F2830;
  --icon-btn-bg-hover: #2A3540;
  --line: #3A4854;
  --line-2: #2C3742;
  --sage-50: #1A2A36;
  --sage-100: #243747;
  --sage-200: #355269;
  --sage-300: #547A95;
  --sage-500: #7CABC5;
  --sage-600: #93BCD3;
  --sage-700: #B5D2E0;
  --sage-900: #D8E8F0;
  --terracotta-50: #2A1F1B;
  --terracotta-100: #3A2A23;
  --terracotta-300: #C28B73;
  --terracotta-500: #D9967A;
  --terracotta-700: #E8B49B;
}

/* DARK + ORANGE — warm-tinted near-black bg + bright orange accents */
:root[data-theme="dark"][data-color="amber"] {
  --cream: #14100C;
  --cream-2: #1F1813;
  --card: #251C15;
  --header-bg: rgba(20, 16, 12, 0.92);
  --nav-bg: #2A2017;
  --nav-border: #4A3825;
  --nav-active-bg: #3A2C1C;
  --icon-btn-bg: #2A2017;
  --icon-btn-bg-hover: #382C1F;
  --line: #4A3825;
  --line-2: #382C1F;
  --sage-50: #2A2017;
  --sage-100: #3A2C1F;
  --sage-200: #5C4530;
  --sage-300: #8A6549;
  --sage-500: #DC9573;
  --sage-600: #E6A887;
  --sage-700: #EFBC9D;
  --sage-900: #F4D2BE;
  --terracotta-50: #2C2317;
  --terracotta-100: #3A2F1F;
  --terracotta-300: #C7A271;
  --terracotta-500: #DEB87C;
  --terracotta-700: #ECCFA8;
}

/* AUTO theme follows OS preference; same palette overrides apply when dark */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"][data-color="ocean"] {
    --cream: #0A0E12;
    --cream-2: #141A1F;
    --card: #181F25;
    --header-bg: rgba(10, 14, 18, 0.92);
    --nav-bg: #1F2830;
    --nav-border: #364452;
    --nav-active-bg: #2F3E4A;
    --icon-btn-bg: #1F2830;
    --icon-btn-bg-hover: #2A3540;
    --line: #3A4854;
    --line-2: #2C3742;
    --sage-50: #1A2A36;
    --sage-100: #243747;
    --sage-200: #355269;
    --sage-300: #547A95;
    --sage-500: #7CABC5;
    --sage-600: #93BCD3;
    --sage-700: #B5D2E0;
    --sage-900: #D8E8F0;
    --terracotta-50: #2A1F1B;
    --terracotta-100: #3A2A23;
    --terracotta-300: #C28B73;
    --terracotta-500: #D9967A;
    --terracotta-700: #E8B49B;
  }
  :root[data-theme="auto"][data-color="amber"] {
    --cream: #14100C;
    --cream-2: #1F1813;
    --card: #251C15;
    --header-bg: rgba(20, 16, 12, 0.92);
    --nav-bg: #2A2017;
    --nav-border: #4A3825;
    --nav-active-bg: #3A2C1C;
    --icon-btn-bg: #2A2017;
    --icon-btn-bg-hover: #382C1F;
    --line: #4A3825;
    --line-2: #382C1F;
    --sage-50: #2A2017;
    --sage-100: #3A2C1F;
    --sage-200: #5C4530;
    --sage-300: #8A6549;
    --sage-500: #DC9573;
    --sage-600: #E6A887;
    --sage-700: #EFBC9D;
    --sage-900: #F4D2BE;
    --terracotta-50: #2C2317;
    --terracotta-100: #3A2F1F;
    --terracotta-300: #C7A271;
    --terracotta-500: #DEB87C;
    --terracotta-700: #ECCFA8;
  }
}

/* Dark theme — auto follows OS */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --cream: #0C100E;
    --cream-2: #161B18;
    --card: #1A201D;
    --header-bg: rgba(12, 16, 14, 0.92);
    --nav-bg: #232A26;
    --nav-border: #3A4540;
    --nav-active-bg: #3E4944;
    --icon-btn-bg: #232A26;
    --icon-btn-bg-hover: #2E3530;
    --icon-btn-color: #E8E4DC;
    --sage-50: #2A332D;
    --sage-100: #364039;
    --sage-200: #4E5E50;
    --sage-300: #6B8170;
    --sage-500: #9CB69F;
    --sage-600: #B0C8B2;
    --sage-700: #C7DBC9;
    --sage-900: #E5EFE5;

    --terracotta-50: #2A211D;
    --terracotta-100: #3A2A22;
    --terracotta-300: #C18B72;
    --terracotta-500: #D9967A;
    --terracotta-700: #E8B49B;

    --amber-50: #2A2418;
    --amber-100: #3A3120;
    --amber-400: #D4A56F;
    --amber-600: #E5B985;

    --rose-50: #2A1F1F;
    --rose-200: #4A3030;
    --rose-500: #D89595;

    --text-900: #E8E4DC;
    --text-700: #B5B0A8;
    --text-500: #8A8479;
    --text-300: #5C574F;

    --line: #46504A;
    --line-2: #3A4540;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6), 0 4px 10px rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--text-900);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

#app {
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text-900);
}

a {
  color: var(--sage-700);
  text-decoration: none;
}

/* Boot / splash screen */
.boot-screen {
  position: fixed;
  inset: 0;
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.3s ease-out;
}

.boot-screen.boot-leaving {
  opacity: 0;
  pointer-events: none;
}

.boot-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px;
  max-width: 360px;
}

.boot-icon {
  /* Fixed size matches the <img width/height> attributes. */
  width: 180px;
  height: 180px;
  opacity: 0;
  transform: scale(0.6);
  animation: boot-icon-in 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.2) forwards,
             boot-icon-breathe 2.6s ease-in-out 0.6s infinite;
  /* Subtle drop shadow on the rounded-square outline only (icon has
     transparent corners, so this no longer makes a visible "card"). */
  filter: drop-shadow(0 6px 14px rgba(122, 155, 126, 0.18));
  line-height: 0;
}
.boot-icon img { display: block; width: 100%; height: 100%; }

.boot-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--sage-700);
  /* Tight spacing — just enough to clear the hands at the icon's bottom. */
  margin: 10px 0 0;
  opacity: 0;
  transform: translateY(6px);
  animation: boot-text-in 0.45s ease-out 0.2s forwards;
  line-height: 1.1;
}

/* Plain capsule-shaped progress bar */
.boot-progress {
  opacity: 0;
  animation: boot-text-in 0.45s ease-out 0.3s forwards;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}
.capsule-shell {
  width: 200px;
  height: 6px;
  border-radius: 3px;
  border: 1px solid var(--sage-300);
  background: var(--cream-2);
  overflow: hidden;
  position: relative;
}
.capsule-fill {
  height: 100%;
  width: 0%;
  background: var(--sage-500);
  border-radius: 0;
  animation: capsule-fill 5s linear forwards;
}
.boot-status {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-500);
  margin: 0;
  min-height: 16px;
  letter-spacing: 0;
}
.boot-status.fade {
  animation: boot-text-in 0.35s ease-out;
}
.boot-percent {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-500);
  margin: 0;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.boot-msg {
  display: none;
  font-size: 13px;
  color: var(--text-500);
  margin: 22px 0 0;
  line-height: 1.5;
  max-width: 280px;
}

@keyframes boot-icon-in {
  from { opacity: 0; transform: scale(0.6); }
  60%  { opacity: 1; transform: scale(1.06); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes boot-icon-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.035); }
}
@keyframes boot-text-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes capsule-fill {
  from { width: 0%; }
  to   { width: 100%; }
}

/* Layout */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 720px;
  margin: 0 auto;
  position: relative;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  /* Tighter side padding so "Medicine Tracker" fits beside the larger logo. */
  /* v0.5.1: respect Android/iOS safe area — Capacitor WebView extends edge-to-
     edge under the status bar, so we add env(safe-area-inset-top) padding. */
  padding: calc(16px + env(safe-area-inset-top, 0px)) 14px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.app-title {
  font-family: var(--font-serif);
  /* clamp() shrinks the title on narrower phones so it never gets chopped. */
  font-size: clamp(15px, 4.5vw, 18px);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-900);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}

.app-subtitle {
  font-size: 11px;
  color: var(--text-500);
  margin: 1px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-logo {
  flex-shrink: 0;
  display: inline-flex;
  line-height: 0;
}
/* v0.4.29: shrunk from 44 → 36 — user feedback was that the header tile
   felt too heavy. The Refresh + Settings buttons next to it are 40x40 so
   the logo can sit slightly smaller without looking lost. */
.app-logo svg, .app-logo img { display: block; width: 36px; height: 36px; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--icon-btn-bg);
  color: var(--icon-btn-color);
  border: 1px solid transparent;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
}

.icon-btn:hover {
  background: var(--icon-btn-bg-hover);
  border-color: var(--line-2);
}
.icon-btn:active { transform: scale(0.96); }

.app-main {
  flex: 1;
  /* v0.5.1: bottom padding accounts for nav bar + safe-area inset (gesture bar) */
  padding: 0 20px calc(120px + env(safe-area-inset-bottom, 0px));
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  /* v0.5.1: float above the system gesture bar */
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--nav-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  display: flex;
  gap: 4px;
  z-index: 20;
  border: 1px solid var(--nav-border);
  max-width: calc(100% - 28px);
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 18px;
  color: var(--text-500);
  font-size: 11px;
  font-weight: 500;
  transition: all 0.15s;
  /* Equal-width tabs: each button takes 1 share of the row so the active
     highlight is the same size for every label. */
  flex: 1 1 0;
  min-width: 0;
}

.nav-btn:hover { color: var(--text-700); }

.nav-btn.active {
  background: var(--nav-active-bg);
  color: var(--sage-700);
}

.nav-btn svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line-2);
  margin-bottom: 14px;
}

.card-tight { padding: 14px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  margin: 0;
}

.card-eyebrow {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-500);
  margin-bottom: 6px;
}

/* Section heading */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 22px 0 12px;
  padding: 0 2px;
}

.section-head h2 {
  font-size: 17px;
  font-weight: 600;
}

.section-head .link {
  font-size: 13px;
  color: var(--sage-700);
  font-weight: 500;
}

/* Greeting block */
.greeting {
  padding: 8px 2px 18px;
}

.greeting h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.greeting p {
  margin: 6px 0 0;
  color: var(--text-500);
  font-size: 15px;
}

/* Dose row */
.dose-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-2);
}

.dose-row:last-child { border-bottom: none; }

.dose-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  color: white;
}

.dose-time {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--text-500);
  font-weight: 500;
  width: 56px;
  text-align: right;
  flex-shrink: 0;
}

.dose-info { flex: 1; min-width: 0; }

.dose-name {
  font-weight: 500;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dose-meta {
  font-size: 12px;
  color: var(--text-500);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dose-actions {
  display: flex;
  gap: 6px;
}

.dose-action {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream-2);
  color: var(--text-700);
  transition: all 0.15s;
}

.dose-action:hover { background: var(--sage-100); color: var(--sage-700); }
.dose-action.taken { background: var(--sage-500); color: white; }
.dose-action.skipped { background: var(--text-300); color: white; }

.dose-status {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
  white-space: nowrap;
}

.dose-status.taken { background: var(--sage-100); color: var(--sage-700); }
.dose-status.skipped { background: var(--cream-2); color: var(--text-500); }
.dose-status.missed { background: var(--rose-50); color: var(--rose-500); }
.dose-status.snoozed { background: var(--amber-100); color: var(--amber-600); }

/* Member chips */
.member-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 0 6px;
  margin: 0 -4px;
  scrollbar-width: none;
}
.member-strip::-webkit-scrollbar { display: none; }

.member-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  flex-shrink: 0;
  min-width: 64px;
}

.member-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 20px;
  color: white;
  border: 2px solid white;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.member-avatar.lg {
  width: 72px;
  height: 72px;
  font-size: 26px;
}

.member-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-700);
  max-width: 70px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-avatar .badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: var(--terracotta-500);
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 6px;
  border: 2px solid white;
}

/* Lists */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  border: 1px solid var(--line-2);
  transition: border-color 0.15s, transform 0.1s;
  cursor: pointer;
  text-align: left;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

/* Only apply hover on real hover-capable devices. On mobile, hover sticks
   after a tap and was filling the card with a translucent palette colour. */
@media (hover: hover) {
  .list-item:hover {
    border-color: var(--sage-200);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }
}

/* Explicitly null out focus/active backgrounds so no lavender (or any other
   colour) flash appears when the card is tapped on Android. */
.list-item:focus,
.list-item:active {
  outline: none;
  background: var(--card);
}
.list-item:focus-visible {
  outline: 2px solid var(--sage-300);
  outline-offset: 2px;
}
.list-item:active { transform: scale(0.998); }

.list-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--sage-50);
  color: var(--sage-700);
}

.list-item-icon svg { width: 20px; height: 20px; }

.list-item-content { flex: 1; min-width: 0; }

.list-item-title {
  font-weight: 500;
  font-size: 15px;
  color: var(--text-900);
}

.list-item-meta {
  font-size: 13px;
  color: var(--text-500);
  margin-top: 2px;
}

.list-item-trail {
  color: var(--text-500);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 14px;
  font-weight: 500;
  font-size: 15px;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--sage-500);
  color: white;
}

.btn-primary:hover { background: var(--sage-600); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: var(--cream-2);
  color: var(--text-900);
}

.btn-secondary:hover { background: var(--sage-50); }

.btn-ghost {
  background: transparent;
  color: var(--sage-700);
}

.btn-ghost:hover { background: var(--sage-50); }

.btn-danger {
  background: var(--rose-50);
  color: var(--rose-500);
}

.btn-danger:hover { background: var(--rose-200); }

.btn-full { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }

.fab {
  position: fixed;
  right: 20px;
  /* v0.5.6: clear the bottom nav pill (~72px tall) AND the system gesture
     bar (env(safe-area-inset-bottom)). Was 96px which got eaten by the
     gesture bar on Capacitor edge-to-edge layouts. */
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--sage-500);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
  z-index: 15;
  transition: all 0.15s;
}

.fab:hover { background: var(--sage-700); transform: translateY(-2px); }
.fab:active { transform: scale(0.96); }
.fab svg { width: 24px; height: 24px; }

/* Forms */
.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-700);
  margin-bottom: 6px;
  padding-left: 4px;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="time"],
.field input[type="tel"],
.field input[type="email"],
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
  color: var(--text-900);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--sage-300);
  box-shadow: 0 0 0 3px rgba(122, 155, 126, 0.15);
}

.field-help {
  font-size: 12px;
  color: var(--text-500);
  margin-top: 4px;
  padding-left: 4px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.chip-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  padding: 8px 14px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text-700);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover { border-color: var(--sage-300); }

.chip.active {
  background: var(--sage-500);
  border-color: var(--sage-500);
  color: white;
}

/* Alert banners */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  border: 1px solid transparent;
}

.alert svg { flex-shrink: 0; margin-top: 1px; }

.alert-amber {
  background: var(--amber-50);
  color: var(--amber-600);
  border-color: var(--amber-100);
}

.alert-rose {
  background: var(--rose-50);
  color: var(--rose-500);
  border-color: var(--rose-200);
}

.alert-sage {
  background: var(--sage-50);
  color: var(--sage-700);
  border-color: var(--sage-100);
}

.alert-title {
  font-weight: 500;
  font-size: 14px;
  margin: 0 0 2px;
}

.alert-body {
  font-size: 13px;
  margin: 0;
  opacity: 0.9;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-500);
}

.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--sage-50);
  color: var(--sage-300);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-icon svg { width: 28px; height: 28px; }

.empty h3 {
  font-family: var(--font-serif);
  color: var(--text-700);
  margin-bottom: 8px;
}

.empty p {
  margin: 0 0 18px;
  font-size: 14px;
}

/* Modal / sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(45, 42, 38, 0.45);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: backdrop-in 0.2s ease-out;
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.sheet {
  background: var(--cream);
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow-y: auto;
  animation: sheet-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  padding-bottom: env(safe-area-inset-bottom);
}

@keyframes sheet-in {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.sheet-header {
  position: sticky;
  top: 0;
  background: var(--cream);
  padding: 16px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-2);
}

.sheet-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
}

.sheet-body { padding: 20px; }

.sheet-handle {
  width: 38px;
  height: 4px;
  background: var(--text-300);
  border-radius: 4px;
  margin: 10px auto 0;
}

/* Page heading */
.page-head { padding: 6px 2px 16px; }
.page-head h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.page-head p {
  margin: 4px 0 0;
  color: var(--text-500);
  font-size: 14px;
}

/* Detail badges */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 12px;
  background: var(--cream-2);
  color: var(--text-700);
  font-weight: 500;
}

.tag-sage { background: var(--sage-100); color: var(--sage-700); }
.tag-amber { background: var(--amber-100); color: var(--amber-600); }
.tag-rose { background: var(--rose-200); color: var(--rose-500); }
.tag-terra { background: var(--terracotta-100); color: var(--terracotta-700); }

/* Schedule editor */
.time-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 12px;
  background: var(--sage-50);
  color: var(--sage-700);
  border-radius: 18px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--sage-100);
}

.time-pill button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--sage-200);
  color: white;
}

/* Stock bar */
.stock-bar {
  height: 6px;
  background: var(--cream-2);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}

.stock-bar > div {
  height: 100%;
  background: var(--sage-500);
  border-radius: 4px;
  transition: width 0.3s;
}

.stock-bar.low > div { background: var(--terracotta-500); }
.stock-bar.warn > div { background: var(--amber-400); }

/* Utility */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.between { justify-content: space-between; }
.spacer { flex: 1; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
/* v0.4.23: unified type scale across all tabs.
   .text-strong → primary row text (medicine name, member name) — 15px
   .text-sm     → 13px
   .text-xs     → 12px (sub-meta: form/strength/relationship/etc.) */
.text-sm { font-size: 13px; line-height: 1.4; }
.text-xs { font-size: 12px; line-height: 1.4; }
.text-muted { color: var(--text-500); }
.text-strong { color: var(--text-900); font-weight: 500; font-size: 15px; line-height: 1.35; }
.grow { flex: 1; }
.hidden { display: none; }

/* Animations */
.fade-in {
  animation: fade-in 0.25s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Reminders banner / toast — wide layout so long messages don't wrap into
   a thin column. Fills near-edge-to-edge on phones, caps at 480px on tablets. */
.reminder-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 480px;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: drop-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  border: 1px solid var(--sage-100);
  color: var(--text-900);
  font-size: 14px;
  line-height: 1.45;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.reminder-banner svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}
.reminder-banner span {
  flex: 1;
  min-width: 0;
}
@media (min-width: 640px) {
  .reminder-banner { font-size: 15px; padding: 14px 18px; }
}
.reminder-banner-error {
  background: var(--rose-50, #fdf2f3);
  border-color: var(--rose-200, #f5c6cb);
  color: var(--rose-700, #9c2f3b);
}
.reminder-banner-error svg {
  color: var(--rose-500);
}

/* --- v0.1.26: form validation visuals --- */
.field-invalid input,
.field-invalid select,
.field-invalid textarea,
input.field-invalid,
select.field-invalid,
textarea.field-invalid {
  border-color: var(--rose-400, #d76e7c) !important;
  background: var(--rose-50, #fdf2f3) !important;
}
.field-invalid input:focus,
.field-invalid select:focus,
.field-invalid textarea:focus,
input.field-invalid:focus,
select.field-invalid:focus,
textarea.field-invalid:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(215, 110, 124, 0.18);
}
.field-error-text {
  color: var(--rose-600, #b53b4a);
  font-size: 12px;
  margin: 4px 0 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.chip-group-invalid {
  border-radius: 12px;
  outline: 1.5px dashed var(--rose-400, #d76e7c);
  outline-offset: 4px;
}
.slot-grid-invalid {
  outline: 1.5px dashed var(--rose-400, #d76e7c);
  outline-offset: 2px;
}

@keyframes drop-in {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* Responsive */
@media (min-width: 640px) {
  .app-header { padding: 22px 28px 16px; }
  .app-main { padding: 0 28px 120px; }
}

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

/* --- v0.1.22 additions: slot picker + settings reminder times --- */
.slot-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--cream-2);
  border-radius: 12px;
  padding: 8px;
}
.slot-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--line-2);
  transition: border-color 0.15s, background 0.15s;
}
.slot-row.active {
  border-color: var(--sage-300);
  background: var(--sage-50);
}
.slot-row-label {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.slot-row-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-900);
}
.slot-row-time {
  font-size: 11px;
  color: var(--text-500);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.slot-row-dose {
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-900);
  min-width: 84px;
}

/* Weekday picker — 7 single-letter chips for "Selected days" frequency */
.weekday-picker {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  background: var(--cream-2);
  border-radius: 12px;
  padding: 8px;
}
.weekday-chip {
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-500);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  font-family: inherit;
}
.weekday-chip.active {
  background: var(--sage-500);
  border-color: var(--sage-700);
  color: white;
}
.weekday-chip:hover:not(.active) {
  background: var(--cream);
  color: var(--text-900);
}

/* +/- stepper for choosing dose per slot */
.dose-stepper {
  display: inline-flex;
  align-items: stretch;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  min-width: 132px;
  height: 38px;
}
.dose-stepper-btn {
  width: 36px;
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-900);
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background 0.15s;
}
.dose-stepper-btn:active:not(:disabled) {
  background: var(--sage-50);
}
.dose-stepper-btn:disabled {
  color: var(--text-300);
  cursor: not-allowed;
}
@media (hover: hover) {
  .dose-stepper-btn:hover:not(:disabled) {
    background: var(--cream-2);
  }
}
.dose-stepper-value {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-left: 1px solid var(--line-2);
  border-right: 1px solid var(--line-2);
  min-width: 60px;
  background: var(--cream-2);
}
.dose-stepper-num {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-900);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.dose-stepper-unit {
  font-size: 10px;
  color: var(--text-500);
  line-height: 1.1;
  margin-top: 1px;
}
.dose-stepper-placeholder {
  font-size: 16px;
  color: var(--text-400);
}
.slot-row.active .dose-stepper {
  border-color: var(--sage-300);
}
.slot-row.active .dose-stepper-value {
  background: var(--sage-50);
}

.slot-times-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.slot-time-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.slot-time-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-700);
  padding-left: 2px;
}
.slot-time-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-900);
  font-variant-numeric: tabular-nums;
}

/* --- v0.1.32: editable refill list in Export --- */
.refill-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--cream-2);
  border-radius: 12px;
  padding: 8px;
}
.refill-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  transition: opacity 0.15s, border-color 0.15s;
}
.refill-row-off {
  opacity: 0.55;
}
.refill-row-info {
  flex: 1;
  min-width: 0;
}
.refill-row-qty {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.refill-row-qty input {
  width: 64px;
  padding: 7px 9px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-900);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.refill-row-qty input:focus {
  outline: none;
  border-color: var(--sage-300);
  box-shadow: 0 0 0 3px rgba(122, 155, 126, 0.15);
}
.refill-row-unit {
  font-size: 11px;
  color: var(--text-500);
  min-width: 38px;
}

/* --- v0.3.7 + v0.4.1: Settings accordion — matches .member-accordion --- */
.settings-card {
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.settings-card[open] { box-shadow: var(--shadow-md); }
.settings-card-summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: var(--card);
  transition: background 0.15s;
}
.settings-card-summary:hover { background: var(--cream-2); }
.settings-card-summary::-webkit-details-marker { display: none; }
.settings-card-summary::marker { content: ''; }
.settings-card-summary-text { min-width: 0; flex: 1; text-align: left; }
.settings-card-chevron {
  flex-shrink: 0;
  display: inline-flex;
  color: var(--text-500);
  transition: transform 0.2s ease;
}
.settings-card[open] .settings-card-chevron { transform: rotate(90deg); }
.settings-card[open] .settings-card-summary { border-bottom: 1px solid var(--line-2); }
.settings-card-body {
  padding: 14px 16px 18px;
  animation: fade-in 0.2s ease-out;
}

/* --- v0.2.0 additions: ErrorBoundary, onboarding dots, storage grid --- */
.crash-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--cream);
}
.crash-card {
  max-width: 460px;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 24px;
}
.crash-card h2 {
  font-family: var(--font-serif);
  font-size: 22px;
  margin: 0 0 8px;
  color: var(--text-900);
}
.crash-details {
  background: var(--cream-2);
  border-radius: 8px;
  padding: 10px;
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
  margin-top: 8px;
}
.onboarding-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sage-100);
  transition: background 0.2s, transform 0.2s;
}
.onboarding-dot.active {
  background: var(--sage-500);
  transform: scale(1.3);
}
.storage-grid {
  display: grid;
  /* 2 columns on phones — keeps full labels readable. 4 columns on tablets+ */
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (min-width: 540px) {
  .storage-grid { grid-template-columns: repeat(4, 1fr); }
}
.storage-cell {
  background: var(--cream-2);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  min-width: 0;
}
.storage-num {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--sage-700);
  margin: 0;
  line-height: 1;
}
.storage-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-500);
  margin: 4px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Export tab: collapsible card */
/* v0.4.1: Export cards now use the same neutral .member-accordion look. */
.export-card {
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-2);
  background: var(--card);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  transition: box-shadow 0.15s;
}
.export-card.open { box-shadow: var(--shadow-md); }
.export-card-med, .export-card-refill {
  background: var(--card);
  border-color: var(--line-2);
}
/* v0.4.2: Circular brand-icon tile — same shape + ring as member avatars.
   Used for Export accordions (heart / box) and Settings accordions.
   Always sage-700 background + white icon so it stays visible across
   theme + palette combinations. */
.brand-icon,
.export-card-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--sage-700);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  /* Match the family-photo Avatar — always a literal white ring, not the
     theme card colour, so it reads as a ring on cream/dark backgrounds too. */
  border: 2px solid #ffffff;
  box-shadow: var(--shadow-sm);
}
/* Force pure white on the SVG so it never inherits the button's text colour. */
.brand-icon svg,
.export-card-logo svg {
  color: #ffffff;
  stroke: #ffffff;
}
/* Dark theme — flip the glyph to black so it reads against the lighter
   sage-700 fill at dark-theme contrast. White borders stay white. */
:root[data-theme="dark"] .brand-icon svg,
:root[data-theme="dark"] .export-card-logo svg {
  color: #000000;
  stroke: #000000;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-icon svg,
  :root:not([data-theme="light"]) .export-card-logo svg {
    color: #000000;
    stroke: #000000;
  }
}
.export-card-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  color: var(--text-900);
  font-family: inherit;
  transition: background 0.15s;
}
.export-card-head:hover { background: var(--cream-2); }
.export-card.open .export-card-head { border-bottom: 1px solid var(--line-2); }
.export-card-head svg:last-child {
  transition: transform 0.2s ease;
  color: var(--text-500);
  flex-shrink: 0;
}
.export-card.open .export-card-head svg:last-child {
  transform: rotate(90deg);
}
.export-card-body {
  padding: 14px 16px 18px;
  animation: fade-in 0.2s ease-out;
}
/* v0.4.2: keep subtitle on a single line so both Export cards render the
   same height regardless of how long the descriptor is. */
.export-card-sub,
.settings-card-summary-sub {
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Postal addresses list (Settings) */
.addr-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.addr-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 10px;
}
.addr-row-info { flex: 1; min-width: 0; }
.addr-row-actions { display: flex; gap: 4px; flex-shrink: 0; }
.addr-edit {
  padding: 10px;
  background: var(--cream-2);
  border: 1px solid var(--line-2);
  border-radius: 10px;
}
.addr-edit .field-tight { margin-bottom: 8px; }

/* Picker list shown under the "Send prescription along" toggle */
.rx-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--cream-2);
  border-radius: 10px;
  padding: 6px;
}
.rx-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s, opacity 0.12s;
}
.rx-picker-row:not(.on) { opacity: 0.55; }
.rx-picker-row.on { border-color: var(--sage-300); }
.rx-picker-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--sage-500);
  flex-shrink: 0;
}
.rx-picker-tag {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-500);
  background: var(--cream-2);
  padding: 3px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}

/* "Send prescription along" toggle */
.rx-attach-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-900);
  user-select: none;
}
.rx-attach-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--sage-500);
  cursor: pointer;
  flex-shrink: 0;
}

/* --- v0.1.23: editable time-slot list in Settings --- */
.slot-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.slot-list-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 10px;
}
.slot-list-row.builtin {
  background: var(--cream-2);
}
.slot-list-handle {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}
.slot-list-handle .icon-btn-xs {
  width: 22px;
  height: 18px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--text-500);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.slot-list-handle .icon-btn-xs:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.slot-list-handle .icon-btn-xs:hover:not(:disabled) {
  background: var(--cream-2);
  color: var(--text-900);
}
.slot-list-name {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-900);
}
.slot-list-row.builtin .slot-list-name {
  background: transparent;
  border-color: transparent;
  font-weight: 500;
  cursor: default;
}
.slot-list-time {
  width: 100px;
  padding: 8px 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-900);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.slot-list-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-500);
  background: var(--cream-3, var(--cream-2));
  padding: 4px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}
.icon-btn-sm {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-500);
  cursor: pointer;
}
.icon-btn-sm:hover {
  color: var(--rose-500);
  border-color: var(--rose-200);
}

/* --- v0.1.16 additions: per-time dose rows + color-palette chips --- */

/* Time + per-time dose stacked rows */
.time-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.time-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.time-input-field {
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-900);
  font-variant-numeric: tabular-nums;
  width: 110px;
  flex-shrink: 0;
}
.time-dose-select {
  flex: 1;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-900);
  min-width: 0;
}
.time-input-field:focus, .time-dose-select:focus {
  outline: none;
  border-color: var(--sage-300);
  box-shadow: 0 0 0 3px rgba(122, 155, 126, 0.15);
}
.time-row-remove {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--cream-2);
  color: var(--rose-500);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.time-row-remove:hover { background: var(--rose-50); }

/* Color palette picker chips */
.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.color-chip-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

/* --- v0.1.8 additions: compact form, table alignment --- */
.card-compact {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line-2);
  margin-bottom: 10px;
}
.field-tight { margin-bottom: 12px; }
.field-tight label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-700);
  margin-bottom: 4px;
  padding-left: 2px;
}
.field-tight input[type="text"],
.field-tight input[type="number"],
.field-tight input[type="date"],
.field-tight input[type="time"],
.field-tight input[type="datetime-local"],
.field-tight input[type="tel"],
.field-tight input[type="email"],
.field-tight select,
.field-tight textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-900);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-tight input:focus, .field-tight select:focus, .field-tight textarea:focus {
  outline: none;
  border-color: var(--sage-300);
  box-shadow: 0 0 0 3px rgba(122, 155, 126, 0.15);
}
.field-tight textarea { resize: vertical; min-height: 52px; }

/* Medicines tab table column fix — give name 55%, dose ~25%, when ~20% */
.dose-table { table-layout: fixed; width: 100%; }
.dose-table th:first-child, .dose-table td:first-child {
  width: 55%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.dose-table th:nth-child(2), .dose-table td:nth-child(2) {
  width: 22%;
  text-align: center;
}
.dose-table th:nth-child(3), .dose-table td:nth-child(3) {
  width: 23%;
  text-align: right;
  padding-right: 14px;
  font-size: 12px;
  word-wrap: break-word;
}

/* --- v0.1.6 additions: timetable, prescription grid --- */

/* v0.4.38 — "NOW" highlight on the time bucket nearest to the current
   clock-time when the user arrives via notification tap (?focus=now). */
.timetable-slot.active-now {
  border-left-color: var(--amber-600, #c98b1d);
  box-shadow: 0 0 0 2px var(--amber-300, #f0c97c);
  background: var(--amber-50, #fdf3e1);
  animation: mt-pulse-glow 1.4s ease-in-out 0s 2;
}
@keyframes mt-pulse-glow {
  0%, 100% { box-shadow: 0 0 0 2px var(--amber-300, #f0c97c); }
  50%      { box-shadow: 0 0 0 5px var(--amber-200, #f7dfa9); }
}

/* Today timetable layout */
/* v0.4.24 — each time bucket is now a clearly-bounded card with a prominent
   time header, so the eye can jump straight to "what's at 8 AM" without
   scanning a flat list. */
.timetable-slot {
  margin: 10px 0 0;
  background: var(--sage-50, var(--cream-2));
  border-radius: 12px;
  border-left: 4px solid var(--sage-500);
  padding: 10px 12px 8px;
}
.timetable-slot:first-child { margin-top: 4px; }
.slot-title {
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--sage-700);
  margin: 0 0 8px;
  padding: 0 0 6px;
  border-bottom: 1px solid var(--sage-200, var(--line-2));
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}
.slot-title::before {
  content: '🕒';
  font-size: 15px;
  line-height: 1;
}
.slot-title-time {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-500);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.food-group { margin: 4px 0 6px; }
.food-group:last-child { margin-bottom: 0; }
.food-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-500);
  margin: 4px 0 2px;
  padding-left: 2px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.timetable-row {
  display: flex;
  gap: 10px;
  padding: 6px 2px;
  border-bottom: none;
}
.timetable-row + .timetable-row { border-top: 1px solid var(--line-2); }
.row-time {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--sage-700);
  font-weight: 600;
  width: 70px;
  flex-shrink: 0;
}
.row-body { flex: 1; min-width: 0; }

/* Prescription grid in MemberEditor */
.rx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}
.rx-thumb {
  background: var(--cream-2);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line-2);
}
.rx-thumb-view {
  width: 100%;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: white;
}
.rx-thumb-view img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.rx-pdf-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--terracotta-500);
}
.rx-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--cream-2);
  border-top: 1px solid var(--line-2);
}
.rx-meta-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}
/* User-given label on the thumbnail. Tap-to-rename. Truncates with ellipsis
   so long names don't blow out the card. */
.rx-label {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 6px 10px 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-900);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: inherit;
}
.rx-label:hover { color: var(--sage-700); }
/* Doctor sub-label below the main name. Empty state shows a muted "+ Doctor"
   affordance so users can tell where to tap. */
.rx-sublabel {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 0 10px 4px;
  font-size: 11px;
  color: var(--text-500);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: inherit;
}
.rx-sublabel:hover { color: var(--sage-700); }
.rx-sublabel-empty { color: var(--text-400, var(--text-500)); font-style: italic; }
.rx-date-input {
  padding: 6px 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-900);
  font-variant-numeric: tabular-nums;
}
.rx-action {
  background: transparent;
  border: none;
  color: var(--text-500);
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rx-action:hover { background: var(--cream); color: var(--text-900); }
.rx-del { color: var(--rose-500); }
.rx-del:hover { color: var(--rose-700, var(--rose-500)); background: var(--rose-100, transparent); }

/* --- v0.1.4 additions: spinning refresh icon, 5-tab nav tighter --- */
.spinning {
  display: inline-block;
  animation: spin 0.8s ease-in-out;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 5 tabs: keep padding tight + ensure every button is the same width. */
.bottom-nav .nav-btn {
  padding: 8px 4px;
  min-width: 0;
  flex: 1 1 0;
}
.bottom-nav .nav-btn span { font-size: 10.5px; }
/* The whole nav stretches edge-to-edge so flex:1 children divide it evenly. */
.bottom-nav { width: calc(100% - 28px); }

/* --- v0.1.3 additions: accordion, dose table, member-color stripes --- */

.member-accordion {
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px solid var(--line-2);
  margin-bottom: 10px;
  overflow: hidden;
  transition: box-shadow 0.15s;
}

.member-accordion.open {
  box-shadow: var(--shadow-md);
}

.member-accordion-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: var(--card);
  transition: background 0.15s;
}

.member-accordion-head:hover { background: var(--cream-2); }

.member-accordion.open .member-accordion-head {
  border-bottom: 1px solid var(--line-2);
}

/* Chevron rotation: declare transition on the base so closing also animates. */
.member-accordion-head > svg:last-child {
  transition: transform 0.2s ease;
}
.member-accordion.open .member-accordion-head > svg:last-child {
  transform: rotate(90deg);
}

.member-accordion-body {
  padding: 14px 16px 18px;
  animation: fade-in 0.2s ease-out;
}

/* Dose table — used in accordion + member summary */
.dose-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.dose-table thead th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-500);
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line-2);
}

.dose-table thead th.num {
  text-align: center;
}

.dose-table tbody td {
  padding: 12px 8px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: top;
}

.dose-table tbody tr:last-child td { border-bottom: none; }

.dose-table tbody td.num {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  vertical-align: middle;
}

.dose-table tbody tr:hover { background: var(--cream-2); }

/* Better chip layout for dose presets */
.chip-group .chip {
  flex-shrink: 0;
}

/* ---------------------------------------------------------------
   v0.4.15 — per-medicine times list (replaces slot grid)
   --------------------------------------------------------------- */
.dose-time-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dose-time-row {
  display: grid;
  /* v0.4.25: tightened so the trash button can never overflow on narrow
     phones. The middle column uses minmax(0, …) so the stepper can shrink
     past its own min-width if absolutely necessary. */
  grid-template-columns: 88px minmax(0, 1fr) 32px;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  background: var(--cream-2);
  border-radius: 10px;
  overflow: hidden;
}
.dose-time-row .dose-stepper { min-width: 0; width: 100%; }
.dose-time-row .icon-btn { padding: 0; }
.dose-time-clock {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  background: var(--card);
  color: var(--text-900);
  font-variant-numeric: tabular-nums;
  min-width: 0;
}

/* v0.4.15 — reminder discovery */
.header-bell-on  { color: var(--sage-700); }
.header-bell-off { color: var(--text-500); opacity: 0.7; }
/* v0.4.44: compact reminders banner — single line, small icon, no body copy. */
.reminders-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 0 0 12px;
  border-radius: 12px;
  color: var(--text-900);
}
.reminders-banner-off {
  background: linear-gradient(135deg, var(--amber-50, #FCE9D3), var(--amber-100, #F9D4A8));
  border: 1px solid var(--amber-200, #E8B47C);
}
.reminders-banner-on {
  background: linear-gradient(135deg, var(--sage-50, #F3F6F3), var(--sage-100, #DDE6DF));
  border: 1px solid var(--sage-300, #A8C1AC);
}
:root[data-theme="dark"] .reminders-banner-off {
  background: rgba(201, 123, 90, 0.18);
  border-color: rgba(201, 123, 90, 0.4);
}
:root[data-theme="dark"] .reminders-banner-on {
  background: rgba(122, 155, 126, 0.18);
  border-color: rgba(122, 155, 126, 0.45);
}
.reminders-banner-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--amber-600, #C97B5A);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.reminders-banner-icon-on { background: var(--sage-700, #4F6A52); }

/* v0.4.22 — height/weight unit toggle as a small text button next to the
   label, plus an inline suffix label on the input itself. */
.unit-toggle {
  background: var(--cream-2);
  border: 1px solid var(--line-2);
  color: var(--sage-700);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 12px;
  flex-shrink: 0;
  white-space: nowrap;
}
.unit-toggle:hover { background: var(--card); }
.input-suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-500);
  font-size: 13px;
  pointer-events: none;
  font-weight: 500;
}

/* v0.4.22 — Medicines tab: clean 2-column row layout (replaces .dose-table) */
.med-row-list {
  display: flex;
  flex-direction: column;
}
.med-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-2);
  cursor: pointer;
  transition: background 0.12s;
}
.med-row:last-child { border-bottom: none; }
.med-row:hover { background: var(--cream-2); }
.med-row-name {
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
}
.med-row-schedule {
  flex-shrink: 0;
  text-align: right;
  max-width: 50%;
}

/* v0.4.25 — soft horizontal rule used inside merged cards (e.g. Medicine
 * details + Schedule live in one card now, divider keeps the visual rhythm
 * without splitting them into two cards). */
.card-divider {
  border: none;
  border-top: 1px solid var(--line-2);
  margin: 14px 0;
  width: 100%;
}

/* v0.4.24 — MemberEditor "More details" toggle. Looks like an accordion
 * head: filled background, chevron rotates open, summary text on the right
 * so the user knows what's inside before opening. */
.more-details-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  margin: 10px 0 0;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--text-700);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}
.more-details-toggle:hover { background: var(--cream-2); }
.more-details-label {
  font-weight: 600;
  color: var(--text-900);
  flex-shrink: 0;
}
.more-details-toggle .text-xs {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.more-details-chevron {
  transition: transform 0.18s ease;
  flex-shrink: 0;
}
.more-details-chevron.open { transform: rotate(90deg); }
.more-details-body { margin-top: 10px; }

/* v0.4.42 — Onboarding mode-picker buttons. Use --card so they adapt to
 * dark theme (was hardcoded #fff which made the text invisible). */
.mode-pick-btn {
  display: block;
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: var(--card);
  color: var(--text-900);
  border: 1px solid var(--line);
  padding: 18px;
  margin-bottom: 12px;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.mode-pick-btn:active { transform: scale(0.99); background: var(--cream-2); }
.mode-pick-btn:hover  { border-color: var(--sage-300); }
.mode-pick-btn:last-child { margin-bottom: 0; }

/* v0.4.40 — ended medicines: section divider + de-emphasised rows. */
.med-ended-divider {
  padding: 10px 16px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-500);
  border-top: 1px dashed var(--line-2);
  margin-top: 6px;
}
.med-row-list-ended .med-row-ended {
  opacity: 0.72;
  background: var(--cream-2);
}
.med-row-list-ended .med-row-ended:hover {
  opacity: 1;
  background: var(--card);
}
.med-row-list-ended .med-row-ended .text-strong {
  text-decoration-color: var(--text-500);
}

/* v0.4.39 — per-row low/warn/untracked pill + accent in Stock tab. */
.stock-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
}
.stock-pill-low {
  background: var(--rose-100, #fde2e4);
  color: var(--rose-700, #9a3340);
  border: 1px solid var(--rose-200, #f5b5bb);
}
.stock-pill-warn {
  background: var(--amber-100, #fbe7c2);
  color: var(--amber-700, #8a5a14);
  border: 1px solid var(--amber-200, #f0c97c);
}
.stock-pill-muted {
  background: var(--cream-2);
  color: var(--text-500);
  border: 1px solid var(--line-2);
  text-transform: none;
  font-weight: 600;
  letter-spacing: 0;
}
.stock-row.stock-row-low {
  background: var(--rose-50, #fdf3f4);
}
.stock-row.stock-row-warn {
  background: var(--amber-50, #fdf6e9);
}

/* v0.4.23 — Stock tab: stacked label/value rows for clarity. The
 * earlier two-column layout squeezed "till 14 Jun · 14d" into the
 * right gutter and nobody could parse it. */
.stock-list {
  display: flex;
  flex-direction: column;
}
.stock-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-2);
}
.stock-row:last-child { border-bottom: none; }
.stock-row-head {
  margin-bottom: 6px;
}
.stock-row-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stock-info-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.stock-info-line .text-xs {
  flex-shrink: 0;
  min-width: 76px;
}
.stock-row-edit {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* v0.4.18 — Family tab list rows with inline empty-state CTA */
.member-list-row {
  background: var(--card);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid var(--line-2);
}
.member-list-row .list-item-inline {
  width: 100%;
  border: none;
  border-radius: 0;
  margin: 0;
  background: transparent;
  border-left: none;
}
.member-empty-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--cream-2);
  border-top: 1px dashed var(--line-2);
}

/* v0.4.16 — month-date picker (1..31 chips) for MONTHLY frequency */
.month-date-picker {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.date-chip {
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text-900);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  font-variant-numeric: tabular-nums;
}
.date-chip:hover { background: var(--cream-2); }
.date-chip.active {
  background: var(--sage-500);
  border-color: var(--sage-500);
  color: white;
}
.reminders-banner-text { flex: 1; min-width: 0; }
.reminders-banner-title { font-size: 13px; font-weight: 600; margin: 0; line-height: 1.2; }
.reminders-banner-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* Print (for emergency export fallback) */
@media print {
  .bottom-nav, .fab, .app-header { display: none !important; }
  body { background: white; }
}

/* ---------------------------------------------------------------
   Health readings (v0.3.8) — per-member tracker UI
   --------------------------------------------------------------- */
.readings-list { display: flex; flex-direction: column; gap: 8px; }
.reading-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line-2, #eee);
  border-radius: 12px;
}
.reading-row-info { flex: 1; min-width: 0; }
.reading-row-actions { display: flex; gap: 4px; flex-shrink: 0; }
.reading-form {
  background: var(--bg, #fafafa);
  border: 1px solid var(--line-2, #eee);
  border-radius: 12px;
  padding: 12px;
  margin-top: 8px;
}
.reading-form .row { display: flex; }
.reading-form .grow { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------
   ConfirmDialog (v0.4.1) — in-app modal, replaces native confirm()
   --------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 20, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
  animation: fade-in 0.15s ease-out;
}
.modal-card {
  background: var(--card);
  border-radius: 16px;
  max-width: 380px;
  width: 100%;
  padding: 22px 20px 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  animation: fade-in 0.18s ease-out;
}
.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-900);
  margin: 0 0 8px;
  line-height: 1.3;
}
.modal-body {
  font-size: 14px;
  color: var(--text-700);
  line-height: 1.5;
  margin: 0 0 18px;
}
.modal-actions {
  display: flex;
  gap: 8px;
}
.modal-actions .grow { flex: 1; }
