/* Workouts. A log book: rows per exercise, a tape of past sessions per row.
   Today's writing is in pen blue; everything else is pencil and ink. */

@font-face {
  font-family: "Archivo";
  src: url("/archivo.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  --paper: #eef0f2;
  --surface: #ffffff;
  --ink: #171c24;
  --pencil: #5d6673;
  --rule: #d4d9df;
  --pen: #1e4fd6;
  --pen-wash: #e7edfc;
  --on-pen: #ffffff;
  --bad: #b3261e;
  --ok: #1d7a46;
  --b-o: #f08a24;
  --b-p: #7b4cc4;
  --b-w: #ffffff;
  --b-g: #b8bdc5;
  --b-d: #666c76;
  --b-b: #15171a;
  --m-y: #efc22e;
  --dot-edge: rgba(23, 28, 36, 0.35);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12151a;
    --surface: #1a1e25;
    --ink: #e9ecf0;
    --pencil: #98a1ae;
    --rule: #2b313a;
    --pen: #8aaaff;
    --pen-wash: #1c2740;
    --on-pen: #0d1220;
    --bad: #ff8a80;
    --ok: #6fd39a;
    --dot-edge: rgba(233, 236, 240, 0.45);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.4 "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
}
#app { max-width: 1180px; margin: 0 auto; overflow-x: clip; }
.boot { padding: 24px 16px; color: var(--pencil); }

button, input, select { font: inherit; color: inherit; }
button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
input, select, textarea { color: var(--ink); }
input, select {
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}
:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; }
label { display: grid; gap: 3px; font-size: 13px; color: var(--pencil); }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.date { position: relative; display: flex; align-items: baseline; gap: 8px; cursor: pointer; }
.date span { font-size: 13px; color: var(--pencil); }
.date strong { font-size: 21px; font-weight: 700; font-stretch: 88%; color: var(--ink); }
.date input { position: absolute; inset: 0; opacity: 0; min-height: 0; cursor: pointer; }
.top { flex-wrap: nowrap; }
.date { min-width: 0; white-space: nowrap; }
.back { min-height: 36px; margin-left: auto; white-space: nowrap; border-color: var(--pen); color: var(--pen); background: transparent; font-size: 13px; }
.sync { min-height: 36px; font-size: 13px; font-weight: 500; color: var(--pencil); background: transparent; }
.sync.ok { color: var(--ok); }
.sync.warn { color: var(--ink); border-color: var(--pencil); }
.sync.bad { color: var(--bad); border-color: var(--bad); }

.banner { margin: 0; padding: 10px 16px; background: var(--pen-wash); font-size: 14px; }
.banner button { min-height: 32px; margin-left: 8px; border-color: var(--pen); color: var(--pen); background: transparent; }

.daynote { grid-template-columns: auto 1fr; align-items: center; gap: 10px; padding: 10px 16px 0; }
.daynote input { min-height: 38px; background: transparent; }

/* sections and rows */
.sec { margin-top: 18px; }
.sec h2, .panel h2 { margin: 0 16px 6px; font-size: 14px; font-weight: 600; color: var(--pencil); }
.sec h2 small { margin-left: 8px; font-size: 13px; font-weight: 400; }
.row { background: var(--surface); border-top: 1px solid var(--rule); }
.row:last-child { border-bottom: 1px solid var(--rule); }
.row.open { box-shadow: inset 3px 0 0 var(--pen); }
.sec.rest .row-head .name, .sec.older .row-head .name { color: var(--pencil); }
.sec.rest .row.open .name, .sec.older .row.open .name { color: var(--ink); }

