*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #000000; --surface: #0f0000; --surface2: #180000; --border: #2e0a0a;
  --text: #F5E6C8; --muted: #8a6050;
  --d1: #E8162A; --d2: #F11A7B; --d3: #c8a46a; --d4: #4fd9a4;
  --good: #4fd9a4; --warn: #f7c84f; --danger: #E8162A; --para: #F11A7B;
  --pull: #E8162A; --push: #F11A7B; --arms: #c8a46a; --opt: #4fd9a4;
  --legs: #c8a46a;
}
html, body { background: var(--bg); color: var(--text); font-family: -apple-system,'SF Pro Display','Segoe UI',sans-serif; min-height: 100vh; overflow-x: hidden; }
.page-inner { max-width: 640px; margin: 0 auto; }

/* NAV */
nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; background: #000; border-top: 1px solid var(--border); display: flex; padding-bottom: env(safe-area-inset-bottom); }
.nav-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 10px 0 8px; border: none; background: none; cursor: pointer; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; transition: color .15s; }
.nav-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.nav-btn.active { color: var(--d1); }

/* PAGES */
.page { display: none; padding-bottom: 90px; min-height: 100vh; }
.page.active { display: block; }
.page-header { padding: 46px 20px 12px; background: var(--bg); position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--border); }
.page-title { font-size: 26px; font-weight: 700; color: var(--text); letter-spacing: -.02em; }
.page-sub { font-size: 12px; color: var(--muted); margin-top: 0px; }
.page-inner-pad { padding: 16px 20px; }

