/* ============================================================================
   AP LIFE — design tokens + component primitives
   ============================================================================

   ONE token layer. Every colour, space, radius, duration and type step in the
   product resolves here. Nothing downstream should hard-code a hex value.

   DIRECTION: dark-first, layered graphite. Depth comes from SURFACE STEPS and
   hairline borders, not from shadows — a dark UI that leans on shadows just
   looks muddy. One accent (electric cobalt blue) carries "active / on-track /
   primary"
   and nothing else competes with it; amber and coral are semantic only. The
   greys are deliberately warm-neutral rather than blue-grey, because a blue-grey
   dark theme reads clinical and this product is personal.

   TYPE: one family (Archivo). The old UI used a serif display face for data,
   which made a performance dashboard read like a magazine. Hierarchy now comes
   from size, weight and tracking — which is also one fewer font to download on
   cellular.

   MIGRATION: the Tailwind CDN config in base.html maps its legacy colour names
   (paper-*, ink-*, surface-*, accent) onto these variables, so pages not yet
   rebuilt pick up the new palette automatically instead of staying light while
   the shell goes dark.
   ========================================================================= */

:root {
  /* ---- Surfaces: five steps, each a visible but quiet increment ---------- */
  --bg:            #0b0c0e;   /* page — near-black, faintly warm, never #000 */
  --surface-1:     #131518;   /* sections */
  --surface-2:     #191c20;   /* cards */
  --surface-3:     #212529;   /* inputs, interactive rests */
  --surface-4:     #2b3036;   /* hover / pressed */
  --surface-sel:   rgba(53, 104, 245, .12);   /* accent-tinted selection */

  /* ---- Lines: hairlines do the work shadows would do in a light UI ------- */
  --line:          #24282d;
  --line-strong:   #343a41;

  /* ---- Text ------------------------------------------------------------- */
  --text:          #f4f5f3;   /* soft off-white, not pure white */
  --text-2:        #a7aeb5;
  --text-3:        #6e767e;
  /* White, not near-black: the accent is now a mid-cobalt FILL, and dark text
     on it fails contrast. This is the token that makes the button legible. */
  --text-on-accent:#ffffff;

  /* ---- Accent: ONE electric-cobalt hue, in two calibrated steps ---------
     No single blue can be both a FILL with readable white text on it and
     accent-coloured TEXT on near-black. Measured against #0b0c0e:

        #3568F5   white-on-fill 4.72 : the button is the control that has to
                                       be readable mid-set, so it takes the
                                       margin; 4.50 was cutting it too fine
                  fill-on-page  4.15 : fine for a graphic (FAB, meter, bar)
        #6EA8FF   on page       8.11 : the text step
                  on a card     7.09

     So --accent FILLS and --accent-text WRITES. Same hue (~220 deg), so it
     still reads as one blue. Using --accent for text is the bug to avoid. */
  --accent:        #3568f5;   /* electric cobalt - fills, buttons, FAB, meters */
  --accent-text:   #6ea8ff;   /* the same blue, as TEXT on a dark surface */
  --accent-dim:    #2a56cc;   /* pressed / hover on a fill */
  --accent-soft:   rgba(53, 104, 245, .15);
  --accent-line:   rgba(53, 104, 245, .42);

  /* ---- Semantic. The accent doubles as "good/on-track", so there is no
         separate green competing with it — that is how a dashboard turns into
         a christmas tree. --------------------------------------------------- */
  --warn:          #f0a93b;
  --warn-soft:     rgba(240, 169, 59, .13);
  --danger:        #ff6b6b;
  --danger-soft:   rgba(255, 107, 107, .12);

  /* ---- Radius: four steps, applied by ROLE, not uniformly ---------------- */
  --r-xs: 4px;    /* chips, tags */
  --r-sm: 8px;    /* inputs, small buttons */
  --r-md: 14px;   /* cards */
  --r-lg: 20px;   /* sheets, hero blocks */
  --r-pill: 999px;

  /* ---- Space ------------------------------------------------------------ */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 48px;

  /* ---- Motion: fast enough to feel like feedback, never like waiting ----- */
  --t-fast: 120ms;
  --t-base: 180ms;
  --t-slow: 260ms;
  --ease: cubic-bezier(.4, 0, .2, 1);

  /* ---- Layout ----------------------------------------------------------- */
  --nav-h: 60px;                 /* mobile bottom bar, excl. safe area */
  --sidebar-w: 232px;            /* desktop rail */
  --tap: 44px;                   /* minimum comfortable target */

  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;

  color-scheme: dark;
}

