:root {
  --bg: #111318;
  --surface: #1b1f26;
  --surface-soft: #242a32;
  --text: #f5f7fa;
  --muted: #a7b0bd;
  --line: #343b46;
  --primary: #f2c94c;
  --primary-dark: #d8ad34;
  --gold: #ffd76a;
  --danger: #ff6b5f;
  --shadow: 0 14px 34px rgba(0, 0, 0, .32);
  --radius: 22px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { overscroll-behavior-y: none; }

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }

#app { min-height: 100vh; padding-bottom: calc(86px + var(--safe-bottom)); }

.app-header {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 52px 1fr 52px; align-items: center;
  gap: 8px; padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 14px;
  background: rgba(17,19,24,.94); backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(52,59,70,.8);
}
.app-header h1 { font-size: 21px; margin: 0; letter-spacing: 0; }
.app-header p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 24px; display: grid; place-items: center;
}
.hidden { display: none !important; }

main { max-width: 760px; margin: 0 auto; }
.screen { padding: 20px 16px calc(104px + var(--safe-bottom)); animation: fade .18s ease; }
@keyframes fade { from { opacity: .3; transform: translateY(4px);} to {opacity:1; transform:none;} }

h2 { font-size: 29px; line-height: 1.08; margin: 4px 0 18px; letter-spacing: 0; }
h3 { margin: 0 0 8px; }
p { line-height: 1.42; }
.eyebrow { text-transform: uppercase; letter-spacing: 0; font-weight: 800; font-size: 12px; color: var(--muted); margin: 0 0 5px; }

