:root {
  --base: #eef2ec;
  --surface: #ffffff;
  --ink: #12211b;
  --muted: #5f6f66;
  --line: #d3dcd5;
  --accent: #1f6f4a;
  --accent-ink: #ffffff;
  --accent-soft: #d9ebe0;
  --amber: #c98a1e;
  --amber-soft: #f6e9cf;
  --warn: #b4452e;
  --radius: 12px;
  --nav-h: 62px;
  --sans: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--base);
}
@media (prefers-color-scheme: dark) {
  :root {
    --base: #141a17;
    --surface: #1f2723;
    --ink: #e9efeb;
    --muted: #97a59d;
    --line: #313c36;
    --accent: #6fbf93;
    --accent-ink: #0f2419;
    --accent-soft: #1f3529;
    --amber: #e0a93d;
    --amber-soft: #3a2f16;
    --warn: #e07a63;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--base); color: var(--ink); }
body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

/* ---------- splash ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100; background: var(--accent); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 32px; transition: opacity .35s ease;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash .mark { width: 88px; height: 88px; margin-bottom: 18px; }
.splash .wordmark { font-family: var(--serif); font-size: 40px; letter-spacing: -.5px; }
.splash .tagline { font-size: 17px; opacity: .85; margin-top: 8px; max-width: 26ch; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 5; background: var(--base);
  padding: calc(10px + env(safe-area-inset-top)) 16px 8px;
  display: flex; align-items: center; justify-content: space-between;
  max-width: 560px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--accent); font-family: var(--serif); font-size: 20px; }
.brand svg { width: 24px; height: 24px; }
.help {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  text-decoration: none; color: var(--accent); border: 1.5px solid var(--accent); font-weight: 700;
}
.help.active { background: var(--accent); color: var(--accent-ink); }

main { max-width: 560px; margin: 0 auto; padding: 4px 16px 24px; }

h1 { font-family: var(--serif); font-size: 26px; font-weight: 500; margin: 6px 0 4px; letter-spacing: -.3px; }
h2 { font-size: 13px; font-weight: 600; color: var(--muted); margin: 24px 0 8px; }
.hint { font-size: 14px; color: var(--muted); margin: 4px 0 12px; max-width: 60ch; }
.empty { color: var(--muted); padding: 28px 12px; text-align: center; }
.prose p { margin: 0 0 12px; max-width: 62ch; }
.prose h2 { margin-top: 26px; font-size: 15px; color: var(--ink); }
.prose ul { padding-left: 20px; margin: 0 0 12px; }
.prose li { margin-bottom: 6px; }
.prose a { color: var(--accent); }
.prose a.btn { color: var(--accent-ink); text-decoration: none; }

input[type=text], input[type=number], input[type=time], input[type=datetime-local] {
  width: 100%; font: inherit; color: inherit; -webkit-appearance: none;
  padding: 13px 14px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
input[type=text]:focus { border-color: var(--accent); outline: none; }
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 18px; border-radius: var(--radius); background: var(--accent); color: var(--accent-ink); font-weight: 600; min-height: 46px;
}
.btn.big { width: 100%; font-size: 17px; min-height: 54px; }
.btn.quiet { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); font-weight: 500; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; }
.btn.danger { background: none; color: var(--warn); }
.btn:disabled { opacity: .45; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* ---------- chip wall (the heart of the app) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 6px; }
.chip {
  padding: 12px 15px; min-height: 46px; border-radius: 999px;
  background: var(--surface); border: 1.5px solid var(--line);
  font-size: 16px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .08s, background .12s;
}
.chip:active { transform: scale(.95); }
.chip.recent { border-color: var(--accent); }
.chip.new { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ---------- lists ---------- */
.list { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-top: 1px solid var(--line); width: 100%; text-align: left; min-height: 48px;
}
.item:first-child { border-top: 0; }
.item .t { color: var(--muted); min-width: 48px; font-variant-numeric: tabular-nums; }
.item .grow { flex: 1; }
.item .meta { color: var(--muted); font-size: 14px; }

/* ---------- check-in ---------- */
label.hint input { margin-top: 4px; }
.sym { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-top: 1px solid var(--line); }
.sym:first-child { border-top: 0; }
.sym .name { flex: 1; }
.sym.on { background: var(--amber-soft); }
.sev { display: flex; gap: 4px; }
.sev button {
  min-width: 44px; height: 38px; padding: 0 8px; border-radius: 8px; font-size: 13px;
  background: var(--base); border: 1.5px solid var(--line); color: var(--muted);
}
.sev button.on { background: var(--amber); border-color: var(--amber); color: #fff; font-weight: 600; }
.submit { position: sticky; bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom)); margin-top: 14px; }

/* ---------- findings ---------- */
.chart { width: 100%; height: auto; display: block; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 6px 4px 2px; }
.progress { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; margin: 8px 0 6px; }
.progress .bar { height: 100%; background: var(--accent); border-radius: 5px; transition: width .3s; }

.stats { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.finding { display: flex; gap: 12px; align-items: baseline; padding: 11px 14px; border-top: 1px solid var(--line); }
.finding:first-child { border-top: 0; }
.finding .delta { min-width: 58px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.finding .delta.up { color: var(--warn); }
.finding .delta.down { color: var(--accent); }
.finding .meta { font-size: 13px; color: var(--muted); }

/* ---------- welcome ---------- */
.welcome { padding-top: 12px; }
.welcome h1 { font-size: 32px; margin-bottom: 8px; }
.welcome .lead { font-size: 18px; color: var(--muted); margin: 0 0 22px; max-width: 30ch; }
.steps { margin: 0 0 24px; padding: 0; list-style: none; }
.steps li { display: flex; gap: 14px; margin-bottom: 16px; }
.steps .n {
  flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-family: var(--serif);
}
.steps b { display: block; margin-bottom: 2px; }
.steps span { color: var(--muted); font-size: 15px; }

/* ---------- component picker ---------- */
.compgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 50vh; overflow: auto; }
.compopt { display: block; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--base); font-size: 13px; line-height: 1.3; }
.compopt.on { border-color: var(--accent); background: var(--accent-soft); }
.compopt input { display: none; }
.compopt b { display: block; }
.compopt span { color: var(--muted); font-size: 12px; }
.hint.warn { border-left: 3px solid var(--amber); padding-left: 10px; color: var(--ink); }

/* ---------- experiments ---------- */
.plan-day { display: flex; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.plan-day:first-child { border-top: 0; }
.plan-day .d { min-width: 64px; color: var(--muted); font-variant-numeric: tabular-nums; }
.plan-day.today { background: var(--accent-soft); }
.plan-day.break { background: var(--amber-soft); }
.plan-day .k { font-size: 12px; color: var(--muted); }
.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.card h3 { margin: 0 0 4px; font-family: var(--serif); font-weight: 500; font-size: 19px; }
.card .why { color: var(--muted); font-size: 14px; margin: 0 0 10px; }
.today-box { background: var(--accent); color: var(--accent-ink); border-radius: var(--radius); padding: 16px; margin: 8px 0 14px; }
.today-box .k { font-size: 12px; opacity: .8; text-transform: uppercase; letter-spacing: .04em; }
.today-box .t { font-size: 18px; font-family: var(--serif); margin-top: 4px; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.modal { background: var(--surface); width: 100%; max-width: 560px; padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0;
  max-height: 88vh; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.modal h3 { margin: 0 0 12px; font-size: 18px; font-family: var(--serif); font-weight: 500; }
.modal label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 4px; }
.modal .row.end { margin-top: 18px; }

/* ---------- nav ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: var(--surface); border-top: 1.5px solid var(--line); z-index: 10;
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; position: relative;
  text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; padding: 0 2px;
}
.tabs a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.active { color: var(--accent); font-weight: 700; }
.tabs a.active svg { stroke-width: 2.2; }
.tabs .dot { position: absolute; top: 8px; right: 22%; width: 9px; height: 9px; border-radius: 50%; background: var(--amber); border: 2px solid var(--surface); }

.toast {
  position: fixed; left: 50%; top: calc(10px + env(safe-area-inset-top));
  transform: translateX(-50%); background: var(--ink); color: var(--base);
  padding: 11px 16px; border-radius: 999px; display: flex; gap: 16px; align-items: center; z-index: 30;
  max-width: calc(100% - 32px); box-shadow: 0 4px 16px rgba(0,0,0,.25); cursor: pointer;
}
.toast[hidden] { display: none; }
.toast button { color: #a9dcc0; font-weight: 700; }

.toggle { display: flex; align-items: center; justify-content: space-between; }
.switch { width: 46px; height: 28px; border-radius: 14px; background: var(--line); position: relative; flex: none; }
.switch.on { background: var(--accent); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .12s; }
.switch.on::after { left: 21px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

a.btn { text-decoration: none; }

/* ---------- expandable component rows in Findings ---------- */
.cmp + .cmp { border-top: 1px solid var(--line); }
.cmp .finding { border-top: 0; }
.cmpbtn { width: 100%; text-align: left; align-items: flex-start; }
.cmpbtn .chev { color: var(--muted); font-size: 14px; margin-left: auto; padding-left: 8px; }
.pill { margin-left: auto; align-self: center; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border: 1.5px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.cmpdetail { padding: 0 14px 12px; }
.cmpfood { display: flex; gap: 12px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--line); }
.cmpfood:first-of-type { border-top: 0; }
.cmpfood .meta { font-size: 13px; color: var(--muted); text-align: right; }


/* ---------- PRO / visual polish ---------- */
.pro-nav { font-size: 8px; line-height: 1; padding: 2px 5px; border-radius: 999px; background: var(--amber-soft); color: var(--amber); font-weight: 800; letter-spacing: .04em; }
.pro-hero { position: relative; overflow: hidden; background: linear-gradient(145deg, var(--accent-soft), var(--surface)); border: 1.5px solid var(--line); border-radius: 20px; padding: 24px 20px 20px; margin: 8px 0 16px; box-shadow: 0 8px 24px rgba(18,33,27,.07); }
.pro-hero::after { content: ''; position: absolute; width: 150px; height: 150px; border-radius: 50%; right: -48px; top: -52px; border: 22px solid rgba(31,111,74,.10); }
.pro-badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.pro-hero h1 { font-size: 28px; max-width: 14ch; margin-top: 12px; position: relative; z-index: 1; }
.pro-hero .lead { font-size: 16px; color: var(--muted); max-width: 42ch; }
.pro-price { display: flex; align-items: baseline; gap: 8px; }
.pro-price span { font-family: var(--serif); font-size: 26px; font-weight: 600; }
.pro-price small { color: var(--muted); font-size: 13px; }
.pro-cta { margin-top: 4px; position: relative; z-index: 1; }
.pro-features { display: grid; gap: 8px; }
.pro-features > div { display: grid; grid-template-columns: minmax(130px, .7fr) 1fr; gap: 10px; padding: 14px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; }
.pro-features b { font-size: 14px; }
.pro-features span { color: var(--muted); font-size: 14px; }
@media (max-width: 420px) { .pro-features > div { grid-template-columns: 1fr; gap: 3px; } }
.list { box-shadow: 0 2px 10px rgba(18,33,27,.035); }
.btn { box-shadow: 0 2px 7px rgba(18,33,27,.08); }
.finding, .item { transition: background .12s; }
.finding:active, .item:active { background: var(--accent-soft); }
.tabs { box-shadow: 0 -4px 18px rgba(18,33,27,.06); }
