/* ═══════════════════════════════════════════════
   RESET & VARIABLES
═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-deep:   #085041;
  --green-mid:    #0F6E56;
  --green-bright: #1D9E75;
  --green-light:  #9FE1CB;
  --green-pale:   #E1F5EE;
  --amber:        #BA7517;
  --amber-pale:   #FAEEDA;
  --gray-dark:    #2C2C2A;
  --gray-mid:     #5F5E5A;
  --gray-light:   #D3D1C7;
  --gray-pale:    #F1EFE8;
  --white:        #ffffff;
  --red:          #A32D2D;
  --red-pale:     #FCEBEB;
  --purple:       #3a3070;
  --purple-light: #c9c4f0;
  --navy:         #1a2a4a;
  --navy-light:   #90caf9;
}

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--gray-pale);
  color: var(--gray-dark);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ═══════════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════════ */
@keyframes spin      { to { transform: rotate(360deg); } }
@keyframes shimmer   { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes fadeIn    { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-100%); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp   { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes heroFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

/* ═══════════════════════════════════════════════
   DEMO HERO BANNER
═══════════════════════════════════════════════ */
.demo-hero {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: linear-gradient(145deg, #064033 0%, #085041 40%, #0F6E56 75%, #1D9E75 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.demo-hero.hidden { display: none; }

.demo-hero-inner {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  padding: 2.8rem 2.5rem 2.5rem;
  max-width: 520px;
  width: 100%;
  text-align: center;
  animation: heroFadeIn 0.4s ease;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
}

.demo-hero-badge {
  display: inline-block;
  background: rgba(186, 117, 23, 0.3);
  border: 1px solid rgba(186, 117, 23, 0.5);
  color: #f5d08a;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 1.2rem;
}

.demo-hero-logo {
  font-size: 3.2rem;
  margin-bottom: 0.6rem;
  line-height: 1;
}

.demo-hero-title {
  font-family: 'DM Serif Display', serif;
  color: white;
  font-size: 2.4rem;
  font-weight: 400;
  margin-bottom: 0.7rem;
  line-height: 1.15;
}

.demo-hero-sub {
  color: rgba(159, 225, 203, 0.85);
  font-size: 0.92rem;
  line-height: 1.7;
  margin-bottom: 1.6rem;
}

.demo-hero-features {
  list-style: none;
  margin: 0 auto 1.8rem;
  max-width: 360px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.demo-hero-features li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.87rem;
  line-height: 1.45;
}
.feat-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.demo-hero-cta {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.4rem;
}

.hero-btn {
  width: 100%;
  padding: 13px 20px;
  border-radius: 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  border: none;
  min-height: 48px;
  touch-action: manipulation;
}
.hero-btn-primary {
  background: white;
  color: var(--green-deep);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.hero-btn-primary:hover  { background: var(--green-light); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,0.2); }
.hero-btn-secondary      { background: rgba(255,255,255,0.12); color: white; border: 1.5px solid rgba(255,255,255,0.3); }
.hero-btn-secondary:hover{ background: rgba(255,255,255,0.2); }
.hero-btn-ghost {
  background: transparent;
  color: rgba(159, 225, 203, 0.75);
  font-size: 0.85rem;
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 8px;
  border: none;
  width: auto;
  min-height: 44px;
}
.hero-btn-ghost:hover { color: var(--green-light); }

.demo-hero-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.6rem 0;
  color: rgba(255,255,255,0.25);
  font-size: 0.75rem;
}
.demo-hero-divider::before,
.demo-hero-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.15);
}
.demo-hero-divider span { color: rgba(255,255,255,0.38); white-space: nowrap; }

.demo-hero-note {
  margin-top: 1.4rem;
  font-size: 0.76rem;
  color: rgba(159, 225, 203, 0.55);
  line-height: 1.55;
  padding: 0 0.5rem;
}

/* ═══════════════════════════════════════════════
   STICKY DEMO SAVE BANNER
═══════════════════════════════════════════════ */
.demo-save-banner {
  display: none;
  position: sticky;
  top: 0;
  z-index: 800;
  background: linear-gradient(90deg, #064033 0%, #085041 100%);
  padding: 0.75rem 1.5rem;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
  animation: slideDown 0.3s ease;
}
.demo-save-banner.visible { display: flex; }

.dsb-icon { font-size: 1.25rem; flex-shrink: 0; }

.dsb-text { flex: 1; min-width: 180px; }
.dsb-text strong { color: white; font-size: 0.88rem; display: block; margin-bottom: 0.15rem; }
.dsb-text span   { color: var(--green-light); font-size: 0.76rem; opacity: 0.85; }

.dsb-actions { display: flex; gap: 0.55rem; flex-shrink: 0; flex-wrap: wrap; align-items: center; }
.dsb-btn {
  padding: 7px 16px;
  border-radius: 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
  border: none;
  min-height: 36px;
  touch-action: manipulation;
}
.dsb-btn-signup       { background: white; color: var(--green-deep); }
.dsb-btn-signup:hover { background: var(--green-light); }
.dsb-btn-signin       { background: var(--green-bright); color: white; }
.dsb-btn-signin:hover { background: var(--green-mid); }
.dsb-btn-dismiss      { background: transparent; color: rgba(255,255,255,0.4); padding: 7px 10px; font-size: 0.85rem; }
.dsb-btn-dismiss:hover{ color: white; }

/* ═══════════════════════════════════════════════
   AUTH MODAL
═══════════════════════════════════════════════ */
.auth-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999; /* ← above everything including isolated stacking contexts */
  background: rgba(0,0,0,0.6);
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.auth-modal-overlay.open { display: flex; }

.auth-card {
  background: white;
  border-radius: 20px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.28);
  overflow: hidden;
  animation: slideUp 0.22s ease;
  margin: auto;
}

.auth-card-head {
  background: var(--green-deep);
  padding: 2rem 2.2rem 1.6rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.auth-card-head::after {
  content: '';
  position: absolute; right: -30px; top: -30px;
  width: 130px; height: 130px; border-radius: 50%;
  background: rgba(255,255,255,0.05);
}
.auth-logo { font-size: 2.2rem; margin-bottom: 0.4rem; }
.auth-card-head h2 {
  font-family: 'DM Serif Display', serif;
  color: white; font-size: 1.5rem; font-weight: 400; margin-bottom: 0.25rem;
}
.auth-card-head p { color: var(--green-light); font-size: 0.8rem; }

.auth-tabs { display: flex; border-bottom: 1px solid var(--gray-light); }
.auth-tab {
  flex: 1; padding: 0.8rem;
  background: none; border: none;
  font-family: 'DM Sans', sans-serif; font-size: 0.85rem; font-weight: 500;
  color: var(--gray-mid); cursor: pointer; transition: all 0.18s;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  min-height: 44px; touch-action: manipulation;
}
.auth-tab.active { color: var(--green-deep); border-bottom-color: var(--green-deep); }

.auth-body { padding: 1.5rem 2rem 1.8rem; }

.auth-close-row { display: flex; justify-content: flex-end; margin-bottom: 0.5rem; }
.auth-close-btn {
  background: var(--gray-pale); border: none; border-radius: 50%;
  width: 32px; height: 32px; font-size: 0.9rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-mid); transition: background 0.15s;
  touch-action: manipulation;
}
.auth-close-btn:hover { background: var(--gray-light); }

.auth-saving-notice {
  background: var(--green-pale);
  border-left: 3px solid var(--green-bright);
  border-radius: 0 8px 8px 0;
  padding: 0.6rem 0.9rem;
  font-size: 0.79rem;
  color: var(--green-mid);
  line-height: 1.5;
  margin-bottom: 1rem;
  display: none;
}
.auth-saving-notice.visible { display: block; }

.auth-field { margin-bottom: 1rem; }
.auth-field label {
  display: block; font-size: 0.74rem; font-weight: 500;
  color: var(--gray-mid); margin-bottom: 0.35rem;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.auth-field input {
  width: 100%; border: 1.5px solid var(--gray-light); border-radius: 10px;
  padding: 12px 13px; font-family: 'DM Sans', sans-serif; font-size: 16px;
  color: var(--gray-dark); outline: none; transition: border-color 0.18s, box-shadow 0.18s;
  -webkit-appearance: none;
}
.auth-field input:focus {
  border-color: var(--green-bright);
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.12);
}

.auth-btn {
  width: 100%; padding: 13px;
  border: none; border-radius: 10px;
  background: var(--green-deep); color: white;
  font-family: 'DM Sans', sans-serif; font-size: 0.9rem; font-weight: 500;
  cursor: pointer; transition: background 0.18s; margin-bottom: 0.8rem;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 48px; touch-action: manipulation;
}
.auth-btn:hover     { background: var(--green-mid); }
.auth-btn:disabled  { background: var(--gray-light); cursor: not-allowed; }
.auth-btn.google    { background: white; color: var(--gray-dark); border: 1.5px solid var(--gray-light); }
.auth-btn.google:hover { background: var(--gray-pale); }

.auth-divider {
  display: flex; align-items: center; gap: 0.75rem; margin: 0.85rem 0;
  color: var(--gray-light); font-size: 0.75rem;
}
.auth-divider::before,
.auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--gray-light); }

