/* Kraft. Quiet everywhere except the weight-stack sparkline. */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("/fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("/fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("/fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 500; font-display: swap; src: url("/fonts/barlow-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 600; font-display: swap; src: url("/fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }

:root {
  color-scheme: light dark;
  --bg: #EEF0EC;
  --surface: #F6F7F4;
  --ink: #1C2633;
  --muted: #566170;
  --rule: #B9C0C8;
  --rule-soft: #D5DAD9;
  --pin: #F0B90B;
  --down: #B83A2A;
  --radius: 10px;
  --gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  --text: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --num: "Barlow Condensed", "Barlow", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141B24;
    --surface: #1A222D;
    --ink: #E4E8EE;
    --muted: #9AA5B3;
    --rule: #2E3946;
    --rule-soft: #243040;
    --pin: #F4C430;
    --down: #E3735F;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.45 var(--text);
  font-variant-numeric: tabular-nums;
  padding: 0 var(--gutter) max(24px, env(safe-area-inset-bottom));
}
a { color: inherit; }
h1, h2, h3 { font-family: var(--num); font-weight: 600; line-height: 1.15; margin: 0; }
h2 { font-size: 1.35rem; margin: 28px 0 12px; }
h3 { font-size: 1.15rem; }
.muted, .meta, .note { color: var(--muted); }
.note { font-size: 0.85rem; margin: 12px 0 0; max-width: 60ch; }
.down { color: var(--down); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: var(--gutter); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

button { font: inherit; cursor: pointer; }
.primary {
  font: 600 0.95rem/1 var(--text);
  background: var(--ink); color: var(--bg);
  border: 0; border-radius: 8px;
  padding: 10px 14px; min-height: 40px;
}
.primary:disabled { opacity: 0.55; cursor: default; }

/* header */
.top {
  max-width: 1100px; margin: 0 auto;
  padding-top: max(8px, env(safe-area-inset-top));
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--rule);
}
.top h1 { font-size: 1.6rem; padding-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.top h1 a { text-decoration: none; }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pin); }
.sync-dot[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .sync-dot { animation: pulse 1.2s ease-in-out infinite; }
}
@keyframes pulse { 50% { opacity: 0.35; } }
nav { display: flex; gap: 2px; }
nav a {
  text-decoration: none; padding: 10px 10px 9px; color: var(--muted);
  font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }

.banner { max-width: 1100px; margin: 12px auto 0; display: grid; gap: 8px; }
.msg { margin: 0; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--rule); background: var(--surface); font-size: 0.92rem; }
.msg.error { border-color: var(--down); }
.msg.error::before { content: "Sync failed. "; font-weight: 600; color: var(--down); }

main { max-width: 1100px; margin: 0 auto; outline: none; }
.loading { margin-top: 32px; }

/* machines: all ten fit on one phone screen */
.region h2 { font-size: 1rem; margin: 9px 0 4px; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; } }
.tile {
  display: grid; grid-template-columns: 46px minmax(0, 1fr); grid-template-rows: auto 46px;
  column-gap: 8px; row-gap: 3px;
  text-decoration: none;
  background: var(--surface); border: 1px solid var(--rule-soft); border-radius: var(--radius);
  padding: 5px 8px 6px;
}
.tile:hover { border-color: var(--rule); }
.tile h3 {
  grid-column: 1 / -1; font-size: 1.02rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thumb { width: 46px; height: 46px; border-radius: 6px; object-fit: cover; background: var(--rule-soft); display: block; }
.thumb.noimg { visibility: hidden; }
.tile-main { display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.big { font: 600 1.6rem/1 var(--num); margin: 0; white-space: nowrap; }
.big small { font-size: 0.95rem; font-weight: 500; color: var(--muted); margin-left: 2px; }
.delta { font: 500 1rem var(--num); margin-left: 6px; color: var(--muted); }
.delta.down { color: var(--down); }
.spark { width: 100%; max-width: 120px; height: auto; display: block; overflow: visible; }
.spark .rule, .bars-plot .rule, .calendar .rule { stroke: var(--rule); stroke-width: 1; opacity: 0.55; }
.spark .step { fill: none; stroke: var(--ink); stroke-width: 1.75; stroke-linejoin: round; }
.spark .pin-shaft { stroke: var(--pin); stroke-width: 2.5; }
.pin { fill: var(--pin); }

/* machine detail */
.back { margin: 14px 0 0; }
.back a { color: var(--muted); text-decoration: none; }
.back a::before { content: "‹ "; }
.detail-head { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.big-thumb { width: 64px; height: 64px; }
.detail h2 { margin: 0; font-size: 1.8rem; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px; margin: 14px 0; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stats dt { font-size: 0.85rem; color: var(--muted); }
.stats dd { margin: 0; font: 600 1.6rem/1.1 var(--num); }
.chart { margin: 8px 0 16px; }
.axis-title { margin: 0 0 4px; font-size: 0.85rem; color: var(--muted); }
.axis-title.x { text-align: center; margin: 2px 0 0 44px; }
.bars { display: flex; align-items: flex-start; }
.bars-axis { flex: none; }
.bars-scroll { overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: thin; }
.bars-plot { display: block; }
.bars-axis .axis, .bars-plot .axis, .calendar .axis { fill: var(--muted); font: 500 12px var(--num); }
.calendar .axis.small { font-size: 10px; }
.bars-plot .baseline, .bars-plot .tick { stroke: var(--muted); stroke-width: 1; }
.bars-plot .seg { fill: var(--ink); stroke: var(--surface); stroke-width: 1; }
.bars-plot .seg.low { fill: var(--muted); fill-opacity: 0.45; }
.bars-plot .bar-val { fill: var(--ink); font: 600 11px var(--num); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; color: var(--muted); margin: 8px 0 0; }
.legend i { display: inline-block; vertical-align: middle; margin-right: 6px; width: 10px; height: 10px; border-radius: 2px; }
.lg-seg { background: var(--ink); }
.lg-seg.low { background: var(--muted); opacity: 0.45; }

table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th { text-align: left; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--rule); padding: 6px 8px 6px 0; }
td { border-bottom: 1px solid var(--rule-soft); padding: 8px 8px 8px 0; vertical-align: top; }
.num { text-align: right; white-space: nowrap; }
td.sets { font-family: var(--num); font-size: 1rem; }
.tag { font-size: 0.75rem; border: 1px solid var(--rule); border-radius: 4px; padding: 0 5px; color: var(--muted); white-space: nowrap; }
.warn-tag { border-color: var(--down); color: var(--down); }

/* sessions */
.cal-wrap { overflow-x: auto; padding-bottom: 4px; }
.calendar { width: 100%; min-width: 320px; max-width: 520px; height: auto; display: block; }
.cal.v0 { fill: var(--rule-soft); }
.cal.v1 { fill: var(--ink); fill-opacity: 0.28; }
.cal.v2 { fill: var(--ink); fill-opacity: 0.48; }
.cal.v3 { fill: var(--ink); fill-opacity: 0.72; }
.cal.v4 { fill: var(--ink); }
.cal.future { fill: none; }
.wk-bar { fill: var(--muted); }
.days { display: grid; gap: 8px; }
.day { background: var(--surface); border: 1px solid var(--rule-soft); border-radius: var(--radius); }
.day summary {
  list-style: none; cursor: pointer; padding: 12px 14px;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
}
.day summary::-webkit-details-marker { display: none; }
.day-date { font: 600 1.15rem/1.2 var(--num); }
.day-time { color: var(--muted); text-align: right; font-size: 0.9rem; }
.day-nums { grid-column: 1 / -1; font-size: 0.92rem; }
.day-nums b { font: 600 1.05rem var(--num); }
.day-machines { grid-column: 1 / -1; color: var(--muted); font-size: 0.85rem; }
.day[open] summary { border-bottom: 1px solid var(--rule-soft); }
.day-items { list-style: none; margin: 0; padding: 6px 14px 10px; }
.day-items li { display: grid; grid-template-columns: 1.4em 1fr; gap: 0 6px; padding: 6px 0; border-bottom: 1px solid var(--rule-soft); }
.day-items li:last-child { border-bottom: 0; }
.day-items .name { font-weight: 500; }
.day-items .sets { grid-column: 2; font-family: var(--num); color: var(--muted); }
@media (min-width: 640px) {
  .day-items li { grid-template-columns: 1.4em 12em 1fr; }
  .day-items .sets { grid-column: 3; }
}
.trend { grid-row: span 2; font-size: 0.85rem; text-align: center; color: var(--muted); }
.trend.up { color: var(--ink); }
.trend.down { color: var(--down); }

/* body */
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; margin-bottom: 14px; }
.seg a { text-decoration: none; padding: 8px 14px; font-weight: 500; color: var(--muted); }
.seg a + a { border-left: 1px solid var(--rule); }
.seg a[aria-current="true"] { background: var(--ink); color: var(--bg); }
.groups { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-width: 640px; }
.groups li { display: grid; grid-template-columns: 9.5em 1fr 3em; align-items: center; gap: 10px; }
.g-label { font-size: 0.95rem; }
.g-bar { height: 10px; background: var(--rule-soft); border-radius: 2px; overflow: hidden; }
.g-fill { display: block; height: 100%; background: var(--ink); }
.g-val { font: 600 1.05rem var(--num); text-align: right; }
.bio { background: var(--surface); border: 1px solid var(--rule-soft); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; max-width: 640px; }
.big-inline { font: 600 1.6rem var(--num); margin-left: 8px; }
.bio-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px; margin: 10px 0 0; }
@media (min-width: 640px) { .bio-list { grid-template-columns: repeat(3, 1fr); } }
.bio-list dt { font-size: 0.82rem; color: var(--muted); }
.bio-list dd { margin: 0; font: 600 1.15rem var(--num); }

.empty { margin: 40px auto; max-width: 420px; text-align: center; }
.empty p { color: var(--muted); }

/* login */
.login-page { display: grid; min-height: 100vh; min-height: 100dvh; place-items: center; }
.login { width: 100%; max-width: 320px; }
.login h1 { font-size: 2.4rem; }
.login form { display: grid; gap: 8px; margin-top: 20px; }
.login label { font-weight: 500; }
.login input[type="password"] {
  font: inherit; padding: 10px 12px; border-radius: 8px; min-height: 44px;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
}
.login .primary { margin-top: 8px; min-height: 44px; }
.form-error { color: var(--down); margin: 0; font-size: 0.92rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
.g-fill.w0 { width: 0%; }
.g-fill.w5 { width: 5%; }
.g-fill.w10 { width: 10%; }
.g-fill.w15 { width: 15%; }
.g-fill.w20 { width: 20%; }
.g-fill.w25 { width: 25%; }
.g-fill.w30 { width: 30%; }
.g-fill.w35 { width: 35%; }
.g-fill.w40 { width: 40%; }
.g-fill.w45 { width: 45%; }
.g-fill.w50 { width: 50%; }
.g-fill.w55 { width: 55%; }
.g-fill.w60 { width: 60%; }
.g-fill.w65 { width: 65%; }
.g-fill.w70 { width: 70%; }
.g-fill.w75 { width: 75%; }
.g-fill.w80 { width: 80%; }
.g-fill.w85 { width: 85%; }
.g-fill.w90 { width: 90%; }
.g-fill.w95 { width: 95%; }
.g-fill.w100 { width: 100%; }