.row-main { padding: 2px 16px 0; }
.row-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: baseline; gap: 8px;
  width: 100%; min-height: 40px; padding: 8px 0 0;
  border: 0; border-radius: 0; background: none; text-align: left;
}
.name { font-size: 18px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.tag { font-size: 12px; font-weight: 500; color: var(--pencil); border: 1px solid var(--rule); border-radius: 4px; padding: 0 5px; }
.when { font-size: 13px; font-weight: 400; color: var(--pencil); white-space: nowrap; }
.has-today .when { color: var(--pen); font-weight: 600; }


.bests { padding: 0 16px 12px; font-size: 14px; color: var(--pencil); }
.bests h4 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.bests ul { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: auto auto 1fr; column-gap: 16px; row-gap: 3px; }
.bests li { display: contents; }
.bests li.b-head { display: block; grid-column: 1 / -1; margin-top: 8px; font-weight: 600; }
.b-reps { color: var(--ink); font-weight: 600; }

/* the history tape */
.tape {
  display: flex; align-items: stretch;
  overflow-x: auto; overscroll-behavior-x: contain;
  padding: 2px 16px 10px;
  scrollbar-width: thin;
}
@media (pointer: coarse) { .tape { scrollbar-width: none; } .tape::-webkit-scrollbar { display: none; } }
.cell {
  flex: none; display: grid; align-content: start; row-gap: 1px;
  min-height: 0; max-width: 60ch;
  padding: 2px 14px 2px 12px;
  border: 0; border-left: 1px solid var(--rule); border-radius: 0;
  background: none; text-align: left; font-weight: 400;
}
.cell:first-child { border-left: 0; padding-left: 0; }
.c-date { font-size: 12px; color: var(--pencil); }
.c-sets { font-size: 16px; font-stretch: 80%; white-space: nowrap; }
.c-note { font-size: 12px; color: var(--pencil); max-width: 30ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell.now .c-date, .cell.now .c-sets { color: var(--pen); font-weight: 600; }
.cell.mark, .cell.more { align-content: center; font-size: 12px; color: var(--pencil); }
.cell.more { color: var(--pen); font-weight: 600; }
.cell.best { padding-right: 12px; margin-right: 0; border-right: 1px solid var(--rule); }
.cell.best + .cell { border-left: 1px solid var(--rule); margin-left: 2px; }
.cell.best .c-sets { font-weight: 600; }

.dot {
  display: inline-block; width: 0.6em; height: 0.6em; margin-right: 0.22em;
  border-radius: 50%; border: 1px solid var(--dot-edge); vertical-align: 0.02em;
}
.b-o { background: var(--b-o); } .b-p { background: var(--b-p); } .b-w { background: var(--b-w); }
.b-g { background: var(--b-g); } .b-d { background: var(--b-d); } .b-b { background: var(--b-b); }
.m-p { background: var(--b-p); border-radius: 2px; } .m-y { background: var(--m-y); border-radius: 2px; }

/* logging */
.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 4px 16px 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 14px; border-radius: 999px; font-size: 16px; font-weight: 500; }
.chip.on { border-color: var(--pen); box-shadow: inset 0 0 0 1px var(--pen); background: var(--pen-wash); font-weight: 600; }
.chip.quiet { color: var(--pencil); border-style: dashed; }
.picker { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); }
.entry { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.entry input { min-height: 52px; font-size: 22px; font-weight: 600; }
.primary { min-height: 52px; padding: 0 18px; border-color: var(--pen); background: var(--pen); color: var(--on-pen); font-size: 16px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 32px; font-size: 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; min-height: 0; margin: 0; padding: 0; accent-color: var(--pen); }
.err { margin: 0; font-size: 14px; color: var(--bad); }
.err:empty { display: none; }
.edit-bar { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--pencil); }
.edit-bar span { margin-right: auto; }
.sets-now { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sets-now .lbl { font-size: 13px; color: var(--pen); font-weight: 600; margin-right: 4px; }
.setchip { min-height: 40px; padding: 0 10px; border-color: transparent; background: var(--pen-wash); color: var(--pen); font-size: 16px; font-stretch: 80%; }
.setchip.on { border-color: var(--pen); }

.notes { min-width: 0; font-size: 13px; color: var(--pencil); }
.notes summary { display: flex; align-items: center; gap: 10px; min-height: 36px; padding-top: 6px; cursor: pointer; font-weight: 600; list-style: none; }
.notes summary::-webkit-details-marker { display: none; }
.notes summary::before { content: ""; flex: none; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); align-self: center; }
.notes[open] summary::before { transform: rotate(45deg); }
.notes summary .standing { flex: 1; min-width: 0; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes[open] summary .standing { display: none; }
.notes label { margin-top: 6px; }
textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); font: inherit; color: var(--ink); resize: vertical; }

/* panels */
.panel { margin-top: 14px; padding: 14px 16px; background: var(--surface); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.panel h2 { margin: 0 0 10px; color: var(--ink); font-size: 16px; }
.panel p { margin: 8px 0; font-size: 14px; }
.info { color: var(--pencil); }
.otherlog { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--bad); border-radius: 8px; }
.otherlog[hidden] { display: none; }
.otherlog p { margin: 0 0 8px; }
.otherlog button { border-color: var(--bad); color: var(--bad); background: transparent; }
.line { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.line .wide { flex: 1 1 220px; }
.filebtn {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--rule); border-radius: 8px; background: var(--surface);
  font-size: 15px; font-weight: 600; color: var(--ink); cursor: pointer; position: relative;
}
.filebtn input { position: absolute; inset: 0; opacity: 0; min-height: 0; cursor: pointer; }
.filebtn:focus-within { outline: 2px solid var(--pen); outline-offset: 2px; }
.older-toggle { padding: 18px 16px 0; }
.big { width: 100%; min-height: 48px; border-style: dashed; border-color: var(--pencil); background: transparent; }

/* wider screens: name on the left, tape on the right, like the sheet */
@media (min-width: 900px) {
  .top { padding-left: 20px; padding-right: 20px; }
  .row { display: grid; grid-template-columns: 300px minmax(0, 1fr); border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); }
  .row-main { padding: 6px 12px 8px 20px; }
  .tape { padding: 14px 16px 12px 4px; }
  .bests { grid-column: 2; padding: 0 16px 12px 4px; }
  .form { grid-column: 1 / -1; grid-template-columns: minmax(0, 520px); padding: 4px 20px 18px; }
  .sec h2 { margin-left: 20px; }
  .daynote { max-width: 560px; padding-left: 20px; }
  .panel { border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); padding: 16px 20px; }
  .older-toggle { max-width: 420px; padding-left: 20px; }
}