.auth-error {
  background: var(--red-pale); border-left: 3px solid var(--red);
  border-radius: 0 8px 8px 0; padding: 0.55rem 0.85rem;
  font-size: 0.78rem; color: var(--red); margin-bottom: 0.9rem; display: none;
}
.auth-error.visible { display: block; }

.auth-success {
  background: var(--green-pale); border-left: 3px solid var(--green-bright);
  border-radius: 0 8px 8px 0; padding: 0.55rem 0.85rem;
  font-size: 0.78rem; color: var(--green-mid); margin-bottom: 0.9rem; display: none;
}
.auth-success.visible { display: block; }

.auth-forgot { text-align: right; margin-top: -0.6rem; margin-bottom: 0.9rem; }
.auth-forgot button {
  background: none; border: none; font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem; color: var(--green-mid); cursor: pointer; text-decoration: underline;
  min-height: 36px; touch-action: manipulation;
}

/* ═══════════════════════════════════════════════
   SPINNERS
═══════════════════════════════════════════════ */
.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: white; border-radius: 50%;
  animation: spin 0.7s linear infinite; flex-shrink: 0;
}
.spinner-green {
  width: 14px; height: 14px;
  border: 2px solid rgba(15,110,86,0.25);
  border-top-color: var(--green-mid); border-radius: 50%;
  animation: spin 0.7s linear infinite; flex-shrink: 0;
}

/* ═══════════════════════════════════════════════
   APP LAYOUT
═══════════════════════════════════════════════ */
#appScreen { padding: 1.5rem 1rem 5rem; }
.page { max-width: 820px; margin: 0 auto; }

