/* Biorhythm: dark first, one colour per cycle */
:root {
  color-scheme: light;
  --bg: #f3f5f7; --surface: #fff; --surface-2: #e8edf1; --ink: #13202a; --ink-2: #44535e; --ink-3: #66757f; --line: #d6dee4; --focus: #2a78d6;
  --phy: #d63c3c; --emo: #1d9a62; --int: #2f74d0; --intu: #b06ad8; --aes: #d98a1c; --spi: #1aa7b3; --accent: #6a4fd6; --on-accent: #fff;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1418; --surface: #182027; --surface-2: #222c35; --ink: #edf3f6; --ink-2: #b4c1ca; --ink-3: #8795a0; --line: #2b3640; --focus: #6aa8f0;
  --phy: #ff6b6b; --emo: #4fd18f; --int: #5aa2ff; --intu: #c89cf0; --aes: #f2b25a; --spi: #4fd0d9; --accent: #a993ff; --on-accent: #160d33;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0f1418; --surface: #182027; --surface-2: #222c35; --ink: #edf3f6; --ink-2: #b4c1ca; --ink-3: #8795a0; --line: #2b3640; --focus: #6aa8f0;
    --phy: #ff6b6b; --emo: #4fd18f; --int: #5aa2ff; --intu: #c89cf0; --aes: #f2b25a; --spi: #4fd0d9; --accent: #a993ff; --on-accent: #160d33;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 Poppins, system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
main, .top, .foot { max-width: 620px; margin: 0 auto; padding: 0 16px; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 18px; }
h3 { font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }
.top { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; padding-bottom: 4px; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 { font-size: 24px; font-weight: 700; }
.home { font-size: 13px; font-weight: 600; color: var(--ink-3); text-decoration: none; }
.round { width: 42px; height: 42px; flex: none; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--ink); font: inherit; font-size: 22px; line-height: 1; cursor: pointer; }
.round.small { width: 36px; height: 36px; font-size: 19px; }
.card { background: var(--surface); border-radius: 16px; padding: 16px; margin: 10px 0; }
.field { display: grid; gap: 6px; }
.field span { font-weight: 600; color: var(--ink-2); font-size: 15px; }
input[type=date] { min-height: 50px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 17px; width: 100%; }
.hint { margin: 8px 0 0; font-size: 14px; color: var(--ink-3); }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field small { font-weight: 400; color: var(--ink-3); }
input[type=text] { min-height: 50px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 17px; width: 100%; }
.mylink { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.mylink-title { margin: 0 0 8px; font-weight: 600; color: var(--ink-2); font-size: 15px; }
.mylink-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 0; background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
@media (max-width: 380px) { .setup-grid { grid-template-columns: 1fr; } }

.today-head { display: flex; align-items: center; gap: 10px; }
.day-pick { position: relative; flex: 1; text-align: center; display: grid; cursor: pointer; }
.day-pick b { font-size: 19px; }
.day-pick small { color: var(--ink-3); font-size: 13px; }
.day-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; min-height: 0; cursor: pointer; }
.meters { display: grid; gap: 12px; margin-top: 14px; }
.meter { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: baseline; }
.meter-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.meter-name i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.meter-val { font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; }
.meter-val small { font-size: 13px; color: var(--ink-3); font-weight: 600; margin-left: 4px; }
.meter-bar { grid-column: 1 / -1; position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); }
.meter-bar::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--line); }
.meter-bar b { position: absolute; top: 0; bottom: 0; border-radius: 5px; background: var(--c); }
.meter-say { grid-column: 1 / -1; font-size: 14px; color: var(--ink-2); }
.critical { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.link { margin-top: 10px; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 4px 0; }

.chart-head { display: flex; align-items: center; justify-content: space-between; }
.weeks { display: flex; gap: 6px; }
.chart { margin-top: 8px; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .mid { stroke: var(--ink-3); stroke-width: 1.2; }
.chart .axis { fill: var(--ink-3); font-size: 11px; }
.chart .today-line { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .sel { fill: var(--ink); opacity: .08; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart path { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; background: var(--c); }

.ahead { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
.ahead ol, .ahead ul { margin: 0; padding-left: 18px; font-size: 14px; display: grid; gap: 4px; }
.ahead small { color: var(--ink-3); }
.ahead button { border: 0; background: none; color: inherit; font: inherit; padding: 0; text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }

.more summary { list-style: none; cursor: pointer; display: flex; align-items: center; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: ""; margin-left: auto; width: 9px; height: 9px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg); }
.more[open] summary::after { transform: rotate(-135deg); }
.more[open] summary { margin-bottom: 12px; }
.compat { margin-top: 12px; }
.compat-big { font-size: 40px; font-weight: 700; line-height: 1; color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.fine { font-size: 13px; color: var(--ink-3); text-align: center; margin: 14px 0; }
.foot { padding-bottom: 28px; font-size: 13px; color: var(--ink-3); text-align: center; }
@media (max-width: 380px) { .ahead { grid-template-columns: 1fr; } }
.people { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.people button { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 0; background: var(--surface-2); color: var(--ink-2); font: inherit; font-weight: 600; cursor: pointer; }
.people button[aria-selected=true] { background: var(--accent); color: var(--on-accent); }
.people .add { background: none; box-shadow: inset 0 0 0 1.5px var(--line); }
.mylink-title small { font-weight: 400; color: var(--ink-3); }
.link.danger { color: var(--phy); font-size: 14px; margin-top: 8px; }
select { min-height: 50px; padding: 0 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 17px; width: 100%; }
/* Folded: just the name buttons, so the biorhythm starts near the top */
.setup.is-folded { padding: 10px 12px; }
.setup.is-folded .people { margin-bottom: 0; }
.people .edit { margin-left: auto; background: none; box-shadow: inset 0 0 0 1.5px var(--line); color: var(--ink-2); }
.people button { min-width: 44px; }
.people[hidden] + .setup-body { margin-top: 0; }

/* Tighter on phones: more of the biorhythm on one screen (2.5) */
.top { padding-top: 8px; padding-bottom: 2px; }
.brand h1 { font-size: 21px; }
.round { width: 38px; height: 38px; font-size: 20px; }
.card { padding: 12px 14px; margin: 8px 0; }
.setup.is-folded { padding: 8px 10px; }
.people { gap: 6px; }
.people button { min-height: 36px; padding: 0 14px; }
.today-head .round { width: 34px; height: 34px; font-size: 19px; }
.day-pick b { font-size: 17px; }
.day-pick small { font-size: 12.5px; line-height: 1.35; }
.day-pick .born { color: var(--ink-2); font-weight: 600; }
.meters { gap: 8px; margin-top: 8px; }
.meter-val { font-size: 18px; }
.meter-bar { height: 8px; }
.meter-say { font-size: 13px; }
h2 { font-size: 16px; }
.chart { margin-top: 4px; }
.legend { margin-top: 4px; font-size: 12px; gap: 2px 12px; }
.hint { font-size: 13px; margin-top: 6px; }
.ahead { margin-top: 6px; gap: 10px; }
.ahead ol, .ahead ul { gap: 2px; }
.fine { margin: 8px 0; }
/* Critical days: which way the cycle is turning */
.turn { font-size: 13px; font-weight: 600; white-space: nowrap; }
.turn.up { color: var(--emo); }
.turn.down { color: var(--phy); }
.critical .turn { font-size: inherit; }
.turn-key { margin: 6px 0 0; font-size: 12px; color: var(--ink-3); }
/* backup shortcut and research notes */
.backup-cta { margin: 6px 0; text-align: center; font-size: 13px; color: var(--ink-3); }
.backup-cta .link { font-weight: 700; margin: 0; }
.backup-cta small { display: block; }
.btn.flash { box-shadow: 0 0 0 3px var(--accent); }
.research .prose { font-size: 14.5px; color: var(--ink-2); }
.research h3 { margin: 12px 0 4px; color: var(--ink); font-size: 15px; }
.research p { margin: 0 0 8px; }
.research code { font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.research .sources { font-size: 12.5px; color: var(--ink-3); }
.research a { color: var(--ink-2); }
