/* Project 43. One stylesheet, no framework.
   Identity: the navy title bar and phase colours of the wall sheet, a cool
   pool-tile background, water as the data colour, DIN-style numerals. */

:root {
  --ink: #1F2A44;
  --ink-soft: #3A4660;
  --muted: #667086;
  --bg: #EEF2F5;
  --surface: #FFFFFF;
  --surface-2: #F5F7FA;
  --line: #D6DDE5;
  --line-strong: #B9C3CF;
  --rail: #1F2A44;
  --rail-ink: #E9EEF6;
  --water: #4F9BD0;
  --water-deep: #2C6C9C;
  --hit: #2F7F6F;
  --miss: #C0504D;
  --warn: #B8742A;
  --btn-bg: #1F2A44;
  --btn-fg: #FFFFFF;
  --focus: #2E7BB8;
  --wt-tile: 60%;
  --wt-row: 38%;
  --font-display: "Bahnschrift", "DIN Alternate", "DIN 2014", "D-DIN", "Barlow Semi Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, Cantarell, sans-serif;
  --r-sm: 5px;
  --r: 9px;
  --rail-w: 228px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #E4EAF3;
    --ink-soft: #C3CCDA;
    --muted: #94A0B4;
    --bg: #0D1626;
    --surface: #142039;
    --surface-2: #1A2945;
    --line: #26375A;
    --line-strong: #34486F;
    --rail: #0A1220;
    --rail-ink: #DCE4F0;
    --water: #4F9BD0;
    --water-deep: #2A6A9C;
    --wt-tile: 16%;
    --wt-row: 12%;
    --hit: #57B39E;
    --miss: #E07673;
    --btn-bg: #DCE4F0;
    --btn-fg: #0D1626;
    --focus: #79B6E2;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
/* Components set display; the hidden attribute must still win. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font-body);
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0 0 .4em; letter-spacing: .005em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .6em; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 100; background: var(--surface); padding: 6px 10px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.grow { flex: 1; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }
.error { color: var(--miss); }
.loading { padding: 3rem 0; color: var(--muted); }
.empty { padding: 1rem 0; color: var(--muted); }
.error-box { padding: 2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
ul.plain { list-style: none; padding: 0; margin: 0; }

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

/* ------------------------------------------------------------- shell -- */

#nav {
  position: fixed; inset: 0 auto 0 0; width: var(--rail-w);
  background: var(--rail); color: var(--rail-ink);
  display: flex; flex-direction: column; gap: 14px; padding: 18px 14px; z-index: 20; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 2px 6px; }
.brand-mark {
  font-family: var(--font-display); font-weight: 700; font-size: 1.15rem;
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px;
  background: linear-gradient(to bottom, transparent 58%, var(--water) 58%), rgba(255,255,255,.08);
  color: #fff;
}
.brand-name { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; }
.log-btn { justify-content: center; }
#nav .btn.primary { background: var(--water); color: #0B1A2C; border-color: transparent; }
.plus { font-size: 1.2rem; line-height: 1; margin-right: 2px; }
.nav-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-list a {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 7px;
  text-decoration: none; color: color-mix(in srgb, var(--rail-ink) 82%, transparent);
}
.nav-list a:hover { background: rgba(255,255,255,.06); color: var(--rail-ink); }
.nav-list a.active { background: rgba(255,255,255,.11); color: #fff; box-shadow: inset 3px 0 0 var(--water); }
.nav-list svg, #tabbar svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; flex: none; }
.nav-foot { margin-top: auto; display: grid; gap: 6px; padding: 0 8px; }
.nav-foot a, .nav-foot .linklike { color: color-mix(in srgb, var(--rail-ink) 70%, transparent); text-align: left; }

.shell { margin-left: var(--rail-w); padding: 26px 34px 60px; max-width: calc(1320px + var(--rail-w)); }
main:focus { outline: none; }
#tabbar { display: none; }

.banner {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px; margin-bottom: 14px;
  border-radius: var(--r); background: var(--water); color: #0B1A2C; text-decoration: none; font-weight: 600;
}
.pulse { width: 10px; height: 10px; border-radius: 50%; background: #0B1A2C; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

@media (max-width: 860px) {
  #nav { transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  body.nav-open #nav { transform: none; box-shadow: 0 0 0 100vmax rgba(10,18,32,.45); }
  .shell { margin-left: 0; padding: 16px 14px calc(88px + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.6rem; }
  #tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    position: fixed; inset: auto 0 0 0; z-index: 15; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--rail); color: var(--rail-ink);
  }
  #tabbar a, #tabbar button {
    display: grid; justify-items: center; gap: 2px; padding: 4px 0; border: 0; background: none;
    text-decoration: none; font-size: .7rem; color: color-mix(in srgb, var(--rail-ink) 72%, transparent);
  }
  #tabbar .active { color: #fff; }
  #tabbar .tab-log {
    width: 56px; height: 56px; margin: -22px auto 0; border-radius: 50%; font-size: 1.9rem; line-height: 1;
    background: var(--water); color: #0B1A2C; box-shadow: 0 0 0 5px var(--rail); place-items: center;
  }
}

