/* ============ Hevy-clone · mobile-first dark theme ============ */
:root {
  --bg: #0d1017;
  --surface: #161b26;
  --surface-2: #1e2534;
  --border: #262e40;
  --text: #eef1f7;
  --muted: #8b93a7;
  --accent: #4f8cff;
  --accent-dark: #2f6ae0;
  --green: #37c978;
  --red: #ef5563;
  --amber: #f3b13d;
  --radius: 14px;
  --nav-h: 62px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type="checkbox"] { width: auto; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(13, 16, 23, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  /* clear the iOS notch / status bar when installed full-screen */
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 680px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
}
.brand { font-size: 19px; font-weight: 700; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.back-link {
  font-size: 21px; font-weight: 700; color: var(--accent);
  padding: 0 10px 0 0; line-height: 1;
}

/* ---- layout ---- */
.content { max-width: 680px; margin: 0 auto; padding: 16px; }
.section-title {
  font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); margin: 22px 0 10px;
}
.section-title:first-child { margin-top: 4px; }
.section-title.row { display: flex; align-items: baseline; justify-content: space-between; }
.section-title .see-all { color: var(--accent); text-transform: none; letter-spacing: 0; font-size: 13px; }

/* ---- cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.card h3 { font-size: 16px; margin-bottom: 2px; }
.card .sub { color: var(--muted); font-size: 13px; }
.card-link:active { background: var(--surface-2); }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff;
  border-radius: 12px; padding: 12px 18px;
  font-weight: 600; font-size: 15px;
  transition: filter .1s;
}
.btn:active { filter: brightness(.85); }
.btn.block { width: 100%; }
.btn.secondary { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn.green { background: var(--green); color: #06281a; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn-ghost { color: var(--accent); font-weight: 600; padding: 8px 10px; }
.btn-ghost.danger { color: var(--red); }

/* ---- stat tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tiles.four { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 560px) { .tiles.four { grid-template-columns: repeat(4, 1fr); } }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
}
.tile .value { font-size: 21px; font-weight: 700; }
.tile .label { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---- lists / chips ---- */
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; color: var(--muted); white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
}
.badge.pr { background: rgba(243, 177, 61, .15); color: var(--amber); }
.badge.warmup { color: var(--amber); }
.badge.drop { color: var(--accent); }
.badge.failure { color: var(--red); }

/* ---- bottom nav ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around; align-items: stretch;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(18, 21, 28, .97);
  border-top: 1px solid var(--border);
}
.bottom-nav a, .bottom-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 500;
}
.bottom-nav svg { width: 23px; height: 23px; fill: currentColor; }
.bottom-nav .active { color: var(--accent); }
.nav-fab-form { flex: 1; display: flex; }
.nav-fab .fab {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; margin-top: -14px;
  box-shadow: 0 4px 14px rgba(79, 140, 255, .45);
}
.nav-fab.active-workout .fab { background: var(--green); font-size: 15px; box-shadow: 0 4px 14px rgba(55, 201, 120, .45); }

/* ---- resume banner ---- */
.resume-banner {
  display: flex; align-items: center; gap: 8px;
  max-width: 680px; margin: 10px auto 0; padding: 10px 16px;
  margin-left: 16px; margin-right: 16px;
  background: rgba(55, 201, 120, .12);
  border: 1px solid rgba(55, 201, 120, .4);
  border-radius: 12px; font-size: 14px;
}
@media (min-width: 712px) { .resume-banner { margin-left: auto; margin-right: auto; } }
.pulse-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--green);
  animation: pulse 1.4s infinite;
}

/* ---- install banner ---- */
/* :not([hidden]) so the `hidden` attribute actually hides it (a plain
   `.install-banner { display: flex }` would override [hidden]) */
