/* Dziennik formy */

/* Deep space: black void, violet nebula, blue and light-blue starlight, red giants.
   The plate slot names (yellow, green) stay because the JS picks colors by slot;
   in this palette the yellow slot is violet and the green slot is light blue. */
:root {
  --void: #030208;
  --bg: #07051A;
  --surface: #110C27;
  --glass: rgba(14, 10, 34, 0.72);
  --ink: #F4F2FF;
  --ink-2: #CBC4F0;
  --steel: #7571A3;
  --muted: #A29BCB;
  --rule: #251E47;
  --platform: #0A0720;
  --platform-ink: #F7F5FF;
  --platform-muted: #B9B1E6;
  --platform-rule: rgba(190, 170, 255, 0.16);
  --plate-red: #FF3F63;
  --plate-blue: #3F6BFF;
  --plate-yellow: #A45CFF;  /* violet */
  --plate-green: #5CD6FF;   /* light blue */
  --plate-white: #F6F4FF;
  --plate-steel: #8A86B8;
  /* Macros: fixed order protein, fat, carbs (bottom to top in the stacked chart).
     Checked for colorblind separation against --surface. */
  --macro-protein: #FF3F63;
  --macro-fat: #A45CFF;
  --macro-carbs: #12A8B8; /* darker than the plate light blue: fits the dark-mode lightness band */
  --good-text: #7FE2FF;
  --bad-text: #FF6F88;
  --focus: #7FE2FF;
  --glow-violet: rgba(164, 92, 255, 0.55);
  --glow-blue: rgba(63, 107, 255, 0.5);
  --cosmic: linear-gradient(120deg, #A45CFF 0%, #3F6BFF 55%, #5CD6FF 100%);
  --pad: 20px;
  --max: 1160px;
  --font-ui: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Big Shoulders Display', 'Barlow', system-ui, sans-serif;
  --font-stencil: 'Big Shoulders Stencil Display', 'Big Shoulders Display', 'Barlow', sans-serif;
  color-scheme: dark;
}

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

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: calc(112px + env(safe-area-inset-bottom));
  background: var(--void);
  color: var(--ink);
  font: 400 16px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

/* Starfield and a faint galactic band behind everything, fixed so the page scrolls over the sky. */
body::before,
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
body::after {
  background:
    radial-gradient(ellipse 55% 40% at 8% 18%, rgba(164, 92, 255, 0.20), transparent 70%),
    radial-gradient(ellipse 45% 35% at 92% 8%, rgba(63, 107, 255, 0.20), transparent 70%),
    radial-gradient(ellipse 40% 30% at 80% 88%, rgba(255, 63, 99, 0.10), transparent 70%),
    radial-gradient(ellipse 70% 18% at 50% 60%, rgba(92, 214, 255, 0.06), transparent 70%),
    linear-gradient(160deg, #0B0722 0%, var(--void) 45%, #05030F 100%);
  z-index: -2;
}
body::before {
  background-image:
    radial-gradient(1px 1px at 23px 41px, #fff, transparent),
    radial-gradient(1px 1px at 131px 97px, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(1.5px 1.5px at 67px 173px, #CFE9FF, transparent),
    radial-gradient(1px 1px at 181px 11px, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1px 1px at 97px 131px, rgba(214, 190, 255, 0.9), transparent),
    radial-gradient(1.5px 1.5px at 251px 223px, #fff, transparent),
    radial-gradient(1px 1px at 311px 61px, rgba(255, 190, 200, 0.8), transparent),
    radial-gradient(2px 2px at 373px 293px, rgba(190, 225, 255, 0.95), transparent),
    radial-gradient(1px 1px at 29px 331px, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1.5px 1.5px at 199px 379px, rgba(220, 200, 255, 0.85), transparent);
  background-size: 211px 211px, 211px 211px, 211px 211px, 211px 211px, 211px 211px,
    409px 409px, 409px 409px, 409px 409px, 409px 409px, 409px 409px;
  opacity: 0.8;
  /* No twinkling: an endless animation on a full-screen layer kept the GPU busy and made scrolling stutter. */
}

h1, h2, h3, p, ul, dl, dd, figure { margin: 0; }
ul { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
a { color: inherit; text-underline-offset: 2px; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Training and badge colors: the order of trainings in settings picks the plate color. */
.t-blue, .b-blue { --c: var(--plate-blue); }
.t-red, .b-red { --c: var(--plate-red); }
.t-yellow, .b-yellow { --c: var(--plate-yellow); }
.t-green, .b-green { --c: var(--plate-green); }
.t-white, .b-white { --c: var(--plate-white); }
.t-steel, .b-steel { --c: var(--plate-steel); }

/* ---------- header ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: var(--max);
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) calc(var(--pad) + env(safe-area-inset-right)) 10px calc(var(--pad) + env(safe-area-inset-left));
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0.01em;
}

.brand-mark { width: 30px; height: 30px; flex: none; filter: drop-shadow(0 0 6px var(--glow-violet)); }
.brand span {
  background: linear-gradient(90deg, #fff 0%, #D9CCFF 60%, #9FE6FF 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topbar-actions { display: flex; align-items: center; gap: 2px; }

.streak {
  margin-right: 6px;
  padding: 3px 12px;
  border: 1px solid rgba(164, 92, 255, 0.45);
  border-radius: 999px;
  background: var(--glass);
  box-shadow: 0 0 14px rgba(164, 92, 255, 0.25);
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.is-spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- banner ---------- */

.banner { font-size: 15px; }
.banner-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 10px calc(var(--pad) + env(safe-area-inset-right)) 10px calc(var(--pad) + env(safe-area-inset-left));
}
.banner.is-demo { background: linear-gradient(90deg, #6A2BD9, #3F6BFF); color: #fff; }
.banner.is-error {
  background: color-mix(in srgb, var(--plate-red) 13%, var(--bg));
  box-shadow: inset 0 -1px 0 color-mix(in srgb, var(--plate-red) 35%, var(--bg));
}
.banner.is-info { background: var(--surface); box-shadow: inset 0 1px 0 var(--rule), inset 0 -1px 0 var(--rule); }
.banner-action {
  padding: 5px 14px;
  border: 1.5px solid currentColor;
  border-radius: 999px;
  background: transparent;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
}

/* ---------- platform (hero) ---------- */

/* The hero is a nebula: violet dust bottom left, blue gas top right, a red glow drifting in. */
.platform {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 55% 85% at 10% 105%, rgba(164, 92, 255, 0.50), transparent 62%),
    radial-gradient(ellipse 50% 75% at 95% -10%, rgba(63, 107, 255, 0.45), transparent 60%),
    radial-gradient(ellipse 35% 45% at 78% 90%, rgba(255, 63, 99, 0.24), transparent 65%),
    radial-gradient(ellipse 30% 40% at 30% 10%, rgba(92, 214, 255, 0.12), transparent 70%),
    linear-gradient(180deg, rgba(10, 7, 32, 0.55), rgba(3, 2, 8, 0.85));
  color: var(--platform-ink);
  box-shadow: inset 0 -1px 0 rgba(164, 92, 255, 0.35), 0 12px 40px -20px var(--glow-violet);
}

.platform-inner {
  display: grid;
  gap: 22px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 28px calc(var(--pad) + env(safe-area-inset-right)) 32px calc(var(--pad) + env(safe-area-inset-left));
}

.platform-top { display: grid; gap: 6px; }

.platform h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(34px, 6vw, 48px);
  line-height: 1;
}

.today-line { color: var(--platform-muted); }

.barbell-figure { margin: 0; }
.barbell { position: relative; max-width: 820px; margin: 0 auto; aspect-ratio: 720 / 176; }
.barbell svg { position: relative; z-index: 1; display: block; width: 100%; height: auto; filter: drop-shadow(0 0 14px rgba(164, 92, 255, 0.35)); }

/* A black hole sits at the middle of the bar: dark event horizon, a thin photon ring,
   and an accretion disk lying along the bar. */
.barbell::before,
.barbell::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
}
.barbell::before {
  width: 26%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle,
    #000 0 40%,
    rgba(0, 0, 0, 0.92) 45%,
    rgba(255, 255, 255, 0.95) 47.5%,
    rgba(127, 226, 255, 0.75) 50%,
    rgba(164, 92, 255, 0.45) 57%,
    rgba(255, 63, 99, 0.16) 66%,
    transparent 71%);
  animation: horizon 6s ease-in-out infinite alternate;
  will-change: transform, opacity;
}
.barbell::after {
  width: 64%;
  height: 16%;
  border-radius: 50%;
  background: radial-gradient(ellipse closest-side,
    rgba(255, 255, 255, 0.85),
    rgba(127, 226, 255, 0.55) 25%,
    rgba(164, 92, 255, 0.35) 55%,
    rgba(255, 63, 99, 0.12) 80%,
    transparent);
  filter: blur(2px);
}
/* Only transform and opacity: the GPU animates those without repainting (a filter here repainted every frame). */
@keyframes horizon {
  from { opacity: 0.85; transform: translate(-50%, -50%) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1.03); }
}
.barbell-caption { margin-top: 10px; text-align: center; color: var(--platform-muted); font-size: 14px; }

.p-red { fill: var(--plate-red); }
.p-blue { fill: var(--plate-blue); }
.p-yellow { fill: var(--plate-yellow); }
.p-green { fill: var(--plate-green); }
.p-white { fill: var(--plate-white); }
.p-steel { fill: var(--plate-steel); }

.barbell .face { stroke: rgba(0, 0, 0, 0.35); stroke-width: 1; }
.barbell .hub { fill: rgba(0, 0, 0, 0.28); }
.barbell .edge { fill: rgba(255, 255, 255, 0.28); }
.barbell .level { opacity: 0.92; }
.barbell .floor { fill: var(--platform-rule); }
.barbell .ghost {
  fill: rgba(255, 255, 255, 0.025);
  stroke: var(--platform-muted);
  stroke-opacity: 0.45;
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

/* The one orchestrated moment: plates slide onto the sleeves and knock against the collar. */
.barbell .slide-l,
.barbell .slide-r {
  animation: plate-in-l 0.6s cubic-bezier(0.25, 0.8, 0.3, 1) both;
  animation-delay: calc(var(--base, 150ms) + var(--i) * 110ms);
}
.barbell .slide-r { animation-name: plate-in-r; }
.barbell .grow {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: level-up 0.8s ease-out both;
  animation-delay: calc(var(--base, 150ms) + var(--i) * 110ms + 200ms);
}

@keyframes plate-in-l {
  0% { transform: translateX(-230px); opacity: 0; }
  25% { opacity: 1; }
  82% { transform: translateX(0); }
  90% { transform: translateX(-3px); }
  100% { transform: translateX(0); opacity: 1; }
}
@keyframes plate-in-r {
  0% { transform: translateX(230px); opacity: 0; }
  25% { opacity: 1; }
  82% { transform: translateX(0); }
  90% { transform: translateX(3px); }
  100% { transform: translateX(0); opacity: 1; }
}
@keyframes level-up { from { transform: scaleY(0); } }

.readout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: end;
  gap: 20px 44px;
  padding-top: 22px;
  border-top: 1px solid var(--platform-rule);
}

.big {
  font-family: var(--font-stencil);
  font-weight: 900;
  font-size: clamp(76px, 22vw, 136px);
  line-height: 0.8;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  background: linear-gradient(100deg, #FFFFFF 10%, #D6C6FF 45%, #7FE2FF 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(164, 92, 255, 0.45));
}
.big .unit {
  margin-left: 0.18em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.26em;
  color: var(--platform-muted);
}
.big-sub { margin-top: 12px; color: var(--platform-muted); font-size: 14px; }

.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.facts > div { padding: 2px 0 2px 16px; border-left: 1px solid var(--platform-rule); }
.facts dt { color: var(--platform-muted); font-size: 14px; }
.facts dd {
  margin-top: 2px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 25px;
  line-height: 1.15;
}
.facts dd.sub {
  margin-top: 4px;
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 13px;
  line-height: 1.35;
  color: var(--platform-muted);
}

.empty-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.coach {
  max-width: 68ch;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--plate-yellow);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border: 1.5px solid transparent;
  border-radius: 999px;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--cosmic); color: #fff; box-shadow: 0 0 18px -2px var(--glow-violet); }
.btn-primary:hover { box-shadow: 0 0 26px 0 var(--glow-violet); }
.btn-outline { background: var(--glass); border-color: rgba(164, 92, 255, 0.4); color: var(--ink); }
.btn-outline:hover { border-color: var(--plate-green); box-shadow: 0 0 14px -2px rgba(92, 214, 255, 0.45); }
.btn-danger { padding: 0 12px; background: transparent; color: var(--bad-text); }
.btn-danger.is-armed { background: var(--plate-red); color: #fff; }
.btn-light { background: var(--platform-ink); color: var(--platform); }
.btn-outline-light { background: rgba(10, 7, 32, 0.4); border-color: rgba(214, 198, 255, 0.4); color: var(--platform-ink); }
.btn-outline-light:hover { border-color: var(--platform-ink); }

/* ---------- page ---------- */

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 calc(var(--pad) + env(safe-area-inset-right)) 0 calc(var(--pad) + env(safe-area-inset-left));
}

/* Week strip: six numbers under the platform, divided by rules. */
.week {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  margin: 0 calc(-1 * var(--pad));
  background: rgba(164, 92, 255, 0.22);
  border-bottom: 1px solid rgba(164, 92, 255, 0.22);
}
.stat {
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 18px var(--pad) 20px;
  background: rgba(6, 4, 18, 0.9);
}
.stat-label { color: var(--muted); font-size: 14px; }
.stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 34px;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.stat-value small { margin-left: 0.2em; font-size: 0.5em; color: var(--muted); }
.stat-value.is-over { color: var(--bad-text); }
.stat-value .emoji { margin-right: 0.2em; font-size: 0.78em; }
.stat-sub { color: var(--muted); font-size: 13px; line-height: 1.35; }

.slots { display: flex; gap: 4px; margin: 2px 0; }
.slot { width: 10px; height: 26px; border-radius: 3px; background: var(--c); }
.slot.is-open { background: transparent; border: 1.5px dashed var(--steel); }

.mood-row { display: flex; align-items: center; gap: 3px; font-size: 18px; line-height: 1.3; }
.mood-row .gap { display: inline-grid; place-items: center; width: 18px; height: 18px; }
.mood-row .gap::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--rule); }

.columns { display: grid; gap: 40px 48px; margin-top: 36px; }
.col-main, .col-side { display: grid; align-content: start; gap: 40px; min-width: 0; }

.block {
  padding-top: 12px;
  border-top: 2px solid transparent;
  border-image: linear-gradient(90deg, #A45CFF, #3F6BFF 40%, rgba(92, 214, 255, 0.5) 70%, transparent) 1;
}
.block-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 10px;
}
.block h2 { font-family: var(--font-display); font-weight: 800; font-size: 28px; line-height: 1.1; text-shadow: 0 0 18px rgba(164, 92, 255, 0.5); }
.block-note { color: var(--muted); font-size: 14px; }
.caption { min-height: 1.5em; margin-top: 10px; color: var(--muted); font-size: 14px; }

.seg { display: inline-flex; padding: 2px; border: 1.5px solid rgba(164, 92, 255, 0.5); border-radius: 999px; background: var(--glass); }
.seg button {
  padding: 4px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--cosmic); color: #fff; box-shadow: 0 0 12px -2px var(--glow-violet); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; flex: none; }
.sw-line { width: 18px; height: 3px; border-radius: 2px; background: var(--c); }
.sw-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.sw-dash { width: 18px; border-top: 2px dashed var(--c); }
.sw-bar { width: 8px; height: 12px; border-radius: 2px; background: var(--c); }
.sw-sq { width: 11px; height: 11px; border-radius: 3px; background: var(--c); }
.sw-sq.is-rest { background: var(--rule); }

.chart-box { position: relative; height: 240px; }
.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--muted);
  text-align: center;
}
.chart-box.is-short { height: 150px; }
.chart-sub { margin: 18px 0 6px; font-weight: 600; font-size: 15px; }
.chart-sub small { margin-left: 4px; color: var(--muted); font-weight: 400; font-size: 13px; }