/* Light mode is a genuine second design, not an inversion: the surface STEPS
   go the other way (page slightly grey, cards white) and the accent darkens so
   it still passes contrast on a light ground. */
:root[data-theme="light"] {
  --bg:            #f2f3f0;
  --surface-1:     #f8f9f7;
  --surface-2:     #ffffff;
  --surface-3:     #f0f1ee;
  --surface-4:     #e5e7e2;
  --surface-sel:   rgba(29, 78, 216, .10);
  --line:          #e2e4de;
  --line-strong:   #cbcfc6;
  --text:          #14161a;
  --text-2:        #545c63;
  --text-3:        #8a9199;
  --text-on-accent:#ffffff;
  /* Light mode needs only ONE step: #1D4ED8 carries white text at 6.70 AND
     reads on the light ground at 6.02, so fill and text are the same token. */
  --accent:        #1d4ed8;
  --accent-text:   #1d4ed8;
  --accent-dim:    #1740b0;
  --accent-soft:   rgba(29, 78, 216, .11);
  --accent-line:   rgba(29, 78, 216, .32);
  --warn:          #a8620b;
  --warn-soft:     rgba(168, 98, 11, .11);
  --danger:        #c0392f;
  --danger-soft:   rgba(192, 57, 47, .10);
  color-scheme: light;
}

/* ========================================================================= */
/* Base                                                                      */
/* ========================================================================= */
* { box-sizing: border-box; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* The bottom nav is fixed; reserve its height plus the home indicator so the
     last element on every page is reachable rather than sitting under the bar. */
  /* The capture FAB overhangs the bar by 16px and is opaque, so reserving only
     the bar height left it sitting ON the last line of content. Reserve the
     FAB too. */
  padding-bottom: calc(var(--nav-h) + 40px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 900px) { body { padding-bottom: 0; } }

/* Numbers are the product. Tabular everywhere they line up. */
.tnum, .stat-value, table, .data { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

/* ---- Type scale --------------------------------------------------------- */
.t-display { font-size: clamp(2.2rem, 9vw, 3rem); font-weight: 700; line-height: .95;
             letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.t-stat    { font-size: 1.75rem; font-weight: 700; line-height: 1; letter-spacing: -.03em;
             font-variant-numeric: tabular-nums; }
.t-title   { font-size: 1.4rem; font-weight: 700; line-height: 1.15; letter-spacing: -.022em; }
.t-section { font-size: 1rem; font-weight: 600; line-height: 1.25; letter-spacing: -.01em; }
.t-body    { font-size: .9375rem; line-height: 1.5; }
.t-sm      { font-size: .8125rem; line-height: 1.45; color: var(--text-2); }
.t-label   { font-size: .6875rem; font-weight: 600; letter-spacing: .1em;
             text-transform: uppercase; color: var(--text-3); }
.t-unit    { font-size: .8em; font-weight: 500; color: var(--text-3); letter-spacing: 0; }

.muted   { color: var(--text-2); }
.faint   { color: var(--text-3); }
.on      { color: var(--accent-text); }
.warn    { color: var(--warn); }
.danger  { color: var(--danger); }

h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ========================================================================= */
/* Layout shells                                                             */
/* ========================================================================= */
.shell { display: block; }

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--s-4) var(--s-4) var(--s-7);
}

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
  /* Desktop gets a genuinely wider workspace rather than a phone column
     floating in the middle of a 1440px screen. */
  .page { max-width: 1080px; padding: var(--s-7) var(--s-7) var(--s-8); }
  .page--wide { max-width: 1320px; }
}

/* ---- Desktop sidebar ---------------------------------------------------- */
.sidebar { display: none; }
@media (min-width: 900px) {
  .sidebar {
    display: flex; flex-direction: column; gap: var(--s-1);
    background: var(--surface-1);
    border-right: 1px solid var(--line);
    padding: var(--s-5) var(--s-3);
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
  }
  .sidebar .brand { padding: 0 var(--s-3) var(--s-5); }
  .sidebar .navgroup { margin-top: var(--s-4); }
  .sidebar a {
    display: flex; align-items: center; gap: var(--s-3);
    padding: 9px var(--s-3); border-radius: var(--r-sm);
    color: var(--text-2); font-size: .9rem; font-weight: 500;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  }
  .sidebar a:hover { background: var(--surface-3); color: var(--text); }
  .sidebar a.active { background: var(--surface-sel); color: var(--accent-text); }
  .sidebar a .ico { width: 18px; flex: none; opacity: .9; }
}

