:root {
  --bg: #f5f7f6;
  --bg-card: #ffffff;
  --bg-subtle: #eaf0ed;
  --text: #1c2b24;
  --text-muted: #566b60;
  --border: #d8e2dc;
  --primary: #2d6a4f;
  --primary-hover: #1b4332;
  --primary-soft: #d8f3dc;
  --accent-teal: #2a7b88;
  --accent-teal-soft: #e0f2f4;
  --accent-amber: #b07d2b;
  --accent-amber-soft: #faedcd;
  --accent-plum: #6d597a;
  --accent-plum-soft: #ede7f2;
  --shadow: 0 2px 10px rgba(28, 43, 36, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
}

[data-theme="dark"] {
  --bg: #111915;
  --bg-card: #1a2620;
  --bg-subtle: #23332b;
  --text: #e8f0ec;
  --text-muted: #9cb0a5;
  --border: #2e4238;
  --primary: #52b788;
  --primary-hover: #74c69d;
  --primary-soft: #1e3a2f;
  --accent-teal: #64b5f6;
  --accent-teal-soft: #1a303d;
  --accent-amber: #e9c46a;
  --accent-amber-soft: #382e18;
  --accent-plum: #c8b6ff;
  --accent-plum-soft: #2d2538;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

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

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 92px;
}

.app-shell {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px 28px;
}

/* Header & Disclaimer */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow);
}

.disclaimer-banner {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.disclaimer-banner strong {
  color: var(--text);
}

.demo-pill {
  background: var(--accent-amber-soft);
  color: var(--accent-amber);
  border: 1px solid var(--accent-amber);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 6px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-sub {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin: 0 0 14px 0;
}

/* Home Hero Buttons */
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.hero-btn {
  border: none;
  border-radius: var(--radius);
  padding: 22px 16px;
  min-height: 128px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease;
}

.hero-btn:active {
  transform: scale(0.98);
}

.hero-btn-meal {
  background: var(--primary);
  color: #ffffff;
}

.hero-btn-symptom {
  background: var(--accent-teal);
  color: #ffffff;
}

.hero-icon {
  font-size: 1.8rem;
  background: rgba(255, 255, 255, 0.18);
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-label {
  font-size: 1.12rem;
  font-weight: 700;
  display: block;
}

.hero-hint {
  font-size: 0.78rem;
  opacity: 0.9;
}

/* Quick Nav Tiles on Home */
.quick-links-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.quick-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
}

.quick-tile span.tile-sub {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.input, .select, .textarea {
  width: 100%;
  padding: 12px 14px;
  min-height: 48px;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

.textarea {
  min-height: 76px;
  resize: vertical;
}

/* Segmented & Pill Selectors */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-btn {
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.12s ease;
}

.pill-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.pill-btn.active-teal {
  background: var(--accent-teal);
  color: #ffffff;
  border-color: var(--accent-teal);
}

.pill-btn.active-amber {
  background: var(--accent-amber);
  color: #ffffff;
  border-color: var(--accent-amber);
}

/* Bristol Stool Grid */
.bristol-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.bristol-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  min-height: 54px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  text-align: left;
  color: var(--text);
}

.bristol-item.selected {
  border-color: var(--accent-teal);
  background: var(--accent-teal-soft);
}

.bristol-svg {
  width: 56px;
  height: 36px;
  flex-shrink: 0;
}

.bristol-title {
  font-weight: 700;
  font-size: 0.9rem;
}

.bristol-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Sliders 0-10 */
.slider-row {
  margin-bottom: 14px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.slider-val {
  display: inline-block;
  min-width: 28px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--bg-subtle);
  font-weight: 700;
}

input[type="range"].calm-slider {
  width: 100%;
  height: 8px;
  border-radius: 6px;
  accent-color: var(--accent-teal);
  cursor: pointer;
}

/* Primary Action Button */
.btn-primary {
  width: 100%;
  min-height: 52px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-secondary {
  min-height: 46px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

/* Timeline */
.timeline-day-header {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 18px 0 8px 4px;
}

.timeline-item {
  position: relative;
  border-left: 3px solid var(--border);
  margin-left: 10px;
  padding-left: 14px;
  padding-bottom: 14px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 14px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--primary);
}

.timeline-item.type-symptom::before {
  background: var(--accent-teal);
}

.timeline-item.type-context::before {
  background: var(--accent-plum);
}

.timeline-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}

.timeline-card.clickable {
  cursor: pointer;
}

.timeline-card.clickable:hover {
  border-color: var(--accent-teal);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}

.badge-reflex {
  background: var(--accent-amber-soft);
  color: var(--accent-amber);
}

.badge-ferment {
  background: var(--accent-plum-soft);
  color: var(--accent-plum);
}

.badge-calm {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-fodmap-low {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-fodmap-medium {
  background: var(--accent-amber-soft);
  color: var(--accent-amber);
}

.badge-fodmap-high {
  background: var(--accent-plum-soft);
  color: var(--accent-plum);
}

/* Modal / Drawer for 24h Meal Lookback */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-sheet {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  max-width: 540px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Bottom Navigation Bar (One-Handed Mobile Ergonomics) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 900;
}

.nav-item {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 8px;
  min-height: 48px;
  min-width: 60px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}

.nav-item.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.nav-icon {
  font-size: 1.2rem;
  line-height: 1;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  z-index: 1100;
}

/* Print / Doctor PDF Summary Styling */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    padding-bottom: 0 !important;
  }
  .bottom-nav,
  .no-print {
    display: none !important;
  }
  .app-shell {
    max-width: 100% !important;
    padding: 0 !important;
  }
  .card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    page-break-inside: avoid;
  }
}
