/* Sullivan: calm, phone-first. Chart series colors are the validated dataviz reference palette. */
:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #fcfcfb;
  --surface-2: #eef2f7;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #6f6e69;
  --line: #e3e7ee;
  --grid: #e8ebf0;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --good: #1f7a3a;
  --warn: #a35c00;
  --tooltip-bg: #1a1a19;
  --tooltip-text: #f0efec;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #2a78d6; --seq-5: #184f95;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 30, 60, .05), 0 6px 20px -12px rgba(15, 30, 60, .25);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --round: "Nunito", "Inter", -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #11161d;
    --surface: #1a1a19;
    --surface-2: #24262a;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #9d9c94;
    --line: #2e3136;
    --grid: #2a2c30;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --good: #5cc27a;
    --warn: #f0a640;
    --tooltip-bg: #f0efec;
    --tooltip-text: #0b0b0b;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --seq-1: #1c3550; --seq-2: #104281; --seq-3: #1c5cab; --seq-4: #3987e5; --seq-5: #86b6ef;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--sans); }
h1, h2, h3 { font-family: var(--round); font-weight: 800; line-height: 1.2; margin: 0 0 .4rem; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.1rem; }
a { color: var(--accent-ink); }
.muted { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.nowrap { white-space: nowrap; }

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(.7rem + env(safe-area-inset-top)) 1.1rem .7rem; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--round); font-weight: 800; font-size: 1.2rem; color: var(--text); text-decoration: none; }
.brand-mark { color: var(--accent); }
.tabs { display: flex; gap: .2rem; background: var(--surface-2); border-radius: 999px; padding: .2rem; }
.tabs a { color: var(--text-2); text-decoration: none; font-size: .9rem; font-weight: 600; padding: .35rem .75rem; border-radius: 999px; }
.tabs a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.page { max-width: 1100px; margin: 0 auto; padding: 1.2rem 1rem 2rem; }
.footer { text-align: center; padding: 0 0 2rem; }
.footer form { display: inline; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--text-3); text-decoration: underline; cursor: pointer; }
.danger { color: #c0392b; }
.flash { max-width: 1100px; margin: 1rem auto 0; padding: .7rem 1rem; border-radius: 12px; background: var(--surface); border-left: 4px solid var(--accent); width: calc(100% - 2rem); }
.flash-alert { border-left-color: #c0392b; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.btn { display: inline-block; border: 0; border-radius: 999px; padding: .7rem 1.3rem; font: 600 1rem var(--sans); cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: var(--surface-2); color: var(--text); }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=date] {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .75rem;
}
.stack { display: flex; flex-direction: column; gap: .7rem; }

/* sign in */
.signin .page { display: grid; place-items: center; min-height: 85vh; }
.signin-card { max-width: 360px; width: 100%; text-align: center; padding: 2rem 1.6rem; }
.signin-mark { font-size: 2rem; color: var(--accent); }

/* today */
.hello h1 span { color: var(--text-3); font-weight: 700; font-size: 1.1rem; }
.hello p { margin: 0 0 1rem; }
.hero-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: .8rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.tile-label { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.tile strong { font-family: var(--round); font-size: 1.5rem; font-weight: 800; line-height: 1.15; }
.tile-sub { font-size: .85rem; color: var(--text-2); }
.tile-hero { padding: 1.1rem 1.2rem; }
.hero-num { font-size: 2.3rem !important; }
.tile.is-due { border-color: var(--warn); }
.tile.is-due .tile-sub { color: var(--warn); font-weight: 600; }
.ok { color: var(--good); }
.pending { color: var(--warn); }

.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1rem; align-items: start; }
.timeline, .schedule { list-style: none; margin: 0; padding: 0; }
.ev { display: grid; grid-template-columns: 4.6rem 1.6rem 1fr auto; gap: .5rem; align-items: start; padding: .55rem 0; border-top: 1px solid var(--line); }
.ev:first-child { border-top: 0; }
.ev time { color: var(--text-2); font-variant-numeric: tabular-nums; font-size: .92rem; }
.ev-notes { font-size: .85rem; color: var(--text-3); }
.ev-by { font-size: .8rem; color: var(--text-3); }
.sched { display: grid; grid-template-columns: 4.8rem 1fr; gap: .5rem; padding: .4rem .5rem; border-radius: 10px; font-size: .93rem; }
.sched time { color: var(--text-3); font-variant-numeric: tabular-nums; }
.sched-feed span { font-weight: 600; }
.sched.past { opacity: .45; }
.sched.next { background: var(--surface-2); outline: 2px solid var(--accent); }
.sync-note { font-size: .82rem; text-align: center; margin-top: 1rem; }

/* trends */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.page-head h1 { margin: 0; }
.range { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .8rem; }
.range a { text-decoration: none; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); padding: .35rem .8rem; border-radius: 999px; font-size: .88rem; font-weight: 600; }
.range a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.range-note { font-size: .85rem; margin: -.3rem 0 1rem; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 1rem; }
.chart-card { margin: 0 0 0; }
.chart-card figcaption p { font-size: .85rem; margin: 0 0 .5rem; }
.chart { position: relative; height: 240px; }
.chart-grid + .card, .chart-grid { margin-bottom: 1rem; }