/* Training heatmap: 20 weeks, one column per week, Sunday on top. */
.heatmap {
  display: grid;
  grid-template-columns: 22px repeat(20, minmax(0, 1fr));
  grid-template-rows: 16px;
  gap: 3px;
}
.hm-month { grid-row: 1; color: var(--muted); font-size: 12px; line-height: 16px; white-space: nowrap; }
.hm-wd { grid-column: 1; align-self: center; color: var(--muted); font-size: 11px; line-height: 1; }
.hm-cell { aspect-ratio: 1; border-radius: 3px; background: var(--c, transparent); opacity: var(--a, 1); cursor: pointer; }
.hm-cell.is-empty { box-shadow: inset 0 0 0 1px var(--rule); }
.hm-cell.is-rest { background: var(--rule); }
.hm-cell.is-future { cursor: default; }
.hm-cell.is-today { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--steel); }
.hm-cell.is-picked { opacity: 1; box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--ink); }

/* Badges: round plates, dashed outline until earned. */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 14px 6px; }
.badge {
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 100%;
  padding: 4px 0;
  border: 0;
  border-radius: 12px;
  background: none;
  text-align: center;
  cursor: pointer;
}
.badge-plate {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 19px;
  line-height: 1;
  box-shadow:
    inset 0 0 0 3px rgba(0, 0, 0, 0.22),
    inset 0 0 0 9px var(--c),
    inset 0 0 0 10.5px rgba(255, 255, 255, 0.32);
}
.badge:not(.is-off) .badge-plate { filter: drop-shadow(0 0 8px color-mix(in srgb, var(--c) 55%, transparent)); }
.b-green .badge-plate, .b-white .badge-plate, .b-steel .badge-plate { color: #0A0720; }
.badge-title { color: var(--ink-2); font-size: 12.5px; line-height: 1.25; }
.badge.is-off .badge-plate { background: transparent; border: 2px dashed var(--rule); box-shadow: none; color: var(--steel); }
.badge.is-off .badge-title { color: var(--muted); }

/* Insights: one comparison per card, the two group means side by side. */
.insights { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.insight { padding: 12px 14px; border: 1px solid var(--rule); border-radius: 12px; background: var(--glass); }
.insight.is-strong { border-color: rgba(164, 92, 255, 0.55); box-shadow: inset 3px 0 0 var(--plate-yellow); }
.insight h3 { font-weight: 600; font-size: 15px; }
.insight p { margin-top: 2px; color: var(--ink-2); font-size: 14px; line-height: 1.4; }
.insight.is-pending { background: transparent; border-style: dashed; }
.insight.is-pending h3 { color: var(--muted); }
.insight.is-pending p { color: var(--muted); font-size: 13px; }
.insight dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.insight dl > div { display: grid; align-content: start; gap: 1px; min-width: 0; }
.insight dt { color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.insight dd { font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.insight dd small { margin-left: 1px; color: var(--muted); font-size: 0.6em; }
.insight dd .emoji { margin-right: 4px; font-size: 0.8em; }
.insight dd.n { color: var(--muted); font-family: var(--font-ui); font-weight: 400; font-size: 12px; }

/* Weeks: one calendar row per week, newest first, with the week's averages under it. */
.weeks { margin-top: 44px; }
/* Long lists below the fold: the browser skips their layout and painting until they scroll into view. */
.weeks, .logbook { content-visibility: auto; contain-intrinsic-size: auto 900px; }
.wk-head, .wk-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.wk-head { margin-bottom: 6px; color: var(--muted); font-size: 12.5px; text-align: center; }

.wk { padding: 14px 0 16px; border-bottom: 1px solid var(--rule); }
.wk-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0 12px;
  margin-bottom: 8px;
}
.wk-range { font-family: var(--font-display); font-weight: 800; font-size: 22px; line-height: 1.1; }
.wk.is-current .wk-range { text-decoration: underline 3px var(--plate-yellow); text-underline-offset: 4px; text-shadow: 0 0 14px var(--glow-violet); }
.wk-tag {
  margin-left: 8px;
  padding: 2px 9px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 12px;
  vertical-align: 2px;
}
.wk-avg {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 27px;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.wk-avg small { margin-left: 0.15em; font-size: 0.52em; color: var(--muted); }
.wk-avg .delta { margin-left: 8px; font-size: 14px; }
.wk-sub { grid-column: 2; color: var(--muted); font-size: 12.5px; text-align: right; }

.wk-day {
  display: grid;
  align-content: start;
  gap: 2px;
  min-height: 66px;
  padding: 6px 3px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: var(--glass);
  text-align: center;
  font: inherit;
  color: inherit;
}
button.wk-day { cursor: pointer; }
button.wk-day:hover { border-color: var(--plate-green); box-shadow: 0 0 12px -3px rgba(92, 214, 255, 0.6); }
.wk-day.is-empty { background: transparent; border-style: dashed; }
.wk-day.is-future { background: transparent; border-color: transparent; }
.wk-day.is-today { border-color: var(--plate-yellow); box-shadow: inset 0 0 0 1px var(--plate-yellow), 0 0 14px -2px var(--glow-violet); }
.wk-num { color: var(--muted); font-size: 12px; line-height: 1.2; }
.wk-day.is-today .wk-num { color: var(--ink); font-weight: 600; }
.wk-kg { min-height: 1.2em; font-weight: 600; font-size: 14px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.wk-mark { display: flex; align-items: center; justify-content: center; gap: 3px; min-height: 16px; font-size: 13px; }

.wk-facts { display: flex; flex-wrap: wrap; gap: 2px 22px; margin-top: 10px; }
.wk-facts > div { display: flex; align-items: baseline; gap: 6px; }
.wk-facts dt { color: var(--muted); font-size: 13px; }
.wk-facts dd { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.wk-facts dd small { color: var(--muted); font-weight: 400; }
.wk-facts .emoji { margin-right: 4px; }
#btn-weeks-more { margin-top: 16px; }

/* Logbook */
.logbook { margin-top: 44px; }
.log-month {
  margin: 18px 0 2px;
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
}
.log-row {
  display: grid;
  grid-template-columns: 50px minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 0.9fr) 34px;
  grid-template-areas:
    "day weight kcal train sleep mood"
    "day garmin garmin garmin garmin garmin"
    "day note note note note note";
  align-items: center;
  gap: 2px 14px;
  width: 100%;
  padding: 12px 8px 12px 0;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  text-align: left;
  font: inherit;
}
button.log-row { cursor: pointer; }
button.log-row:hover { background: linear-gradient(90deg, rgba(164, 92, 255, 0.14), rgba(63, 107, 255, 0.06) 60%, transparent); }
.log-row small { color: var(--muted); font-weight: 400; }
.log-day { grid-area: day; display: grid; justify-items: start; line-height: 1; }
.log-day b { font-family: var(--font-display); font-weight: 800; font-size: 28px; }
.log-day small { margin-top: 3px; font-size: 13px; }
.log-row.is-today .log-day b { text-decoration: underline 3px var(--plate-yellow); text-underline-offset: 4px; }
.log-weight { grid-area: weight; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.log-kcal { grid-area: kcal; font-variant-numeric: tabular-nums; white-space: nowrap; }
.log-macro { display: block; font-size: 12.5px; line-height: 1.3; }
.log-train { grid-area: train; display: flex; align-items: center; gap: 8px; min-width: 0; }
.log-mood { grid-area: mood; font-size: 20px; text-align: center; }
.log-sleep { grid-area: sleep; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Garmin's numbers for the day: one quiet line under the stats. */
.log-garmin { grid-area: garmin; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.log-note {
  grid-area: note;
  display: -webkit-box;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.delta { margin-left: 4px; font-style: normal; font-weight: 600; font-size: 13px; }
.delta.is-down { color: var(--good-text); }
.delta.is-up { color: var(--muted); }
.kcal-over { color: var(--bad-text); font-weight: 600; }
.kcal-under { color: var(--muted); }
.none { color: var(--muted); }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
#btn-more { margin-top: 16px; }

/* ---------- floating button, toasts, confetti ---------- */

.fab {
  position: fixed;
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 0 22px 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--cosmic);
  color: #fff;
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
  box-shadow: 0 0 28px -2px var(--glow-violet), 0 10px 28px rgba(0, 0, 0, 0.5);
}
.fab svg { width: 22px; height: 22px; }

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 40;
  display: grid;
  gap: 8px;
  width: min(440px, calc(100% - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid rgba(164, 92, 255, 0.45);
  border-radius: 12px;
  background: rgba(17, 12, 39, 0.94);
  color: var(--ink);
  font-size: 15px;
  box-shadow: 0 0 24px -4px var(--glow-violet), 0 10px 30px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  animation: toast-in 0.25s ease-out both;
}
.toast a { color: inherit; font-weight: 600; white-space: nowrap; }
.toast.is-error { background: var(--plate-red); color: #fff; }
.toast.is-leaving { animation: toast-out 0.3s ease-in both; }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(8px); opacity: 0; } }

.confetti { position: fixed; inset: 0; z-index: 50; width: 100%; height: 100%; pointer-events: none; }

/* ---------- sheets (dialogs) ---------- */

dialog.sheet {
  width: min(560px, calc(100% - 32px));
  max-height: min(88vh, 900px);
  padding: 0;
  border: 1px solid rgba(164, 92, 255, 0.4);
  border-radius: 20px;
  background:
    radial-gradient(ellipse 80% 40% at 100% 0%, rgba(63, 107, 255, 0.18), transparent 70%),
    radial-gradient(ellipse 70% 40% at 0% 100%, rgba(164, 92, 255, 0.16), transparent 70%),
    var(--surface);
  color: var(--ink);
  box-shadow: 0 0 60px -10px var(--glow-violet), 0 30px 80px rgba(0, 0, 0, 0.6);
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-in 0.22s ease-out; }
dialog.sheet::backdrop { background: rgba(3, 2, 8, 0.8); }
@keyframes sheet-in { from { transform: translateY(16px); opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }

#entry-form { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 14px 6px 22px;
}
.sheet-head h2 { font-family: var(--font-display); font-weight: 800; font-size: 28px; line-height: 1.1; }
.sheet-body {
  display: grid;
  flex: 1 1 auto;
  gap: 18px;
  min-height: 0;
  padding: 8px 22px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
}
.sheet-foot .btn-primary { min-width: 150px; margin-left: auto; }
.is-busy .sheet-body { opacity: 0.7; pointer-events: none; }

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

.field { display: grid; align-content: start; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field > label, .field > legend { padding: 0; font-weight: 600; font-size: 15px; }
fieldset.field > legend { margin-bottom: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-row.is-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.field > .sub-label { color: var(--muted); font-weight: 500; font-size: 13.5px; }
.legend-note { margin-left: 6px; color: var(--muted); font-weight: 400; font-size: 13px; }

input, textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  background: rgba(3, 2, 8, 0.55);
  color: var(--ink);
  font: inherit;
  font-size: 17px; /* 16px+ keeps iOS from zooming in */
}
input:hover, textarea:hover { border-color: var(--steel); }
input:focus, textarea:focus { border-color: var(--plate-yellow); box-shadow: 0 0 12px -2px var(--glow-violet); outline: none; }
input::placeholder, textarea::placeholder { color: var(--steel); }
textarea { min-height: 66px; line-height: 1.4; resize: vertical; }

.with-unit { position: relative; display: flex; align-items: center; }
.with-unit input { padding-right: 52px; }
.with-unit .unit { position: absolute; right: 12px; color: var(--muted); font-size: 15px; pointer-events: none; }
.with-unit.is-narrow input { padding-right: 28px; }

.stepper { display: grid; grid-template-columns: 46px minmax(0, 1fr) 46px; align-items: center; gap: 6px; }
.stepper input { text-align: center; padding-right: 40px; padding-left: 12px; }
.step {
  display: grid;
  place-items: center;
  height: 47px;
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  background: rgba(3, 2, 8, 0.55);
  cursor: pointer;
}
.step:hover { border-color: var(--steel); }
.step svg { width: 18px; height: 18px; }

.date-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.date-row input { flex: 1 1 170px; width: auto; }

.hint { color: var(--muted); font-size: 13px; line-height: 1.4; }
.hint.is-over { color: var(--bad-text); }
.hint.is-ok { color: var(--good-text); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  background: rgba(3, 2, 8, 0.55);
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
}
.chip:hover { border-color: var(--steel); }
.chip[aria-pressed="true"] { border-color: transparent; background: var(--cosmic); color: #fff; box-shadow: 0 0 14px -2px var(--glow-violet); }

.moods { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.mood {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 2px;
  border: 1.5px solid var(--rule);
  border-radius: 12px;
  background: rgba(3, 2, 8, 0.55);
  color: var(--ink-2);
  font-size: 12.5px;
  cursor: pointer;
}
.mood:hover { border-color: var(--steel); }
.mood .emoji { font-size: 24px; line-height: 1.15; }
.mood[aria-pressed="true"] { border-color: var(--plate-yellow); background: rgba(164, 92, 255, 0.16); box-shadow: inset 0 0 0 1px var(--plate-yellow), 0 0 16px -3px var(--glow-violet); color: var(--ink); font-weight: 600; }

.form-error { color: var(--bad-text); font-weight: 600; font-size: 15px; }
.form-msg { color: var(--good-text); font-size: 14px; }
.form-msg.is-error { color: var(--bad-text); }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.settings-group { display: grid; gap: 12px; padding-bottom: 22px; border-bottom: 1px solid var(--rule); }
.settings-group:last-child { padding-bottom: 4px; border-bottom: 0; }
.settings-group h3 { font-family: var(--font-display); font-weight: 800; font-size: 21px; }
.settings-group form { display: grid; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.span-2 { grid-column: 1 / -1; }

.noscript { padding: 24px; text-align: center; }

/* ---------- responsive ---------- */

@media (min-width: 960px) {
  .columns { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }
  .chart-box { height: 280px; }
  .log-row {
    grid-template-columns: 50px 170px 140px 160px 110px 36px minmax(0, 1fr);
    grid-template-areas:
      "day weight kcal train sleep mood note"
      "day garmin garmin garmin garmin garmin note";
    column-gap: 16px;
  }
  .log-note { padding-left: 8px; }
}

@media (max-width: 1000px) {
  /* Six stats as two rows of three. */
  .week { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .week > .stat { grid-column: span 2; }
}

@media (max-width: 760px) {
  :root { --pad: 16px; }
  .barbell { margin: 0 calc(-1 * var(--pad)); overflow: hidden; aspect-ratio: 720 / 208; }
  .barbell svg { width: 118%; max-width: none; margin-left: -9%; }
  .platform-inner { gap: 18px; padding-top: 22px; padding-bottom: 26px; }
  .readout { grid-template-columns: 1fr; gap: 18px; }
  .facts { grid-template-columns: 1fr 1fr; row-gap: 16px; }
  .facts > div:nth-child(odd) { padding-left: 0; border-left: 0; }
  .week { grid-template-columns: 1fr 1fr; }
  .week > .stat { grid-column: auto; }
  .stat-value { font-size: 30px; }
}

@media (max-width: 640px) {
  dialog.sheet {
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: 20px 20px 0 0;
  }
  dialog.sheet[open] { animation: sheet-up 0.28s cubic-bezier(0.2, 0.8, 0.3, 1); }
  .sheet-head { padding-left: 18px; }
  .sheet-body { padding-left: 18px; padding-right: 18px; }
  .sheet-foot { padding-left: 18px; padding-right: 18px; }

  .log-row {
    grid-template-columns: 42px minmax(0, 1fr) minmax(0, 1fr) 28px;
    grid-template-areas:
      "day weight kcal mood"
      "day train sleep sleep"
      "day garmin garmin garmin"
      "day note note note";
    column-gap: 10px;
  }
  .log-train { font-size: 14px; }
  .brand { font-size: 20px; }
}

@media (max-width: 480px) {
  .field-row:not(.is-3), .grid-2 { grid-template-columns: 1fr; }
  .streak { padding: 3px 10px; font-size: 14px; }

  .wk-head, .wk-days { gap: 3px; }
  .wk-head { font-size: 11.5px; }
  .wk-day { min-height: 58px; padding: 5px 2px; border-radius: 7px; }
  .wk-num { font-size: 11px; }
  .wk-kg { font-size: 13px; }
  .wk-mark { min-height: 14px; font-size: 11px; }
  .wk-range { font-size: 19px; }
  .wk-avg { font-size: 23px; }
  .wk-facts { gap: 2px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}