/* DAY TABS */
.day-tabs { display: flex; gap: 8px; padding: 12px 20px 0; overflow-x: auto; scrollbar-width: none; }
.day-tabs::-webkit-scrollbar { display: none; }
.day-tab { flex-shrink: 0; padding: 7px 13px; border-radius: 20px; border: 1px solid var(--border); background: none; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; transition: all .15s; white-space: nowrap; }
.day-tab.active { color: #fff; border-color: transparent; }
.day-panel { display: none; padding: 14px 20px; }
.day-panel.active { display: block; }
.section-label { font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; }
.section-label:first-child { margin-top: 2px; }

/* EXERCISE CARD */
.ex-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 9px; overflow: hidden; transition: border-color .15s; }
.ex-card.done { border-color: rgba(232,22,42,.5); }
.ex-card.warn-reps { border-color: rgba(247,200,79,.5); }
.ex-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 13px; cursor: pointer; user-select: none; }
.ex-left { flex: 1; min-width: 0; }
.ex-name { font-size: 16px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ex-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.ex-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.done-check { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all .15s; background: none; }
.done-check.checked { background: var(--d1); border-color: var(--d1); }
.done-check svg { width: 13px; height: 13px; stroke: #fff; stroke-width: 2.5; fill: none; display: none; }
.done-check.checked svg { display: block; }
.expand-arrow { width: 18px; height: 18px; color: var(--muted); transition: transform .2s; flex-shrink: 0; }
.ex-card.expanded .expand-arrow { transform: rotate(180deg); }

/* LOG PANEL */
.log-panel { display: none; padding: 0 13px 14px; border-top: 1px solid var(--border); }
.ex-card.expanded .log-panel { display: block; }
.target-info { font-size: 13px; color: var(--muted); padding: 9px 0 11px; border-bottom: 1px solid var(--border); margin-bottom: 12px; line-height: 1.65; }
.target-info strong { color: var(--text); font-weight: 600; }
.why-note { margin-top: 5px; font-size: 12px; color: var(--d1); font-style: italic; }

/* PER-SET ROWS */
.per-sets-wrap { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.per-set-row { display: flex; align-items: center; gap: 8px; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 6px 8px; transition: border-color .15s; }
.per-set-row.locked { border-color: rgba(232,22,42,.4); background: rgba(232,22,42,.05); }
.set-num { font-size: 13px; color: var(--muted); font-weight: 600; width: 36px; flex-shrink: 0; }
.set-controls { display: flex; align-items: center; gap: 5px; flex: 1; }
.sv-val { font-size: 18px; font-weight: 700; color: var(--text); min-width: 28px; text-align: center; }
.sv-unit { font-size: 13px; color: var(--muted); }
.sv-sep { font-size: 13px; color: var(--border); }
.stepper-btn.sm { width: 32px; height: 32px; border: none; background: rgba(245,230,200,.08); border-radius: 7px; color: var(--text); font-size: 18px; font-weight: 300; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background .12s; }
.stepper-btn.sm:active { background: rgba(245,230,200,.15); }
.set-done-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: none; color: var(--muted); font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all .15s; }
.set-done-btn.done-set { background: rgba(232,22,42,.15); border-color: rgba(232,22,42,.5); color: var(--d1); }

/* WARN */
.warn-badge { display: flex; align-items: center; gap: 6px; background: rgba(247,200,79,.1); border: 1px solid rgba(247,200,79,.3); color: var(--warn); padding: 8px 11px; border-radius: 8px; font-size: 12px; margin-bottom: 10px; }

/* TARGET EDITOR */
.target-editor { margin-bottom: 12px; }
.target-editor-toggle { width: 100%; background: none; border: 1px dashed var(--border); border-radius: 8px; padding: 7px; font-size: 11px; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; transition: all .15s; }
.target-editor-toggle:active { background: var(--surface2); }
.target-editor-fields { display: none; padding: 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; margin-top: 6px; }
.target-editor-fields.open { display: block; }
.te-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.te-row:last-child { margin-bottom: 0; }
.te-label { font-size: 11px; color: var(--muted); width: 80px; flex-shrink: 0; }
.te-input { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px; color: var(--text); font-size: 14px; font-weight: 500; text-align: center; outline: none; -webkit-appearance: none; }
.te-input:focus { border-color: var(--good); }
.te-save { width: 100%; margin-top: 8px; padding: 8px; background: rgba(79,217,164,.15); border: 1px solid rgba(79,217,164,.3); color: var(--good); border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; }

/* GRAPH */
.graph-toggle { width: 100%; padding: 9px 0; background: none; border: none; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; border-top: 1px solid var(--border); margin-top: 4px; }
.graph-container { display: none; padding-top: 10px; }
.graph-container.visible { display: block; }
.graph-wrap { position: relative; width: 100%; height: 140px; }
.graph-wrap canvas { position: absolute; top: 0; left: 0; width: 100% !important; height: 100% !important; }

/* TAGS */
.tag { font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.tag-para { background: rgba(241,26,123,.15); color: var(--para); border: 1px solid rgba(241,26,123,.3); }
.tag-db   { background: rgba(232,22,42,.12); color: var(--d1); border: 1px solid rgba(232,22,42,.25); }
.tag-bw   { background: rgba(245,230,200,.07); color: var(--muted); border: 1px solid rgba(245,230,200,.15); }
.tag-legs { background: rgba(200,164,106,.12); color: var(--d3); border: 1px solid rgba(200,164,106,.25); }

/* PROGRESS PAGE */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; padding: 14px 20px 0; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.stat-val { font-size: 22px; font-weight: 700; color: #fff; }
.stat-label { font-size: 10px; color: var(--muted); margin-top: 2px; }
.prog-list { padding: 10px 20px; }
.prog-ex-card { background: var(--surface); border: 1px solid var(--border); border-radius: 13px; margin-bottom: 10px; overflow: hidden; }
.prog-ex-header { padding: 12px 13px; display: flex; align-items: center; justify-content: space-between; }
.prog-ex-name { font-size: 14px; font-weight: 600; color: var(--text); }
.prog-ex-stats { font-size: 12px; color: var(--muted); margin-top: 2px; }
.prog-graph-wrap { padding: 4px 13px 13px; border-top: 1px solid var(--border); }
.prog-graph-inner { position: relative; width: 100%; height: 170px; }
.prog-graph-inner canvas { position: absolute; top: 0; left: 0; width: 100% !important; height: 100% !important; }
.no-data { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.action-btn { display: flex; align-items: center; gap: 8px; margin: 10px 20px 0; padding: 11px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; font-size: 13px; color: var(--muted); cursor: pointer; width: calc(100% - 40px); }

/* SETTINGS */
.settings-section { margin-bottom: 28px; }
.settings-heading { font-size: 11px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.settings-desc { font-size: 13px; color: var(--muted); line-height: 1.6; margin-bottom: 12px; }
.settings-desc code { font-family: monospace; color: var(--d3); font-size: 12px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.settings-label { font-size: 12px; color: var(--muted); margin-bottom: 5px; display: block; }
.settings-field { margin-bottom: 12px; }
.settings-input { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; color: var(--text); font-size: 14px; outline: none; font-family: monospace; }
.settings-input:focus { border-color: var(--d1); }
.settings-hint { font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.settings-btn { padding: 9px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; margin-right: 8px; margin-bottom: 8px; }
.settings-btn.primary { background: var(--d1); border-color: var(--d1); color: #fff; }
.settings-btn.danger { color: var(--d1); border-color: rgba(232,22,42,.3); }
.install-banner { margin: 10px 20px; padding: 11px 13px; background: rgba(232,22,42,.07); border: 1px solid rgba(232,22,42,.2); border-radius: 12px; display: flex; align-items: center; gap: 10px; }
.install-banner p { font-size: 13px; color: var(--d1); flex: 1; line-height: 1.5; }
.install-btn { padding: 7px 13px; background: var(--d1); border: none; border-radius: 8px; font-size: 12px; font-weight: 700; color: #fff; cursor: pointer; flex-shrink: 0; }
.hidden { display: none !important; }

/* BODY / WEIGHT PAGE */
.body-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 16px; }
.body-log-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin-bottom: 16px; }
.body-log-label { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.body-stepper-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.body-weight-val { font-size: 42px; font-weight: 700; color: var(--text); min-width: 90px; text-align: center; letter-spacing: -.02em; }
.body-stepper-row .stepper-btn.sm { width: 44px; height: 44px; font-size: 24px; }
.body-log-btn { width: 100%; padding: 12px; background: var(--d1); border: none; border-radius: 10px; color: #fff; font-size: 15px; font-weight: 700; cursor: pointer; transition: opacity .15s; }
.body-log-btn:disabled { opacity: .5; cursor: default; }
.body-log-btn.logged { background: var(--surface2); border: 1px solid var(--border); color: var(--d4); }
.body-graph-wrap { position: relative; width: 100%; height: 220px; margin-bottom: 20px; }
.body-graph-wrap canvas { position: absolute; top: 0; left: 0; width: 100% !important; height: 100% !important; }
.body-history-label { font-size: 10px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.body-history-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.body-history-row:last-child { border-bottom: none; }
.body-history-date { font-size: 13px; color: var(--muted); flex: 1; }
.body-history-kg { font-size: 15px; font-weight: 600; color: var(--text); }