/* ═══════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════ */
header {
  background: var(--green-deep);
  border-radius: 16px;
  padding: 1.75rem 2rem 1.5rem;
  margin-bottom: 1.25rem;
  position: relative;
}
header::after {
  content: '';
  position: absolute; right: -40px; top: -40px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  pointer-events: none; /* ← never intercepts taps or clicks */
  z-index: 0;           /* ← stays behind all header content */
}

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  position: relative; /* ← establishes stacking context */
  z-index: 1;         /* ← sits above the ::after circle */
}
.header-titles h1 {
  font-family: 'DM Serif Display', serif;
  color: #ffffff; font-size: clamp(1.35rem, 4vw, 2rem);
  font-weight: 400; margin-bottom: 0.25rem;
}
.header-titles p {
  color: var(--green-light);
  font-size: clamp(0.76rem, 2.2vw, 0.88rem);
  font-weight: 300;
}

/* ═══════════════════════════════════════════════
   THEME TOGGLE BUTTON
═══════════════════════════════════════════════ */
.theme-toggle {
  background: rgba(255, 255, 255, 0.12);
  border: .5px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.18s;
  flex-shrink: 0;
  touch-action: manipulation;
  margin-bottom: 0.5rem;
  margin-left: auto;
}
.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* chip */
.chip-wrap { position: relative; flex-shrink: 0; }

.demo-chip-btn {
  display: flex; align-items: center; gap: 0.5rem;
  background: rgba(186,117,23,0.25);
  border: 1.5px solid rgba(186,117,23,0.5);
  border-radius: 30px; padding: 8px 14px 8px 10px;
  cursor: pointer; color: #f5d08a;
  font-family: 'DM Sans', sans-serif; font-size: 0.8rem; font-weight: 500;
  white-space: nowrap; transition: background 0.18s;
  min-height: 40px; touch-action: manipulation;
}
.demo-chip-btn:hover { background: rgba(186,117,23,0.38); }

.user-chip {
  display: flex; align-items: center; gap: 0.6rem;
  background: rgba(255,255,255,0.1); border-radius: 30px; padding: 8px 14px 8px 8px;
  cursor: pointer; transition: background 0.18s; border: none;
  min-height: 40px; touch-action: manipulation;
}
.user-chip:hover { background: rgba(255,255,255,0.18); }

.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--green-bright); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 600; flex-shrink: 0;
}
.user-chip-name {
  color: white; font-size: 0.8rem; font-weight: 500;
  max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-chip-sub { color: var(--green-light); font-size: 0.67rem; }

.user-menu {
  position: absolute; top: calc(100% + 0.5rem); right: 0;
  background: white; border: 1px solid var(--gray-light); border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14); min-width: 210px; z-index: 200;
  overflow: hidden; display: none;
}
.user-menu.open { display: block; }

.user-menu-header { padding: 0.7rem 1rem 0.35rem; }
.user-menu-header strong { font-size: 0.85rem; display: block; color: var(--gray-dark); }
.user-menu-header span   { font-size: 0.74rem; color: var(--gray-mid); }
.user-menu-divider { height: 1px; background: var(--gray-light); margin: 0.2rem 0; }

.user-menu-item {
  display: flex; align-items: center; gap: 0.55rem; padding: 0.75rem 1rem;
  font-size: 0.82rem; cursor: pointer; transition: background 0.14s;
  background: none; border: none; width: 100%; text-align: left;
  font-family: 'DM Sans', sans-serif; color: var(--gray-dark);
  min-height: 44px; touch-action: manipulation;
}
.user-menu-item:hover         { background: var(--gray-pale); }
.user-menu-item.danger        { color: var(--red); }
.user-menu-item.danger:hover  { background: var(--red-pale); }

/* header meta */
.header-meta {
  display: flex; align-items: center;
  gap: 1.5rem; margin-top: 1.1rem; flex-wrap: wrap;
  position: relative;
}
.date-field {
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--green-light); font-size: 0.85rem;
}
.date-field input[type="date"] {
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px; color: white; padding: 6px 10px;
  font-family: 'DM Sans', sans-serif; font-size: 0.85rem; cursor: pointer;
}
.date-field input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }

.progress-row { display: flex; align-items: center; gap: 1rem; flex: 1; min-width: 160px; }
.progress-bar { flex: 1; height: 6px; background: rgba(255,255,255,0.15); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green-light); border-radius: 3px; transition: width 0.4s ease; width: 0%; }
.progress-label { color: var(--green-light); font-size: 0.8rem; white-space: nowrap; }

.header-strip {
  margin-top: 1.1rem; padding-top: 1.1rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  position: relative;
}
.header-strip label {
  color: var(--green-light); font-size: 0.85rem; font-weight: 500; white-space: nowrap;
}

.wake-input {
  background: rgba(255,255,255,0.13); border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: 9px; color: white; padding: 8px 14px;
  font-family: 'DM Sans', sans-serif; font-size: 1rem; font-weight: 500;
  cursor: pointer; outline: none; transition: background 0.18s, border-color 0.18s;
  min-width: 120px; min-height: 40px; -webkit-appearance: none;
}
.wake-input:focus { background: rgba(255,255,255,0.2); border-color: var(--green-light); }
.wake-input::-webkit-calendar-picker-indicator { filter: invert(1); cursor: pointer; }