.install-banner:not([hidden]) {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  max-width: 680px; margin: 10px 16px 0; padding: 10px 14px;
  background: rgba(79, 140, 255, .12);
  border: 1px solid rgba(79, 140, 255, .4);
  border-radius: 12px; font-size: 14px;
}
@media (min-width: 712px) { .install-banner { margin-left: auto; margin-right: auto; } }
.install-banner-actions { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* ---- forms ---- */
.form-grid { display: grid; gap: 12px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
label.field { display: block; font-size: 13px; color: var(--muted); }
label.field > span { display: block; margin-bottom: 5px; font-weight: 600; }

/* ---- set table (logger + detail) ---- */
.exercise-block { margin-bottom: 14px; }
.exercise-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.exercise-head .name { font-weight: 700; color: var(--accent); font-size: 15px; }
.set-table { width: 100%; border-collapse: collapse; }
.set-table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; text-align: center; padding: 4px 2px;
}
.set-table td { padding: 4px 3px; text-align: center; }
.set-table .col-set { width: 44px; }
.set-table .col-prev { width: 86px; color: var(--muted); font-size: 13px; }
.set-table .col-check { width: 48px; }
.set-table input {
  text-align: center; padding: 9px 4px; font-size: 15px; font-weight: 600;
  background: var(--surface-2);
}
.set-row.done input { background: rgba(55, 201, 120, .12); border-color: rgba(55, 201, 120, .35); }
.set-type-btn {
  width: 34px; height: 34px; border-radius: 9px; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13px;
}
.set-type-btn.warmup { color: var(--amber); }
.set-type-btn.drop { color: var(--accent); }
.set-type-btn.failure { color: var(--red); }
.check-btn {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 17px; color: var(--muted);
}
.check-btn.on { background: var(--green); border-color: var(--green); color: #06281a; }
.set-table .col-del { width: 30px; }

/* ---- one-time tip cards + help page ---- */
.hint-card {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  background: rgba(79, 140, 255, .08);
  border: 1px solid rgba(79, 140, 255, .35);
  border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px; font-size: 13.5px;
}
.hint-card .guide-list { margin-top: 6px; }
.hint-card .guide-list li { margin-bottom: 4px; }
.hint-actions { display: flex; flex-direction: column; align-items: flex-end; flex: 0 0 auto; }
.hint-dismiss { white-space: nowrap; }
.help-card .guide-list { margin-top: 0; }

/* ---- logger tools: supersets, RPE, plates, progression ---- */
.exercise-tools { display: flex; align-items: center; gap: 0; }
.exercise-tools .badge { margin-right: 4px; }
.btn-ghost.tool { padding: 6px 7px; font-size: 13px; color: var(--muted); }
.btn-ghost.tool.on { color: var(--accent); }
.badge.ss { background: transparent; border: 1px solid currentColor; margin-left: 6px; }
.progress-hint { margin: -4px 0 8px; }
.plate-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.plate-chip {
  padding: 8px 12px; border-radius: 10px; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--accent);
}
.sync-badge:not([hidden]) {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 10px);
  z-index: 45; padding: 8px 14px; border-radius: 999px; font-size: 12.5px;
  background: rgba(243, 177, 61, .15); color: var(--amber);
  border: 1px solid rgba(243, 177, 61, .5); white-space: nowrap;
}