/* ---- Brand -------------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: var(--accent); color: var(--text-on-accent);
  display: grid; place-items: center;
  font-weight: 700; font-size: .72rem; letter-spacing: -.03em;
}
.brand-word { font-weight: 700; letter-spacing: .01em; font-size: .95rem; }

/* ---- Mobile top bar: intentionally minimal. The old one spent a whole row
       on a wordmark, a capture pill and a profile switcher. ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--s-3);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) var(--s-4) 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
@media (min-width: 900px) { .topbar { display: none; } }
.topbar .spacer { flex: 1; }

/* ---- Mobile bottom nav: 4 destinations + a centre capture action --------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface-1) 94%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (min-width: 900px) { .tabbar { display: none; } }
.tabbar a, .tabbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; height: var(--nav-h); background: none; border: 0;
  color: var(--text-3); font-size: .625rem; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tabbar a.active { color: var(--accent-text); }
.tabbar a.active .ico { transform: translateY(-1px); }
.tabbar .ico { width: 21px; height: 21px; transition: transform var(--t-fast) var(--ease); }

/* The capture action sits dead centre, in the thumb zone, because it is the
   most-used control in the product and it used to live in the top-right
   corner — the least reachable point on a phone. */
.tabbar .fab-slot { position: relative; }
/* `.tabbar button` above is (0,1,1) and would otherwise beat a bare `.fab`
   (0,1,0), stripping the accent background and shrinking the glyph to the 10px
   tab-label size. Scoping the selector to .tabbar restores the intended win. */
.tabbar .fab {
  position: absolute; left: 50%; top: -16px; transform: translateX(-50%);
  width: 52px; height: 52px; border-radius: var(--r-pill);
  background: var(--accent); color: var(--text-on-accent);
  display: grid; place-items: center; border: 3px solid var(--bg);
  font-size: 1.5rem; font-weight: 700; line-height: 1;
  /* No bloom: the system says depth comes from surface steps and hairlines.
     The FAB reads as raised because of the ring against the bar, not a glow. */
  box-shadow: none;
  transition: transform var(--t-fast) var(--ease);
}
.tabbar .fab:active { transform: translateX(-50%) scale(.93); }

/* ========================================================================= */
/* Components                                                                */
/* ========================================================================= */

/* ---- Card --------------------------------------------------------------- */
.card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-4);
}
.card--flush { padding: 0; overflow: hidden; }
.card--accent { border-color: var(--accent-line); background:
  linear-gradient(180deg, var(--accent-soft), transparent 60%), var(--surface-2); }
.card--warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent);
              background: var(--warn-soft); }

/* ---- Section header ----------------------------------------------------- */
.sec { margin-top: var(--s-6); }
.sec:first-child { margin-top: 0; }
.sec-head {
  display: flex; align-items: baseline; gap: var(--s-3);
  margin-bottom: var(--s-3);
}
.sec-head .fill { flex: 1; }
.sec-head a { color: var(--text-3); font-size: .75rem; font-weight: 600; }
.sec-head a:hover { color: var(--accent-text); }

/* ---- Stat: the core data primitive -------------------------------------- */
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .k { font-size: .625rem; font-weight: 600; letter-spacing: .1em;
           text-transform: uppercase; color: var(--text-3); }
.stat .v { font-size: 1.6rem; font-weight: 700; line-height: 1.05;
           letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: .55em; font-weight: 500; color: var(--text-3);
                 letter-spacing: 0; }
.stat .sub { font-size: .6875rem; color: var(--text-3); }
.stat--on .v { color: var(--accent-text); }
.stat--warn .v { color: var(--warn); }

/* Stat grid: dense enough that six numbers are one glance, not one screen. */
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
            background: var(--line); border: 1px solid var(--line);
            border-radius: var(--r-md); overflow: hidden; }
