/* Body Log — calm, readable, big tap targets. Light + dark. */
:root {
  --bg: #F5F4F0; --surface: #FFFFFF; --ink: #1C2320; --ink2: #4A544F; --muted: #78827D;
  --line: #E4E2DC; --grid: #ECEAE5;
  --accent: #1F6F66; --accent-ink: #FFFFFF; --accent-soft: #E2EEEB;
  --serious: #B3261E; --serious-bg: #FBEAE8; --warn: #9A5B00; --warn-bg: #FCF1DF; --info: #2F5E9E; --info-bg: #E8EFF9;
  --r: 14px; --gap: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111513; --surface: #1A1F1D; --ink: #EEF1EF; --ink2: #C3CAC6; --muted: #8E9893;
    --line: #2A312E; --grid: #252B28;
    --accent: #5BB5A8; --accent-ink: #0E1412; --accent-soft: #1F302C;
    --serious: #F2827A; --serious-bg: #3A1F1D; --warn: #E9AE52; --warn-bg: #352A17; --info: #8DB3EA; --info-bg: #1C2636;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--font); }
body { padding: env(safe-area-inset-top) 0 calc(76px + env(safe-area-inset-bottom)); }
main { max-width: 560px; margin: 0 auto; padding: 4px 14px 24px; }
a { color: var(--accent); text-decoration: none; }
h1, h2 { margin: 0; font-weight: 650; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
p { margin: 6px 0; }
code { font-size: 13px; background: var(--accent-soft); padding: 1px 4px; border-radius: 4px; }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  max-width: 560px; margin: 0 auto; padding: 10px 16px 8px; background: var(--bg); }
.top h1 { font-size: 22px; }
.top-r { display: flex; align-items: center; gap: 10px; }
.gear { font-size: 20px; color: var(--muted); }
.sync { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px; }
.sync.ok::before { content: "● "; color: var(--accent); }
.sync.warn { color: var(--warn); border-color: currentColor; }
.sync.demo { color: var(--info); border-color: currentColor; }
.date { color: var(--ink2); margin: 0 2px 10px; }

/* check-in buttons */
.checkins { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.checkins.small { grid-template-columns: 1fr 1fr; }
.ci { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; color: var(--ink); min-height: 64px; }
.ci-i { grid-row: span 2; font-size: 24px; }
.ci-t { font-weight: 600; }
.ci-s { font-size: 13px; color: var(--muted); }
.ci.done { background: var(--accent-soft); border-color: transparent; }
.ci.done .ci-s { color: var(--accent); font-weight: 600; }
.checkins:not(.small) .ci:last-child:nth-child(odd) { grid-column: span 2; }
.checkins.small .ci { min-height: 52px; padding: 8px 12px; }
.checkins.small .ci-i { font-size: 18px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: var(--gap); }
.card.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
details.card > summary { cursor: pointer; font-weight: 600; }
.sub { color: var(--muted); font-size: 14px; }
.big { font-size: 28px; font-weight: 650; margin: 0; }
.empty { color: var(--muted); font-size: 14px; padding: 14px 0; text-align: center; }
.row { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.foot { text-align: center; font-size: 14px; color: var(--muted); }
.link { font-size: 14px; }
.ch-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ch-head h2 { margin-bottom: 4px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats.four { grid-template-columns: repeat(4, 1fr); }
.stat { display: flex; flex-direction: column; min-width: 0; }
.stat-l { font-size: 13px; color: var(--muted); }
.stat-v { font-size: 22px; font-weight: 650; }
.stat-s { font-size: 12px; color: var(--muted); }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; font-size: 14px; color: var(--ink2); }
.pill.on { background: var(--accent-soft); border-color: transparent; color: var(--ink); }

/* flags: color + icon + label, never color alone */
.flag { display: flex; gap: 10px; padding: 10px; border-radius: 10px; margin-top: 8px; }
.flag p { margin: 2px 0 0; font-size: 14px; color: var(--ink); }
.flag b { font-size: 13px; }
.flag-i { font-size: 14px; line-height: 1.5; }
.flag.serious { background: var(--serious-bg); } .flag.serious b, .flag.serious .flag-i { color: var(--serious); }
.flag.warning { background: var(--warn-bg); } .flag.warning b, .flag.warning .flag-i { color: var(--warn); }
.flag.info { background: var(--info-bg); } .flag.info b, .flag.info .flag-i { color: var(--info); }

/* entries */
.entries { list-style: none; padding: 0; margin: 0; }
.entries li { border-top: 1px solid var(--line); padding: 9px 0; }
.entries li:first-child { border-top: 0; }
.entries a { display: flex; justify-content: space-between; gap: 10px; color: var(--ink); }
.entries .r { text-align: right; white-space: nowrap; }
.entries p { margin: 2px 0 0; }

/* buttons */
button { font: inherit; }
.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 600; font-size: 15px; cursor: pointer; margin: 2px 0; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.primary { flex: 1; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px; padding: 14px; font-size: 17px; font-weight: 650; cursor: pointer; }
.danger { background: transparent; color: var(--serious); border: 1px solid var(--serious); border-radius: 12px; padding: 14px 16px; font-weight: 600; cursor: pointer; }

/* forms */
.form-top { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.form-top h1 { font-size: 22px; }
.back { background: none; border: 0; color: var(--accent); font-size: 17px; padding: 6px 4px; cursor: pointer; }
.field { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; margin-bottom: 10px; }
.sec .field { border: 0; border-top: 1px solid var(--line); border-radius: 0; margin: 0; padding: 12px 0; }
.sec .field:first-child { border-top: 0; }
details.sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 0 12px; margin-bottom: 10px; }
details.sec > summary { padding: 12px 0; font-weight: 650; cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
details.sec > summary::after { content: "＋"; color: var(--muted); }
details.sec[open] > summary::after { content: "－"; }
details.sec > summary::-webkit-details-marker { display: none; }
.f-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.f-head label { font-weight: 600; }
.hint { font-size: 12px; color: var(--muted); }
.scale { display: grid; gap: 6px; }
.scale.n4 { grid-template-columns: repeat(4, 1fr); } .scale.n5 { grid-template-columns: repeat(5, 1fr); }
.scale.n10 { grid-template-columns: repeat(10, 1fr); gap: 4px; } .scale.n11 { grid-template-columns: repeat(11, 1fr); gap: 3px; }
.opt { background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; min-height: 44px; font-size: 16px; cursor: pointer; padding: 0; }
.scale.n10 .opt, .scale.n11 .opt { font-size: 14px; border-radius: 8px; }
.opt.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
.ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 0 13px; min-height: 40px; border-radius: 99px; font-size: 15px; }
.chips.range { margin-bottom: 10px; }
input, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
textarea { resize: vertical; }
.num { display: flex; align-items: center; gap: 8px; }
.num input { max-width: 140px; font-size: 20px; }
.num span { color: var(--muted); }
.when { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.when .f-head { margin: 0; }
.when input { max-width: 220px; }
.actions { position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 10px; margin-top: 14px; }
.signin { margin-top: 30px; } .signin h1 { margin-bottom: 4px; } .signin .field { border: 0; padding: 8px 0; }
.signin label { display: block; font-weight: 600; margin-bottom: 4px; } .err { color: var(--serious); font-size: 14px; }

/* charts: one hue, thin marks, recessive grid */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; touch-action: pan-y; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 10px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .bar { fill: var(--accent); }
.chart .band { fill: var(--accent-soft); }
.chart .guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .hl { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.chart .hit { fill: transparent; }
.chart .guide, .chart .hl { visibility: hidden; }
.chart.active .guide, .chart.active .hl { visibility: visible; }
.tip { position: absolute; top: -6px; transform: translate(-50%, -100%); background: var(--ink); color: var(--bg); font-size: 13px;
  padding: 4px 8px; border-radius: 8px; white-space: nowrap; pointer-events: none; }
.tip b { font-weight: 650; }

/* cycle heat strip: one hue, light -> dark */
.tbl { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 4px 6px; text-align: left; }
table.list th { color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); }
table.list td { border-bottom: 1px solid var(--line); }
.heat { border-collapse: separate; border-spacing: 2px; width: auto; }
.heat th { font-size: 10px; color: var(--muted); font-weight: 500; text-align: center; padding: 0 0 2px; }
.heat th.rl { text-align: right; font-size: 12px; color: var(--ink2); white-space: nowrap; padding-right: 6px; }
.hc { width: 15px; height: 22px; padding: 0; border-radius: 3px; background: color-mix(in oklab, var(--accent) var(--k), var(--accent-soft)); cursor: pointer; }
.hc.none { background: transparent; outline: 1px dashed var(--line); outline-offset: -1px; cursor: default; }
.tipline { min-height: 1.4em; }
.meter { display: inline-block; vertical-align: middle; width: 60px; height: 6px; border-radius: 3px; background: var(--accent-soft); position: relative; overflow: hidden; }
.meter::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--accent); border-radius: 3px; }
.lowhi { color: var(--warn); font-weight: 600; }

/* bottom nav */
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; justify-content: space-around;
  background: color-mix(in oklab, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.nav:empty { display: none; }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 11px; color: var(--muted); min-width: 60px; padding: 2px 0; }
.nav a span { font-size: 20px; line-height: 1.2; }
.nav a.on { color: var(--accent); font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-weight: 600; transition: .2s; pointer-events: none; z-index: 10; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) { .checkins { grid-template-columns: repeat(3, 1fr); } }
@media (forced-colors: active) { .opt.on { outline: 3px solid CanvasText; } .hc { forced-color-adjust: none; } }