.heatmap { overflow-x: auto; }
.hm-row { display: grid; grid-template-columns: 3.6rem repeat(24, minmax(10px, 1fr)); gap: 2px; margin-bottom: 2px; min-width: 420px; }
.hm-date, .hm-hour { font-size: .72rem; color: var(--text-3); white-space: nowrap; }
.hm-hour { text-align: left; }
.hm-cell { display: block; height: 16px; border-radius: 3px; background: var(--surface-2); }
.hm-cell.s1 { background: var(--seq-1); } .hm-cell.s2 { background: var(--seq-2); } .hm-cell.s3 { background: var(--seq-3); }
.hm-cell.s4 { background: var(--seq-4); } .hm-cell.s5 { background: var(--seq-5); }
.hm-legend { display: flex; align-items: center; gap: 3px; font-size: .75rem; margin-top: .5rem; }
.hm-legend .hm-cell { width: 16px; }
.hm-legend span:first-child { margin-right: .3rem; } .hm-legend span:last-child { margin-left: .3rem; }

.vitd { list-style: none; padding: 0; margin: .3rem 0 0; display: flex; flex-wrap: wrap; gap: 4px; }
.vitd li { width: 30px; text-align: center; border-radius: 8px; padding: .2rem 0; background: var(--surface-2); color: var(--text-3); font-weight: 700; }
.vitd li.given { background: color-mix(in srgb, var(--good) 18%, var(--surface)); color: var(--good); }
.vitd small { display: block; font-size: .65rem; font-weight: 500; color: var(--text-3); }
.vitd-key { font-size: .8rem; margin: .5rem 0 0; }

/* log */
.log-search { flex: 1; max-width: 280px; }
.log-day h2 { margin-bottom: .3rem; }
.log-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.log-table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 600; padding: .3rem .5rem .4rem 0; border-bottom: 1px solid var(--line); }
.log-table td { padding: .5rem .6rem .5rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.log-table tr:last-child td { border-bottom: 0; }
.log-table form { margin: 0; }
.more { text-align: center; }

/* growth */
.measure-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; align-items: end; }
.measure-form label { display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; font-weight: 600; color: var(--text-2); }
.measure-form .wide { grid-column: 1 / -1; }
.form-error { grid-column: 1 / -1; color: #c0392b; margin: 0; }

@media (max-width: 760px) {
  .two-col { grid-template-columns: 1fr; }
  h1 { font-size: 1.45rem; }
  .hero-num { font-size: 1.9rem !important; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tabs a { padding: .3rem .55rem; font-size: .84rem; }
  .brand { font-size: 1.05rem; }
  .log-table th:nth-child(5), .log-table td:nth-child(5) { display: none; }
  .log-table td .muted { display: none; }
  .ev { grid-template-columns: 4.2rem 1.4rem 1fr; }
  .ev-by { display: none; }
}
