/* Pump Log
   Soft violet and lavender, with layered waves across the top of each page.
   Dark mode (deep plum) and light mode follow the phone's setting. Type: Atkinson Hyperlegible (SIL OFL),
   drawn by the Braille Institute for legibility. */

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --page: #150f24;
  --panel: #1f1733;
  --well: #2a2042;
  --field: #120c1e;
  --ink: #f1ecfa;
  --ink-2: #b3a8cc;
  --rule: #33284d;
  --rule-strong: #54477a;
  --glow: #c4a3f2;          /* the accent: buttons, the timer, the hero */
  --on-glow: #1e1135;
  --series: #8f68d8;        /* chart marks, validated against --panel */
  --series-soft: rgba(143, 104, 216, 0.16);
  --series-2: #d0628f;      /* right side, second slot */
  --on-series: #ffffff;
  --on-series-2: #1a0e24;
  --danger: #ff8fa3;
  --good: #8fd6b0;
  --radius: 16px;
  --font: "Atkinson Hyperlegible", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --tabbar: 64px;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --page: #f7f2fd;
    --panel: #ffffff;
    --well: #efe6fa;
    --field: #ffffff;
    --ink: #24163d;
    --ink-2: #5f5277;
    --rule: #e6dcf3;
    --rule-strong: #b9a8d6;
    --glow: #6e3fc0;
    --on-glow: #ffffff;
    --series: #7b4fc9;
    --series-soft: rgba(123, 79, 201, 0.12);
    --series-2: #d0558f;
    --on-series: #ffffff;
    --on-series-2: #1a0e24;
    --danger: #b4233f;
    --good: #2f7d57;
  }
}

/* ------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page) url("../img/waves-dark.svg") no-repeat top center;
  background-size: 100% 150px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
@media (prefers-color-scheme: light) {
  body { background-image: url("../img/waves-light.svg"); }
  /* The header sits on the deepest wave, so it uses white text in both modes. */
  .topbar .brand { color: #ffffff; }
  .brand__mark { background: #ffffff; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.3); }
}

h1, h2, p { margin: 0; }
h1, h2 { line-height: 1.2; }
h2 { font-size: 1.125rem; }
a { color: var(--glow); text-underline-offset: 0.2em; }
:focus-visible { outline: 3px solid var(--glow); outline-offset: 2px; }
code, pre { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 20;
  padding: 8px 12px; border-radius: 8px; background: var(--glow); color: var(--on-glow);
}
.skip-link:focus { top: 12px; }

/* ------------------------------------------------------------ frame and navigation */

.page {
  max-width: 30rem;
  margin: 0 auto;
  padding: 76px 16px calc(var(--tabbar) + 40px + env(safe-area-inset-bottom));
}

.topbar {
  max-width: 30rem;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px 0;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); font-weight: 700; font-size: 1.0625rem; text-decoration: none;
}
.brand--large { font-size: 1.375rem; }
.brand__mark {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--glow);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--glow) 25%, transparent);
}

/* Phone-only layout: tabs sit at the bottom, in thumb reach. */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  padding-inline: max(0px, calc((100vw - 30rem) / 2));
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border-top: 1px solid var(--rule);
  backdrop-filter: blur(10px);
}
.tabs a {
  display: grid; justify-items: center; align-content: center; gap: 3px;
  color: var(--ink-2); font-size: 0.75rem; font-weight: 700; text-decoration: none;
}
.tabs__icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--glow); }

.page-title { font-size: 1.625rem; margin-bottom: 18px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head .page-title { margin: 0; }

.flashes { display: grid; gap: 8px; margin-bottom: 18px; }
.flash {
  padding: 12px 14px; border-radius: 10px; background: var(--panel);
  border: 1px solid var(--rule); border-left: 4px solid var(--good);
}
.flash--error { border-left-color: var(--danger); }

.card {
  margin-top: 16px; padding: 18px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--rule);
}
.card > h2 { margin-bottom: 10px; }
.card > p + p { margin-top: 10px; }
.empty { margin-top: 24px; color: var(--ink-2); }
.hint { color: var(--ink-2); font-size: 0.875rem; }
.error { color: var(--danger); font-size: 0.875rem; font-weight: 700; }
.about { margin-top: 28px; color: var(--ink-2); font-size: 0.875rem; }

/* ------------------------------------------------------------ buttons */

