[hidden] { display: none !important; }

:root {
  --bg: #fbf7f1;
  --bg-alt: #f3ece1;
  --surface: #ffffff;
  --surface-2: #faf5ec;
  --text: #1a120b;
  --text-soft: #5a4a3a;
  --muted: #8a7860;
  --border: #e6dccb;
  --primary: #9a3b2b;        /* oxblood / forged copper-red */
  --primary-hover: #7c2c20;
  --accent: #d4a24c;         /* gilded gold */
  --accent-soft: #f4dba0;
  --danger: #b3261e;
  --success: #2e7d32;
  --warning: #b07000;
  --shadow: 0 4px 16px rgba(40, 25, 10, 0.10);
  --shadow-lg: 0 14px 40px rgba(40, 25, 10, 0.18);
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'Helvetica Neue', Arial, system-ui, sans-serif;
  --font-display: 'Georgia', 'Times New Roman', serif;
}

[data-theme="dark"] {
  --bg: #16110c;
  --bg-alt: #1e1812;
  --surface: #221b14;
  --surface-2: #2b231a;
  --text: #f4ecdf;
  --text-soft: #d6c7b2;
  --muted: #a08f78;
  --border: #3a2f22;
  --primary: #c05a45;
  --primary-hover: #d6705a;
  --accent: #e6b860;
  --accent-soft: #5a4a25;
  --shadow: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 14px 40px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
h1,h2,h3,h4 { font-family: var(--font-display); line-height: 1.15; margin: 0 0 .5rem; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.4rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 .8rem; }
a { color: var(--primary); text-decoration: none; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; }
.muted { color: var(--muted); }
.muted-label { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: 1.5px; margin: 0; }
.spacer { flex: 1; }
code, kbd { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-size: .85em; }

/* ---------- HEADER ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: .65rem; color: var(--text); }
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 1.1rem;
  letter-spacing: .5px; flex: none; box-shadow: var(--shadow);
}
.brand-text strong { font-family: var(--font-display); font-size: 1.15rem; display: block; line-height: 1; }
.brand-text small { color: var(--muted); font-size: .72rem; letter-spacing: .5px; }
.main-nav { display: flex; align-items: center; gap: .25rem; }
.nav-link {
  background: none; border: none; color: var(--text-soft); cursor: pointer;
  font: inherit; font-size: .92rem; padding: .55rem .8rem; border-radius: var(--radius-sm);
  transition: .15s ease;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { color: var(--primary); font-weight: 700; }
.nav-icon {
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%; font-size: 1.1rem; color: var(--text);
  transition: .15s ease;
}
.nav-icon:hover { transform: rotate(25deg); border-color: var(--accent); }
.hamburger { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 8px; }
.hamburger span { width: 24px; height: 2px; background: var(--text); border-radius: 2px; transition: .2s; }

/* ---------- VIEWS ---------- */
.view { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.section { padding: 2.5rem 0; }
.section-title { position: relative; }
.section-title::after { content: ''; display: block; width: 50px; height: 3px; background: var(--accent); margin-top: .5rem; }

/* ---------- HERO ---------- */
.hero {
  position: relative; color: #f4ecdf; overflow: hidden;
  background:
    linear-gradient(rgba(20,17,13,0.72), rgba(20,17,13,0.9)),
    radial-gradient(circle at 30% 30%, #6e2418, #160e08 70%);
}
.hero::before {
  content: ''; position: absolute; inset: 0; opacity: .05; pointer-events: none;
  background: repeating-linear-gradient(45deg, var(--accent) 0 2px, transparent 2px 14px);
}
.hero-inner { position: relative; padding: 3rem 1.25rem 2.5rem; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: 2px; font-size: .78rem; margin: 0 0 .4rem; }
.hero h1 { color: #fff; margin-bottom: .4rem; }
.hero .lead { color: #e8dcc8; max-width: 56ch; font-size: 1.05rem; }
.hero-ctas { display: flex; gap: .75rem; flex-wrap: wrap; margin: 1.2rem 0 1.5rem; }
.stats-strip { display: flex; flex-wrap: wrap; gap: 1.8rem; }
.stat b { font-family: var(--font-display); font-size: 1.8rem; color: var(--accent); display: block; line-height: 1; }
.stat span { font-size: .7rem; text-transform: uppercase; letter-spacing: 1.5px; color: #cdbba2; }

/* ---------- BUTTONS ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm);
  border: 1px solid transparent; padding: 0 1.1rem; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  transition: .15s ease; line-height: 1;
}
.btn-sm { min-height: 36px; padding: 0 .8rem; font-size: .85rem; }
.btn-lg { min-height: 52px; font-size: 1.05rem; padding: 0 1.6rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); background: var(--surface-2); }
.hero .btn-ghost { color: #f4ecdf; border-color: rgba(244,236,223,.4); }
.hero .btn-ghost:hover { background: rgba(244,236,223,.12); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }

/* ---------- TRAIN BODY ---------- */
.train-body { padding: 2rem 1.25rem 3rem; }
.exercise-list { display: grid; gap: 1.25rem; }

.ex-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.ex-card.done { border-color: var(--success); }
.ex-head { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.1rem; border-bottom: 1px solid var(--border); }
.ex-avatar {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--accent)); font-size: 1.4rem; flex: none;
}
.ex-title { flex: 1; min-width: 0; }
.ex-title h3 { margin: 0; font-size: 1.15rem; }
.ex-title small { color: var(--muted); }
.ex-weight { text-align: right; }
.ex-weight b { font-family: var(--font-display); font-size: 1.4rem; color: var(--primary); display: block; line-height: 1; }
.ex-weight span { font-size: .68rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }

/* touch-friendly plate calculator button on each exercise */
.plate-btn {
  margin-top: .5rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: 0 1rem;
  border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--surface-2); color: var(--text-soft);
  font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
  letter-spacing: .3px; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: .15s ease;
}
.plate-btn:hover { border-color: var(--accent); color: var(--text); }
.plate-btn:active { transform: scale(.95); background: var(--accent-soft); }

.warmup { padding: .8rem 1.1rem; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: .85rem; }
.warmup summary { cursor: pointer; color: var(--text-soft); font-weight: 600; }
.warmup-row { display: flex; justify-content: space-between; padding: .25rem 0; color: var(--text-soft); }

.set-row { display: flex; gap: .7rem; padding: 1.1rem; flex-wrap: wrap; align-items: center; }
.set-btn {
  position: relative; width: 56px; height: 56px; border-radius: 50%; flex: none;
  border: 2px solid var(--border); background: var(--surface-2); color: var(--text);
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; cursor: pointer;
  transition: transform .12s ease, background .15s ease, border-color .15s ease; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.set-btn:active { transform: scale(.92); }
.set-btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.set-btn.partial { background: var(--warning); border-color: var(--warning); color: #fff; }
.set-btn.fail { background: var(--danger); border-color: var(--danger); color: #fff; }
.set-btn small { position: absolute; bottom: 4px; left: 0; right: 0; font-size: .5rem; letter-spacing: 1px; text-transform: uppercase; font-family: var(--font); opacity: .8; }
.set-hint { width: 100%; font-size: .78rem; color: var(--muted); margin-top: -.3rem; }

/* ---------- REST BAR ---------- */
.rest-bar {
  position: sticky; top: 72px; z-index: 30; margin-bottom: 1.25rem;
  display: flex; gap: 1.2rem; align-items: center;
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 1rem 1.2rem; box-shadow: var(--shadow-lg);
}
.rest-ring-wrap { position: relative; width: 84px; height: 84px; flex: none; }
.rest-ring { width: 84px; height: 84px; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--border); stroke-width: 8; }
.ring-fill { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset .9s linear; }
.rest-time { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; }
.rest-meta { flex: 1; }
.rest-label { text-transform: uppercase; letter-spacing: 2px; font-size: .7rem; color: var(--accent); margin: 0; }
.rest-next { font-weight: 600; margin: .1rem 0 .6rem; }
.rest-controls { display: flex; gap: .5rem; flex-wrap: wrap; }

.finish-row { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: 1.8rem; }

/* ---------- CARDS / GRID ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow); transition: .15s ease; }
.settings-card { margin-bottom: 1.25rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; }
.field > span { font-weight: 600; color: var(--text-soft); }
.field input, .field select {
  font: inherit; padding: .65rem .7rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); transition: .15s ease; min-height: 44px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field input.error, .field select.error { border-color: var(--danger); }
.field input.valid { border-color: var(--success); }
.field.checkbox { flex-direction: row; align-items: center; gap: .6rem; }
.field.checkbox input { min-height: 0; width: 20px; height: 20px; accent-color: var(--primary); }
.field-msg { font-size: .78rem; min-height: 1em; color: var(--muted); }
.field-msg.error { color: var(--danger); }
.field-msg.valid { color: var(--success); }
.volume-slider { accent-color: var(--accent); }
.alarm-block { margin-top: 1rem; display: grid; gap: 1rem; }
.toolbar { margin: 1rem 0; }

/* ---------- EXERCISE LIBRARY ---------- */
.ex-lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 1rem; }
.lib-card { display: flex; align-items: center; gap: .9rem; cursor: pointer; }
.lib-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.lib-card .ex-avatar { width: 42px; height: 42px; font-size: 1.2rem; }
.lib-meta { flex: 1; }
.lib-meta h4 { margin: 0; font-size: 1.05rem; }
.lib-meta small { color: var(--muted); }

/* ---------- HISTORY / SUMMARY TILES ---------- */
.history-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 1rem; margin: 1rem 0 1.5rem; }
.summary-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; }
.summary-tile b { font-family: var(--font-display); font-size: 1.7rem; color: var(--primary); display: block; }
.summary-tile span { font-size: .68rem; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.history-list { display: grid; gap: 1rem; }
.hist-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.hist-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; flex-wrap: wrap; }
.hist-top h4 { margin: 0; }
.hist-lifts { display: grid; gap: .35rem; }
.hist-lift { display: flex; justify-content: space-between; font-size: .9rem; color: var(--text-soft); border-top: 1px dashed var(--border); padding-top: .35rem; gap: .5rem; }
.hist-sets { font-family: var(--font-display); letter-spacing: 1px; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }

/* ---------- FORECAST ---------- */
.forecast-week { margin-bottom: 1.8rem; }
.fweek-title { position: relative; font-size: 1.05rem; color: var(--text); margin-bottom: .8rem; padding-left: .7rem; border-left: 4px solid var(--accent); }
.fweek-title span { color: var(--muted); font-family: var(--font); font-size: .78rem; font-weight: 400; margin-left: .5rem; }
.forecast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px,1fr)); gap: 1rem; }
.fcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); transition: .15s ease; }
.fcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.fcard .hist-top h4 { font-size: 1.05rem; }
.fcard .badge.deload { font-size: .6rem; }
.forecast-note { color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
.lift-up { color: var(--success); font-size: .7rem; margin-left: .3rem; }

/* ---------- BADGES / CHIPS ---------- */
.badge { display: inline-block; border-radius: 999px; padding: .2rem .65rem; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.badge.win { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.badge.fail { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.badge.deload { background: var(--accent-soft); color: var(--warning); }
.chip-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 1.4rem; }
.chip {
  border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface);
  padding: .45rem 1rem; cursor: pointer; font: inherit; font-size: .85rem; color: var(--text-soft); transition: .15s ease;
  min-height: 40px;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- CHART ---------- */
.chart-card { margin-bottom: 1.5rem; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: .8rem; }
.chart-pr { text-align: right; }
.chart-pr b { font-family: var(--font-display); color: var(--accent); font-size: 1.5rem; display: block; }
.chart-pr span { font-size: .68rem; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 1.2rem; margin-top: .6rem; font-size: .78rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.legend-item i { width: 22px; height: 0; display: inline-block; }
.lg-solid { border-top: 3px solid var(--primary); }
.lg-dash { border-top: 3px dashed var(--accent); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 1rem; }

/* ---------- MODALS ---------- */
.modal { position: fixed; inset: 0; z-index: 100; background: rgba(20,14,8,.6); padding: 1.25rem; overflow-y: auto; align-items: flex-start; justify-content: center; }
.modal-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  max-width: 540px; width: 100%; margin: 5vh auto; box-shadow: var(--shadow-lg);
  animation: modalIn .22s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.3rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.icon-close { background: var(--surface-2); border: 1px solid var(--border); border-radius: 50%; width: 36px; height: 36px; font-size: 1.4rem; line-height: 1; cursor: pointer; color: var(--text); }
.modal-body { padding: 1.3rem; display: grid; gap: 1rem; }
.modal-actions { display: flex; gap: .6rem; align-items: center; }
.coach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.rule { border: none; border-top: 1px solid var(--border); margin: .4rem 0; }
.day-choice { width: 100%; text-align: left; justify-content: flex-start; padding: 1rem 1.1rem; border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius-sm); cursor: pointer; font: inherit; }
.day-choice:hover { border-color: var(--accent); }
.day-choice strong { font-family: var(--font-display); display: block; }
.day-choice small { color: var(--muted); }

/* ---------- PLATE CALC ---------- */
.plate-result { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 90px; flex-wrap: wrap; }
.plate {
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .7rem;
  border-radius: 4px; box-shadow: inset 0 0 0 2px rgba(0,0,0,.2);
}
.bar-stub { width: 30px; height: 8px; background: linear-gradient(var(--muted), var(--text-soft)); border-radius: 3px; }
.plate-note { text-align: center; }

/* ---------- BLOCKQUOTE ---------- */
.footer-quote { border-left: 4px solid var(--accent); padding-left: .9rem; font-family: var(--font-display); font-style: italic; color: var(--text-soft); margin: 0; font-size: .9rem; }
.footer-quote cite { display: block; font-size: .75rem; color: var(--muted); margin-top: .4rem; font-style: normal; }

/* ---------- FOOTER ---------- */
.site-footer { background: var(--bg-alt); border-top: 1px solid var(--border); margin-top: 2rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 1.5rem; padding: 2.5rem 1.25rem 1.5rem; }
.footer-brand p { color: var(--text-soft); font-size: .9rem; margin-top: .6rem; }
.footer-col h4 { font-family: var(--font-display); margin-bottom: .6rem; }
.footer-col a { display: block; color: var(--text-soft); padding: .2rem 0; font-size: .9rem; }
.footer-col a:hover { color: var(--primary); }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); padding: 1rem 1.25rem; font-size: .82rem; color: var(--muted); flex-wrap: wrap; gap: .6rem; }
.social { display: flex; gap: .5rem; }
.social-chip { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; }

/* ---------- TOAST ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(1.4rem + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: .8rem 1.3rem; border-radius: 999px;
  box-shadow: var(--shadow-lg); z-index: 200; opacity: 0; transition: .25s ease; max-width: 90vw; text-align: center;
  font-weight: 600; font-size: .9rem;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 880px) {
  .hamburger { display: flex; }
  .main-nav {
    position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch;
    background: var(--surface); border-bottom: 1px solid var(--border); padding: .5rem 1.25rem 1rem;
    max-height: 0; overflow: hidden; transition: max-height .25s ease; gap: .15rem;
  }
  .main-nav.open { max-height: 520px; }
  .nav-link { text-align: left; padding: .8rem .6rem; }
  .nav-icon { align-self: flex-start; margin-top: .4rem; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .rest-bar { top: 64px; }
  .footer-grid { grid-template-columns: 1fr; }
  .coach-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .set-btn { width: 50px; height: 50px; font-size: 1.2rem; }
  .ex-weight b { font-size: 1.2rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
