  /* "Topo": guidebook topo lines on a home-wall board. Granite ground with a T-nut grid,
     chalk-paper panel, pine ink. Pine is you (your messages, actions); topo red is only the
     day's sequence line and "today". */
  :root {
    --bg: #d8d5cd; --panel: #f7f7f4; --line: #d3cfc6; --text: #1f2622; --muted: #646b66;
    --me: #245c45; --me-text: #f7f7f4; --them: #e7e5df; --them-text: #1f2622;
    --topo: #d93a2b; --ok: #2f8a5f; --err: #c2352a; --tnut: rgba(31,38,34,.13);
    --tape-home: #f2b33d; --tape-gym: #19b5a5; --tape-ink: #1b1508;
    --display: "Big Shoulders Display", "Arial Narrow", "Roboto Condensed", sans-serif;
    --body: "Libre Franklin", system-ui, sans-serif;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #101512; --panel: #18201b; --line: #2b352f; --text: #e8ece7; --muted: #95a097;
      --me: #2e7556; --me-text: #f4f7f3; --them: #242d27; --them-text: #e8ece7;
      --topo: #ff5a45; --ok: #4fbf86; --err: #ff6b5c; --tnut: rgba(232,236,231,.07);
      --tape-home: #e9a52c; --tape-gym: #14a597; --tape-ink: #120e04;
    }
  }
  * { box-sizing: border-box; }
  #root { display: contents; }
  [hidden] { display: none !important; }
  body { margin: 0; font: 16px/1.45 var(--body); color: var(--text); height: 100vh; display: flex;
         /* T-nut holes on a training-board grid */
         background: radial-gradient(circle, var(--tnut) 2.4px, transparent 3px) 0 0 / 40px 40px, var(--bg); }
  /* Shell: a rail of sections on the left (a bottom bar on phones), one page to its right. */
  #app { margin: 0 auto; width: 100%; max-width: 1240px; height: 100vh; display: flex; background: var(--panel);
         border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  #app.signed-out { flex-direction: column; align-items: center; justify-content: center; gap: 24px; }
  #app.signed-out .brand { font-size: 44px; padding: 0; }
  #rail { width: 196px; flex: none; display: flex; flex-direction: column; gap: 2px; padding: 18px 12px;
          border-right: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 35%, var(--panel)); }
  #rail a { color: var(--muted); text-decoration: none; font: 700 22px/1 var(--display); letter-spacing: .01em;
            padding: 10px 12px; border-radius: 8px; display: flex; align-items: center; gap: 8px; }
  #rail a:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
  #rail a.active { color: var(--text); background: var(--panel); box-shadow: inset 3px 0 0 var(--topo); }
  #rail a.brand { color: var(--text); font-size: 30px; font-weight: 800; padding: 4px 12px 22px; background: none; box-shadow: none; }
  .badge { font: 700 12px/1 var(--body); background: var(--topo); color: #fff; border-radius: 999px; padding: 3px 7px; }
  #main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-y: auto; }
  #main > #chat-view, #main > #training-view { min-height: 0; flex: 1; }
  #main:has(> #chat-view), #main:has(> #training-view) { overflow: hidden; }
  .page { padding: 28px 32px 64px; max-width: 980px; width: 100%; }
  .page-title { font: 800 46px/1 var(--display); margin: 0 0 8px; letter-spacing: .005em; }
  .lede { color: var(--muted); margin: 0 0 8px; max-width: 70ch; }
  .lede a, .page a { color: var(--me); }
  .section { font: 800 24px/1 var(--display); margin: 32px 0 12px; display: flex; align-items: baseline; gap: 10px; }
  .section .sub, .sub { font: 400 14px var(--body); color: var(--muted); }
  .back { font-size: 14px; text-decoration: none; }
  .back::before { content: "‹ "; }
  @media (max-width: 760px) {
    #app { flex-direction: column-reverse; border: 0; }
    #rail { width: auto; flex-direction: row; justify-content: space-around; padding: 4px 4px
            calc(4px + env(safe-area-inset-bottom, 0px)); border-right: 0; border-top: 1px solid var(--line); }
    #rail a { font-size: 17px; padding: 10px 8px; }
    #rail a.brand { display: none; }
    #rail a.active { box-shadow: inset 0 3px 0 var(--topo); }
    .page { padding: 20px 16px 40px; }
    .page-title { font-size: 36px; }
  }
  :focus-visible { outline: 2px solid var(--topo); outline-offset: 2px; }
  .brand { font: 800 26px/1 var(--display); letter-spacing: .01em; }
  #log { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
  .row { display: flex; }
  .row.me { justify-content: flex-end; }
  .bubble { max-width: min(76%, 62ch); padding: 9px 14px; border-radius: 14px; white-space: pre-wrap;
            word-wrap: break-word; }
  .them .bubble { background: var(--them); color: var(--them-text); border-top-left-radius: 3px; }
  .me .bubble { background: var(--me); color: var(--me-text); border-top-right-radius: 3px; }
  .bubble .time { display: block; text-align: right; font: 11px/1 var(--body);
                  opacity: .65; margin: 3px -4px -2px 0; }
  .meta { font-size: 11px; color: var(--muted); margin: 2px 6px 0; }
  .bubble:has(.att) { max-width: 320px; }
  .bubble.deleted { background: none; color: var(--muted); font-style: italic;
                    box-shadow: inset 0 0 0 1px var(--line); }
  .att { display: block; width: 100%; margin-top: 4px; border-radius: 10px; }
  audio.att { height: 36px; margin: 2px 0; }
  .receipt { align-self: flex-end; font-size: 11px; color: var(--muted); margin: 1px 6px 2px; }
  .receipt.read { color: var(--me); }
  .day { display: flex; align-items: center; gap: 12px; color: var(--muted); margin: 14px 0 4px;
         font: 700 15px/1 var(--display); letter-spacing: .02em; }
  .day::before, .day::after { content: ""; flex: 1; border-top: 1px dashed var(--line); }
  /* Reserves a little headroom above the oldest row so there is always somewhere
     to scroll into, which is what triggers the next page. */
  #banner { flex: none; padding: 9px 14px; font-size: 13px; line-height: 1.35;
            border-bottom: 1px solid var(--line); color: var(--text); background: var(--them); }
  #banner.warning { background: color-mix(in srgb, var(--tape-home) 22%, var(--panel));
                    border-bottom-color: color-mix(in srgb, var(--tape-home) 50%, transparent); }
  .sub { color: var(--muted); font-weight: normal; font-size: 12px; }
  .note.err { color: var(--err); }
  #health-link { display: flex; gap: 8px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
  #health-link input { flex: 1; min-width: 220px; padding: 7px 9px; border-radius: 8px;
                       border: 1px solid var(--line); background: var(--panel); color: var(--text); }
  #health-link button.google { display: inline-flex; align-items: center; gap: 9px;
                               background: #fff; color: #1f1f1f; border: 1px solid #dadce0;
                               border-radius: 8px; padding: 9px 16px; font-size: 14px;
                               font-weight: 500; cursor: pointer; }
  #health-link button.google:hover:not(:disabled) { background: #f7f8f8; }
  #health-link button.google:disabled { opacity: .6; cursor: default; }
  .fallback { font-size: 12px; color: var(--muted); margin-top: 4px; }
  .fallback summary { cursor: pointer; }
  #sleep-rows { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
  .sleep-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
  .sleep-row .d { color: var(--muted); width: 84px; flex: none; font-variant-numeric: tabular-nums; }
  .sleep-row .w { width: 106px; flex: none; color: var(--muted);
                  font-variant-numeric: tabular-nums; }
  .sleep-row .t { width: 62px; flex: none; font-variant-numeric: tabular-nums; }
  .sleep-row .s { width: 44px; flex: none; text-align: right; color: var(--muted);
                  font-variant-numeric: tabular-nums; }
  #stage-legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 2px; }
  #stage-legend .lg { display: grid; grid-template-columns: 10px auto; gap: 2px 7px;
                      align-items: center; flex: 1 1 128px; padding: 7px 9px;
                      border: 1px solid var(--line); border-radius: 10px; }
  #stage-legend .lg i { width: 10px; height: 10px; border-radius: 3px; grid-row: 1 / span 3; }
  #stage-legend .lg b { font-size: 12px; font-weight: 600; }
  #stage-legend .lg .v { font-size: 12px; font-variant-numeric: tabular-nums; }
  #stage-legend .lg i.deep { background: #3b5bdb; }
  #stage-legend .lg i.rem { background: #7048e8; }
  #stage-legend .lg i.light { background: #74a0f0; }
  #stage-legend .lg i.awake { background: #ffce4d; }
  #evening-rows { display: flex; flex-direction: column; gap: 3px; margin: 8px 0 4px; }
  .ev { display: grid; grid-template-columns: 62px 48px 68px 68px 48px 48px 56px;
        gap: 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
  .ev span:not(.n) { text-align: right; }
  .ev.head { color: var(--muted); font-size: 12px; }
  .ev.weekend { color: var(--me); }
  .ev .n { font-weight: 500; }
  .sleep-row .bar { position: relative; }
  .sleep-row .bar .seg { position: absolute; top: 0; bottom: 0;
                         border-radius: 5px; overflow: hidden; }
  .sleep-row .bar .seg i { position: absolute; top: 0; bottom: 0; }
  .sleep-row.head .bar.axis { position: relative; height: 14px; }
  .sleep-row.head .bar.axis .tick { position: absolute; top: 0; font-style: normal;
                                    font-size: 10px; transform: translateX(-50%);
                                    color: var(--muted); white-space: nowrap; }
  .sleep-row .hr { width: 34px; flex: none; text-align: right; color: var(--muted);
                   font-variant-numeric: tabular-nums; }
  .sleep-row.head { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
  .sleep-row.head .bar { background: none; height: auto; font-size: 11px; }
  /* Weekend nights read differently - later bedtimes and catch-up sleep are
     expected there, so they shouldn't look like weeknight regressions. */
  .sleep-row.weekend { color: var(--me); }
  .sleep-row.weekend .d { color: var(--me); font-weight: 500; }
  .sleep-row .bar { flex: 1; height: 10px; border-radius: 5px; background: var(--them); }
  .sleep-row .bar i.deep { background: #3b5bdb; }
  .sleep-row .bar i.rem { background: #7048e8; }
  .sleep-row .bar i.light { background: #74a0f0; }
  .sleep-row .bar i.awake { background: #ffce4d; }
  #older { flex: none; min-height: 28px; text-align: center; color: var(--muted); font-size: 12px; }
  /* Inherit the bubble's own text colour - the browser's default link blue sits
     badly on the dark grey bubble. */
  .bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
  .bubble a:hover { text-decoration-thickness: 2px; }
  .transcript { clear: both; font-size: 13px; }
  .transcript summary { color: var(--muted); cursor: pointer; font-size: 12px; }
  .transcript[open] summary { margin-bottom: 4px; }
  .att-save { float: right; margin-left: 8px; font-size: 13px; text-decoration: none; opacity: .6;
              background: none; border: none; color: inherit; padding: 0; cursor: pointer; }
  .att-save:hover { opacity: 1; }
  form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line);
         position: relative; }
  svg.icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
             flex: none; display: block; }
  #emoji-btn, #attach-btn, #icloud-btn, #mic-btn { background: none; color: var(--muted); width: 40px; height: 40px;
             padding: 0; border-radius: 10px; display: grid; place-items: center; align-self: flex-end; }
  #emoji-btn:hover, #attach-btn:hover, #icloud-btn:hover, #mic-btn:hover { color: var(--text); background: var(--them); }
  #emoji-btn[aria-expanded="true"] { color: var(--text); background: var(--them); }
  #mic-btn.on { color: #fff; background: var(--topo); animation: pulse 1.2s ease-in-out infinite; }
  #send-btn { display: flex; align-items: center; gap: 7px; height: 40px; align-self: flex-end; }
  #send-btn svg.icon { stroke-width: 2; }
  .attlink { display: inline-flex; align-items: center; gap: 5px; }
  .att-save { display: inline-grid; place-items: center; }
  @keyframes pulse { 50% { opacity: .35; } }
  #attachments { display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
                 padding: 8px 12px 0; }
  #attachments .chip { display: flex; align-items: center; gap: 6px; max-width: 200px;
                       padding: 4px 6px 4px 4px; border: 1px solid var(--line);
                       border-radius: 10px; font-size: 12px; }
  #attachments .chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; }
  #attachments .chip .icon { width: 28px; display: grid; place-items: center; color: var(--muted); }
  #attachments .chip.audio { max-width: none; }
  #attachments .chip audio { height: 30px; }
  #attachments .chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #attachments .chip button { background: none; color: var(--muted); padding: 2px; border-radius: 6px;
                              display: grid; place-items: center; }
  #attachments .chip button:hover { color: var(--text); background: var(--them); }
  .hint { color: var(--muted); font-size: 12px; margin: 0; }
  #attachments .hint { font-size: 11px; }
  .compose-err { padding: 8px 12px 0; }
  /* Replies: a quote block in the bubble, a hover button beside it, the quote being written above the composer. */
  .quote { border-left: 3px solid currentColor; padding-left: 8px; margin-bottom: 6px; opacity: .75;
           font-size: 13px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
           overflow: hidden; }
  .bubble > .quote:not(:first-child) { margin-top: 10px; }
  .row { align-items: center; gap: 4px; }
  .reply { background: none; color: var(--muted); padding: 6px; border-radius: 8px; display: grid;
           place-items: center; opacity: 0; }
  .me .reply { order: -1; }
  .row:hover .reply, .reply:focus-visible { opacity: 1; }
  @media (hover: none) { .reply { opacity: .5; } }
  .reply:hover { color: var(--text); background: var(--them); }
  #quoting { display: flex; align-items: flex-start; gap: 8px; margin: 8px 12px 0; padding: 6px 6px 6px 10px;
             border-left: 3px solid var(--me); background: var(--them); border-radius: 0 8px 8px 0;
             font-size: 13px; }
  #quoting .quote { flex: 1; border: 0; padding: 0; margin: 0; white-space: pre-wrap; -webkit-line-clamp: 2; }
  #quoting button { background: none; color: var(--muted); padding: 2px; border-radius: 6px;
                    display: grid; place-items: center; }
  #quoting button:hover { color: var(--text); background: var(--panel); }
  #modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.5);
           display: flex; align-items: center; justify-content: center; }
  #modal .sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
                  width: min(680px, 92vw); max-height: 82vh; display: flex; flex-direction: column; }
  #modal .top { display: flex; align-items: center; gap: 10px; padding: 12px 14px;
                border-bottom: 1px solid var(--line); font-weight: 600; }
  #modal .top button { background: transparent; color: var(--muted); padding: 6px; border-radius: 8px; display: grid; place-items: center; }
  #modal .top button:hover { color: var(--text); background: var(--them); }
  #modal .body { padding: 14px; overflow-y: auto; }
  #modal .foot { display: flex; align-items: center; gap: 10px; padding: 12px 14px;
                 border-top: 1px solid var(--line); }
  #modal .foot .spacer { margin-left: auto; }
  #modal form { display: flex; flex-direction: column; gap: 10px; padding: 0; border: 0;
                position: static; }
  #modal form button { padding: 11px 18px; }
  #modal input { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
                 background: var(--bg); color: var(--text); font: inherit; }
  #grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
  #grid .cell { position: relative; aspect-ratio: 1; border: 2px solid transparent;
                border-radius: 10px; overflow: hidden; padding: 0; background: var(--them); }
  #grid .cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
  #grid .cell.on { border-color: var(--me); }
  #grid .sk { aspect-ratio: 1; height: auto; }
  #grid .cell .badge { position: absolute; right: 5px; bottom: 5px; color: #fff; padding: 3px; border-radius: 6px;
                       background: rgba(0,0,0,.55); background-color: rgba(0,0,0,.55); }
  #sentinel { padding: 14px 0 2px; text-align: center; color: var(--muted); font-size: 12px; }
  #emoji-pick { position: absolute; bottom: 100%; left: 8px; z-index: 5; width: 280px;
                display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px;
                background: var(--panel); border: 1px solid var(--line);
                border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.35); }
  #emoji-pick button { background: none; font-size: 20px; padding: 4px 0; border-radius: 6px; }
  #emoji-pick button:hover { background: var(--line); }
  textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px;
             padding: 9px 14px; font: inherit; background: var(--them); color: var(--text);
             min-height: 40px; max-height: 60vh; }
  form.composer { align-items: flex-end; }  /* a tall message keeps the buttons on its last line */
  /* The composer sits at the bottom of the screen, so the resize grip is on its top edge: drag up to grow. */
  .grip { position: absolute; top: -7px; left: 0; right: 0; height: 14px; cursor: ns-resize;
          touch-action: none; display: grid; place-items: center; z-index: 1; }
  .grip::before { content: ""; width: 40px; height: 4px; border-radius: 2px; background: var(--line); }
  .grip:hover::before, .grip.on::before { background: var(--me); }
  textarea:focus { outline: none; border-color: var(--me); background: var(--panel); }
  button { border: 0; background: var(--me); color: var(--me-text); border-radius: 10px; padding: 0 18px;
           font: inherit; font-weight: 700; cursor: pointer; }
  button:disabled { opacity: .4; cursor: default; }
  #login { margin: auto; display: flex; flex-direction: column; gap: 10px; width: min(300px, 100% - 32px); }
  #login h1 { font: 800 40px/1 var(--display); margin: 0 0 6px; }
  #login input { padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
                 background: var(--them); color: var(--text); font: inherit; }
  #login button { padding: 11px 18px; }
  #err { color: var(--err); font-size: 13px; min-height: 16px; padding: 0 16px; }
  #chat-view, #training-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
  #tabs { display: flex; gap: 6px; margin-left: auto; }
  #tabs button { background: transparent; color: var(--muted); font: 700 19px/1 var(--display);
                 letter-spacing: .02em; padding: 8px 10px 13px; border-radius: 0;
                 border-bottom: 3px solid transparent; }
  #tabs button:hover { color: var(--text); }
  #tabs button.active { color: var(--text); border-bottom-color: var(--text); }
  #week-nav { display: flex; align-items: center; gap: 12px; padding: 14px 20px;
              border-bottom: 1px solid var(--line); }
  #week-nav .step { background: transparent; color: var(--text); border: 1px solid var(--line);
                    width: 36px; height: 36px; padding: 0; font-size: 20px; line-height: 1; }
  #week-nav .step:hover { background: var(--them); }
  #weekLabel { display: flex; flex-direction: column; min-width: 0; }
  #weekLabel .wk { font: 800 30px/1 var(--display); display: flex; align-items: baseline; gap: 10px; }
  #weekLabel .phase { font: 700 20px/1 var(--display); color: var(--muted); }
  #weekLabel .dates { font-size: 13px; color: var(--muted); margin-top: 4px; text-decoration: none; }
  #weekLabel .dates:hover { color: var(--text); text-decoration: underline; }
  #week-nav .libtoggle { margin-left: auto; padding: 9px 14px; }
  #week-nav .libtoggle.open { background: var(--them); color: var(--text); }
  #workouts { flex: 1; overflow-y: auto; padding: 8px 20px 40px; display: flex; flex-direction: column; }
  .daygroup { display: flex; flex-direction: column; gap: 8px; padding: 14px 0 6px; }
  .daygroup + .daygroup { border-top: 1px solid var(--line); }
  .dayhead { display: flex; align-items: baseline; gap: 10px; }
  .dayhead .dname { font: 800 24px/1 var(--display); }
  .dayhead .ddate { color: var(--muted); font-size: 14px; }
  .dayhead .dtime { margin-left: auto; font: 700 17px/1 var(--display); letter-spacing: .02em;
                    font-variant-numeric: tabular-nums; }
  .today .dname, .today .ddate { color: var(--topo); }
  /* How hard the day is (TypeSafe, see lattice_chat/judge.py): four bars filled to the level. */
  .dayhead .dload { margin-left: auto; display: flex; align-items: center; gap: 6px;
                    font: 700 13px/1 var(--body); color: var(--muted); letter-spacing: .02em; }
  .dayhead .dload + .dtime { margin-left: 0; }
  .dload .bars { display: flex; gap: 2px; }
  .dload .bars i { width: 5px; height: 12px; border-radius: 1px; background: var(--tnut); }
  .dload .bars i.on { background: var(--muted); }
  .dload.l3 .bars i.on, .dload.l4 .bars i.on { background: var(--topo); }
  .dload.l3, .dload.l4 { color: var(--topo); }
  .dload .warn { color: var(--err); font-size: 14px; }
  /* When to leave for the gym, so the session ends well before the doors lock. */
  .dayhead .dwhen { font: 700 15px/1 var(--display); color: var(--muted);
                    font-variant-numeric: tabular-nums; }
  .dayhead .dwhen b { color: var(--text); font-weight: 700; }
  /* The topo: a day is a sequence, drawn like a guidebook line with numbered markers. */
  .topo { position: relative; display: flex; flex-direction: column; gap: 10px; padding-left: 46px; }
  .topo::before { content: ""; position: absolute; left: 16px; top: 18px; bottom: 18px; width: 3px;
                  border-radius: 2px; background: var(--topo); transform-origin: top;
                  animation: topo-draw .5s cubic-bezier(.3,.7,.3,1) both; }
  .topo.loose::before { background: repeating-linear-gradient(var(--line) 0 6px, transparent 6px 11px);
                        animation: none; }
  .mark { position: absolute; left: -46px; top: 8px; width: 34px; height: 34px; border-radius: 50%;
          display: grid; place-items: center; background: var(--c, var(--muted)); color: #16201b;
          font: 700 15px/1 var(--body); box-shadow: 0 0 0 4px var(--panel);
          animation: mark-pop .35s cubic-bezier(.2,1.5,.4,1) both;
          animation-delay: calc(.12s + var(--i, 0) * .06s); }
  .mark.alt { font: 700 13px/1 var(--body); background: var(--panel); color: var(--text);
              border: 2px dashed var(--c, var(--muted)); }
  .loose .mark { width: 16px; height: 16px; left: -37px; top: 16px; }
  @keyframes topo-draw { from { transform: scaleY(0); } }
  @keyframes mark-pop { from { transform: scale(0); } }
  @media (prefers-reduced-motion: reduce) { .topo::before, .mark { animation: none; } }
  .workout { position: relative; background: var(--panel); border: 1px solid var(--line);
             border-radius: 10px; padding: 11px 14px; }
  .workout:hover { border-color: color-mix(in srgb, var(--text) 30%, var(--line)); }
  .wtop { display: flex; align-items: center; gap: 10px; }
  .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
  .wname { font-weight: 700; font-size: 16px; }
  .wmeta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); margin-top: 3px; }
  .wmeta b { color: var(--text); font-weight: 700; }
  .wdesc { font-size: 14px; color: var(--muted); margin-top: 6px; max-width: 72ch;
           display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .logged { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px;
             background: var(--ok); color: #fff; font-weight: 700; }
  .workout.done { background: color-mix(in srgb, var(--ok) 10%, var(--panel));
                  border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); box-shadow: inset 4px 0 0 var(--ok); }
  .workout.done .wname { color: color-mix(in srgb, var(--ok) 55%, var(--text)); }
  .workout.done .mark { background: var(--ok); color: #fff; border: 0; }
  #train-body { flex: 1; display: flex; min-height: 0; }
  .daygroup.dropzone.over { border-radius: 10px; background: color-mix(in srgb, var(--me) 9%, transparent);
                            box-shadow: 0 0 0 2px var(--me) inset; }
  .empty { color: var(--muted); font-size: 14px; padding: 4px 0 4px 46px; }
  .workout[draggable="true"], .libitem { cursor: grab; }
  .workout.over { box-shadow: 0 -3px 0 -1px var(--me); }  /* drop lands above this card */
  .workout .bin { margin-left: auto; background: transparent; color: var(--muted); padding: 0 6px;
                  border-radius: 6px; font-size: 15px; line-height: 1; }
  .workout .bin:hover { color: #ff453a; background: rgba(255,69,58,.12); }
  /* Home/gym tags look like route tape: the coloured strip a gym uses to mark a problem. */
  .workout .place {
    margin-left: auto; position: relative; cursor: pointer;
    font: 800 15px/1 var(--display); letter-spacing: .03em; padding: 4px 11px 4px 13px;
    background: transparent; color: var(--muted); border: 1px dashed var(--line); border-radius: 2px;
    transition: filter .15s, transform .15s;
  }
  .workout button.place:hover { transform: translateY(-1px); filter: brightness(1.08); }
  .workout span.place { cursor: default; opacity: .8; }  /* needs kit that isn't at home: gym by rule, not clickable */
  .workout .place + .bin { margin-left: 0; }
  .workout .place.home, .workout .place.gym {
    border: 0; color: var(--tape-ink);
    clip-path: polygon(0 0, 100% 0, calc(100% - 5px) 50%, 100% 100%, 0 100%, 4px 50%);  /* torn ends */
    box-shadow: inset 0 -2px 0 rgba(0,0,0,.18);
    animation: tape-stick .32s cubic-bezier(.2,1.6,.4,1) both;
  }
  .workout .place.home { background: var(--tape-home); transform: rotate(-2deg); }
  .workout .place.gym { background: var(--tape-gym); transform: rotate(1.5deg); }
  .workout button.place.home:hover, .workout button.place.gym:hover { transform: rotate(0) translateY(-1px); }
  @keyframes tape-stick {
    from { opacity: 0; transform: scale(1.35) rotate(-8deg); }
    to { opacity: 1; }
  }
  @media (prefers-reduced-motion: reduce) { .workout .place { animation: none !important; transition: none; } }
  #library { width: 270px; flex: none; border-left: 1px solid var(--line); background: var(--them);
             display: flex; flex-direction: column; min-height: 0; }
  #library input { margin: 12px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line);
                   background: var(--panel); color: var(--text); font: inherit; }
  .libitems { flex: 1; overflow-y: auto; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 6px; }
  .libitem { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--panel);
             border: 1px solid var(--line); border-radius: 8px; }
  .libname { font-weight: 700; font-size: 14px; }
  .libmeta { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }
  @media (max-width: 700px) {
    #library { position: fixed; left: 0; right: 0; bottom: 0; width: auto; height: 55vh; z-index: 30;
               border-left: 0; border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(0,0,0,.25); }
    #workouts { padding-left: 16px; padding-right: 16px; }
  }
  #analytics-view { flex: 1; overflow-y: auto; padding: 22px 24px 40px; }
  #analytics-view h3 { font: 800 24px/1 var(--display); margin: 30px 0 12px; display: flex;
                       align-items: baseline; gap: 10px; }
  #analytics-view h3 .sub { font: 400 14px var(--body); }
  #analytics-view h3:first-child { margin-top: 0; }
  /* Grades read like a guidebook prints them: the grade is the headline, its label is small. */
  .grades { display: flex; flex-wrap: wrap; border-top: 3px solid var(--text); }
  .grade { flex: 1 1 120px; padding: 10px 16px 12px 0; }
  .grade + .grade { padding-left: 16px; border-left: 1px solid var(--line); }
  .grade .v { font: 800 64px/1 var(--display); font-variant-numeric: tabular-nums; }
  .grade .k { font-size: 14px; color: var(--muted); margin-top: 4px; }
  .grades.small { border-top-width: 1px; }
  .grades.small .v { font-size: 38px; }
  .grades.small .u { font: 700 18px var(--display); color: var(--muted); margin-left: 4px; }
  .note { color: var(--muted); font-size: 14px; border-left: 3px solid var(--line);
          padding: 8px 14px; margin-top: 14px; }
  /* Workout sheet */
  .modal-bg { position: fixed; inset: 0; background: rgba(12,16,14,.6); display: flex; z-index: 50;
              backdrop-filter: blur(2px); animation: fade .18s ease-out; }
  .modal-bg > .sheet { margin: auto; background: var(--panel); border-radius: 16px; width: min(820px, calc(100% - 32px));
           max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
           box-shadow: 0 24px 60px rgba(0,0,0,.35); border-top: 6px solid var(--c);
           animation: rise .24s cubic-bezier(.2,.9,.3,1); }
  @keyframes fade { from { opacity: 0; } }
  @keyframes rise { from { transform: translateY(18px); opacity: 0; } }
  @media (prefers-reduced-motion: reduce) { .modal-bg, .modal-bg > .sheet { animation: none; } }
  .sheet-head { display: flex; align-items: flex-start; gap: 16px; padding: 20px 24px 16px; border-bottom: 1px solid var(--line); }
  .sheet-head > div { flex: 1; min-width: 0; }
  .kicker { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
  .kicker .swatch { background: var(--c); width: 10px; height: 10px; border-radius: 50%; }
  .sheet-title { font: 800 38px/1.02 var(--display); margin: 6px 0 10px; }
  .facts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; font-size: 14px; color: var(--muted); }
  .facts b { color: var(--text); font: 700 18px/1 var(--display); }
  .facts .place { font: 800 14px/1 var(--display); padding: 4px 10px 4px 12px; color: var(--tape-ink);
                  clip-path: polygon(0 0, 100% 0, calc(100% - 5px) 50%, 100% 100%, 0 100%, 4px 50%); }
  .facts .place.home { background: var(--tape-home); } .facts .place.gym { background: var(--tape-gym); }
  .sheet .x { background: var(--them); color: var(--text); width: 40px; height: 40px; padding: 0; border-radius: 50%;
              display: grid; place-items: center; flex: none; }
  .sheet .x:hover { background: color-mix(in srgb, var(--text) 14%, var(--them)); }
  .sheet .x svg.icon { stroke-width: 2.2; }
  .sheet-body { overflow-y: auto; padding: 20px 24px 28px; display: flex; flex-direction: column; gap: 14px; }
  .coachnote { background: color-mix(in srgb, var(--tape-home) 16%, var(--panel)); border-radius: 10px;
               padding: 12px 16px; box-shadow: inset 4px 0 0 var(--tape-home); }
  .coachnote .who { font: 700 15px/1 var(--display); letter-spacing: .02em; margin-bottom: 6px; }
  .tiptext { white-space: pre-line; }
  .sheet-lead { font-size: 17px; margin: 0; max-width: 64ch; }
  .sheet-p { margin: 0; color: var(--muted); max-width: 64ch; }
  .chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .chip { font-size: 13px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
  .excard { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 18px; padding-top: 16px;
            border-top: 1px solid var(--line); align-items: start; }
  .excard:has(> .exinfo:first-child) { grid-template-columns: minmax(0, 1fr); }
  .exvideo { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #0e1210; }
  .exvideo img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .exvideo iframe, .exvideo video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #0e1210; }
  .exvideo .play { position: absolute; inset: 0; margin: auto; width: 60px; height: 60px; border-radius: 50%;
                   padding: 0; display: grid; place-items: center; background: rgba(247,247,244,.92); color: #16201b;
                   box-shadow: 0 6px 20px rgba(0,0,0,.35); transition: transform .15s; }
  .exvideo .play:hover { transform: scale(1.08); }
  .exvideo .play svg { width: 26px; height: 26px; fill: currentColor; margin-left: 3px; }
  .exname { font: 800 24px/1.05 var(--display); margin: 0 0 4px; display: flex; align-items: baseline; gap: 8px; }
  .exnum { font: 700 14px/1 var(--body); color: var(--muted); }
  .figs { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
  .fig { display: flex; flex-direction: column; min-width: 72px; padding: 8px 12px; border-radius: 8px; background: var(--them); }
  .fig b { font: 800 22px/1 var(--display); }
  .fig span { font-size: 12px; color: var(--muted); margin-top: 3px; }
  .exmeta { font-size: 13px; color: var(--muted); margin-top: 3px; }
  .howto { margin-top: 8px; font-size: 14px; }
  .howto summary { cursor: pointer; font-weight: 700; }
  .howto p { white-space: pre-line; margin: 6px 0 0; max-width: 62ch; }
  .exlink { display: inline-block; margin-top: 10px; font-size: 14px; font-weight: 700; color: var(--me); }
  @media (prefers-color-scheme: dark) { .exlink, .sheet a { color: var(--chart-a); } }
  .tiptext { line-height: 1.55; }
  @media (max-width: 700px) {
    .modal-bg > .sheet { width: 100%; max-height: 100%; height: 100%; border-radius: 0; margin: 0; }
    .excard { grid-template-columns: minmax(0, 1fr); }
    .sheet-title { font-size: 32px; }
    .sheet-head, .sheet-body { padding-left: 16px; padding-right: 16px; }
  }
  .workout { cursor: pointer; }
  /* Today */
  .today-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 8px 40px; }
  .today-grid .section:first-child { margin-top: 20px; }
  @media (max-width: 900px) { .today-grid { grid-template-columns: minmax(0, 1fr); } }
  .rest { font: 700 22px/1.2 var(--display); color: var(--muted); padding: 18px 0; }
  .plainlist { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
  .plainlist li span + span { margin-left: 8px; }
  .weekstrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-decoration: none; color: inherit; }
  .ws { display: flex; flex-direction: column; gap: 3px; padding: 8px 4px; border-radius: 8px; text-align: center;
        background: var(--them); font-size: 12px; color: var(--muted); }
  .ws b { font: 700 16px/1 var(--display); color: var(--text); }
  .ws.now { box-shadow: inset 0 0 0 2px var(--topo); }
  .ws.done { background: color-mix(in srgb, var(--ok) 22%, var(--them)); }
  .coachcard { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 10px;
               background: var(--them); color: var(--text) !important; text-decoration: none; }
  .clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
  /* Plan */
  .plan-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
  .plan-head select, .ex-tools input[type=search] { font: inherit; padding: 8px 10px; border-radius: 8px;
        border: 1px solid var(--line); background: var(--panel); color: var(--text); }
  .nextplan { font: 700 20px/1.2 var(--display); margin: 14px 0; padding: 10px 14px; border-radius: 8px;
              background: color-mix(in srgb, var(--topo) 10%, var(--panel)); box-shadow: inset 3px 0 0 var(--topo); }
  .plan-desc { white-space: pre-line; max-width: 70ch; padding: 12px 16px; border-left: 3px solid var(--line); margin: 12px 0; }
  .weeks { list-style: none; margin: 0; padding: 0; border-top: 3px solid var(--text); }
  .weeks a { display: grid; grid-template-columns: 34px 90px 70px minmax(60px, 1fr) 70px 44px; gap: 12px;
             align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
  .weeks a:hover { background: var(--them); }
  .weeks .now a { box-shadow: inset 3px 0 0 var(--topo); }
  .wn { font: 800 24px/1 var(--display); text-align: right; }
  .wp { font: 700 17px/1 var(--display); }
  .wd, .wl { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
  .wt { font: 700 16px/1 var(--display); text-align: right; }
  .wbar { position: relative; height: 12px; }
  .wbar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
  .wbar .tot { box-shadow: inset 0 0 0 1.5px var(--chart-ref); }
  .wbar .log { background: var(--chart-a); }
  @media (max-width: 600px) { .weeks a { grid-template-columns: 26px 1fr 60px 40px; } .wd, .wbar { display: none; } }
  .ov { border-bottom: 1px solid var(--line); padding: 10px 0; max-width: 72ch; }
  .ov summary { cursor: pointer; font-weight: 700; }
  .ov-body { white-space: pre-line; margin-top: 8px; color: var(--muted); }
  /* Progress + exercise */
  .ex-tools { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
  .ex-tools input[type=search] { flex: 1; min-width: 200px; max-width: 360px; }
  .ex-tools label { font-size: 14px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
  .exlist { border-top: 1px solid var(--line); }
  .exrow { display: grid; grid-template-columns: 10px minmax(0, 1fr) 110px 70px 64px; gap: 12px; align-items: center;
           padding: 9px 4px; border-bottom: 1px solid var(--line); color: inherit !important; text-decoration: none; }
  .exrow:hover { background: var(--them); }
  .exn { font-weight: 700; display: flex; flex-direction: column; }
  .exn .sub { font-weight: 400; font-size: 13px; }
  .exb { font: 700 17px/1 var(--display); text-align: right; font-variant-numeric: tabular-nums; }
  .exc, .exd { color: var(--muted); font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
  @media (max-width: 600px) { .exrow { grid-template-columns: 10px 1fr 80px; } .exc, .exd { display: none; } }
  .table-wrap { overflow-x: auto; }
  table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
  th { text-align: left; font-weight: 700; color: var(--muted); padding: 6px 10px 6px 0; border-bottom: 2px solid var(--text); }
  td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
  .pbv { font-weight: 700; box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--topo) 45%, transparent); }
  .prose { max-width: 68ch; white-space: pre-line; }
  /* charts: logged is the one data colour; planned is an outlined reference, never a second hue */
  :root { --chart-a: #12825a; --chart-ref: #9b958a; }
  @media (prefers-color-scheme: dark) { :root { --chart-a: #3aa674; --chart-ref: #6d776f; } }
  .chart { margin: 4px 0 8px; }
  .legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
  .legend span { display: flex; align-items: center; gap: 6px; }
  .sw { width: 14px; height: 10px; border-radius: 3px; display: inline-block; }
  .sw.logged { background: var(--chart-a); }
  .sw.planned { box-shadow: inset 0 0 0 1.5px var(--chart-ref); }
  .chart-scroll, .chart-wrap { position: relative; overflow-x: auto; }
  .chart-wrap { overflow: visible; }
  svg.fluid { width: 100%; height: auto; display: block; }
  .chart .grid { stroke: var(--line); stroke-width: 1; }
  .chart .base { stroke: var(--muted); stroke-width: 1; }
  .chart .axis { fill: var(--muted); font: 11px var(--body); }
  .chart .planned { fill: none; stroke: var(--chart-ref); stroke-width: 1.5; }
  .chart .logged { fill: var(--chart-a); }
  .chart .now { fill: var(--topo); }
  .chart .hit { fill: transparent; }
  .chart .line { fill: none; stroke: var(--chart-a); stroke-width: 2; stroke-linejoin: round; }
  .chart .dot { fill: var(--chart-a); stroke: var(--panel); stroke-width: 2; }
  .chart .dot.pb { stroke: var(--topo); stroke-width: 2.5; }
  .chart .cross { stroke: var(--muted); stroke-dasharray: 3 3; }
  :root { --g0: #12825a; --g1: #3b6fd4; --g2: #b86e00; }
  @media (prefers-color-scheme: dark) { :root { --g0: #3aa674; --g1: #5b8ae0; --g2: #c3862a; } }
  .chart .step { fill: none; stroke-width: 2; stroke-linejoin: round; }
  .chart .step.s0, .chart .dot.s0 { stroke: var(--g0); } .chart .dot.s0 { fill: var(--g0); }
  .chart .step.s1, .chart .dot.s1 { stroke: var(--g1); } .chart .dot.s1 { fill: var(--g1); }
  .chart .step.s2, .chart .dot.s2 { stroke: var(--g2); } .chart .dot.s2 { fill: var(--g2); }
  .chart .step.target { stroke: var(--text); stroke-dasharray: 6 4; stroke-width: 1.5; }
  .chart .dot.s0, .chart .dot.s1, .chart .dot.s2 { stroke: var(--panel); stroke-width: 2; }
  .chart .endlabel { fill: var(--text); font: 12px var(--body); }
  .sw.s0 { background: var(--g0); } .sw.s1 { background: var(--g1); } .sw.s2 { background: var(--g2); }
  .sw.target { border-top: 2px dashed var(--text); height: 0; border-radius: 0; }
  .grade .since { display: block; font-size: 12px; }
  form.weightedit { display: block; position: static; border-top: 0; padding: 10px 16px 12px; gap: 0; }
  .weightedit .v { display: flex; align-items: baseline; }
  .weightedit input { font: 800 38px/1 var(--display); width: 4.2ch; background: transparent; color: var(--text);
                      border: 0; border-bottom: 2px dashed var(--line); padding: 0; -moz-appearance: textfield; }
  .weightedit input::-webkit-outer-spin-button, .weightedit input::-webkit-inner-spin-button { -webkit-appearance: none; }
  .weightedit input:focus { outline: none; border-bottom-color: var(--text); }
  .weightedit .k .link { font-size: 14px; padding-left: 6px; }
  .gradepick { font: 800 44px/1 var(--display); color: var(--text); background: transparent; border: 0;
               border-bottom: 2px dashed var(--line); border-radius: 0; padding: 0 22px 2px 0; cursor: pointer;
               appearance: none; -webkit-appearance: none; max-width: 100%;
               background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                                 linear-gradient(135deg, var(--muted) 50%, transparent 50%);
               background-position: calc(100% - 10px) 55%, calc(100% - 4px) 55%;
               background-size: 6px 6px; background-repeat: no-repeat; }
  .gradepick:hover { border-bottom-color: var(--text); }
  .gradepick option { font: 16px var(--body); }
  .grade.target .v { -webkit-text-stroke: 1.5px var(--text); color: transparent; }
  .tip { position: absolute; top: 4px; transform: translateX(-50%); background: var(--text); color: var(--panel);
         font-size: 12px; line-height: 1.35; padding: 6px 9px; border-radius: 6px; pointer-events: none; white-space: nowrap; z-index: 2; }
  .table-view { font-size: 13px; margin-top: 4px; }
  .table-view summary { cursor: pointer; color: var(--muted); }
  /* Account */
  .kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0; max-width: 720px; }
  .kv dt { color: var(--muted); }
  .kv dd { margin: 0; }
  .kv.units { align-items: center; }
  .kv select { font: inherit; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line);
               background: var(--panel); color: var(--text); min-width: 240px; }
  button.link { background: none; color: var(--me); padding: 0 0 0 8px; font-weight: 700; text-decoration: underline; }
  button.link.danger { color: var(--err); }
  .setups { display: flex; gap: 12px; flex-wrap: wrap; }
  .setup { flex: 1 1 260px; border-left: 3px solid var(--line); padding: 4px 14px; }
  .setup p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
  /* loading placeholders */
  .sk { background: var(--line); border-radius: 8px; animation: pulse 1.2s ease-in-out infinite; }
  .row .bubble.sk { color: transparent; }
  /* Testing: each domain keeps Lattice's colour so the radar, cards and gold bars read as one key. */
  .t-finger { --c: #3fb1c4; } .t-endurance { --c: #5b55f0; } .t-strength { --c: #6cc44f; } .t-flex { --c: #e6b93d; }
  .seg-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 2px; gap: 2px; }
  .seg-toggle button { border: 0; background: none; color: var(--muted); font: 600 14px var(--body);
                       padding: 6px 14px; border-radius: 8px; cursor: pointer; }
  .seg-toggle button[aria-pressed="true"] { background: var(--panel); color: var(--text);
                                            box-shadow: 0 1px 2px rgba(0,0,0,.15); }
  .t-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0 4px; }
  .t-tools .grade-chip { font: 700 16px var(--display); padding: 5px 10px; border-radius: 8px;
                         background: color-mix(in srgb, var(--topo) 18%, var(--panel)); }
  .radar { display: block; width: min(560px, 100%); margin: 8px auto; }
  .radar .ring { fill: none; stroke: var(--line); }
  .radar .ring.mid { stroke-dasharray: 4 4; stroke: var(--muted); }
  .radar .shape { fill: color-mix(in srgb, var(--me) 25%, transparent); stroke: var(--me); stroke-width: 2; }
  .radar text { font: 600 15px var(--body); fill: var(--c); }
  .radar circle.pt { fill: var(--c); }
  .tcard { border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin: 12px 0; background: var(--panel); }
  a.tcard { display: block; color: inherit; text-decoration: none; }
  a.tcard:hover { border-color: var(--c); }
  .tcard-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
  .tcard-head h3 { font: 800 24px/1 var(--display); margin: 0; display: flex; align-items: center; gap: 8px; }
  .tcard-head h3::before { content: ""; width: 8px; height: 18px; border-radius: 2px; background: var(--c); }
  .tcard-head .sub { margin-left: auto; font-size: 14px; }
  .tbar { position: relative; display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; margin: 16px 0 4px; }
  .tbar i { height: 8px; border-radius: 3px; background: color-mix(in srgb, var(--text) calc(10% + var(--k) * 9%), transparent); }
  .tbar .dot { position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%; background: var(--c);
               border: 3px solid var(--panel); box-shadow: 0 0 0 2px var(--c); transform: translate(-50%, -50%); }
  .tscale { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
  .pill { display: inline-block; font-size: 13px; padding: 2px 10px; border-radius: 999px; border: 1px solid; }
  .pill { margin: 0 6px; }
  .pill.under { color: var(--err); } .pill.ahead { color: var(--ok); }
  .pill.typical { color: color-mix(in srgb, var(--tape-home) 75%, var(--text)); }
  .tline { margin-top: 10px; font-size: 14px; color: var(--muted); }
  .tresult { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 4px; }
  .tresult > div { flex: 1 1 160px; display: flex; justify-content: space-between; align-items: baseline;
                   border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
  .tresult b { font: 800 28px/1 var(--display); font-variant-numeric: tabular-nums; }
  .tresult .side { font-weight: 700; margin-right: 6px; }
  .tresult .side.L { color: var(--topo); } .tresult .side.R { color: var(--ok); }
  .curve { display: block; width: 100%; height: auto; margin-top: 8px; }
  .curve .area { fill: color-mix(in srgb, var(--text) 10%, transparent); stroke: var(--muted); stroke-width: 1.5; }
  .curve .cut { stroke: var(--muted); stroke-dasharray: 3 4; }
  .curve .you { stroke: var(--c); stroke-width: 2.5; }
  .curve .you.L { stroke: var(--topo); } .curve .you.R { stroke: var(--ok); }
  .curve .tag rect { fill: var(--panel); stroke: currentColor; }
  .curve .tag { color: var(--c); } .curve .tag.L { color: var(--topo); } .curve .tag.R { color: var(--ok); }
  .curve .tag text { fill: var(--text); font: 600 14px var(--body); }
  .curve .lvl { fill: color-mix(in srgb, var(--text) 14%, transparent); }
  .curve .lvl.you { fill: var(--c); stroke: none; }
  .curve .lab { fill: var(--muted); font: 13px var(--body); }
  .bands { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; font-size: 14px; margin-top: 2px; }
  .bands span { display: block; font-size: 12px; color: var(--muted); }
  .gold { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 0;
          border-top: 1px solid var(--line); align-items: baseline; }
  .gold:first-of-type { border-top: 0; }
  a.gold { color: inherit; text-decoration: none; }
  a.gold:hover .gv { text-decoration: underline; }
  .t-editbtn { margin-left: auto; }
  .tcard-head .sub + .t-editbtn { margin-left: 12px; }
  .t-edit { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end; margin: 14px 0 4px;
            padding: 14px; border-radius: 10px; background: var(--them); }
  .t-edit label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
  .t-edit .t-in { display: flex; align-items: center; gap: 6px; }
  .t-edit input, .t-edit select { padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line);
                                  background: var(--panel); color: var(--text); font: inherit; }
  .t-edit input[type=number] { width: 110px; }
  .t-edit .note { flex-basis: 100%; margin: 0; }
  .t-edit-actions { flex-basis: 100%; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
  .gold .gt { color: var(--tape-home); font-weight: 700; text-align: right; }
  .gold .gv { font-variant-numeric: tabular-nums; }
  .gold .gv.none { color: var(--muted); }
  .gbar { grid-column: 1 / -1; position: relative; height: 10px; border-radius: 999px;
          background: linear-gradient(90deg, color-mix(in srgb, var(--text) 10%, transparent) 76%,
                                      color-mix(in srgb, var(--tape-home) 30%, transparent) 76%); }
  .gbar i { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--text); }
  .gbar::after { content: ""; position: absolute; left: 76%; top: -4px; bottom: -4px; width: 3px;
                 border-radius: 2px; background: var(--tape-home); }
/* Tindeq programs: the library is read-only, your own programs are editable, so the two
   lists share a row layout but only one of them grows Edit/Delete. */
.tq-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0 10px; }
.tq-toolbar input[type="search"] { flex: 1 1 220px; font: inherit; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); }
.tq-list { display: flex; flex-direction: column; gap: 6px; }
.tq-row { display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.tq-row .nm { font: 600 15px var(--body); }
.tq-row .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tq-row .acts { display: flex; gap: 12px; flex-shrink: 0; }
.tq-row .acts button { background: none; border: 0; color: var(--muted); font: 600 13px var(--body);
  cursor: pointer; padding: 2px 0; }
.tq-row .acts button:hover { color: var(--text); }
/* Catalogue climbs you have a send logged on: same look as a done workout */
.tb-row.sent { background: color-mix(in srgb, var(--ok) 10%, var(--panel)); box-shadow: inset 4px 0 0 var(--ok); }
.chip.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.tq-form { display: grid; gap: 12px; max-width: 680px; margin-top: 10px; }
.tq-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 10px; }
.tq-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.tq-field input, .tq-field select, .tq-field textarea { font: 400 15px var(--body); padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
.tq-field textarea { min-height: 64px; resize: vertical; }
.tq-block { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; align-items: end; }
.tq-actions { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.tq-actions button { font: 600 15px var(--body); padding: 8px 16px; border-radius: 9px; white-space: nowrap; min-height: 44px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
.tq-actions .primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.tq-err { color: #c0392b; font-size: 14px; }
.tq-note { font-size: 13px; color: var(--muted); }

/* Tension Board: the board image with an SVG of holds over it (see board.mjs). */
.tb-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; }
.tb-head .tq-note { flex-basis: 100%; margin: 0; }
.tb-filters .tq-field select { padding: 6px 8px; }
.tb-filters > button, .tb-filters .tq-field select { min-height: 44px; }
/* a full-width target at the end of a list: it is reached with a thumb, mid-scroll */
.tb-more { width: 100%; min-height: 44px; }
.tb-check { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.tb-rules { margin: 0 0 16px; display: flex; flex-direction: column; gap: 10px; }
.tb-rules-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tb-rules-body { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; max-width: 560px; }
.tb-rules-body .tq-note { margin: 0; }
.tb-rule { display: grid; grid-template-columns: 1fr auto 64px auto 44px; gap: 6px; width: 100%; }
.tb-rule select, .tb-rule input { font: 400 15px var(--body); padding: 0 8px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); min-width: 0; }
.tb-rules button, .tb-rule select, .tb-rule input, .tb-rules .tb-check { min-height: 44px; }
.tb-rules .chip { cursor: pointer; background: var(--panel); }
.tb-rules-head .chip { cursor: default; }
.tb-x { padding: 0; }
@media (max-width: 520px) {  /* a rule on two rows: what and how, then how many; its ✕ spans both */
  .tb-rule { grid-template-columns: 1fr 1fr 44px; grid-template-areas: "kind op x" "n unit x"; }
  .tb-rule > :nth-child(1) { grid-area: kind; } .tb-rule > :nth-child(2) { grid-area: op; }
  .tb-rule > :nth-child(3) { grid-area: n; } .tb-rule > :nth-child(4) { grid-area: unit; }
  .tb-rule > :nth-child(5) { grid-area: x; }
}
.tb-pick { max-width: 560px; margin: 0 0 16px; }
.tb-row { text-decoration: none; color: inherit; }
.tb-row .chip { font-size: 11px; padding: 1px 7px; margin-left: 4px; vertical-align: 2px; }
.tb-grade { font: 800 22px/1 var(--display); color: var(--me); white-space: nowrap; }
.tb-grade small { font: 600 13px/1 var(--body); opacity: 0.75; margin-left: 1px; }  /* condensed "V1" reads as "Vl" */
.tb-detail { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(0, 600px); gap: 24px; align-items: start; margin-top: 12px; }
.tb-board { position: relative; width: 100%; background: #2b2b2b; border-radius: 10px; overflow: hidden;
  user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.tb-board img, .tb-board svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tb-board circle.tap { cursor: pointer; pointer-events: all; }
.tb-zoom { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; }
.tb-zoombtns { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; }
.tb-zoombtns button { width: 36px; height: 36px; padding: 0; font-size: 18px; line-height: 1; border-radius: 8px;
  background: rgba(20, 24, 22, .8); color: #fff; border: 1px solid rgba(255, 255, 255, .25); }
.tb-zoombtns button:disabled { opacity: .4; }
.tb-board circle.tap:hover { fill: rgba(255, 255, 255, .18); }
.tb-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.tb-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 3px solid; margin-right: 5px; vertical-align: -2px; }
.tb-login { max-width: 380px; }
.tb-hold { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.tb-hold h2 { margin: 0; font: 800 22px/1.1 var(--display); }
.tb-types { display: flex; flex-wrap: wrap; gap: 6px; }
.tb-types .chip { cursor: pointer; font: inherit; font-size: 13px; padding: 4px 10px; background: transparent; color: var(--text); border: 1px solid var(--line); border-radius: 999px; }
.tb-types .chip.on { background: var(--text); color: var(--panel); border-color: var(--text); }
.tb-types .chip i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.tb-types .chip.static { cursor: default; color: var(--muted); }
.tb-shapekey .chip { min-height: 36px; }
.tb-tint-label { font: 700 11px/1 system-ui, sans-serif; fill: #fff; text-anchor: middle; paint-order: stroke; stroke: #000; stroke-width: 3px; }
.tb-types .chip .n { opacity: .7; font-variant-numeric: tabular-nums; }
.tb-shapes-panel { margin: 8px 0; }
.tb-shapes-panel .chip { min-height: 44px; padding: 0 14px; }
a.button { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 10px;
  background: var(--me); color: var(--me-text); font-weight: 700; text-decoration: none; }
.tb-progress { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }

/* Classify: the board zoomed onto one hold, a 2 by 4 grid of answers in thumb reach at the bottom */
.tb-classify { padding-bottom: calc(140px + env(safe-area-inset-bottom)); max-width: 640px; }
.tb-classify-info { margin: 10px 0; }
.tb-classify-grid { position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 640px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.tb-classify-grid button { min-height: 56px; padding: 0 4px; font-size: 15px; }
.tb-classify-grid button[aria-pressed="true"] { outline: 3px solid var(--text); outline-offset: -3px; }
.tb-classify-grid .unsure { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.tb-classify-grid .login { grid-column: 1 / -1; justify-content: center; min-height: 56px; }
.tb-toast { position: fixed; z-index: 6; left: 50%; transform: translateX(-50%);
  bottom: calc(146px + env(safe-area-inset-bottom)); display: flex; gap: 12px; align-items: center;
  padding: 6px 6px 6px 14px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 14px; white-space: nowrap; }
.tb-toast button { min-height: 44px; background: var(--bg); color: var(--text); }
.tb-pulse { animation: tb-pulse 1.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes tb-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(1.25); } }
@media (prefers-reduced-motion: reduce) { .tb-pulse { animation: none; } }
.tb-row2 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 980px) { .tb-detail { grid-template-columns: 1fr; } .tb-detail > :last-child { order: -1; } }
.tb-heatkey { display: flex; align-items: center; gap: 2px; margin: 6px 0 12px; font-size: 12px; color: var(--muted, #999); }
.tb-heatkey i { width: 22px; height: 12px; border-radius: 2px; }
.tb-heatkey span { margin: 0 6px; }
.tb-spread { margin: 4px 0 12px; }
.tb-spread svg { width: 100%; max-width: 320px; display: block; }
.tb-spread .bar { fill: #3987e5; }
.tb-spread .axis { stroke: var(--line); stroke-width: 1; }
.tb-spread text { font-size: 8px; text-anchor: middle; fill: var(--muted); }
.tb-spread text.val { fill: var(--text); }
.tb-spread text.lbl.on { fill: var(--text); font-weight: 700; }
.chart .rep { fill: var(--chart-a); opacity: .08; }
.chart .target { stroke-dasharray: 5 4; }
.tq-sets { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px 24px; }
.tq-set h3 { font: 600 14px var(--body); margin: 0 0 2px; }
.tq-set .meta, .tq-set summary { font-size: 12px; color: var(--muted); }
.tq-set table { width: 100%; font-size: 12px; border-collapse: collapse; }
.tq-set td, .tq-set th { text-align: right; padding: 2px 6px; font-variant-numeric: tabular-nums; }
.tq-set td:first-child, .tq-set th:first-child { text-align: left; }
.tq-stats { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 8px 0 16px; }
.tq-stats div { display: flex; flex-direction: column; }
.tq-stats b { font: 600 20px var(--body); font-variant-numeric: tabular-nums; }
.tq-stats span { font-size: 12px; color: var(--muted); }
.tq-hands { width: auto; border-collapse: collapse; margin: 0 0 16px; font-variant-numeric: tabular-nums; }
.tq-hands th, .tq-hands td { border: 0; border-bottom: 1px solid var(--line); padding: 4px 32px 4px 0; text-align: left; }
.tq-hands tbody th { font-weight: 400; color: var(--muted); }
.tq-hands tbody th[title] { cursor: help; text-decoration: underline dotted; }
.tq-hands caption { caption-side: bottom; text-align: left; font-size: 12px; color: var(--muted); padding-top: 4px; }
.chart svg.force { touch-action: pan-y; cursor: crosshair; user-select: none; }
.chart .force .line { stroke-width: 1.25; }
.chart .force .line.s0 { stroke: var(--g0); } .chart .force .rep.s0, .chart .force .dot.s0 { fill: var(--g0); }
.chart .force .line.s1 { stroke: var(--g1); } .chart .force .rep.s1, .chart .force .dot.s1 { fill: var(--g1); }
.chart .force .rep { opacity: .07; }
.hand-toggle { display: flex; gap: 8px; margin: 4px 0 10px; }
.hand-toggle button { display: inline-flex; align-items: center; gap: 6px; font: 13px var(--body);
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: none; color: var(--text); cursor: pointer; }
.hand-toggle button[aria-pressed="false"] { color: var(--muted); }
.hand-toggle button[aria-pressed="false"] .sw { background: none; box-shadow: inset 0 0 0 1.5px var(--muted); }
.tip .sw { width: 10px; height: 8px; }
.chart .brush { fill: var(--muted); opacity: .18; }
.zoom-note { font-size: 11px; color: var(--muted); min-height: 18px; }
.zoom-note .link { font-size: 11px; }
.sw.s0 { background: var(--g0); } .sw.s1 { background: var(--g1); }
.tb-logday { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tb-coachtext { width: 100%; font: 12px/1.5 ui-monospace, monospace; white-space: pre; overflow-x: auto;
  background: none; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 0 0 12px; }
/* Board: likes and circuits */
.tb-heart { color: var(--topo); }
.tb-dot { display: inline-block; width: .7em; height: .7em; border-radius: 50%; margin-right: 6px; vertical-align: baseline; }
.tb-circuits { border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; margin: 12px 0; display: grid; gap: 6px; }
.tb-circuits legend { padding: 0 4px; color: var(--muted); }