.wake-meta { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; min-width: 160px; }
.wake-summary { color: rgba(159,225,203,0.9); font-size: 0.82rem; }
.wake-sub     { color: rgba(159,225,203,0.6); font-size: 0.76rem; font-style: italic; }

/* db loading */
.db-loading-banner {
  display: none;
  background: var(--green-pale); border-left: 4px solid var(--green-bright);
  border-radius: 0 12px 12px 0; padding: 0.65rem 1rem;
  font-size: 0.82rem; color: var(--green-mid); margin-bottom: 1.25rem;
  align-items: center; gap: 0.6rem;
}
.db-loading-banner.visible { display: flex; }

/* ═══════════════════════════════════════════════
   SETUP PANEL
═══════════════════════════════════════════════ */
.setup-panel {
  background: var(--white); border: 1px solid var(--gray-light);
  border-radius: 16px; margin-bottom: 1.5rem; overflow: hidden;
}
.setup-panel-head {
  background: var(--green-deep); padding: 1rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.setup-panel-head h2 {
  font-family: 'DM Serif Display', serif; color: white;
  font-size: 1.2rem; font-weight: 400;
}
.setup-panel-head p { color: var(--green-light); font-size: 0.78rem; margin-top: 0.15rem; }

.btn-collapse {
  background: rgba(255,255,255,0.15); border: none; color: white;
  padding: 7px 14px; border-radius: 20px; font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem; cursor: pointer; white-space: nowrap; transition: background 0.18s;
  flex-shrink: 0; min-height: 36px; touch-action: manipulation;
}
.btn-collapse:hover { background: rgba(255,255,255,0.28); }

.setup-body { padding: 1rem 1.25rem; }

.med-form-labels {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.2fr 1fr auto;
  gap: 0.5rem; margin-bottom: 0.35rem; padding: 0 0.1rem;
}
.med-form-labels span {
  font-size: 0.7rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--gray-mid);
}

/* ── MED ENTRY CARD (mobile) ── */
.med-entry {
  position: relative;
}

.med-form-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.2fr 1fr auto;
  gap: 0.5rem; align-items: start; margin-bottom: 0.6rem;
}
.med-form-row input,
.med-form-row select {
  width: 100%; border: 1.5px solid var(--gray-light); border-radius: 9px;
  padding: 9px 11px; font-family: 'DM Sans', sans-serif; font-size: 16px;
  color: var(--gray-dark); background: white; outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  -webkit-appearance: none; appearance: none;
  min-height: 44px;
}
.med-form-row select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235F5E5A' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.med-form-row input:focus,
.med-form-row select:focus {
  border-color: var(--green-bright);
  box-shadow: 0 0 0 3px rgba(29,158,117,0.12);
}
.med-form-row input::placeholder { color: var(--gray-light); }

.prn-subrow {
  grid-column: 1 / -1; display: none; gap: 0.5rem; align-items: center;
  background: var(--amber-pale); border-radius: 9px;
  padding: 0.55rem 0.9rem; margin-top: -0.3rem; margin-bottom: 0.4rem;
  font-size: 0.8rem; color: var(--amber); flex-wrap: wrap;
}
.prn-subrow.visible { display: flex; }
.prn-subrow input {
  border: 1.5px solid #d4a030; border-radius: 7px; padding: 7px 9px;
  font-family: 'DM Sans', sans-serif; font-size: 16px; background: white;
  outline: none; min-width: 0; min-height: 40px; -webkit-appearance: none;
}
.prn-subrow input:focus { border-color: var(--amber); }

.btn-del-med {
  width: 40px; height: 40px; border-radius: 8px; border: none;
  background: var(--red-pale); color: var(--red); font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; flex-shrink: 0;
  touch-action: manipulation; min-height: 44px; min-width: 44px;
}
.btn-del-med:hover { background: #f5c6c6; }

.setup-footer {
  display: flex; gap: 0.75rem; flex-wrap: wrap; padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--gray-pale); align-items: center;
}
.btn-add-med {
  background: transparent; border: 1.5px dashed var(--green-bright);
  color: var(--green-mid); border-radius: 9px; padding: 9px 18px;
  font-family: 'DM Sans', sans-serif; font-size: 0.85rem; font-weight: 500;
  cursor: pointer; transition: background 0.15s;
  min-height: 44px; touch-action: manipulation;
}
.btn-add-med:hover { background: var(--green-pale); }

.btn-generate {
  background: var(--green-deep); border: none; color: white;
  border-radius: 10px; padding: 11px 22px;
  font-family: 'DM Sans', sans-serif; font-size: 0.88rem; font-weight: 500;
  cursor: pointer; transition: background 0.18s;
  display: flex; align-items: center; gap: 0.5rem;
  min-height: 44px; touch-action: manipulation;
}
.btn-generate:hover { background: var(--green-mid); }

.save-confirm-msg {
  font-size: 0.82rem; color: var(--green-mid);
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.save-confirm-msg.visible { opacity: 1; }

/* ═══════════════════════════════════════════════
   INFO CARDS
═══════════════════════════════════════════════ */
.info-section { margin-bottom: 2rem; }
.info-section-head {
  display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.info-section-head h3 {
  font-family: 'DM Serif Display', serif; font-size: 1.15rem;
  font-weight: 400; color: var(--green-deep);
}
.db-badge {
  font-size: 0.7rem; padding: 2px 10px; border-radius: 20px;
  font-weight: 500; background: var(--green-pale); color: var(--green-mid);
}

.info-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.85rem;
}
.info-card {
  background: var(--white); border: 1px solid var(--gray-light);
  border-radius: 14px; padding: 1.1rem 1.2rem; transition: box-shadow 0.2s;
}
.info-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.07); }
.info-card-head { display: flex; align-items: flex-start; gap: 0.7rem; margin-bottom: 0.65rem; }
.info-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.info-card-name { font-size: 0.9rem; font-weight: 500; color: var(--gray-dark); line-height: 1.3; }
.info-card-sub  { font-size: 0.74rem; color: var(--gray-mid); margin-top: 2px; }
.info-card-desc { font-size: 0.82rem; color: var(--gray-mid); line-height: 1.65; }

