:root {
  --ivory: #FDFBF7;
  --sage: #E2EAD9;
  --forest: #2C4A3E;
  --amber: #D97706;
  --muted: #718096;
  --body-text: #4A5568;
  --line: #DCE3D3;
  --danger: #B3261E;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ivory);
  color: var(--forest);
  font-family: 'Inter', -apple-system, sans-serif;
  min-height: 100vh;
}

body {
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background: var(--ivory);
  position: relative;
  padding-bottom: 40px;
}

/* Desktop / tablet testers: the phone-width layout is intentional (this is a
   mobile app prototype), but stretched edge-to-edge on a wide monitor it reads
   as broken rather than deliberate. Frame it like a device instead. */
@media (min-width: 720px) {
  body {
    align-items: flex-start;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(180deg, var(--sage) 0%, var(--ivory) 420px);
    padding: 48px 24px;
  }

  #app {
    min-height: min(860px, calc(100vh - 96px));
    max-height: calc(100vh - 96px);
    overflow-y: auto;
    border-radius: 28px;
    box-shadow: 0 30px 60px -20px rgba(44, 74, 62, 0.35), 0 0 0 1px rgba(44, 74, 62, 0.06);
    scrollbar-width: thin;
  }

  #app::-webkit-scrollbar { width: 8px; }
  #app::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
}

h1, h2, h3 {
  font-family: 'Playfair Display', Georgia, serif;
  color: var(--forest);
  margin: 0 0 8px;
}

p { margin: 0 0 12px; line-height: 1.5; }

.screen {
  padding: 32px 24px 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 600;
  margin-bottom: 12px;
}

.headline { font-size: 26px; font-weight: 700; }
.subhead { font-style: italic; color: var(--muted); font-size: 14.5px; }
.body-copy { font-size: 14px; color: var(--body-text); }

.spacer { flex: 1; }

.btn-primary, .btn-secondary {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 700;
  border-radius: 24px;
  padding: 16px 24px;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: center;
}
.btn-primary {
  background: var(--forest);
  color: var(--ivory);
}
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-secondary {
  background: transparent;
  color: var(--forest);
  border: 1.5px solid var(--forest);
}
.btn-primary:active, .btn-secondary:active { transform: scale(0.98); }

.target-cards { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.target-card {
  background: var(--sage);
  border-radius: 16px;
  padding: 16px 18px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.target-card.selected { border-color: var(--forest); }
.target-card .t-label { font-weight: 600; font-size: 14.5px; margin-bottom: 4px; }
.target-card .t-desc { font-size: 12.5px; color: var(--body-text); }

.input-group { margin-bottom: 16px; }
.input-group label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.input-group input, .input-group select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--ivory);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--forest);
}
.input-group input:focus, .input-group select:focus { outline: 2px solid var(--forest); }

.checkbox-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--sage);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 14px 0;
}
.checkbox-row input { margin-top: 3px; }
.checkbox-row label { font-size: 11.5px; color: var(--body-text); line-height: 1.5; }

/* Dashboard */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
}
.topbar .brand {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
}
.topbar .tagline {
  font-family: 'Inter', sans-serif;
  font-style: italic;
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
}
.aura-ring {
  width: 46px; height: 46px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 12px;
  color: var(--forest);
  border: 3px solid var(--amber);
  background: rgba(226,234,217,0.6);
  transition: border-color 0.3s;
}
.aura-ring.high { border-color: #4C9A6C; }
.aura-ring.mid { border-color: var(--amber); }
.aura-ring.low { border-color: #B3261E; }

.greeting { padding: 0 20px 12px; }
.greeting .g-name { font-size: 22px; font-weight: 700; }
.greeting .g-sub { font-size: 13px; color: var(--muted); }

.streak-row {
  display: flex;
  gap: 10px;
  padding: 0 20px 16px;
  font-size: 12.5px;
  color: var(--body-text);
}
.streak-row span { background: var(--sage); padding: 5px 10px; border-radius: 100px; }

.macro-card {
  margin: 0 20px 18px;
  background: var(--sage);
  border-radius: 16px;
  padding: 16px 18px;
}
.macro-card .m-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.macro-bar-row { margin-bottom: 10px; }
.macro-bar-row:last-child { margin-bottom: 0; }
.macro-bar-label { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; }
.macro-bar-track { height: 8px; border-radius: 4px; background: rgba(44,74,62,0.12); overflow: hidden; }
.macro-bar-fill { height: 100%; background: var(--forest); border-radius: 4px; transition: width 0.3s; }
.macro-bar-fill.over { background: var(--danger); }

.track-tabs {
  display: flex;
  gap: 8px;
  padding: 0 20px 14px;
  overflow-x: auto;
}
.track-tab {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 100px;
  background: var(--ivory);
  border: 1.5px solid var(--line);
  color: var(--body-text);
  white-space: nowrap;
  cursor: pointer;
}
.track-tab.active { background: var(--forest); color: var(--ivory); border-color: var(--forest); }

.region-section { padding: 0 20px; }
.region-section h4 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 18px 0 8px;
}
.dish-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(226,234,217,0.5);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.dish-row .d-name { font-size: 14px; font-weight: 600; }
.dish-row .d-kcal { font-size: 11px; color: var(--muted); font-family: 'IBM Plex Mono', monospace; }
.trigger-btn {
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ivory);
  background: var(--forest);
  border: none;
  padding: 8px 14px;
  border-radius: 100px;
  cursor: pointer;
  white-space: nowrap;
}

/* Bottom sheet */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(44,74,62,0.4);
  display: flex; align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.sheet-backdrop.hidden { display: none; }
.sheet {
  width: 100%; max-width: 480px;
  background: var(--ivory);
  border-radius: 24px 24px 0 0;
  padding: 24px 24px 28px;
  max-height: 80vh;
  overflow-y: auto;
}
.sheet h3 { font-size: 20px; }
.sheet .sheet-region { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: var(--amber); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.sheet .sheet-body { font-size: 14px; color: var(--body-text); line-height: 1.6; margin-bottom: 18px; }
.sheet .cite-row {
  display: flex; align-items: center; gap: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; color: var(--muted);
  margin-bottom: 18px;
}
.sheet .cite-row .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--forest); }

.toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  background: var(--forest);
  color: var(--ivory);
  padding: 12px 20px;
  border-radius: 100px;
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.toast.show { opacity: 1; }

.timer-modal {
  position: fixed; inset: 0;
  background: var(--forest);
  color: var(--ivory);
  z-index: 60;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  padding: 24px;
}
.timer-modal.hidden { display: none; }
.timer-ring {
  width: 160px; height: 160px;
  border-radius: 50%;
  border: 6px solid var(--amber);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 700;
  margin-bottom: 20px;
}

.reset-link {
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  padding: 20px;
  text-decoration: underline;
  cursor: pointer;
}

.progress-dots { display: flex; gap: 6px; margin-bottom: 24px; }
.progress-dots span { width: 24px; height: 4px; border-radius: 2px; background: var(--line); }
.progress-dots span.done { background: var(--forest); }

@media (prefers-color-scheme: dark) {
  /* Prototype intentionally single-theme (matches the app's own light UI system, section 05.6) */
}
