/* Training Log. Dark (default, charcoal + orange) and light (cream + coral) themes, both from tokens.
   Display type: Archivo (SIL OFL, fonts/OFL.txt), condensed italic, self-hosted (CSP font-src 'self'). */
@font-face {
  font-family: "Archivo Display";
  src: url("fonts/archivo-italic.woff2") format("woff2");
  font-style: italic; font-weight: 100 900; font-stretch: 62% 125%; font-display: swap;
}
:root {
  color-scheme: dark;
  --bg: #0b0b0c;
  --bg-glow: radial-gradient(1200px 600px at 75% -10%, rgba(255, 91, 31, 0.10), transparent 60%);
  --panel: #161618;
  --panel-2: #1f1f22;
  --panel-3: #2a2a2e;
  --line: #2c2c31;
  --text: #f4f4f5;
  --muted: #8f8f97;
  --accent: #ff5b1f;
  --accent-2: #ff8a4c;
  --accent-soft: rgba(255, 91, 31, 0.14);
  --yellow: #f6c445;
  --good: #8bd17c;
  --muscle-base: #2c2c31;
  --muscle-line: #3a3a40;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 40px -24px rgba(0, 0, 0, 0.8);
  --radius: 22px;
  --radius-sm: 14px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Archivo Display", var(--font);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f1ede6;
  --bg-glow: radial-gradient(900px 500px at 80% -10%, rgba(240, 86, 63, 0.10), transparent 60%);
  --panel: #fbfaf7;
  --panel-2: #f3efe8;
  --panel-3: #e6e0d6;
  --line: #e3ddd2;
  --text: #1b1a18;
  --muted: #7c776e;
  --accent: #ef5a3c;
  --accent-2: #f5895f;
  --accent-soft: rgba(239, 90, 60, 0.12);
  --yellow: #f2b632;
  --good: #3f9a52;
  --muscle-base: #e3ddd2;
  --muscle-line: #d3ccbf;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.05), 0 18px 40px -26px rgba(60, 40, 20, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
button { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 88px minmax(0, 1fr); min-height: 100%; }
.rail {
  position: sticky; top: 16px; align-self: start;
  margin: 16px 0 16px 16px; height: calc(100vh - 32px);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 14px 0; border-radius: 40px;
  background: var(--panel); box-shadow: var(--shadow); border: 1px solid var(--line);
}
.brand { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); margin-bottom: 16px; }
.brand svg { width: 24px; fill: var(--accent); }
.tab {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  color: var(--muted); text-decoration: none; transition: background .2s, color .2s;
}
.tab svg { width: 22px; height: 22px; fill: currentColor; }
.tab span { display: none; }
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab[aria-current="page"] { background: var(--accent); color: #fff; }
.rail .spacer { flex: 1; }
.theme-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--panel-2); cursor: pointer; display: grid; place-items: center; }
.theme-btn svg { width: 20px; fill: var(--text); }