/* ---- cardio set grid (machine parameters) ---- */
.cardio-set { border-top: 1px solid var(--border); padding: 10px 0 12px; }
.cardio-set:first-of-type { border-top: none; padding-top: 2px; }
.cardio-set-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
.cardio-set-head .sub { flex: 1; text-align: right; font-variant-numeric: tabular-nums; }
.cardio-set-actions { display: flex; align-items: center; gap: 2px; }
.cardio-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 6px; }
@media (min-width: 560px) { .cardio-grid { grid-template-columns: repeat(4, 1fr); } }
.cardio-field span {
  display: block; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-bottom: 3px; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cardio-field input {
  text-align: center; padding: 9px 4px; font-size: 15px; font-weight: 600;
  background: var(--surface-2);
}
.del-set-btn {
  width: 26px; height: 38px; color: var(--muted); font-size: 13px;
}
.del-set-btn:active { color: var(--red); }

/* ---- live workout ---- */
.live-meta { display: flex; gap: 14px; align-items: baseline; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.live-meta .clock { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 16px; color: var(--text); }
.rest-bar {
  position: fixed; left: 0; right: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  z-index: 35; display: none;
  background: var(--surface-2); border-top: 1px solid var(--accent);
}
.rest-bar.visible { display: block; }
.rest-bar-inner {
  max-width: 680px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.rest-time { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }

/* ---- modal ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .6); display: none;
  align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity .2s ease;
}
.modal-overlay.open { display: flex; }
.modal-overlay.shown { opacity: 1; }
body.modal-open { overflow: hidden; }
.modal {
  background: var(--surface); width: 100%; max-width: 680px;
  border-radius: 18px 18px 0 0; border: 1px solid var(--border);
  max-height: 82vh; display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform .24s cubic-bezier(.2, .8, .25, 1);
}
.modal-overlay.shown .modal { transform: none; }
/* grab handle on bottom sheets */
.modal::before {
  content: ""; flex: 0 0 auto; width: 38px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 8px auto 0;
}
/* centered dialogs (confirm / alert) */
.modal-overlay.center { align-items: center; padding: 24px; }
.modal.dialog {
  max-width: 340px; border-radius: 18px; padding: 18px;
  transform: translateY(14px) scale(.97);
  transition: transform .2s cubic-bezier(.2, .8, .25, 1);
}
.modal-overlay.center.shown .modal.dialog { transform: none; }
.modal.dialog::before { display: none; }
.dialog-title { font-size: 17px; margin-bottom: 6px; }
.dialog-message { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.dialog-actions { display: flex; gap: 10px; }
.dialog-actions .btn { flex: 1; padding: 11px 12px; }
.btn.danger.solid { background: var(--red); color: #fff; border: none; }
.modal-head { padding: 14px 16px 8px; display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 16px; }
.modal-body { overflow-y: auto; padding: 0 16px 16px; }
.picker-item {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; text-align: left;
  padding: 12px 4px; border-bottom: 1px solid var(--border);
}
.picker-item .meta { color: var(--muted); font-size: 12px; }

/* ---- charts ---- */
.chart { width: 100%; height: auto; display: block; }
.chart-empty { color: var(--muted); text-align: center; padding: 34px 0; font-size: 14px; }

/* ---- exercise guidance ---- */
.feel-card { border-left: 3px solid var(--accent); }
.dos-donts { display: grid; gap: 12px; }
@media (min-width: 560px) { .dos-donts { grid-template-columns: 1fr 1fr; } }
.guide-list { margin: 8px 0 0 18px; color: var(--muted); font-size: 14px; }
.guide-list li { margin-bottom: 6px; }
.red-flags { border-left: 3px solid var(--red); }
.red-flags h3 { color: var(--red); }
.ladder-step { border-left: 3px solid var(--accent); }
#sore-level .chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- body map ---- */
.bodymap-wrap { display: flex; gap: 8px; justify-content: center; }
.bodymap { width: 46%; max-width: 190px; height: auto; }
.bodymap .bm-neutral { fill: #1a2030; stroke: #252d40; stroke-width: 1; }
.bodymap .bm-muscle { fill: #232b3d; stroke: #303a52; stroke-width: 1; }
.bodymap .bm-muscle.p { fill: var(--accent); stroke: #6ba1ff; filter: drop-shadow(0 0 3px rgba(79, 140, 255, .55)); }
.bodymap .bm-muscle.s { fill: #2b477c; stroke: #3a5da0; }
.bodymap .bm-caption { fill: var(--muted); font-size: 12px; font-family: inherit; }
.bodymap .bm-click { cursor: pointer; }
.bodymap .bm-click:hover { stroke: var(--accent); stroke-width: 1.6; }
.bm-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.bm-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.bm-dot.p { background: var(--accent); }
.bm-dot.s { background: #2b477c; }
#bm-3d-canvas { width: 100%; min-height: 380px; display: flex; align-items: center; justify-content: center; position: relative; }
.bm3d-controls {
  position: absolute; right: 10px; bottom: 10px; z-index: 5;
  display: flex; flex-direction: column; gap: 6px;
}
.bm3d-controls button {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(22, 27, 38, .88); border: 1px solid var(--border);
  color: var(--text); font-size: 16px; line-height: 1;
}
.bm3d-controls button:active { background: var(--accent); border-color: var(--accent); }
#bm-3d-canvas canvas { display: block; cursor: grab; border-radius: 12px; background: radial-gradient(circle at 50% 35%, #172033, #0d1017); }
#bm-3d-canvas canvas:active { cursor: grabbing; }
.bm-hint { text-align: center; margin-top: 6px; }

/* ---- exercise form animation ---- */
.anim-card canvas { display: block; width: 100%; height: 250px; }
.anim-controls { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.anim-controls input[type="range"] { flex: 1; padding: 0; background: transparent; border: none; }
.anim-controls .sub { white-space: nowrap; }

/* ---- workout summary ---- */
.summary-hero { text-align: center; padding: 18px 0 20px; }
.summary-hero .big { font-size: 44px; margin-bottom: 6px; }
.summary-hero h2 { font-size: 21px; }

/* ---- misc ---- */
.empty-state { text-align: center; color: var(--muted); padding: 42px 16px; }
.empty-state .big { font-size: 38px; margin-bottom: 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.flex { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.right { text-align: right; }
.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.split-bar { height: 8px; border-radius: 4px; background: var(--accent); min-width: 4px; }
.title-input {
  background: transparent; border: none; font-size: 19px; font-weight: 700;
  padding: 4px 0; border-radius: 0;
}
.title-input:focus { outline: none; border-bottom: 2px solid var(--accent); }