.interaction-flag {
  margin-top: 0.6rem; background: var(--red-pale); border-left: 3px solid var(--red);
  border-radius: 0 8px 8px 0; padding: 0.45rem 0.75rem;
  font-size: 0.78rem; color: var(--red); line-height: 1.55;
}
.warn-flag {
  margin-top: 0.6rem; background: var(--amber-pale); border-left: 3px solid var(--amber);
  border-radius: 0 8px 8px 0; padding: 0.45rem 0.75rem;
  font-size: 0.78rem; color: var(--amber); line-height: 1.55;
}

.info-card.skeleton .info-card-name,
.info-card.skeleton .info-card-desc,
.info-card.skeleton .info-card-sub {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
  border-radius: 6px; color: transparent; min-height: 14px;
}
.info-card.skeleton .info-card-name { width: 70%; margin-bottom: 4px; }
.info-card.skeleton .info-card-sub  { width: 45%; }
.info-card.skeleton .info-card-desc { margin-top: 0.65rem; min-height: 52px; }

/* ═══════════════════════════════════════════════
   CONTROLS
═══════════════════════════════════════════════ */
.controls { display: flex; gap: 0.6rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.btn {
  padding: 0.6rem 1.1rem; border-radius: 10px; border: 1.5px solid;
  font-family: 'DM Sans', sans-serif; font-size: 0.85rem; font-weight: 500;
  cursor: pointer; transition: all 0.18s;
  min-height: 44px; touch-action: manipulation;
}
.btn-reset        { background: var(--white); border-color: var(--red);          color: var(--red); }
.btn-reset:hover  { background: var(--red-pale); }
.btn-print        { background: var(--green-deep); border-color: var(--green-deep); color: white; }
.btn-print:hover  { background: var(--green-mid); }
.btn-all          { background: var(--white); border-color: var(--green-bright); color: var(--green-mid); }
.btn-all:hover    { background: var(--green-pale); }
.btn-prn-toggle       { background: var(--white); border-color: var(--amber); color: var(--amber); }
.btn-prn-toggle:hover { background: var(--amber-pale); }

/* ═══════════════════════════════════════════════
   BANNERS
═══════════════════════════════════════════════ */
.midnight-banner {
  display: none; background: #f0eeff; border-left: 3px solid #6b5fc7;
  border-radius: 0 10px 10px 0; padding: 0.75rem 1rem;
  font-size: 0.82rem; color: #3a3070; margin-bottom: 1.25rem; line-height: 1.65;
}
.midnight-banner.visible { display: block; }

.prn-banner {
  display: none; background: var(--amber-pale); border-left: 3px solid var(--amber);
  border-radius: 0 10px 10px 0; padding: 0.75rem 1rem;
  font-size: 0.82rem; color: var(--amber); margin-bottom: 1.25rem; line-height: 1.6;
}
.prn-banner.visible { display: block; }

/* ═══════════════════════════════════════════════
   SECTION TITLES
═══════════════════════════════════════════════ */
.section-title {
  font-family: 'DM Serif Display', serif; font-size: 1.15rem; font-weight: 400;
  color: var(--green-deep); margin: 1.75rem 0 0.85rem;
}

/* ═══════════════════════════════════════════════
   CHECKLIST
═══════════════════════════════════════════════ */
.time-block { margin-bottom: 1.25rem; }
.prn-hidden .time-block.all-prn { display: none; }
.prn-hidden .med-row.is-prn     { display: none; }

.time-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.6rem; }
.time-badge {
  font-size: 0.75rem; font-weight: 500; padding: 5px 12px; border-radius: 20px;
  white-space: nowrap; background: var(--green-deep); color: var(--green-light);
}
.time-badge.night    { background: var(--navy);   color: var(--navy-light); }
.time-badge.next-day { background: var(--purple); color: var(--purple-light); }
.time-line { flex: 1; height: 1px; background: var(--gray-light); }