.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px; padding: 10px 18px;
  border: 1px solid var(--rule-strong); border-radius: 12px;
  background: var(--panel); color: var(--ink);
  font: inherit; font-weight: 700; font-size: 1rem; text-decoration: none; cursor: pointer;
  touch-action: manipulation;
}
.button:hover { background: var(--well); }
.button--primary { background: var(--glow); border-color: var(--glow); color: var(--on-glow); }
.button--primary:hover { background: var(--glow); filter: brightness(1.06); }
.button--big { min-height: 60px; width: 100%; font-size: 1.125rem; border-radius: 16px; }
.button--quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.button--danger { border-color: currentColor; background: transparent; color: var(--danger); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* ------------------------------------------------------------ Today */

.since { padding: 18px 2px 8px; }
.since__lead { color: var(--ink-2); font-size: 1.0625rem; }
.since__value {
  margin-top: 2px;
  font-size: clamp(2.75rem, 11vw, 4rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.since__value time { color: var(--glow); }
.since__detail { margin-top: 8px; color: var(--ink-2); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.actions form { display: contents; }

.timer {
  margin-top: 22px; padding: 22px 18px; border-radius: 20px; text-align: center;
  background: var(--panel); border: 1px solid color-mix(in srgb, var(--glow) 45%, var(--rule));
  box-shadow: 0 10px 40px -18px color-mix(in srgb, var(--glow) 60%, transparent);
}
.timer__lead { color: var(--ink-2); }
.timer__clock {
  font-size: clamp(3.5rem, 18vw, 5rem); font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--glow);
}
.timer__since { color: var(--ink-2); font-size: 0.9375rem; }
.timer__actions { display: grid; gap: 6px; margin-top: 18px; }
.timer__warning, .notice {
  margin-top: 14px; padding: 10px 12px; border-radius: 10px; text-align: left;
  background: var(--well); color: var(--ink); font-size: 0.9375rem;
}
.notice { margin: 0 0 18px; }

.today { margin-top: 30px; }
.today__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.today__head h2 { font-size: 1.375rem; }
.today__sum { color: var(--ink-2); }
.today__sum strong { color: var(--ink); font-size: 1.25rem; }
.today__note { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 0.875rem; }
.today__more { margin-top: 14px; }

.gauge { display: block; margin-top: 14px; overflow: visible; }
.gauge__tube { fill: var(--well); }
.gauge__fill { fill: var(--series); }
.gauge__tick { stroke: color-mix(in srgb, var(--ink) 35%, transparent); stroke-width: 1.5; }
.gauge__label { fill: var(--ink-2); font-size: 12px; font-family: var(--font); }
.gauge__avg { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
.key-avg { width: 2px; height: 14px; border-radius: 1px; background: var(--ink); flex: none; }

/* ------------------------------------------------------------ session lists */

.entries { list-style: none; margin: 14px 0 0; padding: 0; border-top: 1px solid var(--rule); }
.entry { border-bottom: 1px solid var(--rule); }
.entry__link {
  display: grid; grid-template-columns: 5.5rem 1fr auto; align-items: start; gap: 12px;
  padding: 13px 2px; color: inherit; text-decoration: none;
}
.entry__link:hover .entry__edit { color: var(--glow); }
.entry__time { color: var(--ink-2); font-variant-numeric: tabular-nums; padding-top: 2px; }
.entry__main { display: grid; gap: 2px; min-width: 0; }
.entry__amount { font-weight: 700; font-size: 1.125rem; }
.entry__detail, .entry__note { color: var(--ink-2); font-size: 0.875rem; }
.entry__detail:empty { display: none; }
.entry__note { overflow-wrap: anywhere; }
.entry__edit { color: var(--ink-2); font-size: 0.875rem; padding-top: 3px; }
.entry:target .entry__link { background: var(--series-soft); }

.day { margin-top: 26px; }
.day:first-of-type { margin-top: 6px; }
.day__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.day__head p { color: var(--ink-2); }
.day__head strong { color: var(--ink); }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; }
.pager .button:only-child { margin-left: auto; }

/* ------------------------------------------------------------ forms */

.form { display: grid; gap: 16px; }
.form__row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.form__row .field:last-child { max-width: 10rem; }
@media (min-width: 480px) {
  .form__row { grid-template-columns: minmax(0, 1fr) 8rem; gap: 12px; }
  .form__row .field:last-child { max-width: none; }
}
.amounts { border: 0; margin: 0; padding: 0; display: grid; gap: 12px; }
.amounts legend { padding: 0; margin-bottom: 10px; font-weight: 700; font-size: 1.125rem; }
.amounts__sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field label { font-weight: 700; font-size: 0.9375rem; }
.field__box { position: relative; }
.field__suffix {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--ink-2); pointer-events: none;
}
.field__box--suffix input { padding-right: 3.2rem; }

:where(input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="file"]), textarea) {
  width: 100%; min-height: 52px; padding: 12px 14px;
  border: 1px solid var(--rule-strong); border-radius: 12px;
  background: var(--field); color: var(--ink); font: inherit; font-size: 1.125rem;
}
textarea { min-height: 76px; resize: vertical; font-size: 1rem; }
.field--error :where(input, textarea) { border-color: var(--danger); }
input[type="datetime-local"] { min-width: 0; }