.hero-card, .summary-card {
  background: linear-gradient(135deg,#191d23,#2a2f38 68%,#3a321d); color: var(--text);
  border-radius: 28px; padding: 24px; box-shadow: var(--shadow); margin-bottom: 18px;
  border: 1px solid var(--line);
}
.hero-card h2, .summary-card h2 { margin-bottom: 8px; }
.hero-card p:last-child { margin: 0; color: var(--muted); }

.grid { display: grid; gap: 14px; }
.two-col { grid-template-columns: repeat(2, minmax(0,1fr)); }
.body-part-card {
  min-height: 126px; border: 0; border-radius: var(--radius); background: var(--surface);
  padding: 20px; text-align: left; box-shadow: var(--shadow);
  display: flex; flex-direction: column; justify-content: space-between;
  color: var(--text); border: 1px solid var(--line);
}
.body-icon {
  width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center;
  background: #283246; color: #9db9ff;
}
.body-icon svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.body-icon.back { background:#252d45; color:#9ea7ff; }
.body-icon.shoulders { background:#302942; color:#c7a6ff; }
.body-icon.biceps { background:#20352a; color:#7ce3a4; }
.body-icon.triceps { background:#3a2a22; color:#ff9b6e; }
.body-icon.legs { background:#3a2424; color:#ff8f8a; }
.body-icon.special, .body-icon.fullbody { background:#2f2a18; color:var(--gold); }
.body-part-card strong { font-size: 20px; }
.body-part-card .body-part-count { color: var(--muted); font-size: 13px; }
.body-part-name.has-end { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.body-part-name.has-end.long-name { font-size: 16px; }
.end-star { width: 42px; height: 42px; flex: 0 0 42px; filter: drop-shadow(0 0 5px rgba(67,245,138,.36)); }
@media (max-width: 360px) {
  .body-part-card { padding: 14px; }
  .body-part-name.has-end { font-size: 17px; }
  .body-part-name.has-end.long-name { font-size: 13.5px; }
  .end-star { width: 32px; height: 32px; flex-basis: 32px; }
}

.stack { display: grid; gap: 12px; }
.section-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.exercise-row {
  width: 100%; border: 0; border-radius: 18px; background: var(--surface);
  box-shadow: var(--shadow); padding: 18px; display: flex; justify-content: space-between;
  align-items: center; text-align: left; font-weight: 750; font-size: 18px;
  color: var(--text); border: 1px solid var(--line);
}
.exercise-row .chevron { color: var(--muted); font-size: 24px; }
.empty-list { background: var(--surface); border-radius: var(--radius); padding: 24px; color: var(--muted); text-align: center; border: 1px solid var(--line); }

.primary-btn, .secondary-btn, .danger-btn, .file-btn {
  border: 0; border-radius: 16px; padding: 15px 18px; font-weight: 800;
  text-align: center; display: inline-flex; align-items: center; justify-content: center;
}
.primary-btn { background: var(--primary); color: #111318; }
.primary-btn:active { background: var(--primary-dark); transform: scale(.99); }
.secondary-btn { background: var(--surface-soft); color: var(--text); border: 1px solid var(--line); }
.danger-btn { background: rgba(255,107,95,.14); color: #ff9b93; border: 1px solid rgba(255,107,95,.35); }
.file-btn { background: var(--primary); color: #111318; }
.small { padding: 11px 14px; border-radius: 13px; }
.huge { width: 100%; min-height: 62px; font-size: 20px; }

.context-chip {
  display: inline-flex; border-radius: 99px; padding: 8px 12px; background: rgba(242,201,76,.14);
  color: var(--gold); font-weight: 800; margin-bottom: 16px; border: 1px solid rgba(242,201,76,.32);
}
.record-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.record-card, .input-card, .info-card, .warning-card, .filter-card {
  background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.record-card:not(:first-child) { border-color: rgba(242,201,76,.38); }
.record-card:not(:first-child) .record-main { color: var(--gold); }
.record-content { min-height: 62px; }
.record-main { font-size: 23px; font-weight: 900; margin-bottom: 5px; }
.record-sub { color: var(--muted); font-size: 14px; }
.empty-state { color: var(--muted); display: flex; align-items: center; }
.record-content.empty-state { display: block; }

.input-card { display: grid; gap: 12px; margin-top: 16px; }
.weight-guide {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
}
.weight-guide div {
  background: #14181e;
  border: 1px solid rgba(242,201,76,.30);
  border-radius: 14px;
  padding: 12px;
}
.weight-guide span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 850;
  margin-bottom: 4px;
}
.weight-guide strong {
  color: var(--gold);
  font-size: 18px;
}
.phase1-guide {
  background: rgba(242,201,76,.10);
  border: 1px solid rgba(242,201,76,.30);
  border-radius: 14px;
  padding: 13px;
}
.phase1-guide span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 850;
  margin-bottom: 4px;
}
.phase1-guide strong {
  color: var(--gold);
  font-size: 17px;
}
.workout-list-heading { margin-top: 22px; }
label { font-weight: 750; }
input, textarea, select {
  width: 100%; border: 1px solid var(--line); background: #12161c; border-radius: 14px;
  padding: 15px 14px; min-height: 52px; color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 3px solid rgba(242,201,76,.24); border-color: var(--primary); }
textarea { resize: vertical; }

.workout-screen { min-height: calc(100vh - 180px); display: flex; flex-direction: column; }
.phase2-record-banner {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.record-pill {
  background: #14181e;
  border: 1px solid rgba(242,201,76,.34);
  border-radius: 14px;
  padding: 10px;
  min-height: 66px;
}
.record-pill span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 850;
  margin-bottom: 4px;
}
.record-pill strong {
  color: var(--gold);
  font-size: 16px;
  line-height: 1.12;
}
.workout-status-card {
  background: var(--surface); border-radius: 30px; box-shadow: var(--shadow);
  padding: 26px; text-align: center; margin-bottom: 16px;
  border: 1px solid var(--line);
}
.failure-number { font-weight: 1000; font-size: 82px; letter-spacing: 0; margin: 14px 0; color: var(--text); }
.countdown-number { font-size: 70px; font-weight: 950; color: var(--primary); }
.progress-track { height: 12px; border-radius: 99px; background: #2e3540; overflow: hidden; }
.progress-bar { height: 100%; width: 100%; background: var(--primary); transition: width .1s linear; }
.failure-btn {
  width: 100%; min-height: 140px; border: 0; border-radius: 30px; color: white;
  background: linear-gradient(135deg,#b42318,#f04438); box-shadow: 0 14px 34px rgba(240,68,56,.28);
  font-weight: 950; font-size: 31px; margin-bottom: 14px;
}
.failure-btn:active { transform: scale(.985); }
.phase3-counter-card {
  display: grid;
  gap: 12px;
  text-align: center;
}
.phase3-failure-number {
  font-size: 98px;
  line-height: .9;
  font-weight: 1000;
  letter-spacing: 0;
  color: var(--gold);
}
.phase3-btn {
  min-height: 104px;
  margin-bottom: 0;
  background: linear-gradient(135deg,#8f2f28,#ff6b5f);
}
.choice-section {
  display: grid;
  gap: 10px;
}
.choice-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
}
.choice-btn {
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 56px;
  padding: 12px;
  background: #12161c;
  color: var(--muted);
  font-weight: 850;
}
.choice-btn.active {
  background: rgba(242,201,76,.16);
  color: var(--gold);
  border-color: rgba(242,201,76,.50);
}
.live-score {
  display: flex; justify-content: space-between; gap: 12px; margin-top: 14px;
  background: var(--surface); padding: 15px 18px; border-radius: 18px; color: var(--muted);
  border: 1px solid var(--line);
}
.live-score strong { color: var(--gold); font-size: 24px; }

.filter-card { display: grid; gap: 10px; margin-bottom: 16px; }
.history-card {
  background: var(--surface); border-radius: 20px; padding: 17px; box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.history-top { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; }
.history-title { font-weight:900; font-size:18px; }
.exercise-empty-card { border: 1px dashed var(--line); box-shadow: none; }
.empty-pill {
  border-radius:99px; padding:6px 10px; font-size:12px; font-weight:900;
  background:var(--surface-soft); color:var(--muted); white-space:nowrap;
}
.history-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-top:14px; }
.stat-box { background:#14181e; border-radius:13px; padding:10px; border: 1px solid #252c35; }
.stat-box span { display:block; color:var(--muted); font-size:11px; text-transform:uppercase; font-weight:800; }
.stat-box strong { display:block; margin-top:3px; font-size:18px; }
.history-note {
  margin:12px 0 0;
  color:var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.note-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.note-card p {
  margin: 9px 0 0;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.history-actions { display:flex; justify-content:flex-end; gap: 10px; margin-top:12px; }
.text-action, .text-danger { border:0; background:transparent; font-weight:800; padding:8px; }
.text-action { color: var(--gold); }
.text-danger { color:#ff9b93; }

.warning-card { background: rgba(242,201,76,.10); border: 1px solid rgba(242,201,76,.34); }
.warning-card p, .info-card p { color: var(--muted); }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3,1fr);
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: rgba(17,19,24,.96); border-top: 1px solid var(--line); backdrop-filter: blur(18px);
}
.nav-btn {
  border: 0; background: transparent; color: var(--muted); padding: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 21px; border-radius: 12px;
}
.nav-btn span { font-size: 11px; font-weight: 750; }
.nav-btn.active { color: var(--primary); background: rgba(242,201,76,.13); }

dialog { border: 1px solid var(--line); border-radius: 24px; padding: 0; width: min(90vw,420px); box-shadow: 0 30px 80px rgba(0,0,0,.55); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.62); backdrop-filter: blur(3px); }
.dialog-card { padding: 22px; display: grid; gap: 12px; }
.dialog-actions { display:flex; justify-content:flex-end; gap:10px; }

.toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-bottom)); transform: translateX(-50%);
  background: #f5f7fa; color: #111318; padding: 12px 16px; border-radius: 14px;
  box-shadow: var(--shadow); z-index: 50; max-width: 88vw; text-align:center;
}

@media (min-width: 680px) {
  .record-grid { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 420px) {
  .weight-guide { grid-template-columns: 1fr; }
  .choice-group { grid-template-columns: 1fr; }
  .failure-number { font-size: 68px; }
  .phase3-failure-number { font-size: 84px; }
  .fire-emoji { font-size: 96px; }
  .go-word { font-size: 64px; }
  .history-stats { grid-template-columns: repeat(2,1fr); }
}

.body-part-banner {
  background: linear-gradient(135deg, #20252d, #2c3038 66%, #4a3a1c);
  color: var(--text); border-radius: 24px; padding: 20px 22px; margin-bottom: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.body-part-banner .eyebrow { color: var(--gold); }
.body-part-banner h2 { margin: 2px 0 0; font-size: 34px; }
.subheading { margin: 6px 0 15px; font-size: 24px; }
.saved-btn { background: #12b76a !important; color: white !important; opacity: 1 !important; }

.version-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 14px;
  padding: 8px 13px;
  border-radius: 999px;
  background: rgba(242,201,76,.14);
  color: var(--gold);
  border: 1px solid rgba(242,201,76,.42);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 6px 18px rgba(122, 77, 0, .10);
}

.app-header > .icon-btn:first-child { grid-column: 1; }
.app-header > div { grid-column: 2; min-width: 0; }
.app-header > #settingsBtn { grid-column: 3; justify-self: end; }
.app-header > .hidden:first-child { display: grid !important; visibility: hidden; pointer-events: none; }

.go-signal {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: goPulse .58s ease both;
}
.fire-emoji {
  font-size: 112px;
  line-height: 1;
  filter: drop-shadow(0 14px 22px rgba(240, 68, 56, .30));
}
.go-word {
  margin-top: 2px;
  font-size: 76px;
  line-height: .95;
  font-weight: 1000;
  letter-spacing: 0;
  color: #b42318;
}
.workout-status-card.go-active {
  background: linear-gradient(145deg, #301c1b, #1b1f26);
  box-shadow: 0 14px 40px rgba(255, 107, 95, .24);
  border: 2px solid var(--danger);
}
@keyframes goPulse {
  0% { transform: scale(.70); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.exercise-row-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 9px;
  align-items: stretch;
}
.exercise-manage-btn {
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0;
  display: grid;
  place-items: center;
}
.exercise-manage-btn:active {
  background: var(--surface-soft);
  transform: scale(.98);
}

@media (max-width: 420px) {
  .weight-guide { grid-template-columns: 1fr; }
  .choice-group { grid-template-columns: 1fr; }
  .failure-number { font-size: 68px; }
  .phase3-failure-number { font-size: 84px; }
  .fire-emoji { font-size: 96px; }
  .go-word { font-size: 64px; }
  .history-stats { grid-template-columns: repeat(2,1fr); }
}

.condition-option { display: grid; gap: 10px; text-align: left; padding: 22px; white-space: normal; }
.condition-option strong { font-size: 1.35rem; }
.condition-option span { font-size: 1rem; font-weight: normal; line-height: 1.5; }
#changeConditionBtn { margin-bottom: 16px; }