.statgrid > * { background: var(--surface-2); padding: var(--s-3) var(--s-3) 13px; }
@media (max-width: 380px) { .statgrid { grid-template-columns: repeat(2, 1fr); } }

/* ---- Meter -------------------------------------------------------------- */
.meter { height: 5px; border-radius: var(--r-pill); background: var(--surface-4);
         overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: inherit;
             background: var(--accent); transition: width var(--t-slow) var(--ease); }
.meter--warn > i { background: var(--warn); }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-4);
  border-radius: var(--r-sm); border: 1px solid transparent;
  font-family: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--accent); color: var(--text-on-accent); }
.btn--primary:hover { background: var(--accent-dim); }
.btn--ghost { background: var(--surface-3); color: var(--text); border-color: var(--line); }
.btn--ghost:hover { background: var(--surface-4); }
.btn--quiet { background: transparent; color: var(--text-2); }
.btn--quiet:hover { color: var(--text); background: var(--surface-3); }
.btn--danger { background: transparent; color: var(--danger);
               border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn--block { width: 100%; }
.btn--lg { min-height: 54px; font-size: 1rem; border-radius: var(--r-md); }

/* ---- Chips / tags ------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-xs);
  font-size: .6875rem; font-weight: 600; letter-spacing: .03em;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--line);
}
.chip--on { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }
.chip--warn { background: var(--warn-soft); color: var(--warn);
              border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.chip--danger { background: var(--danger-soft); color: var(--danger);
                border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

/* State must never be carried by colour alone — every state chip pairs its
   hue with a glyph, so it survives colour-blindness and greyscale. */
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* ---- Rows / lists ------------------------------------------------------- */
.rows > * + * { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) 0; min-height: var(--tap);
}
.row .grow { flex: 1; min-width: 0; }
/* BLOCK, and min-width:0 on the flex item. As inline siblings a long title and
   sub form one continuous inline run that ignores the flex item's width, which
   pushed the vacation mode picker 59px off every phone. The _ui.html row macro
   had always set display:block inline; every hand-written row now inherits it
   instead of having to remember. */
.row .title { font-size: .9375rem; font-weight: 500; display: block; min-width: 0;
              overflow-wrap: anywhere; }
.row .sub { font-size: .75rem; color: var(--text-3); display: block; min-width: 0;
            overflow-wrap: anywhere; }
.row a.title:hover { color: var(--accent-text); }

/* Tappable list rows need real feedback on touch, where there is no hover. */
.row--tap { border-radius: var(--r-sm); padding-left: var(--s-3); padding-right: var(--s-3);
            margin: 0 calc(var(--s-3) * -1); transition: background var(--t-fast) var(--ease); }
.row--tap:active { background: var(--surface-3); }

/* ---- Inputs ------------------------------------------------------------- */
input, select, textarea {
  font-family: inherit;
  /* 16px minimum: anything smaller makes iOS Safari zoom the page on focus,
     which is jarring and then leaves the layout scrolled sideways. */
  font-size: 16px;
  color: var(--text);
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 11px var(--s-3);
  min-height: var(--tap);
  width: 100%;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent-line); background: var(--surface-2);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
                    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: var(--s-7);
}
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }

/* ---- Segmented control -------------------------------------------------- */
.seg { display: inline-flex; background: var(--surface-3); border: 1px solid var(--line);
       border-radius: var(--r-sm); padding: 3px; gap: 3px; }
.seg a, .seg button {
  padding: 7px var(--s-3); border-radius: 6px; border: 0; background: none;
  color: var(--text-2); font: inherit; font-size: .8125rem; font-weight: 600;
  cursor: pointer; min-height: 36px;
}
.seg .active { background: var(--surface-1); color: var(--text); }

/* ---- Bottom sheet: the mobile-native pattern for a light action, instead of
       a full page navigation that loses your place. ------------------------ */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55);
  opacity: 0; pointer-events: none; transition: opacity var(--t-base) var(--ease);
}
.sheet-backdrop[data-open] { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
  background: var(--surface-1);
  border-top: 1px solid var(--line-strong);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--s-3) var(--s-4) calc(var(--s-5) + env(safe-area-inset-bottom, 0px));
  transform: translateY(101%);
  transition: transform var(--t-slow) var(--ease);
  max-height: 88vh; overflow-y: auto;
}
.sheet[data-open] { transform: translateY(0); }
.sheet .grabber { width: 36px; height: 4px; border-radius: var(--r-pill);
                  background: var(--line-strong); margin: 0 auto var(--s-4); }