/* --------------------------------------------------------- controls -- */

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; min-height: 36px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface);
  cursor: pointer; text-decoration: none; white-space: nowrap; font-weight: 500;
}
.btn:hover { border-color: var(--ink-soft); }
.btn.primary { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--miss); border-color: color-mix(in srgb, var(--miss) 50%, var(--line)); }
.btn.danger:not(.ghost) { background: var(--miss); color: #fff; border-color: var(--miss); }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  width: 30px; height: 30px; display: inline-grid; place-items: center; border: 1px solid transparent;
  border-radius: var(--r-sm); background: none; cursor: pointer; color: var(--muted); font-size: 1rem; flex: none;
}
.icon-btn:hover { border-color: var(--line); color: var(--ink); }
.icon-btn.danger:hover { color: var(--miss); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.linklike { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

.input {
  width: 100%; padding: 7px 10px; min-height: 36px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface);
}
textarea.input { resize: vertical; }
.input:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.input.inline { border-color: transparent; background: transparent; min-height: 30px; padding: 4px 6px; }
.input.inline:hover { border-color: var(--line); }
.input.inline:focus { background: var(--surface); border-color: var(--focus); }
.input.num { width: 64px; text-align: right; }
.input.short { width: 70px; }
.input.small { font-size: .82rem; }
.color { width: 42px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.check { width: 22px; height: 22px; accent-color: var(--hit); flex: none; }
.check-row { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check-row input[type=checkbox] { accent-color: var(--hit); width: 17px; height: 17px; }

.field { display: grid; gap: 4px; }
.field-label { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.hint { font-size: .78rem; color: var(--muted); }
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: start; }
.stack { display: grid; gap: 14px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.toolbar .input { width: auto; min-width: 150px; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; margin: 6px 0 12px; }
.seg button, .seg a { border: 0; background: none; padding: 6px 12px; border-radius: 6px; cursor: pointer; text-decoration: none; color: var(--ink-soft); }
.seg .on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line-strong); font-weight: 600; }
.seg.big { display: flex; background: none; border: 0; padding: 0; gap: 2px; border-bottom: 1px solid var(--line); border-radius: 0; }
.seg.big a { border-radius: 6px 6px 0 0; padding: 9px 14px; }
.seg.big .on { box-shadow: inset 0 -3px 0 var(--water); background: none; }
.seg.big .linklike { margin-left: auto; padding: 8px 6px; }
.count { font-size: .75rem; color: var(--muted); margin-left: 6px; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: .72rem; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; border-radius: 4px; font-size: .72rem; line-height: 1.6;
  background: color-mix(in srgb, var(--c, var(--water)) 20%, var(--surface)); border-left: 3px solid var(--c, var(--water));
}
.chip.active { outline: 1px dashed var(--c); }

/* ----------------------------------------------------------- panels -- */

.page-head { margin-bottom: 18px; }
.lede { color: var(--muted); max-width: 72ch; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; min-width: 0; }
.panel + .panel { margin-top: 0; }
.panel-title { font-size: 1.05rem; margin-bottom: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-head .panel-title { margin: 0; }

.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.dash-grid > .panel { grid-column: span 4; }
.dash-grid > .panel.wide { grid-column: span 8; }
.dash-grid > .panel.full { grid-column: 1 / -1; }
@media (max-width: 1180px) {
  .dash-grid > .panel { grid-column: span 6; }
  .dash-grid > .panel.wide { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .dash-grid > .panel { grid-column: 1 / -1; }
}

/* This week + KPIs */
.kpis { display: grid; gap: 18px; }
.thisweek { border-left: 6px solid var(--phase, var(--water)); padding: 2px 0 2px 16px; }
.tw-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.tw-meta { color: var(--muted); font-size: .88rem; margin: 0 0 4px; }
.tw-meta a { color: inherit; }
.tw-focus { font-size: 1.6rem; margin: 0 0 6px; }
.tw-challenge { color: var(--ink-soft); margin: 0; }
.tw-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.kpi { padding: 14px 16px 4px 0; display: grid; align-content: start; gap: 2px; }
.kpi + .kpi { padding-left: 16px; border-left: 1px solid var(--line); }
.kpi-num { font-family: var(--font-display); font-size: 2.6rem; font-weight: 600; line-height: 1; }
.kpi-num small { font-size: 1.1rem; color: var(--muted); font-weight: 500; }
.kpi-label { font-weight: 600; color: var(--ink-soft); }
.kpi-level { display: grid; gap: 4px; margin-top: 6px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; border: 1px solid var(--line); }
.progress span { display: block; height: 100%; background: var(--water); }
@media (max-width: 760px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .kpi:nth-child(3) { padding-left: 0; border-left: 0; }
  .kpi-num { font-size: 2.1rem; }
}

/* The lane: points against floor and goal */
.lane { position: relative; height: 30px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; margin: 4px 0 26px; }
.lane-water {
  position: absolute; inset: 0 auto 0 0; border-radius: 3px 0 0 3px;
  background: repeating-linear-gradient(90deg, var(--water) 0 18px, color-mix(in srgb, var(--water) 82%, #fff) 18px 20px);
  transition: width .5s ease;
}
.lane-mark { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: 2px solid var(--ink); }
.lane-mark.goal { border-left-style: dashed; }
.lane-mark span { position: absolute; top: calc(100% + 2px); left: 0; transform: translateX(-50%); font-size: .75rem; color: var(--muted); white-space: nowrap; }

/* The chain */
.chain { display: grid; gap: 6px; margin: 8px 0 10px; }
.chain-row { display: grid; grid-template-columns: 112px 1fr; gap: 10px; align-items: center; }
.chain-phase { border-left: 4px solid var(--phase); padding-left: 8px; font-family: var(--font-display); font-weight: 600; font-size: .92rem; }
.chain-tiles { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 5px; }
.tile {
  position: relative; aspect-ratio: 1 / 1; min-width: 0; padding: 0; overflow: hidden; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 5px;
  background: color-mix(in srgb, var(--wt) var(--wt-tile), var(--surface));
}
.tile-water { position: absolute; inset: auto 0 0 0; height: calc(var(--fill) * 100%); background: var(--water); transition: height .4s ease; }
.tile.st-goal .tile-water { background: var(--water-deep); }
.tile-floor { position: absolute; left: 0; right: 0; bottom: calc(var(--floor) * 100%); border-top: 2px dotted color-mix(in srgb, var(--ink) 55%, transparent); }
.tile-num { position: absolute; top: 3px; left: 5px; font-family: var(--font-display); font-size: .74rem; font-weight: 600; color: var(--ink-soft); }
.tile-tag { position: absolute; top: 3px; right: 4px; font-size: .62rem; font-weight: 700; color: var(--ink-soft); }
.tile-mark { position: absolute; bottom: 2px; right: 5px; color: #fff; font-weight: 700; font-size: .85rem; text-shadow: 0 0 2px rgba(0,0,0,.4); }
.tile.st-miss { border-color: color-mix(in srgb, var(--miss) 70%, var(--line)); box-shadow: inset 0 -3px 0 var(--miss); }
.tile.st-future { opacity: .78; }
.tile.st-future .tile-floor { opacity: .4; }
.tile.today { outline: 2px solid var(--ink); outline-offset: 1px; }
.tile:hover { border-color: var(--ink-soft); }
@media (max-width: 760px) {
  .chain-row { grid-template-columns: 1fr; gap: 4px; }
  .chain-tiles { gap: 3px; }
  .tile-num { font-size: .6rem; left: 3px; }
  .tile-tag { display: none; }
}
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .78rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border: 1px solid var(--line-strong); border-radius: 3px; display: inline-block; }
.legend .lg-hit { background: var(--water); }
.legend .lg-miss { box-shadow: inset 0 -3px 0 var(--miss); }

/* Charts */
.chart-scroll { overflow-x: auto; }
.chart { width: 100%; min-width: 320px; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .bar { fill: color-mix(in srgb, var(--water) 55%, var(--surface)); }
.chart .bar.st-hit { fill: var(--water); }
.chart .bar.st-goal { fill: var(--water-deep); }
.chart .bar.st-miss { fill: color-mix(in srgb, var(--miss) 55%, var(--surface)); }
.chart .floor-mark { stroke: var(--ink); stroke-width: 1.5; }
.chart .avg-line { fill: none; stroke: var(--warn); stroke-width: 2; stroke-linejoin: round; }
.hbars { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; }
.hbars li { display: grid; grid-template-columns: minmax(70px, 34%) 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; }
.hb-label { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.hb-bar { display: block; height: 100%; background: var(--water); border-radius: 5px; }
.hb-value { grid-column: 2; font-size: .75rem; color: var(--muted); }
.spark { overflow: visible; }
.spark polyline { fill: none; stroke: var(--water); stroke-width: 1.8; stroke-linejoin: round; }
.spark circle { fill: var(--ink); }
.spark circle.up { fill: var(--hit); }
.spark circle.down { fill: var(--miss); }
.mini-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.mini-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; padding: 4px 8px 6px 0; border-bottom: 1px solid var(--line); }
.mini-table td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.mini-table tr:last-child td { border-bottom: 0; }
.recent { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.recent a { display: grid; grid-template-columns: 12px 1fr; column-gap: 8px; text-decoration: none; padding: 5px 0; align-items: center; }
.recent a .muted { grid-column: 2; }
.recent a:hover span:first-of-type { text-decoration: underline; }

/* ------------------------------------------------------------- week -- */

.week-head { border-left: 6px solid var(--phase); padding-left: 16px; }
.week-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.week-nav .btn { min-width: 36px; justify-content: center; }
.week-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.week-grid .col { display: grid; gap: 16px; }
@media (max-width: 960px) { .week-grid { grid-template-columns: 1fr; } }
.planned { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.planned-row {
  width: 100%; display: grid; grid-template-columns: 1fr auto 70px; align-items: center; gap: 12px; text-align: left;
  padding: 8px 12px; border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: var(--r-sm);
  background: var(--surface); cursor: pointer;
}
.planned-row:hover { border-color: var(--ink-soft); border-left-color: var(--c); }
.pl-name { font-weight: 600; }
.boxes { display: flex; gap: 4px; }
.box { width: 22px; height: 22px; border: 1.5px solid var(--line-strong); border-radius: 4px; display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.box.done { background: var(--c); border-color: var(--c); color: #fff; }
.days { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.day-title { font-size: .95rem; color: var(--muted); margin-bottom: 6px; }
.session-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.session-card { display: grid; gap: 2px; padding: 9px 12px; border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: var(--r-sm); text-decoration: none; }
.session-card:hover { border-color: var(--ink-soft); border-left-color: var(--c); }
.session-card.active { border-style: dashed; border-left-style: solid; }
.sc-title { font-weight: 600; }
.sc-notes { font-size: .85rem; color: var(--ink-soft); white-space: pre-wrap; }
.guidance { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; }
.guidance dt { font-weight: 700; }
.guidance dd { margin: 0; }

/* ---------------------------------------------------- activity flow -- */

.flow { display: grid; gap: 14px; }
.flow-date { display: flex; align-items: center; gap: 10px; }
.flow-date .input { width: auto; }
.flow-type { border-left: 5px solid var(--c); padding-left: 10px; margin: 2px 0 0; font-size: 1.3rem; }
.type-lists { display: grid; gap: 16px; }
.type-lists h3 { color: var(--ink-soft); font-size: .95rem; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.type-btn {
  display: grid; gap: 2px; text-align: left; padding: 12px 14px; border: 1px solid var(--line);
  border-left: 5px solid var(--c); border-radius: var(--r-sm); background: var(--surface); cursor: pointer;
}
.type-btn:hover { border-color: var(--ink-soft); border-left-color: var(--c); }
.type-name { font-weight: 600; font-size: 1.02rem; }
.type-meta { font-size: .8rem; color: var(--muted); }
.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.mode {
  display: grid; gap: 6px; align-content: start; text-align: left; padding: 16px; border: 1px solid var(--line);
  border-radius: var(--r); background: var(--surface-2); cursor: pointer; min-height: 120px;
}
.mode strong { font-family: var(--font-display); font-size: 1.15rem; }
.mode span { color: var(--muted); font-size: .88rem; }
.mode:hover:not(:disabled) { border-color: var(--ink-soft); background: var(--surface); }
.mode:disabled { cursor: not-allowed; opacity: .6; }
.sticky-actions { position: sticky; bottom: -18px; background: var(--surface); padding: 10px 0 4px; border-top: 1px solid var(--line); }

/* Items */
.items { display: grid; gap: 10px; }
.item-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; counter-reset: item; }
.item { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 10px 9px 12px; background: var(--surface); display: grid; gap: 4px; }
.item-head { display: flex; align-items: center; gap: 10px; }
.item-title { flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 8px; min-width: 0; }
.slot { font-size: .75rem; color: var(--muted); font-weight: 600; min-width: 64px; }
.item-name { font-weight: 600; }
.item-name.missing { color: var(--warn); font-weight: 500; }
.item-actions { display: flex; gap: 0; }
.item-fields { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding-left: 32px; }
.item-fields .input { flex: 1 1 180px; }
.item-fields .input.result { flex: 2 1 240px; border-color: var(--line); background: var(--surface-2); }
.item-dose { font-size: .9rem; color: var(--ink-soft); min-width: 120px; }
.cue { font-size: .82rem; color: var(--muted); margin: 0 0 0 32px; }
.last { font-size: .78rem; color: var(--hit); margin-left: 32px; }
.item.is-done { background: color-mix(in srgb, var(--hit) 7%, var(--surface)); border-color: color-mix(in srgb, var(--hit) 40%, var(--line)); }
.item.is-done .item-name { text-decoration: line-through; text-decoration-color: var(--hit); }
.picker { display: grid; gap: 10px; }
.pick-list { max-height: 46vh; overflow-y: auto; display: grid; gap: 2px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px; }
.pick-row { display: grid; text-align: left; padding: 7px 10px; border: 0; border-radius: 4px; background: none; cursor: pointer; }
.pick-row:hover, .pick-row:focus-visible { background: var(--surface-2); }
.pick-name { font-weight: 600; }
.plan-meta p { margin: 0; }

/* Session page */
.session-head { border-left: 6px solid var(--c); padding-left: 16px; }
.run-bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.clock { font-family: var(--font-display); font-size: 2.6rem; font-weight: 600; letter-spacing: .02em; }
.page > .panel { margin-bottom: 16px; }

/* --------------------------------------------------------- calendar -- */

.cal-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(260px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .cal-layout { grid-template-columns: 1fr; } }
.cal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.cal-head, .cal-week { display: grid; grid-template-columns: 40px repeat(7, minmax(0, 1fr)); }
.cal-head span { padding: 6px 8px; font-size: .78rem; color: var(--muted); font-weight: 600; }
.cal-week { border-top: 1px solid var(--line); }
.cal-wk { display: grid; place-items: start center; padding-top: 6px; font-size: .72rem; color: var(--muted); text-decoration: none; background: var(--surface-2); }
.cal-wk:hover { color: var(--ink); }
.cal-day { min-height: 86px; padding: 4px 5px; border-left: 1px solid var(--line); text-decoration: none; display: grid; align-content: start; gap: 3px; min-width: 0; }
.cal-day:hover { background: var(--surface-2); }
.cal-day.out { color: var(--muted); background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.cal-day.today .cal-num { background: var(--ink); color: var(--surface); border-radius: 50%; }
.cal-day.sel { box-shadow: inset 0 0 0 2px var(--water); }
.cal-num { width: 24px; height: 24px; display: grid; place-items: center; font-size: .82rem; font-weight: 600; }
.cal-chips { display: flex; flex-wrap: wrap; gap: 2px; min-width: 0; }
@media (max-width: 600px) {
  .cal-day { min-height: 58px; padding: 2px; }
  .cal-chips .chip { font-size: 0; width: 8px; height: 8px; padding: 0; border-radius: 50%; border: 0; background: var(--c); }
}
.day-sessions { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.full-session { border-left: 4px solid var(--c); padding-left: 10px; }
.fs-title { font-weight: 600; }
.fs-items { margin: 4px 0; padding-left: 18px; display: grid; gap: 2px; font-size: .9rem; }
.fs-items li { display: flex; flex-wrap: wrap; gap: 0 8px; }
.fs-items li.done span:first-child::after { content: " ✓"; color: var(--hit); }
.fs-items li.missing { color: var(--warn); }

/* ------------------------------------------------------------- plan -- */

.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.plan-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.plan-table th { position: sticky; top: 0; z-index: 1; background: var(--rail); color: var(--rail-ink); font-weight: 600; padding: 7px 6px; text-align: left; white-space: nowrap; }
.plan-table th.slots { text-align: center; box-shadow: inset 0 -3px 0 var(--c); }
.plan-table th.num, .plan-table td.num { text-align: center; }
.plan-table td { padding: 3px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.week-row td { background: color-mix(in srgb, var(--wt) var(--wt-row), var(--surface)); }
.week-row.today td { box-shadow: inset 0 2px 0 var(--ink), inset 0 -2px 0 var(--ink); }
.week-row .wk a { font-weight: 700; text-decoration: none; }
.week-row .dates { white-space: nowrap; color: var(--ink-soft); }
.week-row .focus { min-width: 220px; }
.week-row .challenge { min-width: 180px; color: var(--muted); font-style: italic; }
.week-row .mark { color: var(--hit); font-weight: 700; }
.week-row.st-miss .mark { color: var(--miss); }
.box-cell { padding: 3px 2px !important; text-align: center; }
.tick {
  position: relative; width: 28px; height: 28px; border: 1.5px solid var(--line-strong); border-radius: 4px; background: var(--surface);
  cursor: pointer; font-weight: 700; color: var(--hit); font-size: .95rem;
}
.tick:hover { border-color: var(--ink); }
.tick.detailed::after { content: ""; position: absolute; top: 2px; right: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--water-deep); }
.tick sup { position: absolute; top: -6px; right: -8px; font-size: .62rem; color: var(--muted); }
.phase-row td { padding: 9px 12px; font-size: .86rem; }
.phase-row strong { font-family: var(--font-display); font-size: 1rem; }
.phase-guidance { display: flex; flex-wrap: wrap; gap: 2px 18px; margin-top: 3px; opacity: .92; font-size: .8rem; }
.phase-row.edit td { background: var(--surface-2); border-left: 6px solid var(--phase); }
.phase-edit { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.phase-edit .field:nth-child(5) { grid-column: 1 / -1; }
.plan-table.editing td { padding: 2px 3px; }
.plan-table .handle { white-space: nowrap; cursor: grab; }
.grip { color: var(--muted); letter-spacing: -2px; margin-right: 2px; }
.week-row.dragging { opacity: .4; }
.week-row.drop td { box-shadow: inset 0 3px 0 var(--water); }
.plan-table td.actions { white-space: nowrap; }
.plan-table select.input { min-width: 90px; padding: 3px 6px; min-height: 30px; }
.plan-settings { margin-bottom: 16px; display: grid; gap: 12px; }

/* -------------------------------------------------------- exercises -- */

.lib-table, .bench-table, .slot-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.lib-table th, .bench-table th, .slot-table th { text-align: left; padding: 7px 6px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line-strong); white-space: nowrap; background: var(--surface-2); }
.lib-table td, .bench-table td, .slot-table td { padding: 1px 2px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.lib-table td.name .input { font-weight: 600; min-width: 170px; }
.lib-table td.cue .input { min-width: 220px; }
.lib-table tr.unusable td { background: color-mix(in srgb, var(--warn) 6%, var(--surface)); }
td.saved { animation: saved .9s ease; }
@keyframes saved { from { background: color-mix(in srgb, var(--hit) 22%, var(--surface)); } }
.templates { display: grid; gap: 14px; margin-top: 8px; }
.title-input { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; max-width: 420px; }
.template textarea { margin-bottom: 10px; }
.pool { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pool-chip { padding-right: 0; }
.pool-chip .icon-btn { width: 20px; height: 20px; font-size: .8rem; }
.pool select { width: auto; }

/* ------------------------------------------------------- benchmarks -- */

.bench-table td.test { display: grid; padding: 6px 8px; min-width: 220px; }
.bench-table td.test-edit { min-width: 260px; padding: 4px; }
.bench-table .unit { font-size: .75rem; color: var(--muted); }
.bench-table td.res .input { width: 84px; text-align: center; }
.bench-table td.target { white-space: nowrap; padding: 0 8px; color: var(--hit); font-weight: 600; }
.page > .btn { margin: 10px 0; }
.page > .panel { margin-top: 16px; }

/* ------------------------------------------------------ guide/settings -- */

.guide-grid, .settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 430px), 1fr)); gap: 16px; align-items: start; }
.guide-grid .wide, .settings-grid .wide { grid-column: 1 / -1; }
.guide-list { display: grid; grid-template-columns: minmax(90px, max-content) 1fr; gap: 6px 14px; margin: 0; }
.guide-list dt { font-weight: 700; }
.guide-list dd { margin: 0; }
.guide-item { display: grid; grid-template-columns: 160px 1fr auto; gap: 6px; margin-bottom: 6px; }
.phase-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.phase-card { border-top: 5px solid var(--phase); background: var(--surface-2); border-radius: var(--r-sm); padding: 12px 14px; }
.phase-card .guidance { font-size: .88rem; }
.token-list, .check-list, .order-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.token-list li, .order-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.types-table .input.inline { min-width: 90px; }
.settings-grid h3 { margin-top: 14px; }
.settings-grid form.row .input { flex: 1 1 140px; width: auto; }

/* ------------------------------------------------------ dialog/toast -- */

.modal { border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(580px, 94vw); max-height: 92vh; background: var(--surface); color: var(--ink); }
.modal.wide { width: min(880px, 96vw); }
.modal::backdrop { background: rgba(10, 18, 32, .5); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h2 { margin: 0; font-size: 1.2rem; }
.modal-body { padding: 16px 18px 18px; }
@media (max-width: 600px) {
  .modal, .modal.wide { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
}
.confirm p { margin-bottom: 16px; }
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 1000; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 24px rgba(10,18,32,.25); transition: opacity .3s, transform .3s; max-width: 90vw; }
.toast.error { background: var(--miss); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }
@media (max-width: 860px) { #toasts { bottom: calc(96px + env(safe-area-inset-bottom)); } }

/* ------------------------------------------------------------ login -- */

.login-page { display: grid; place-items: center; min-height: 100vh; background: var(--rail); }
.login { width: min(360px, 92vw); background: var(--surface); border-radius: 14px; padding: 28px; }
.login-mark {
  width: 64px; height: 64px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 16px;
  font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; color: #fff;
  background: linear-gradient(to bottom, var(--rail) 60%, var(--water) 60%);
}

/* Wide editable tables: give inputs room and let the wrapper scroll. */
.lib-table .input.inline { min-width: 96px; }
.lib-table td.name .input { min-width: 190px; }
.lib-table td.cue .input { min-width: 260px; }
.lib-table select.input.inline { min-width: 132px; }
.lib-table td.actions, .slot-table td.actions, .plan-table td.actions { white-space: nowrap; }
.slot-table .input.inline { min-width: 110px; }
.pool select.input.inline { width: auto; min-width: 0; max-width: 150px; }
.templates > .btn { justify-self: start; }
.tick sup { top: -4px; right: -14px; }
.tile-num, .tile-tag { background: color-mix(in srgb, var(--surface) 72%, transparent); border-radius: 3px; padding: 0 3px; line-height: 1.35; }
.flow > .linklike { justify-self: start; }
@media (max-width: 720px) { .chart { min-width: 600px; } }

/* ------------------------------------------------------------- setup -- */

body.gated #nav, body.gated #tabbar, body.gated #active-banner { display: none; }
body.gated .shell { margin-left: 0; max-width: 980px; margin-inline: auto; }
.setup { display: grid; gap: 18px; padding: 10px 0 40px; }
.setup-head h1 { font-size: 2.1rem; }
.setup-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; align-items: stretch; }
.choice { display: grid; gap: 12px; align-content: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; }
.choice:first-child { border-top: 6px solid var(--water); }
.choice h2 { margin: 0; }
.choice .btn { justify-self: start; }
.setup-form { display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; }
.setup-form h2 { margin: 8px 0 0; font-size: 1.1rem; }
.preset-list { display: grid; gap: 6px; }
.preset { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-left: 5px solid var(--c, var(--line)); border-radius: var(--r-sm); }
.preset.on { background: color-mix(in srgb, var(--c, var(--water)) 8%, var(--surface)); }
.preset-nums { display: flex; gap: 12px; }
.preset-nums .field { grid-template-columns: auto auto; align-items: center; gap: 6px; }
.add-custom .input { flex: 1 1 200px; width: auto; }
.add-custom .input.num { flex: 0 0 72px; }
.setup-summary { font-weight: 600; color: var(--ink-soft); }
.equip-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.narrow { max-width: 420px; }

/* ----------------------------------------------------------- sharing -- */

.col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.col-card { display: grid; gap: 4px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); text-decoration: none; background: var(--surface); }
.col-card:hover { border-color: var(--ink-soft); }
.badge.update { color: #fff; background: var(--water-deep); border-color: var(--water-deep); }
.badge.own { color: var(--hit); border-color: color-mix(in srgb, var(--hit) 45%, var(--line)); }
.tpl-list { display: grid; gap: 14px; }
.share-list, .ex-pick { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.pick-group h3 { font-size: .95rem; color: var(--ink-soft); margin: 10px 0 4px; }
.check-list { display: grid; }
.cell-text { display: block; padding: 4px 6px; min-width: 90px; color: var(--ink-soft); }
.lib-table td.name .cell-text { font-weight: 600; color: var(--ink); min-width: 190px; }
.lib-table td.name { white-space: nowrap; }
.lib-table td.name .badge { margin-left: 4px; }
.lib-table td.name .input { display: inline-block; width: auto; }
.people .mini-table td { vertical-align: middle; }
.people .badge { margin-left: 6px; }
.people form.row .input { width: auto; flex: 1 1 160px; }
.setup > .linklike { justify-self: start; }
.add-custom .field { grid-template-columns: auto auto; align-items: center; gap: 6px; }
.narrow-grid { max-width: 640px; }
.people h3 { margin: 22px 0 8px; }

/* ---- several plans ---------------------------------------------------- */
.plan-switch { display: grid; gap: 3px; margin: -4px 6px 4px; color: color-mix(in srgb, var(--rail-ink) 70%, transparent); }
.plan-switch select {
  width: 100%; font: inherit; font-size: .9rem; padding: 6px 8px; border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--rail-ink) 10%, var(--rail)); color: var(--rail-ink);
  border: 1px solid color-mix(in srgb, var(--rail-ink) 25%, transparent);
}
.section-title { font-size: 1rem; margin: 22px 0 10px; color: var(--ink-soft); }
.plan-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.plan-card {
  display: grid; gap: 10px; align-content: start; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 16px 18px;
}
.plan-card.current { border-color: var(--water); box-shadow: inset 0 3px 0 var(--water); }
.plan-card.ps-archived { background: var(--surface-2); }
.pc-head { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.pc-head h3 { margin: 0 0 2px; font-size: 1.1rem; }
.pc-head p { margin: 0; }
.pc-state { margin: 0; font-weight: 600; font-size: .92rem; }
.pc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.pc-stats div { display: grid; gap: 1px; }
.pc-stats dt { font-size: .74rem; color: var(--muted); }
.pc-stats dd { margin: 0; font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; }
.pc-stats small { font-size: .78rem; color: var(--muted); font-weight: 400; }
.pc-acts { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.pc-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: .8rem; color: var(--ink-soft); }

/* One square per week: the chain in miniature. */
.mini-chain { display: flex; flex-wrap: wrap; gap: 2px; }
.mini-chain i {
  width: 9px; height: 9px; border-radius: 2px; background: color-mix(in srgb, var(--line) 70%, var(--surface));
}
.mini-chain .st-hit { background: var(--water); }
.mini-chain .st-goal { background: var(--water-deep); }
.mini-chain .st-miss { background: color-mix(in srgb, var(--miss) 70%, var(--surface)); }
.mini-chain .st-current { background: var(--surface); outline: 1.5px solid var(--ink); outline-offset: -1.5px; }
.mini-chain .st-untracked, .mini-chain .st-ended {
  background: repeating-linear-gradient(135deg, var(--line) 0 2px, transparent 2px 4px);
}

/* Weeks outside the judged range, in the chain and the plan table. */
.tile.st-untracked, .tile.st-ended {
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--line) 60%, transparent) 0 3px, var(--surface) 3px 7px);
}
.tile.st-untracked .tile-floor, .tile.st-ended .tile-floor { display: none; }
.week-row.st-untracked td, .week-row.st-ended td { color: var(--muted); }

.tpl-list { display: grid; gap: 2px; }
.tpl-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.tpl-row:first-child { border-top: 0; }
.tpl-main p { margin: 3px 0 0; }
.tpl-actions { flex-wrap: wrap; justify-content: end; gap: 6px; }
.tpl-swatches { display: grid; grid-template-columns: repeat(2, 8px); gap: 2px; align-content: center; }
.tpl-swatches i { width: 8px; height: 8px; border-radius: 2px; }
.tpl-choice .tpl-swatches { grid-template-columns: repeat(auto-fill, 14px); grid-auto-flow: column; justify-content: start; }
.tpl-choice .tpl-swatches i { width: 14px; height: 6px; border-radius: 3px; }
.tpl-facts { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; }
.seg label { display: flex; align-items: center; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { padding: 6px 12px; cursor: pointer; font-size: .9rem; }
.seg input:checked + span { background: var(--btn-bg); color: var(--btn-fg); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -2px; }
.import-panel { margin-top: 18px; }
.newplan .setup-choices { margin-bottom: 8px; }
.plan-activities table td.actions { white-space: nowrap; text-align: right; }
.range-pick { flex-wrap: wrap; gap: 6px; }
.session-card.off-plan { opacity: .62; border-left-style: dashed; }

@media (max-width: 640px) {
  .plan-cards { grid-template-columns: 1fr; }
  .tpl-row { grid-template-columns: auto 1fr; }
  .tpl-actions { grid-column: 1 / -1; justify-content: start; }
}
.choice h2 { overflow-wrap: anywhere; }
.brand-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