.med-row {
  background: var(--white); border: 1px solid var(--gray-light);
  border-radius: 12px; padding: 0.9rem 1rem; margin-bottom: 0.5rem;
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 0 0.85rem; align-items: center;
  transition: opacity 0.2s, background 0.2s; cursor: pointer; user-select: none;
  /* larger touch target on mobile */
  min-height: 60px;
}
.med-row:active   { background: var(--green-pale); }
.med-row:hover    { background: #fafaf8; }
.med-row.taken    { background: var(--green-pale); border-color: var(--green-light); opacity: 0.75; }
.med-row.taken .med-name { text-decoration: line-through; color: var(--gray-mid); }

.checkbox {
  width: 24px; height: 24px; border: 2px solid var(--green-bright);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.18s, border-color 0.18s;
}
.med-row.taken .checkbox { background: var(--green-bright); border-color: var(--green-bright); }
.checkbox svg { display: none; }
.med-row.taken .checkbox svg { display: block; }

.med-name { font-size: 0.95rem; font-weight: 500; color: var(--gray-dark); }
.med-dose { font-size: 0.8rem; color: var(--gray-mid); margin-top: 1px; }
.med-tag  {
  font-size: 0.72rem; padding: 3px 9px; border-radius: 20px;
  font-weight: 500; white-space: nowrap; align-self: start; margin-top: 2px;
}
.tag-prn { background: var(--amber-pale); color: var(--amber); }
.tag-rx  { background: var(--green-pale); color: var(--green-mid); }

.sleep-divider { display: flex; align-items: center; gap: 0.75rem; margin: 1.6rem 0; }
.sleep-divider-line { flex: 1; height: 0; border-top: 1px dashed var(--gray-light); }
.sleep-divider-pill {
  background: #e8f0fe; color: #3c5a99;
  font-size: 0.74rem; font-weight: 500;
  padding: 4px 14px; border-radius: 20px; white-space: nowrap;
}

/* ═══════════════════════════════════════════════
   SCHEDULE TABLE
═══════════════════════════════════════════════ */
.schedule-table {
  background: var(--white); border: 1px solid var(--gray-light);
  border-radius: 14px; overflow-x: auto; margin-bottom: 1.5rem;
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; min-width: 480px; }
thead th {
  background: var(--green-deep); color: var(--green-light); font-weight: 500;
  padding: 0.55rem 0.9rem; text-align: left; font-size: 0.75rem; letter-spacing: 0.04em;
}
tbody tr { border-bottom: 1px solid var(--gray-pale); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 0.6rem 0.9rem; color: var(--gray-dark); }
tbody tr:nth-child(even) td { background: #fafaf8; }
.td-time          { font-weight: 500; color: var(--green-mid); white-space: nowrap; }
.td-time.night    { color: #1565C0; }
.td-time.next-day { color: #6b5fc7; }
.td-note { color: var(--gray-mid); font-style: italic; font-size: 0.78rem; }
.td-prn  { color: var(--amber);     font-size: 0.76rem; font-weight: 600; }
.td-rx   { color: var(--green-mid); font-size: 0.76rem; font-weight: 500; }
.table-sleep-row td {
  background: #e8f0fe !important; color: #3c5a99;
  font-size: 0.76rem; font-style: italic; text-align: center; padding: 0.4rem 0.9rem;
}
.prn-hidden .tr-prn { display: none; }

/* ═══════════════════════════════════════════════
   DISCLAIMER
═══════════════════════════════════════════════ */
.disclaimer {
  background: var(--gray-pale); border: 1px solid var(--gray-light); border-radius: 10px;
  padding: 0.75rem 1rem; font-size: 0.75rem; color: var(--gray-mid);
  line-height: 1.6; margin-bottom: 1.5rem;
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — TABLET  (max 768px)
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  #appScreen { padding: 1rem 0.75rem 6rem; }

  header { padding: 1.25rem 1.25rem 1.1rem; border-radius: 14px; }

  .header-meta { gap: 0.85rem; margin-top: 0.9rem; }

  .progress-row { min-width: 140px; }

  .setup-body { padding: 0.9rem 1rem; }
  .setup-footer { padding: 0.75rem 1rem; gap: 0.5rem; }

  .controls { gap: 0.45rem; }
  .btn { padding: 0.55rem 0.9rem; font-size: 0.82rem; }

  .info-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.65rem; }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — MOBILE  (max 620px)
═══════════════════════════════════════════════ */
@media (max-width: 620px) {

  /* ── layout ── */
  #appScreen { padding: 0.75rem 0.65rem 6rem; }
  .page { padding: 0; }

  /* ── header ── */
  header { padding: 1rem 1rem 0.9rem; border-radius: 12px; margin-bottom: 0.9rem; }

  .header-top { gap: 0.5rem; align-items: center; }

  .header-titles h1 { font-size: 1.3rem; }
  .header-titles p  { font-size: 0.75rem; }

  /* chip — full width row on very small screens */
  .demo-chip-btn { width: 100%; justify-content: center; font-size: 0.82rem; }
  .user-chip     { width: 100%; justify-content: center; }

  /* hide sub on small screens to save space */
  .user-chip-sub { display: none; }

  /* user menu full width */
  .user-menu {
    position: fixed;
    top: auto; bottom: 0; left: 0; right: 0;
    border-radius: 16px 16px 0 0;
    min-width: unset; width: 100%;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
  }
  .user-menu-item { padding: 1rem 1.25rem; font-size: 0.88rem; }
  .user-menu-header { padding: 1rem 1.25rem 0.5rem; }

  /* header meta — stack vertically */
  .header-meta { flex-direction: column; align-items: stretch; gap: 0.55rem; margin-top: 0.8rem; }
  .date-field  { justify-content: space-between; }
  .date-field input[type="date"] { flex: 1; text-align: center; }
  .progress-row { min-width: unset; }

  /* wake strip — column */
  .header-strip { flex-direction: column; align-items: stretch; gap: 0.5rem; margin-top: 0.85rem; padding-top: 0.85rem; }
  .wake-input   { width: 100%; text-align: center; font-size: 1.1rem; }
  .wake-meta    { min-width: unset; }
  .wake-summary,
  .wake-sub     { font-size: 0.76rem; }

  /* ── setup panel ── */
  .setup-panel { border-radius: 12px; margin-bottom: 1rem; }
  .setup-panel-head { flex-direction: column; align-items: flex-start; gap: 0.5rem; padding: 0.9rem 1rem; }
  .setup-panel-head h2 { font-size: 1.05rem; }
  .btn-collapse { width: 100%; text-align: center; padding: 8px; font-size: 0.8rem; }

  /* hide column labels — placeholders take over */
  .med-form-labels { display: none; }

  /* med form — 2 column card layout */
  .med-form-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    background: var(--gray-pale);
    border-radius: 10px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--gray-light);
  }

  /* name field spans full width */
  .med-form-row .span-full { grid-column: 1 / -1; }

  /* delete button — bottom right */
  .btn-del-med {
    grid-column: 2;
    justify-self: end;
    margin-top: 0;
    background: transparent;
    color: var(--red);
    border: 1px solid var(--red-pale);
  }

  /* add a subtle label hint above each input via placeholder emphasis */
  .med-form-row input,
  .med-form-row select {
    font-size: 15px;
    padding: 9px 10px;
    border-radius: 8px;
  }

  /* prn subrow stacked */
  .prn-subrow {
    flex-direction: column;
    align-items: stretch;
    border-radius: 8px;
    padding: 0.65rem 0.75rem;
  }
  .prn-subrow input { width: 100% !important; }

  /* setup footer — stack buttons */
  .setup-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding: 0.75rem 0.9rem;
  }
  .btn-add-med  { width: 100%; text-align: center; justify-content: center; }
  .btn-generate { width: 100%; justify-content: center; }
  .save-confirm-msg { text-align: center; }

  /* ── controls bar — 2×2 grid ── */
  .controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    margin-bottom: 1.1rem;
  }
  .btn { text-align: center; justify-content: center; font-size: 0.8rem; padding: 0.6rem 0.5rem; }

  /* ── checklist ── */
  .section-title { font-size: 1rem; margin: 1.25rem 0 0.65rem; }

  .time-badge { font-size: 0.7rem; padding: 4px 10px; }

  .med-row {
    padding: 0.85rem 0.85rem;
    border-radius: 10px;
    gap: 0 0.65rem;
    min-height: 64px;
  }

  .med-name { font-size: 0.9rem; }
  .med-dose { font-size: 0.76rem; }
  .med-tag  { font-size: 0.68rem; padding: 2px 7px; }

  .checkbox { width: 22px; height: 22px; border-radius: 5px; }

  /* ── info cards — single column ── */
  .info-grid { grid-template-columns: 1fr; gap: 0.6rem; }
  .info-card { padding: 0.9rem 1rem; border-radius: 12px; }

  /* ── banners ── */
  .midnight-banner,
  .prn-banner { font-size: 0.78rem; padding: 0.6rem 0.85rem; }

  /* ── demo save banner ── */
  .demo-save-banner { padding: 0.65rem 0.9rem; gap: 0.5rem; }
  .dsb-icon { display: none; }
  .dsb-text span { display: none; }
  .dsb-text strong { font-size: 0.82rem; }
  .dsb-actions { width: 100%; justify-content: stretch; gap: 0.4rem; }
  .dsb-btn { flex: 1; text-align: center; padding: 8px 10px; font-size: 0.78rem; }
  .dsb-btn-dismiss { flex: 0; min-width: 36px; }

  /* ── demo hero ── */
  .demo-hero { padding: 1rem 0.75rem; align-items: flex-start; }
  .demo-hero-inner { padding: 1.8rem 1.25rem 2rem; border-radius: 18px; }
  .demo-hero-logo  { font-size: 2.6rem; }
  .demo-hero-title { font-size: 1.9rem; }
  .demo-hero-sub   { font-size: 0.86rem; margin-bottom: 1.2rem; }
  .demo-hero-features { max-width: 100%; margin-bottom: 1.4rem; }
  .demo-hero-features li { font-size: 0.83rem; }
  .hero-btn { font-size: 0.88rem; padding: 12px 16px; }

  /* ── auth modal — full screen sheet on mobile ── */
  .auth-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .auth-card {
    border-radius: 20px 20px 0 0;
    max-width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .auth-card-head { padding: 1.5rem 1.5rem 1.2rem; }
  .auth-card-head h2 { font-size: 1.3rem; }
  .auth-body { padding: 1.25rem 1.5rem 2rem; }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — SMALL MOBILE  (max 380px)
═══════════════════════════════════════════════ */
@media (max-width: 380px) {
  header { padding: 0.85rem 0.85rem 0.8rem; }
  .header-titles h1 { font-size: 1.15rem; }
  .demo-hero-title  { font-size: 1.65rem; }

  .med-form-row { grid-template-columns: 1fr; }
  .btn-del-med  { grid-column: 1; width: 100%; justify-content: center; }

  .controls { grid-template-columns: 1fr; }

  .auth-body { padding: 1rem 1.25rem 2rem; }
}

/* ═══════════════════════════════════════════════
   PRINT
═══════════════════════════════════════════════ */
@media print {
  .demo-hero, .demo-save-banner, .auth-modal-overlay,
  .setup-panel, .controls, .header-strip, .info-section,
  .disclaimer, .chip-wrap, .db-loading-banner { display: none !important; }
  #appScreen { padding: 0; }
  body { background: white; }
  header { border-radius: 0; }
  .med-row { break-inside: avoid; }
  .schedule-table { overflow: visible; }
  table { min-width: unset; }
}

/* ═══════════════════════════════════════════════
   APP SHELL LAYOUT
   Desktop : sidebar (220px) + main content
   Mobile  : full width + bottom nav bar
═══════════════════════════════════════════════ */
#appScreen {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--green-deep);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  padding: 1.5rem 0 1rem;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 0.75rem;
}
.sidebar-logo-icon { font-size: 1.4rem; }
.sidebar-logo-text {
  font-family: 'DM Serif Display', serif;
  color: white;
  font-size: 1.1rem;
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0 0.75rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.65);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  text-align: left;
  width: 100%;
  min-height: 44px;
  touch-action: manipulation;
}
.sidebar-item:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}
.sidebar-item.active {
  background: rgba(255,255,255,0.15);
  color: white;
}
.sidebar-icon  { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-label { flex: 1; }

/* badge on sidebar items (e.g. unread count) */
.sidebar-badge {
  background: var(--red);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.sidebar-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 0.25rem 0; }

.sidebar-theme {
  display: flex !important;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.65);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  min-height: 44px;
}
.sidebar-theme:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.sidebar-demo {
  width: 100%;
  text-align: left;
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  font-size: 0.8rem;
}