@media (min-width: 900px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 12vh; transform: translate(-50%, 12px);
           width: min(520px, 92vw); border-radius: var(--r-lg); border: 1px solid var(--line-strong);
           opacity: 0; transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease); }
  .sheet[data-open] { transform: translate(-50%, 0); opacity: 1; }
  .sheet .grabber { display: none; }
}

/* ---- Empty state: an empty domain should read as an invitation, never as a
       broken page. ------------------------------------------------------- */
.empty { text-align: center; padding: var(--s-7) var(--s-4); }
.empty .t { font-size: 1.05rem; font-weight: 600; margin-bottom: 6px; }
.empty .d { font-size: .875rem; color: var(--text-2); max-width: 42ch;
            margin: 0 auto var(--s-4); }

/* ---- Skeleton ----------------------------------------------------------- */
.skel { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-4) 50%,
        var(--surface-3) 75%); background-size: 200% 100%;
        animation: shimmer 1.3s infinite; border-radius: var(--r-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- HTMX feedback: never leave someone wondering whether it saved ------- */
.htmx-indicator { opacity: 0; transition: opacity var(--t-fast) var(--ease); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-request .btn { pointer-events: none; opacity: .6; }

/* ---- Toast -------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 14px);
  z-index: 60; background: var(--surface-4); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  padding: 10px var(--s-4); font-size: .8125rem; font-weight: 600;
  animation: rise var(--t-base) var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---- Wide content must scroll in its own container, never the page ------- */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll-x > table { min-width: 34rem; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---- Week: the day timeline --------------------------------------------
   NOT a seven-column calendar. A week squeezed into seven columns on a 375px
   phone gives each day 50px, which is enough for a coloured block and nothing
   you can actually read. So: a vertical stack of days, each one a small
   timeline. The time gutter is fixed-width so the eye runs straight down it,
   and an item with no time leaves the gutter blank rather than claiming
   midnight. ------------------------------------------------------------- */
.wk-day { margin-bottom: var(--s-4); }
.wk-day-head {
  display: flex; align-items: baseline; gap: var(--s-3);
  padding: 0 0 var(--s-2); border-bottom: 1px solid var(--line);
  margin-bottom: var(--s-2);
}
.wk-day-head .d { font-size: .8125rem; font-weight: 700; letter-spacing: .06em;
                  text-transform: uppercase; }
.wk-day-head .n { font-size: .75rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.wk-day-head .fill { flex: 1; }
.wk-day--today .wk-day-head { border-bottom-color: var(--accent-line); }
.wk-day--today .wk-day-head .d { color: var(--accent-text); }
/* A past day recedes rather than disappearing — what already happened is
   context, not clutter. */
.wk-day--past .wk-day-head .d, .wk-day--past .wk-item .t { color: var(--text-2); }

.wk-item { display: flex; gap: var(--s-3); padding: 9px 0; min-height: var(--tap);
           align-items: flex-start; }
.wk-item + .wk-item { border-top: 1px solid var(--line); }
.wk-time { flex: none; width: 62px; padding-top: 2px;
           font-size: .75rem; font-weight: 600; color: var(--text-2);
           font-variant-numeric: tabular-nums; }
.wk-time.none { color: var(--text-3); font-weight: 500; }
.wk-body { flex: 1; min-width: 0; }
.wk-item .t { font-size: .9375rem; font-weight: 600; display: block; }
/* The title block IS the target when it links somewhere: a 23px line of text is
   a comfortable click and a missed tap. See the 44px rule. */
.wk-item a.t { min-height: var(--tap); display: flex; flex-direction: column;
               justify-content: center; }
.wk-item a.t:hover { color: var(--accent-text); }
.wk-item a.t .s { font-weight: 400; }
.wk-item .s { font-size: .75rem; color: var(--text-3); display: block; margin-top: 1px; }
.wk-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
/* Done work is struck through, not hidden: seeing the week fill up is the
   reward, and a day that empties as you work reads as if nothing happened. */
.wk-item--done .t { text-decoration: line-through; color: var(--text-3); }

/* The lock glyph is a BUTTON, and it is a full tap target even though the mark
   itself is small (see the 44px rule). */
.wk-lock { display: inline-flex; align-items: center; justify-content: center;
           gap: 5px; min-height: var(--tap); padding: 0 11px; border-radius: var(--r-xs);
           border: 1px solid var(--line); background: var(--surface-3);
           color: var(--text-2); font: inherit; font-size: .6875rem; font-weight: 600;
           letter-spacing: .03em; cursor: pointer; }
.wk-lock:hover { background: var(--surface-4); color: var(--text); }
.wk-lock--locked { background: var(--surface-4); color: var(--text); }
.wk-lock--flex { background: var(--accent-soft); color: var(--accent-text);
                 border-color: var(--accent-line); }
.wk-lock--icon { min-width: var(--tap); padding: 0; font-size: 1.05rem; line-height: 1; }

/* Inline day form, opened from the day header. `details` so it works with no
   JavaScript at all — the gym has no signal and the phone is one-handed. */
.wk-form { margin-top: var(--s-2); padding: var(--s-3); background: var(--surface-1);
           border: 1px solid var(--line); border-radius: var(--r-sm); }
.wk-form summary { cursor: pointer; list-style: none; font-size: .75rem;
                   font-weight: 600; color: var(--text-3); min-height: var(--tap);
                   display: flex; align-items: center; }
.wk-form summary::-webkit-details-marker { display: none; }
.wk-form summary:hover { color: var(--accent-text); }
.wk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2);
           margin-top: var(--s-2); }
.wk-grid .full { grid-column: 1 / -1; }
.wk-grid input, .wk-grid select, .wk-grid textarea {
  width: 100%; min-height: var(--tap); padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm); }
.wk-grid textarea { padding: 10px; min-height: 66px; }

/* A proposed change is shown BEFORE it happens, never after. */
.wk-move { display: flex; align-items: baseline; gap: var(--s-2); padding: 7px 0;
           font-size: .875rem; }
.wk-move + .wk-move { border-top: 1px solid var(--line); }
.wk-move .arrow { color: var(--accent-text); font-weight: 700; }
.wk-move .why { color: var(--text-3); font-size: .75rem; margin-left: auto;
                text-align: right; }

/* ---- RPE picker: how hard was that set? ---------------------------------
   Tapped mid-set, one-handed, with sweaty fingers, so it is five big targets
   rather than a number field. `check_progression` REQUIRES RPE — the rule that
   adds weight skips any set where it is NULL — so this control is the input to
   progressive overload, not a nicety.

   The checked state uses `input:checked + .face`, deliberately NOT `:has()`.
   This is installed to an iPhone home screen; a sibling selector has worked
   since forever, while `:has()` has a Safari 15.4 floor and fails SILENTLY —
   the tap registers, the value posts, and the chip just never lights up, which
   reads as a broken control. (It did exactly that here first.) ------------- */
.rpe { margin-top: var(--s-4); }
.rpe-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
           margin-top: 6px; }
