:root {
  --ink: #17201d;
  --muted: #65716d;
  --surface: #fffdf8;
  --canvas: #f2efe8;
  --deep: #112521;
  --deep-2: #1a3630;
  --accent: #d9b36c;
  --accent-soft: #f3e7cb;
  --mint: #dbe9df;
  --line: #dedbd2;
  --danger: #8f3b3b;
  --warning: #9a6b21;
  --shadow: 0 18px 50px rgba(17, 37, 33, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at top left, #fbf8ef 0%, var(--canvas) 48%, #ece9e0 100%); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(217,179,108,.45); outline-offset: 2px; }

#app { min-height: 100vh; }
.shell { min-height: 100vh; display: flex; justify-content: center; }
.phone { width: min(100%, 520px); min-height: 100vh; background: var(--surface); position: relative; box-shadow: var(--shadow); overflow-x: hidden; }
.screen { padding: 24px 20px 108px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.brand-row { display:flex; align-items:center; gap:10px; }
.brand-mark { width:38px; height:38px; border-radius:13px; background:var(--deep); display:grid; place-items:center; color:var(--accent); font-weight:800; letter-spacing:-.06em; }
.brand-copy { font-weight:800; letter-spacing:-.02em; }
.icon-btn { border:1px solid var(--line); background:#fff; border-radius:14px; width:42px; height:42px; display:grid; place-items:center; color:var(--deep); }
.eyebrow { color: var(--muted); text-transform: uppercase; letter-spacing: .13em; font-size: .72rem; font-weight: 800; margin-bottom: 7px; }
h1,h2,h3,p { margin-top:0; }
h1 { font-size: clamp(2rem, 8vw, 2.7rem); line-height: .98; letter-spacing: -.055em; margin-bottom: 12px; }
h2 { font-size: 1.35rem; letter-spacing: -.03em; margin-bottom: 12px; }
h3 { font-size: 1rem; letter-spacing: -.015em; margin-bottom: 8px; }
.subtle { color: var(--muted); line-height: 1.5; }
.small { font-size: .82rem; }
.micro { font-size: .72rem; }

.hero { background: linear-gradient(145deg, var(--deep), var(--deep-2)); color:white; border-radius: var(--radius-xl); padding: 22px; position:relative; overflow:hidden; margin-bottom:16px; }
.hero:after { content:""; position:absolute; width:180px; height:180px; border:1px solid rgba(255,255,255,.13); border-radius:50%; right:-65px; top:-35px; }
.hero .subtle { color: rgba(255,255,255,.68); }
.hero-metric { display:flex; justify-content:space-between; align-items:end; gap:18px; margin-top:22px; }
.metric-big { font-size:2.1rem; font-weight:850; letter-spacing:-.055em; }
.metric-label { font-size:.78rem; color:rgba(255,255,255,.68); margin-top:4px; }
.progress { height:9px; border-radius:999px; background:rgba(255,255,255,.12); overflow:hidden; margin-top:14px; }
.progress > span { display:block; height:100%; background:var(--accent); border-radius:inherit; }

.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.card { background:#fff; border:1px solid var(--line); border-radius:var(--radius-lg); padding:17px; box-shadow:0 8px 24px rgba(17,37,33,.035); }
.card.soft { background:#fbf8ef; }
.card.deep { background:var(--deep); color:#fff; border-color:var(--deep); }
.stat { font-size:1.5rem; font-weight:850; letter-spacing:-.045em; }
.label { color:var(--muted); font-size:.78rem; font-weight:700; }
.deep .label { color:rgba(255,255,255,.58); }
.section { margin-top:22px; }
.section-head { display:flex; align-items:end; justify-content:space-between; gap:14px; margin-bottom:10px; }
.section-head h2 { margin:0; }
.link-btn { border:0; background:none; color:var(--deep); font-weight:800; padding:0; }

.pills { display:flex; flex-wrap:wrap; gap:8px; }
.pill { border:1px solid var(--line); background:#fff; padding:9px 12px; border-radius:999px; font-size:.82rem; font-weight:700; }
.pill.active { background:var(--deep); border-color:var(--deep); color:#fff; }
.badge { display:inline-flex; align-items:center; gap:6px; border-radius:999px; padding:7px 10px; background:var(--accent-soft); color:#654c1f; font-weight:800; font-size:.75rem; }
.badge.good { background:var(--mint); color:#285640; }
.badge.warn { background:#f7e6c6; color:#7a5315; }

.list { display:flex; flex-direction:column; gap:9px; }
.list-row { display:flex; align-items:center; justify-content:space-between; gap:14px; padding:13px 0; border-bottom:1px solid var(--line); }
.list-row:last-child { border-bottom:0; padding-bottom:0; }
.list-main { min-width:0; }
.list-title { font-weight:800; }
.list-note { color:var(--muted); font-size:.8rem; margin-top:3px; }
.dot { width:9px; height:9px; border-radius:50%; background:var(--accent); flex:0 0 auto; }

.score-wrap { display:flex; align-items:center; gap:16px; }
.score-ring { width:88px; height:88px; border-radius:50%; display:grid; place-items:center; background:conic-gradient(var(--deep) calc(var(--score) * 10%), var(--mint) 0); position:relative; flex:0 0 auto; }
.score-ring:after { content:""; position:absolute; inset:8px; border-radius:50%; background:#fff; }
.score-ring strong { position:relative; z-index:1; font-size:1.4rem; }
.score-bars { flex:1; display:flex; flex-direction:column; gap:7px; }
.score-line { display:grid; grid-template-columns:70px 1fr 24px; gap:8px; align-items:center; font-size:.75rem; }
.mini-bar { height:6px; border-radius:999px; background:#e8e7e2; overflow:hidden; }
.mini-bar span { display:block; height:100%; background:var(--deep); border-radius:inherit; }

.nav { position:fixed; z-index:20; bottom:0; left:50%; transform:translateX(-50%); width:min(100%,520px); padding:9px 12px calc(9px + env(safe-area-inset-bottom)); background:rgba(255,253,248,.95); backdrop-filter:blur(16px); border-top:1px solid var(--line); display:grid; grid-template-columns:1fr 1fr 64px 1fr 1fr; align-items:end; }
.nav button { border:0; background:none; min-height:54px; color:#7b817e; font-size:.68rem; font-weight:800; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:5px; }
.nav button.active { color:var(--deep); }
.nav .plus { width:56px; height:56px; align-self:center; justify-self:center; transform:translateY(-17px); background:var(--deep); color:#fff; border-radius:20px; font-size:1.7rem; box-shadow:0 12px 28px rgba(17,37,33,.26); }
.nav-icon { font-size:1.15rem; }

.primary, .secondary, .danger-btn { border:0; border-radius:15px; padding:14px 16px; font-weight:850; width:100%; }
.primary { background:var(--deep); color:#fff; }
.secondary { background:#fff; color:var(--deep); border:1px solid var(--line); }
.danger-btn { background:#faecec; color:var(--danger); border:1px solid #ebcccc; }
.inline-actions { display:flex; gap:9px; }
.inline-actions > * { flex:1; }

.form-stack { display:flex; flex-direction:column; gap:14px; }
.field label { display:block; font-size:.77rem; font-weight:800; margin-bottom:7px; }
.field input, .field select, .field textarea { width:100%; border:1px solid var(--line); background:#fff; color:var(--ink); border-radius:14px; padding:13px 14px; }
.field textarea { min-height:96px; resize:vertical; }
.field input[type="range"] { padding:0; }
.helper { font-size:.75rem; color:var(--muted); margin-top:6px; }

.onboarding { min-height:100vh; padding:26px 22px 38px; display:flex; flex-direction:column; }
.onboarding .top { display:flex; align-items:center; justify-content:space-between; }
.step-dots { display:flex; gap:6px; }
.step-dots span { width:26px; height:5px; background:#dedbd2; border-radius:999px; }
.step-dots span.on { background:var(--deep); }
.onboard-body { margin:auto 0; }
.choice-grid { display:grid; gap:10px; }
.choice { border:1px solid var(--line); background:#fff; border-radius:17px; padding:15px; text-align:left; display:flex; align-items:center; justify-content:space-between; gap:12px; font-weight:800; }
.choice.selected { border-color:var(--deep); background:#f1f5f2; }
.onboard-actions { margin-top:auto; padding-top:28px; display:flex; gap:10px; }

.modal-wrap { position:fixed; z-index:40; inset:0; background:rgba(14,23,20,.42); display:flex; align-items:flex-end; justify-content:center; }
.modal { width:min(100%,520px); max-height:88vh; overflow:auto; background:var(--surface); border-radius:28px 28px 0 0; padding:17px 20px calc(24px + env(safe-area-inset-bottom)); box-shadow:0 -20px 60px rgba(0,0,0,.16); }
.modal-handle { width:46px; height:5px; border-radius:99px; background:#d7d4cb; margin:0 auto 19px; }
.modal-head { display:flex; align-items:center; justify-content:space-between; gap:14px; margin-bottom:18px; }
.log-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.log-option { border:1px solid var(--line); border-radius:18px; padding:17px; background:#fff; text-align:left; min-height:92px; }
.log-option strong { display:block; margin-top:8px; }

.site-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:9px; }
.site { border:1px solid var(--line); background:#fff; border-radius:16px; padding:13px; text-align:left; }
.site.recent { opacity:.48; }
.site.suggested { border-color:var(--deep); background:#eef4f0; box-shadow:inset 0 0 0 1px var(--deep); }
.site.selected { background:var(--deep); color:#fff; border-color:var(--deep); opacity:1; }

.symptom-list { display:flex; flex-direction:column; gap:12px; }
.symptom-row { border:1px solid var(--line); border-radius:16px; padding:13px; }
.severity { display:grid; grid-template-columns:repeat(5,1fr); gap:6px; margin-top:10px; }
.severity button { border:1px solid var(--line); border-radius:10px; padding:8px 0; background:#fff; font-weight:800; color:var(--muted); }
.severity button.on { background:var(--deep); color:#fff; border-color:var(--deep); }

.lifestyle-grid { display:grid; gap:10px; }
.toggle-row { display:flex; align-items:center; justify-content:space-between; border:1px solid var(--line); border-radius:15px; padding:13px; background:#fff; }
.switch { width:47px; height:28px; background:#dcdedb; border-radius:999px; padding:3px; transition:.2s; }
.switch span { width:22px; height:22px; display:block; background:#fff; border-radius:50%; box-shadow:0 2px 7px rgba(0,0,0,.16); transition:.2s; }
.switch.on { background:var(--deep); }
.switch.on span { transform:translateX(19px); }

.chart { width:100%; overflow:hidden; }
.chart svg { width:100%; height:auto; display:block; }
.chart-label { font-size:10px; fill:#7d8581; }
.chart-line { fill:none; stroke:var(--deep); stroke-width:3; stroke-linecap:round; stroke-linejoin:round; }
.chart-area { fill:url(#areaFill); }
.chart-dot { fill:var(--surface); stroke:var(--deep); stroke-width:2.5; }
.chart-dose { stroke:#d9b36c; stroke-width:1.5; stroke-dasharray:4 4; }

.timeline { position:relative; padding-left:24px; }
.timeline:before { content:""; position:absolute; left:7px; top:8px; bottom:7px; width:2px; background:var(--line); }
.timeline-item { position:relative; padding-bottom:18px; }
.timeline-item:before { content:""; position:absolute; width:10px; height:10px; border-radius:50%; background:var(--accent); left:-21px; top:5px; box-shadow:0 0 0 4px var(--surface); }
.timeline-item strong { display:block; }

.notice { border-radius:16px; padding:13px 14px; background:#f8f1e3; color:#6b531e; border:1px solid #eadbbb; line-height:1.45; }
.notice.danger { background:#f9ecec; color:#733434; border-color:#eacccc; }
.empty { padding:28px 8px; text-align:center; color:var(--muted); }

.report { background:#fff; color:#161b19; }
.report-head { border-bottom:2px solid #111; padding-bottom:12px; margin-bottom:18px; }
.report-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
.report-box { border:1px solid #ddd; padding:10px; border-radius:10px; }

.toast { position:fixed; z-index:70; left:50%; bottom:95px; transform:translateX(-50%); background:var(--deep); color:white; border-radius:999px; padding:11px 15px; font-size:.82rem; font-weight:800; box-shadow:0 10px 32px rgba(17,37,33,.25); animation:toast-in .2s ease-out; }
@keyframes toast-in { from { opacity:0; transform:translate(-50%, 8px); } }

@media (min-width: 700px) {
  body { padding:24px 0; }
  .phone { min-height:calc(100vh - 48px); border-radius:32px; overflow:hidden; }
  .nav { bottom:24px; border-radius:0 0 32px 32px; }
}

@media print {
  body { background:white; padding:0; }
  .phone, .shell { box-shadow:none; width:100%; max-width:none; }
  .nav, .topbar, .no-print { display:none !important; }
  .screen { padding:0; }
}

/* PWA install/offline states */
.install-card .primary { margin-top: 12px; }
.pwa-status { position:sticky; top:0; z-index:35; min-height:38px; display:flex; align-items:center; justify-content:center; gap:12px; padding:8px 14px; background:#f4e8c9; color:#63491a; border-bottom:1px solid #e3d2a9; font-size:.76rem; font-weight:800; text-align:center; }
.pwa-status.update { background:#e6f1e9; color:#234d38; border-bottom-color:#c8dfcf; }
.pwa-status button { border:0; border-radius:999px; padding:6px 10px; background:var(--deep); color:#fff; font-weight:850; }
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
  .phone { min-height: 100dvh; }
}