.sidebar-user {
  width: 100%;
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  justify-content: flex-start;
}
.sidebar-user-info { text-align: left; }

/* ── MAIN CONTENT AREA ── */
.app-main {
  flex: 1;
  margin-left: 220px;
  min-width: 0;
  padding: 1.5rem 1.5rem 2rem;
  max-width: 860px;
}

/* ── TAB PANELS ── */
.tab-panel {
  display: none;
  animation: fadeIn 0.22s ease;
}
.tab-panel.active { display: block; }

/* ── EMPTY STATES ── */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.empty-state-icon  { font-size: 3rem; line-height: 1; margin-bottom: 0.25rem; }
.empty-state-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.2rem;
  color: var(--gray-dark);
  font-weight: 400;
}
.empty-state-sub {
  font-size: 0.85rem;
  color: var(--gray-mid);
  max-width: 300px;
  line-height: 1.6;
}
.empty-state-btn {
  margin-top: 0.5rem;
  background: var(--green-deep);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 22px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s;
  min-height: 44px;
  touch-action: manipulation;
}
.empty-state-btn:hover { background: var(--green-mid); }

/* setup panel — remove card wrapper on the medications tab
   since the tab itself provides the container */
.tab-panel .setup-panel {
  border: none;
  border-radius: 0;
  background: transparent;
}
.tab-panel .setup-panel .setup-panel-head { display: none; }