.rpe-chip { position: relative; display: block; cursor: pointer;
            -webkit-tap-highlight-color: transparent; }
/* The input stays in the DOM and focusable — visually replaced, never removed,
   so the control is still operable by keyboard and screen reader. */
.rpe-chip input { position: absolute; width: 1px; height: 1px; opacity: 0;
                  margin: 0; pointer-events: none; }
.rpe-chip .face {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1px;
  min-height: 52px;                 /* above the 44px floor: this is a gym control */
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-3); color: var(--text-2);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.rpe-chip .n { font-size: 1.05rem; font-weight: 700; line-height: 1; }
.rpe-chip .h { font-size: .5625rem; letter-spacing: .02em; color: var(--text-3);
               text-align: center; }
.rpe-chip:active .face { background: var(--surface-4); }
/* The selected state is carried by OUTLINE plus the accent number, not by a
   background swap: something in the Tailwind bridge wins the background on this
   element, and an outline is drawn outside the box so nothing can override it
   into invisibility. Verified rendering, not assumed. */
.rpe-chip input:checked + .face { outline: 2px solid var(--accent-text);
                                  outline-offset: -2px; }
.rpe-chip input:checked + .face .n,
.rpe-chip input:checked + .face .h { color: var(--accent-text); }
.rpe-chip input:focus-visible + .face { outline: 2px solid var(--accent-text);
                                        outline-offset: 2px; }
@media (max-width: 340px) { .rpe-chip .h { display: none; } }
