/* ============================================================
   Personal site — quiet, minimalistic design system
   System sans · near-black ink on off-white · one subtle accent
   Hairline rules · generous whitespace · no external fonts
   ============================================================ */

:root {
  --ink:    #1b1b1a;   /* near-black text            */
  --paper:  #fbfbf9;   /* off-white background       */
  --card:   #ffffff;   /* raised surfaces            */
  --muted:  #6c6a64;   /* secondary text             */
  --faint:  #97948c;   /* tertiary / captions        */
  --line:   #e7e5df;   /* hairline borders           */
  --accent: #3a6ea5;   /* the single subtle accent   */
  --accent-soft: #eef3f8;

  --measure: 66ch;     /* comfortable reading width  */
  --gap: 1rem;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
          "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 0 24px; }

/* ---------- Top bar (authenticated chrome) ---------- */
.topbar { border-bottom: 1px solid var(--line); background: var(--card); }
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding-top: 8px; padding-bottom: 8px;
}
.topbar-brand {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
  text-decoration: none;
}
.topbar-account { display: flex; align-items: center; gap: 0.75rem; }
.topbar-user { font-size: 0.82rem; color: var(--muted); }
.topbar-account button {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.topbar-account button:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- History sheet (moves × dates) ---------- */
.history { max-width:860px; margin:0 auto; padding:34px 16px 64px; }
.hist-head { margin-bottom:16px; }
.hist-head .back { font-size:.82rem; font-weight:600; text-decoration:none; }
.hist-head h1 { font-size:1.7rem; letter-spacing:-0.02em; margin-top:.6rem; }
.hist-sub { color:var(--faint); font-size:.84rem; margin-top:.4rem; max-width:60ch; }
.hist-empty { color:var(--muted); font-size:.92rem; padding:24px 0; }
.hist-hint { color:var(--faint); font-size:.76rem; margin-top:10px; }

.sheet-scroll {
  overflow-x:auto; -webkit-overflow-scrolling:touch;
  border:1px solid var(--line); border-radius:12px; background:var(--card);
}
table.grid { border-collapse:separate; border-spacing:0; width:max-content; min-width:100%; font-size:.82rem; }
table.grid th, table.grid td { padding:9px 10px; text-align:center; white-space:nowrap; border-bottom:1px solid var(--line); }
table.grid thead th {
  font-weight:600; color:var(--faint); font-size:.7rem; text-transform:uppercase; letter-spacing:.04em;
  background:var(--card); border-bottom:2px solid var(--ink);
}
table.grid thead th .dow { display:block; font-size:.62rem; font-weight:500; letter-spacing:0; }
table.grid tbody tr:last-child td { border-bottom:none; }

/* frozen first column */
.move {
  position:sticky; left:0; z-index:2; background:var(--card);
  text-align:left !important; font-weight:600; color:var(--ink);
  min-width:118px; box-shadow:1px 0 0 var(--line);
}
thead th.move { z-index:3; color:var(--muted); }

td.cell { min-width:74px; }
td.cell.empty { color:var(--faint); }
.cellbtn {
  font:inherit; background:none; border:none; cursor:pointer; color:inherit;
  padding:4px 6px; margin:-4px -6px; border-radius:7px; width:100%;
}
.cellbtn:hover, .cellbtn:focus-visible { background:var(--accent-soft); outline:none; }
.cellbtn .v { display:block; font-weight:650; color:var(--ink); }
.cellbtn .r { display:block; font-size:.72rem; color:var(--muted); margin-top:1px; }
.cellbtn .up { color:#2e7d5b; font-size:.66rem; }

/* empty cell = tap to add; shows a dot, turns into a + on hover/focus */
.addbtn {
  font:inherit; background:none; border:none; cursor:pointer; color:var(--faint);
  padding:4px 6px; margin:-4px -6px; border-radius:7px; width:100%; min-height:34px;
}
.addbtn::before { content:"·"; }
.addbtn:hover, .addbtn:focus-visible { background:var(--accent-soft); color:var(--accent); outline:none; }
.addbtn:hover::before, .addbtn:focus-visible::before { content:"+"; font-weight:700; }

/* pager over date columns */
.hist-pager {
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  margin-top:12px; font-size:.82rem;
}
.hist-pager a { font-weight:600; text-decoration:none; }
.hist-pager a:hover { text-decoration:underline; }
.hist-pager .range { color:var(--faint); font-size:.78rem; }

/* ---------- Edit bottom sheet ---------- */
.backdrop { position:fixed; inset:0; background:rgba(20,20,20,.4); z-index:10; }
.esheet {
  position:fixed; left:0; right:0; bottom:0; z-index:11;
  background:var(--card); border-radius:16px 16px 0 0; padding:20px 20px 28px;
  box-shadow:0 -8px 40px rgba(0,0,0,.2); max-width:480px; margin:0 auto;
}
.esheet .grabber { width:38px; height:4px; background:var(--line); border-radius:2px; margin:0 auto 16px; }
.esheet h3 { font-size:1.05rem; margin-bottom:16px; }
.esheet .frow { margin-bottom:12px; }
.esheet .frow label { display:block; font-size:.7rem; text-transform:uppercase; letter-spacing:.06em; color:var(--muted); font-weight:600; margin-bottom:5px; }
.esheet .frow input { width:100%; font:inherit; font-size:1rem; border:1px solid var(--line); border-radius:8px; padding:10px; color:var(--ink); background:var(--card); }
.esheet .frow input:focus-visible { outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft); }
.esheet .two { display:flex; gap:10px; }
.esheet .two .frow { flex:1; }
.eactions { display:flex; gap:8px; margin-top:18px; }
.eactions .btn { font:inherit; font-size:.85rem; font-weight:600; border:none; border-radius:9px; padding:11px 16px; cursor:pointer; }
.eactions .btn.save { background:var(--accent); color:#fff; flex:1; }
.eactions .btn.del { background:#fdeceb; color:#b3261e; border:1px solid #f3c9c6; }
.eactions .btn.ghost { background:none; color:var(--muted); border:1px solid var(--line); }

/* link to history from the training page */
.hist-link { display:inline-block; margin-top:1.2rem; font-size:.85rem; font-weight:600; text-decoration:none; }
.hist-link:hover { text-decoration:underline; }

/* ---------- Error page ---------- */
.error-page {
  max-width: 480px;
  margin: 0 auto;
  padding: clamp(64px, 15vh, 140px) 24px;
  text-align: center;
}
.error-code {
  font-size: clamp(3rem, 12vw, 4.5rem);
  font-weight: 650;
  color: var(--accent);
  letter-spacing: -0.03em;
  line-height: 1;
}
.error-page h1 { font-size: 1.25rem; font-weight: 600; margin: 0.75rem 0 1.5rem; }
.error-home { font-size: 0.9rem; font-weight: 600; }

/* ---------- Dashboard ---------- */
.dashboard { max-width: 720px; margin: 0 auto; padding: clamp(48px, 10vh, 96px) 24px 64px; }
.dash-head { margin-bottom: 2rem; }
.dash-head h1 { margin-top: 0.5rem; }
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.app-card {
  display: block;
  text-decoration: none;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.app-card:hover, .app-card:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
.app-icon { font-size: 1.8rem; line-height: 1; margin-bottom: 12px; }
.app-name { font-weight: 650; font-size: 1.05rem; letter-spacing: -0.01em; margin-bottom: 4px; }
.app-desc { font-size: 0.85rem; color: var(--muted); line-height: 1.5; }
.dash-empty { color: var(--muted); }

/* ---------- Auth / sign-in ---------- */
.auth {
  max-width: 360px;
  margin: 0 auto;
  padding: clamp(48px, 12vh, 120px) 24px 48px;
}
.auth-card .eyebrow { margin-bottom: 0.8rem; }
.auth-card h1 { font-size: 1.9rem; margin-bottom: 1.5rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
.auth-form input {
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  width: 100%;
}
.auth-form input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.auth-form button {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 12px;
  margin-top: 0.25rem;
  cursor: pointer;
}
.auth-form button:hover { filter: brightness(0.95); }
.auth-error {
  font-size: 0.85rem;
  color: #b3261e;
  background: #fdeceb;
  border: 1px solid #f3c9c6;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 1.1rem;
}

/* ---------- Typography ---------- */
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; font-weight: 650; }
h1 { font-size: clamp(2rem, 5vw, 2.9rem); letter-spacing: -0.03em; }
h2 { font-size: clamp(1.35rem, 3vw, 1.7rem); }
h3 { font-size: 1.02rem; font-weight: 600; margin: 1.75rem 0 0.5rem; }

p { margin-bottom: 0.9rem; max-width: var(--measure); }
p:last-child { margin-bottom: 0; }
.lede { font-size: 1.1rem; color: var(--muted); }
b, strong { font-weight: 650; color: var(--ink); }

a { color: var(--accent); text-underline-offset: 2px; }

/* ---------- Hero ---------- */
.hero { padding: 88px 0 40px; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 1.1rem;
}
.hero h1 { margin-bottom: 1.4rem; }
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.4rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.stats span { white-space: nowrap; }

/* ---------- Sections ---------- */
.section { padding: 40px 0; border-top: 1px solid var(--line); }
.section-label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--faint);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.section-label::before {
  content: "";
  width: 18px; height: 1px;
  background: var(--accent);
}
.section > .wrap > h2 { margin-bottom: 1rem; }

/* ---------- Week strip ---------- */
.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 1.25rem;
}
.day {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 6px 10px;
  text-align: center;
}
.day .dow {
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 6px;
}
.day .icon { font-size: 1.2rem; line-height: 1; margin-bottom: 5px; }
.day .what { font-size: 0.7rem; font-weight: 600; color: var(--muted); }
.day--rest { background: transparent; }

/* ---------- Exercise grid ---------- */
.exercises {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
  margin-top: 1.25rem;
}
.exercise {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  color: var(--ink);
}
.exercise svg { width: 100%; height: 80px; display: block; margin-bottom: 10px; }
.exercise-name { font-weight: 600; font-size: 0.86rem; margin-bottom: 2px; }
.exercise-sets { font-size: 0.78rem; color: var(--muted); }
.exercise .demo { padding-top: 0; }

/* ---------- Exercise footer + log control ---------- */
.exercise-foot {
  margin-top: auto;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.log-last {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  line-height: 1.3;
}
.log-last:empty { display: none; }

details.log { width: 100%; text-align: center; }
details.log > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 14px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
details.log > summary::-webkit-details-marker { display: none; }
details.log > summary::before { content: "+"; font-weight: 700; }
details.log[open] > summary { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
details.log[open] > summary::before { content: "−"; }

.log-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}
.log-input {
  width: 66px;
  font: inherit;
  font-size: 0.85rem;
  text-align: center;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}
.log-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.log-form button {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
}
.log-form button:hover { filter: brightness(0.95); }
.demo a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.demo a:hover, .demo a:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.demo a::after { content: "\203A"; font-size: 0.85rem; }

/* ---------- Callout ---------- */
.callout {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 1.25rem 0;
}
.callout h3 { margin-top: 0; }
.callout ul { margin: 0.5rem 0 0 1.1rem; }
.callout li { margin-bottom: 0.4rem; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; }
th, td { text-align: left; padding: 10px 12px; font-size: 0.9rem; }
th {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.68rem;
  color: var(--faint);
  border-bottom: 1px solid var(--ink);
}
td { border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }

/* ---------- Macro cards ---------- */
.macros {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin: 1.25rem 0;
}
.macro {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
.macro-value { font-size: 1.6rem; font-weight: 650; line-height: 1; letter-spacing: -0.02em; }
.macro-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  margin-top: 0.4rem;
}

/* ---------- Lists ---------- */
.checklist { list-style: none; margin: 0.5rem 0; }
.checklist li {
  padding: 9px 0 9px 22px;
  position: relative;
  border-bottom: 1px solid var(--line);
  max-width: var(--measure);
}
.checklist li::before {
  content: "";
  position: absolute; left: 0; top: 16px;
  width: 7px; height: 7px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
}
.checklist li:last-child { border-bottom: none; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0.75rem 0; }
.tags span {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ---------- Breathing grid ---------- */
.breathing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin: 1.25rem 0;
}
.bcard {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
}
.bcard h3 { margin: 0 0 0.6rem; font-size: 0.95rem; }
.bcard ul { margin: 0 0 0 1.1rem; }
.bcard li { margin-bottom: 0.5rem; font-size: 0.9rem; }

/* ---------- Priorities ---------- */
.priorities { counter-reset: p; list-style: none; margin-top: 0.5rem; }
.priorities li {
  position: relative;
  padding: 12px 0 12px 40px;
  border-bottom: 1px solid var(--line);
  max-width: var(--measure);
}
.priorities li:last-child { border-bottom: none; }
.priorities li::before {
  counter-increment: p;
  content: counter(p, decimal-leading-zero);
  position: absolute; left: 0; top: 13px;
  font-weight: 650;
  font-size: 0.85rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ---------- Footer ---------- */
footer { padding: 40px 0 80px; color: var(--faint); font-size: 0.84rem; border-top: 1px solid var(--line); }

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .week { grid-template-columns: repeat(4, 1fr); }
  .hero { padding: 56px 0 32px; }
  th, td { padding: 8px; font-size: 0.85rem; }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .exercise svg animate,
  .exercise svg animateTransform { display: none; }
}