/* ── BOTTOM NAV BAR (mobile only) ── */
.bottom-nav {
  display: none; /* hidden on desktop */
}

/* ═══════════════════════════════════════════════
   EMPTY STATE VISIBILITY HELPERS
═══════════════════════════════════════════════ */
.has-schedule #todayEmpty    { display: none; }
.has-schedule #scheduleEmpty { display: none; }
.has-schedule #infoEmpty     { display: none; }

/* before schedule generated, hide these sections */
#scheduleSection    { display: none; }
#scheduleTableSection { display: none; }
#infoSection        { display: none; }

/* show them when schedule exists */
.has-schedule #scheduleSection      { display: block; }
.has-schedule #scheduleTableSection { display: block; }
.has-schedule #infoSection          { display: block; }

/* hide controls until schedule generated */
#mainControls { display: none; }
.has-schedule #mainControls { display: flex; }

/* ═══════════════════════════════════════════════
   RESPONSIVE — TABLET / MOBILE
═══════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* hide sidebar */
  .sidebar { display: none; }

  /* main fills full width */
  .app-main {
    margin-left: 0;
    padding: 0.75rem 0.75rem 5.5rem; /* bottom padding for nav bar */
    max-width: 100%;
  }

  /* show bottom nav */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 300;
    background: var(--white);
    border-top: 1px solid var(--gray-light);
    box-shadow: 0 -2px 16px rgba(0,0,0,0.08);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0.55rem 0.25rem;
    background: none;
    border: none;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--gray-mid);
    cursor: pointer;
    transition: color 0.15s;
    min-height: 56px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav-item.active { color: var(--green-deep); }
  .bottom-nav-icon {
    font-size: 1.3rem;
    line-height: 1;
    transition: transform 0.15s;
  }
  .bottom-nav-item.active .bottom-nav-icon { transform: scale(1.15); }
  .bottom-nav-label { line-height: 1; }

  /* hide the header theme toggle on mobile — no sidebar */
  #themeToggle { display: flex; }
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  background: rgba(255,255,255,0.1);
  border: none;
  cursor: pointer;
  transition: background 0.18s;
  min-height: 44px;
  touch-action: manipulation;
}
.sidebar-user:hover { background: rgba(255,255,255,0.18); }

.sidebar-user .user-chip-name { color: white; font-size: 0.85rem; font-weight: 500; }
.sidebar-user .user-chip-sub  { color: var(--green-light); font-size: 0.7rem; }
.user-menu {
  position: fixed;
  z-index: 9998;
  min-width: 210px;
  border-left: none;             /* remove left border so it blends flush */
  border-radius: 0 12px 12px 0;  /* flat left edge, rounded right edge */
}

/* Mobile account button avatar style */
#mobileAccountIcon {
  font-size: 1rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--green-bright);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  line-height: 1;
  margin: 0 auto;
  transition: background 0.18s;
}

/* When logged in the icon becomes initials — shrink font */
.is-logged-in #mobileAccountIcon {
  font-size: 0.72rem;
}