.danger { margin-top: 28px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 14px; background: var(--well); }
.segmented button {
  min-height: 46px; border: 0; border-radius: 10px; background: transparent;
  color: var(--ink-2); font: inherit; font-weight: 700; cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 0 var(--rule-strong); }
.segmented + .hint { margin-top: 10px; }

.import { display: grid; gap: 8px; justify-items: start; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--rule); }
.import label { font-weight: 700; }
.import input[type="file"] { max-width: 100%; color: var(--ink-2); }

/* ------------------------------------------------------------ trends */

.ranges { display: flex; flex-wrap: wrap; gap: 6px; }
.ranges a {
  flex: none; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--rule);
  color: var(--ink-2); font-weight: 700; font-size: 0.9375rem; text-decoration: none;
}
.ranges a[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: var(--page); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.tile { padding: 14px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--rule); }
.tile__label { color: var(--ink-2); font-size: 0.875rem; }
.tile__value { font-size: 1.5rem; font-weight: 700; }
.tiles__note { margin-top: 8px; color: var(--ink-2); font-size: 0.8125rem; }

.chart__sub { color: var(--ink-2); font-size: 0.875rem; margin-top: -4px; }
.chart__plot { position: relative; height: 210px; margin-top: 12px; }
.chart__plot--tall { height: 320px; }
.chart__plot--bar { height: 64px; }
.sides__text { color: var(--ink-2); font-size: 0.9375rem; }

.chart-svg { display: block; overflow: visible; font-family: var(--font); }
.chart-svg .grid { stroke: var(--rule); stroke-width: 1; }
.chart-svg .axis-text { fill: var(--ink-2); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart-svg .value-text { fill: var(--ink); font-size: 12px; font-weight: 700; }
.chart-svg .bar { fill: var(--series); }
.chart-svg .bar--today { fill: var(--series); opacity: 0.55; }
.chart-svg .avg-line { stroke: var(--ink); stroke-width: 1.5; }
.chart-svg .dot { fill: var(--series); stroke: var(--panel); stroke-width: 2; }
.chart-svg .seg-left { fill: var(--series); }
.chart-svg .seg-right { fill: var(--series-2); }
.chart-svg .seg-text { font-size: 12.5px; font-weight: 700; }
.chart-svg .seg-text--left { fill: var(--on-series); }
.chart-svg .seg-text--right { fill: var(--on-series-2); }
.chart-svg .hit { fill: transparent; cursor: pointer; }
.chart-svg .hit:hover + .bar, .chart-svg .hit:focus + .bar,
.chart-svg .hit:hover + .dot, .chart-svg .hit:focus + .dot { filter: brightness(1.18); }
.chart-svg .hit:focus { outline: none; }
.chart-svg .hit:focus-visible { stroke: var(--glow); stroke-width: 2; }

.tooltip {
  position: absolute; z-index: 5; pointer-events: none;
  min-width: 7rem; padding: 8px 10px; border-radius: 10px;
  background: var(--ink); color: var(--page); font-size: 0.875rem; line-height: 1.35;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  transform: translate(-50%, calc(-100% - 10px));
}
.tooltip strong { display: block; font-size: 1rem; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; color: var(--ink-2); font-size: 0.875rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend .l { background: var(--series); }
.legend .r { background: var(--series-2); }
.legend .bar-key { width: 10px; height: 12px; border-radius: 3px 3px 0 0; background: var(--series); }
.legend .line-key { width: 16px; height: 0; border-radius: 0; border-top: 2px solid var(--series-2); }
.chart-svg .trend-line { fill: none; stroke: var(--series-2); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .trend-end { fill: var(--series-2); stroke: var(--panel); stroke-width: 2; }

.table-view summary { cursor: pointer; font-weight: 700; color: var(--glow); }
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--rule); text-align: left; font-size: 0.9375rem; }
thead th { color: var(--ink-2); font-size: 0.8125rem; }
td.num, th.num { text-align: right; }
tbody th { font-weight: 400; }

/* ------------------------------------------------------------ sign-in */

.auth { display: grid; place-content: center; gap: 16px; min-height: 100vh; min-height: 100dvh; padding: 24px 16px; }
.auth__panel {
  display: grid; gap: 18px; width: min(24rem, calc(100vw - 32px));
  padding: 28px 22px; border-radius: 20px; background: var(--panel); border: 1px solid var(--rule);
}
.auth__panel h1 { font-size: 1.375rem; }
.auth pre { margin: 0; padding: 12px; border-radius: 10px; background: var(--well); white-space: pre-wrap; overflow-wrap: anywhere; }
.auth .flashes { width: min(24rem, calc(100vw - 32px)); margin: 0; }

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