main { padding: 24px clamp(16px, 3vw, 36px) 48px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.top h1 { margin: 0; font-size: clamp(24px, 3vw, 32px); font-weight: 500; letter-spacing: -0.02em; text-wrap: balance; }
.top h1 span { color: var(--muted); }
.top h1 b { font-weight: 700; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.unit-toggle { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.unit-toggle button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13px; }
.unit-toggle button[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* ---------- cards + grid ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; position: relative; overflow: hidden;
}
.card h2 { margin: 0; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.card h2 small { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 12px; }
.chip-ico { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; flex: none; }
.chip-ico svg { width: 16px; height: 16px; fill: #fff; }
.card .lede { color: var(--muted); font-size: 12px; margin: 2px 0 0 40px; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }

.big { font-size: clamp(30px, 4vw, 44px); font-weight: 600; letter-spacing: -0.03em; line-height: 1; }
.big small, .num small { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: 0; margin-left: 4px; }
.num { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.accent { color: var(--accent); }
.muted { color: var(--muted); }
.row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 14px; margin-top: 16px; }

/* ---------- hero: body map ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 8px; align-items: center; min-height: 360px; padding: 26px 28px; }
.hero h2 { font-size: clamp(24px, 2.6vw, 30px); font-weight: 500; letter-spacing: -0.02em; display: block; line-height: 1.1; }
.hero .stats { grid-template-columns: 1fr 1fr; gap: 18px 14px; }
.body-map { display: flex; justify-content: center; gap: 4%; }
.body-map svg { width: 46%; max-width: 190px; height: auto; overflow: visible; }
.body-map .outline { fill: var(--panel-2); stroke: var(--muscle-line); stroke-width: 1; }
.body-map .m { fill: var(--muscle-base); stroke: var(--muscle-line); stroke-width: .8; transition: fill .4s; }
.body-map .m.on { fill: var(--accent); filter: drop-shadow(0 0 6px var(--accent)); }
.body-map figcaption { text-align: center; font-size: 11px; color: var(--muted); margin-top: 4px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- week strip + plan dots ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 14px; text-align: center; }
.week .d { display: grid; gap: 6px; justify-items: center; font-size: 12px; color: var(--muted); }
.week .dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: 12px; }
.week .dot.done { background: var(--yellow); border-color: transparent; color: #1b1a18; }
.week .dot.today { outline: 2px solid var(--accent); outline-offset: 2px; }
.week .dot svg { width: 14px; fill: currentColor; }
.honey { display: grid; grid-template-columns: repeat(7, 22px); gap: 6px; }
.honey i { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--yellow); }
.honey i.on { background: var(--yellow); }

/* ---------- meters, bars, rings ---------- */
.segments { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; height: 54px; margin: 14px 0 6px; }
.segments i { border-radius: 8px; background: var(--panel-3); position: relative; overflow: hidden; }
.segments i b { position: absolute; inset: auto 0 0 0; background: linear-gradient(var(--accent-2), var(--accent)); border-radius: 8px; }
.bar-track { height: 10px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.bar-track b { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--yellow)); }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .val { fill: var(--text); font-weight: 600; }
.chart .grid-line { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .bar { fill: var(--panel-3); }
.chart .bar.cur { fill: url(#hatch); }
.chart .bar.hi { fill: var(--accent); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.alt { stroke: var(--text); stroke-width: 1.5; opacity: .55; }
.chart .area { fill: url(#fade); }
.chart .pt { fill: var(--panel); stroke: var(--accent); stroke-width: 2; }
.chart .pt.pr { fill: var(--accent); }
.ring-wrap { display: grid; place-items: center; position: relative; }
.ring-wrap .center { position: absolute; text-align: center; }
.ring-track { fill: none; stroke: var(--panel-3); }
.ring-val { fill: none; stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.donut-seg { fill: none; }

/* ---------- lists + tables ---------- */
.goals { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.goals li { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.goals .tick { width: 22px; height: 22px; border-radius: 50%; background: var(--panel-3); display: grid; place-items: center; flex: none; margin-left: auto; }
.goals li.done .tick { background: var(--accent); }
.goals li.done span { color: var(--muted); text-decoration: line-through; }
.goals .tick svg { width: 12px; fill: #fff; }
.list { display: grid; gap: 8px; margin-top: 12px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--panel-2); }
.item .ico { width: 38px; height: 38px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; flex: none; color: var(--accent); font-weight: 700; font-size: 13px; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { color: var(--muted); font-size: 12px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--panel-3); font-size: 12px; color: var(--muted); }
.pill.hot { background: var(--accent-soft); color: var(--accent); }
.pill.up { color: var(--good); }
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.prog { min-width: 140px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }

/* ---------- progress view ---------- */
.ex-pills { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.ex-pills button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 8px 14px; white-space: nowrap; cursor: pointer; font-size: 13px; }
.ex-pills button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.suggest { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: 0; }
.suggest .label, .suggest .muted { color: rgba(255, 255, 255, 0.8); }
.suggest .big small { color: rgba(255, 255, 255, 0.85); }

/* ---------- sessions ---------- */
details.session { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
details.session + details.session { margin-top: 12px; }
details.session summary { list-style: none; cursor: pointer; padding: 16px 20px; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; }
details.session summary::-webkit-details-marker { display: none; }
details.session .date { width: 54px; height: 54px; border-radius: 16px; background: var(--panel-2); display: grid; place-items: center; text-align: center; line-height: 1; }
details.session .date b { font-size: 20px; display: block; }
details.session .date small { font-size: 11px; color: var(--muted); text-transform: uppercase; }
details.session .metrics { display: flex; gap: 16px; color: var(--muted); font-size: 13px; flex-wrap: wrap; justify-content: flex-end; }
details.session .metrics b { color: var(--text); }
details.session .body { padding: 0 20px 18px; display: grid; gap: 12px; }
.sets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sets span { font-family: var(--mono); font-size: 12px; padding: 4px 8px; border-radius: 8px; background: var(--panel-2); }
.sets span.w { opacity: .55; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 18px; margin-bottom: 6px; }

/* ---------- display type ---------- */
.top h1, .hero h2, .big, .num, .card h2, details.session .date b {
  font-family: var(--display); font-style: italic; font-stretch: 78%; letter-spacing: -0.01em;
}
.top h1 { font-weight: 800; text-transform: uppercase; }
.top h1 span { font-weight: 500; }
.hero h2 { font-weight: 800; text-transform: uppercase; }
.big { font-weight: 800; }
.num { font-weight: 700; }
.card h2 { font-weight: 700; font-size: 17px; }
.card.hero h2 { font-size: clamp(30px, 3.4vw, 46px); font-weight: 800; line-height: .95; margin: 6px 0 4px; }

/* ---------- sign-in + forms ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.login-card {
  width: min(400px, 100%); display: grid; gap: 10px; padding: 28px 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.login-card h1 { margin: 8px 0 0; font-family: var(--display); font-style: italic; font-stretch: 78%; font-weight: 800; font-size: 34px; text-transform: uppercase; letter-spacing: -0.01em; }
.login-card .sub { margin: 0 0 8px; }
.big-brand { width: 52px; height: 52px; margin: 0; }
.big-brand svg { width: 28px; }
.form { display: grid; gap: 10px; margin-top: 14px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
input, select {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops iOS zooming into the field */
  color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.label + input, label + input, label + select { margin-top: -4px; }
button.primary { border: 0; border-radius: 999px; padding: 12px 20px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
button.primary:disabled { opacity: .6; cursor: progress; }
button.ghost { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 8px 14px; cursor: pointer; color: var(--text); font-size: 13px; }
button.link { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px; font-size: 13px; text-decoration: underline; justify-self: center; }
.error { color: #ff6b5b; font-size: 13px; margin: 0; min-height: 0; }
.error:empty { display: none; }
.note { background: var(--accent-soft); color: var(--text); border-radius: 12px; padding: 10px 12px; font-size: 13px; margin: 0; }
.hint { color: var(--muted); font-size: 12px; margin: -2px 0 0; }
code { font-family: var(--mono); font-size: 12px; background: var(--panel-2); padding: 2px 6px; border-radius: 6px; }
.key-reveal { margin-top: 12px; padding: 14px; border-radius: 14px; background: var(--accent-soft); display: grid; gap: 10px; }
.key-reveal code { word-break: break-all; font-size: 13px; padding: 10px; background: var(--panel); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .span-4 { grid-column: span 6; } .span-5, .span-7 { grid-column: span 12; } .span-8 { grid-column: span 12; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: fixed; z-index: 10; inset: auto 12px calc(12px + env(safe-area-inset-bottom)) 12px; top: auto;
    margin: 0; height: 64px; flex-direction: row; justify-content: space-around; padding: 0 10px; border-radius: 32px;
    background: var(--accent); border: 0;
  }
  .rail .brand, .rail .spacer { display: none; }
  .tab { width: auto; height: 46px; padding: 0 14px; border-radius: 999px; display: flex; gap: 8px; color: rgba(255, 255, 255, 0.85); }
  .tab span { display: inline; font-size: 13px; font-weight: 600; }
  .tab:not([aria-current="page"]) span { display: none; }
  .tab[aria-current="page"] { background: #fff; color: var(--accent); }
  .theme-btn { background: rgba(255, 255, 255, 0.2); }
  .theme-btn svg { fill: #fff; }
  main { padding-bottom: 110px; }
  .grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .grid > * { grid-column: 1 / -1 !important; }
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .card { padding: 16px; }
  details.session summary { grid-template-columns: auto 1fr; }
  details.session .metrics { grid-column: 1 / -1; justify-content: flex-start; }
  .form .two { grid-template-columns: 1fr; }
  .tab { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
