@font-face {
  font-family: "Montserrat";
  src: url("./fonts/Montserrat-Variable.ttf") format("truetype-variations");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg-deep: #03050a;
  --bg: #07090d;
  --surface-1: #101319;
  --surface-2: #151922;
  --surface-3: #1a1f29;
  --border-subtle: rgba(255, 255, 255, .06);
  --border: rgba(255, 255, 255, .09);
  --border-active: rgba(255, 255, 255, .14);
  --text: #f4f6f8;
  --text-secondary: #a5aab3;
  --muted: #858c98;
  --accent: #9b365d;
  --accent-bright: #d76a91;
  --accent-soft: rgba(155, 54, 93, .16);
  --success: #47d7a0;
  --warning: #f6a54d;
  --danger: #f05d67;
  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --shadow: 0 18px 48px rgba(0, 0, 0, .32);
  --glow: 0 0 24px rgba(168, 56, 98, .18), 0 0 56px rgba(168, 56, 98, .05);
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat", "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% -6%, rgba(121, 32, 67, .16), transparent 30rem),
    radial-gradient(circle at 95% 88%, rgba(126, 49, 76, .08), transparent 34rem),
    linear-gradient(180deg, #060910 0, var(--bg) 38%, var(--bg-deep) 100%);
  background-attachment: fixed;
}

button,
input,
select,
textarea { font: inherit; }

button { cursor: pointer; touch-action: manipulation; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
}

input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: 0;
  background: var(--surface-2);
  color: var(--text);
  padding: 11px 12px;
  font-size: 16px;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

input:hover,
select:hover,
textarea:hover { border-color: var(--border-active); }

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(215, 106, 145, .62);
  background: #171c26;
  box-shadow: 0 0 0 3px rgba(155, 54, 93, .12);
}

textarea { width: 100%; resize: vertical; line-height: 1.5; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin: 2px 0 0; font-size: 30px; line-height: 1.05; letter-spacing: -.04em; }
h2 { letter-spacing: -.025em; }
h3 { letter-spacing: -.015em; }
.hidden { display: none !important; }
.full { width: 100%; }

.app {
  width: 100%;
  max-width: 760px;
  margin: auto;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + 116px);
}

main { min-width: 0; }

.topbar,
.row,
.hero-top,
.section-heading,
.card-head,
.exercise-head,
.modal-header,
.session-head,
.session-title-row,
.measure-card {
  display: flex;
  align-items: center;
}

.topbar,
.hero-top,
.section-heading,
.card-head,
.exercise-head,
.modal-header,
.session-head,
.session-title-row,
.measure-card { justify-content: space-between; }

.row.between { justify-content: space-between; gap: 12px; }
.topbar { min-height: 44px; justify-content: flex-end; margin-bottom: 12px; }
.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: .115em;
  text-transform: uppercase;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(16, 19, 25, .82);
  color: var(--text-secondary);
}

.icon-btn svg,
.tab-icon {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tabs {
  position: fixed;
  z-index: 50;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 10px);
  left: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  width: auto;
  max-width: 520px;
  margin: auto;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(12, 15, 22, .9);
  box-shadow: 0 16px 46px rgba(0, 0, 0, .58);
  backdrop-filter: blur(18px);
}

.tab {
  display: flex;
  min-width: 0;
  min-height: 56px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.tab.active {
  background: var(--accent-soft);
  color: var(--accent-bright);
  box-shadow: inset 0 0 0 1px rgba(215, 106, 145, .12), 0 0 20px rgba(155, 54, 93, .08);
}
.tab > span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.view { display: none; }
.view.active { display: block; }

.hero-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 26px;
  padding: 20px;
  border: 1px solid rgba(205, 88, 128, .24);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 92% 8%, rgba(154, 48, 88, .28), transparent 40%),
    linear-gradient(145deg, rgba(42, 16, 28, .96), rgba(18, 12, 18, .98) 70%);
  box-shadow: var(--shadow), 0 0 44px rgba(137, 39, 75, .1);
}

.hero-card::after {
  position: absolute;
  top: 0;
  right: 24px;
  left: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(226, 118, 158, .5), transparent);
  content: "";
}

.hero-top { margin-bottom: 28px; }

.pill,
.trend,
.score {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.bright {
  border-color: rgba(215, 106, 145, .3);
  background: rgba(155, 54, 93, .18);
  color: var(--accent-bright);
}

.hero-card h2 { margin: 7px 0 6px; font-size: clamp(27px, 7vw, 34px); line-height: 1.08; }
.hero-copy { margin-bottom: 18px; color: var(--text-secondary); line-height: 1.45; }

.plan-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 18px 0; }

.plan-choice {
  min-width: 0;
  padding: 10px 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .025);
  color: var(--text-secondary);
}

.plan-choice strong,
.plan-choice small { display: block; }
.plan-choice strong { font-size: 15px; }
.plan-choice small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.plan-choice.active {
  border-color: rgba(215, 106, 145, .42);
  background: rgba(155, 54, 93, .18);
  color: var(--accent-bright);
  box-shadow: 0 0 20px rgba(155, 54, 93, .1);
}

.plan-choice.active small { color: #e4a6bd; }

.primary-btn,
.secondary-btn,
.timer-btn,
.text-btn,
.danger-link {
  min-height: 46px;
  padding: 11px 15px;
  border-radius: var(--radius-md);
  font-weight: 700;
}

.primary-btn {
  border: 0;
  background: linear-gradient(135deg, #762445, #a83a61 58%, #c45876);
  color: white;
  box-shadow: 0 10px 26px rgba(132, 39, 75, .28);
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 20px;
  padding-top: 17px;
  border-top: 1px solid var(--border-subtle);
}

.hero-metrics div { min-width: 0; }
.hero-metrics strong,
.hero-metrics span { display: block; }
.hero-metrics strong { color: var(--text); font-size: 20px; font-weight: 700; }
.hero-metrics span { margin-top: 3px; color: var(--muted); font-size: 10px; }

.secondary-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.text-btn { border: 0; background: transparent; color: var(--accent-bright); }
.danger-link { border: 0; background: transparent; color: var(--danger); }

.section-block { margin-top: 24px; }
.section-heading { gap: 12px; margin: 0 2px 11px; }
.section-heading h2 { margin: 3px 0 0; font-size: 20px; }

.card,
.history-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: rgba(16, 19, 25, .9);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
}

.card { margin-bottom: 12px; padding: 16px; }
.metrics-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; }
.metrics-grid label > span,
.measure-card label > span,
.session-note > span { display: block; margin: 0 0 6px; color: var(--muted); font-size: 12px; }
.metrics-grid input,
.metrics-grid select { width: 100%; }
.daily-card { padding-bottom: 14px; }

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.check-row input { width: 21px; height: 21px; accent-color: var(--accent); }
.check-row span { display: flex; flex-direction: column; }
.check-row small { margin-top: 2px; color: var(--muted); }

.insight {
  margin: 14px 0 0;
  padding: 11px 12px;
  border: 1px solid rgba(215, 106, 145, .1);
  border-radius: var(--radius-md);
  background: rgba(155, 54, 93, .1);
  color: #e6becd;
  font-size: 13px;
  line-height: 1.45;
}

.measure-card { gap: 12px; }
.measure-card label { flex: 1; min-width: 0; }
.measure-input { display: flex; align-items: center; gap: 7px; }
.measure-input input { width: 100%; min-width: 0; font-size: 22px; font-weight: 700; }
.measure-input b { color: var(--muted); }
.fineprint,
.muted { color: var(--muted); font-size: 13px; line-height: 1.5; }
.fineprint { margin: 8px 3px; }

.schedule { display: grid; gap: 8px; }
.schedule-item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 13px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: rgba(16, 19, 25, .88);
}

.schedule-item .day { color: var(--accent-bright); font-size: 12px; font-weight: 750; }
.schedule-item strong,
.schedule-item small { display: block; }
.schedule-item small { margin-top: 3px; color: var(--muted); }
.schedule-item .status { color: #3e4550; font-size: 18px; }
.schedule-item.done .status { color: var(--success); }

.coach-shell { max-width: 680px; margin: 0 auto; }
.coach-chat { display: grid; gap: 11px; padding-bottom: 14px; }
.coach-message { display: flex; }
.coach-message.user { justify-content: flex-end; }
.coach-bubble {
  max-width: min(92%, 590px);
  padding: 13px 15px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px var(--radius-lg) var(--radius-lg) var(--radius-lg);
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}
.coach-message.user .coach-bubble {
  border-color: rgba(215, 106, 145, .18);
  border-radius: var(--radius-lg) 6px var(--radius-lg) var(--radius-lg);
  background: linear-gradient(135deg, rgba(155, 54, 93, .3), rgba(99, 34, 60, .23));
  color: var(--text);
}
.coach-replies { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 5px 0 18px; }
.coach-choice {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-secondary);
  text-align: left;
  line-height: 1.3;
}
.coach-choice.selected {
  border-color: rgba(215, 106, 145, .5);
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(215, 106, 145, .08);
}
.coach-replies .full, .coach-status { grid-column: 1 / -1; }
.coach-status { margin: 1px 0 3px; padding: 11px 13px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); color: var(--muted); font-size: 13px; line-height: 1.45; }
.coach-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.coach-bubble h3 { margin: 0 0 4px; color: var(--text); font-size: 20px; }
.coach-mode { padding: 5px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-bright); font-size: 10px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.coach-mode.maintenance { background: rgba(246, 165, 77, .12); color: var(--warning); }
.coach-mode.rest { background: rgba(240, 93, 103, .12); color: var(--danger); }
.coach-preview-meta { color: var(--muted); font-size: 12px; }
.coach-plan { margin: 15px 0 13px; padding: 0; list-style: none; }
.coach-plan li { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--border-subtle); }
.coach-plan li strong { color: var(--text); font-size: 13px; }
.coach-plan li span { color: var(--muted); font-size: 11px; }
.coach-explain { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.coach-explain > strong { color: var(--text); font-size: 12px; }
.coach-explain p, .coach-alert p { margin: 5px 0 0; font-size: 12px; }
.coach-alert { margin-top: 10px; padding: 10px 11px; border: 1px solid rgba(246, 165, 77, .22); border-radius: var(--radius-sm); background: rgba(246, 165, 77, .07); color: var(--warning); }
.coach-alert.danger { border-color: rgba(240, 93, 103, .25); background: rgba(240, 93, 103, .08); color: #ff8b93; }

.session-head { margin-bottom: 14px; }
.session-time { color: var(--text-secondary); font-size: 15px; font-weight: 700; }
.session-title-row { align-items: flex-start; margin-bottom: 14px; }
.session-title-row h2 { margin: 3px 0 0; font-size: 27px; }

.notice {
  margin-bottom: 12px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  font-size: 13px;
  line-height: 1.45;
}

.notice strong,
.notice span { display: block; }
.notice span { margin-top: 4px; color: var(--muted); }
.notice.warmup { border-color: rgba(215, 106, 145, .16); background: rgba(155, 54, 93, .08); }
.notice.danger { border-color: rgba(240, 93, 103, .28); color: var(--danger); }

.readiness-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 13px 0; }
.readiness-row label { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.readiness-row input,
.readiness-row select { width: 100%; }

.swipe-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 0 12px;
  padding: 10px 11px;
  border: 1px solid rgba(215, 106, 145, .18);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.4;
}
.swipe-hint button { min-height: 44px; padding: 7px 9px; border: 0; border-radius: var(--radius-sm); background: rgba(215, 106, 145, .14); color: var(--accent-bright); font-size: 11px; font-weight: 700; }

.exercise { margin-top: 14px; padding: 17px; }
.exercise-head { align-items: flex-start; gap: 10px; }
.exercise-toggle { display: flex; min-width: 0; min-height: 44px; flex: 1; align-items: center; justify-content: space-between; gap: 8px; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; }
.exercise-title { min-width: 0; }
.exercise-number { margin-bottom: 3px; color: var(--accent-bright); font-size: 10px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.exercise-name { display: block; margin: 0; overflow-wrap: anywhere; font-size: 19px; font-weight: 700; line-height: 1.2; }
.exercise-summary-state { display: flex; flex: 0 0 auto; align-items: center; gap: 4px; color: var(--muted); font-size: 11px; font-weight: 700; }
.exercise-summary-state svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform .18s ease; }
.exercise-toggle[aria-expanded="true"] .exercise-summary-state svg { transform: rotate(180deg); }
.add-set { min-height: 44px; flex: 0 0 auto; }
.target-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.target-row span { padding: 5px 8px; border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-secondary); font-size: 11px; font-weight: 700; }

.progression-hint {
  margin: 11px 0 0;
  padding: 10px 11px;
  border-left: 2px solid var(--accent-bright);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: rgba(155, 54, 93, .08);
  color: #dfbcc9;
  font-size: 12px;
  line-height: 1.45;
}

.technique { margin-top: 10px; color: var(--muted); font-size: 12px; }
.technique summary { cursor: pointer; }
.technique p { margin: 7px 0 0; line-height: 1.5; }
.sets-table { margin-top: 14px; }
.sets-head,
.set-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) minmax(0, 1fr) minmax(0, .8fr) 44px; align-items: center; gap: 7px; }
.sets-head { padding: 0 9px 5px; color: var(--muted); font-size: 10px; text-align: center; }

.set-swipe {
  position: relative;
  margin-top: 8px;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, rgba(94, 21, 39, .54), rgba(164, 43, 70, .9));
  touch-action: pan-y;
}

.set-row {
  position: relative;
  z-index: 1;
  min-height: 56px;
  padding: 6px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: #121721;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .18);
  transition: transform .18s cubic-bezier(.2, .75, .25, 1);
  will-change: transform;
}

.set-swipe.dragging .set-row { transition: none; }
.delete-set {
  position: absolute;
  z-index: 0;
  top: 0;
  right: 0;
  bottom: 0;
  width: 102px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-size: 11px;
  font-weight: 750;
}

.delete-set:focus-visible + .set-row { transform: translateX(-102px); }
.set-row input { width: 100%; min-width: 0; min-height: 44px; padding: 10px 4px; text-align: center; }
.set-index { color: var(--text-secondary); font-size: 12px; font-weight: 750; text-align: center; }

.done-set {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 20px;
}

.done-set.completed {
  border-color: rgba(71, 215, 160, .4);
  background: rgba(71, 215, 160, .15);
  color: var(--success);
  box-shadow: 0 0 18px rgba(71, 215, 160, .09);
}

.session-note { display: block; margin: 18px 0 12px; }
.finish-btn { margin-top: 5px; }

.rest-timer {
  position: fixed;
  z-index: 60;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 84px);
  left: 12px;
  display: flex;
  max-width: 736px;
  align-items: center;
  justify-content: space-between;
  margin: auto;
  padding: 12px 14px;
  border: 1px solid rgba(215, 106, 145, .28);
  border-radius: var(--radius-lg);
  background: rgba(12, 19, 31, .96);
  color: var(--text);
  box-shadow: 0 18px 54px rgba(0, 0, 0, .62), var(--glow);
  backdrop-filter: blur(18px);
}

.rest-label { max-width: 130px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.rest-countdown { color: var(--accent-bright); font-size: 27px; font-weight: 800; line-height: 1; }
.rest-actions { display: flex; gap: 5px; }
.timer-btn { min-height: 42px; padding: 8px 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-secondary); }
.timer-btn:last-child { border-color: rgba(215, 106, 145, .28); color: var(--accent-bright); }

.history-item { margin-bottom: 10px; padding: 16px; }
.history-item h3 { margin: 0 0 5px; }
.history-meta { color: var(--muted); font-size: 12px; }
.history-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.exercise-summary { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border-subtle); font-size: 13px; line-height: 1.6; }
.empty-state { display: grid; justify-items: start; gap: 9px; color: var(--text-secondary); }
.empty-state strong { color: var(--text); }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }
.empty-state button { margin-top: 3px; }

.big-stat { margin-top: 5px; font-size: 31px; font-weight: 700; letter-spacing: -.035em; }
.card-head { align-items: flex-start; gap: 10px; }
.card-head h3 { margin: 5px 0; font-size: 15px; }

.chart {
  min-height: 140px;
  margin: 15px 0;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(15, 22, 34, .92), rgba(10, 13, 19, .72));
}

.chart.empty { display: grid; place-items: center; padding: 20px; color: var(--muted); font-size: 13px; text-align: center; }
.chart svg { display: block; width: 100%; height: 145px; }
.chart text { fill: var(--text-secondary); font-family: inherit; font-size: 10px; }
.mini-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border-subtle); font-size: 13px; }
.mini-list > div strong { text-align: right; }
.measure-card.inline { margin: 13px 0 0; padding: 0; border: 0; box-shadow: none; }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat-box { padding: 11px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-2); }
.stat-box strong,
.stat-box span { display: block; }
.stat-box strong { font-size: 23px; font-weight: 700; }
.stat-box span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.trend.good { border-color: rgba(71, 215, 160, .24); color: var(--success); }
.trend.warn { border-color: rgba(246, 165, 77, .26); color: var(--warning); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(7px);
}

.modal {
  width: 100%;
  max-width: 760px;
  max-height: 92vh;
  margin: auto;
  overflow: auto;
  padding: 20px 16px calc(env(safe-area-inset-bottom) + 25px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: #0b0e14;
  box-shadow: 0 -18px 60px rgba(0, 0, 0, .42);
}

.modal-header { position: sticky; z-index: 2; top: -20px; padding: 12px 0; background: rgba(11, 14, 20, .94); backdrop-filter: blur(16px); }
.modal-header h2 { margin: 3px 0 0; }
.setting-block { margin-top: 20px; padding-top: 19px; border-top: 1px solid var(--border-subtle); }
.setting-block h3 { margin-bottom: 9px; }
.stack { display: grid; gap: 8px; }
.file-label { display: block; text-align: center; }
.file-label input { display: none; }

.plan-block { margin-top: 9px; padding: 13px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-1); }
.plan-block h4 { margin: 0; }
.plan-meta { margin: 3px 0 8px; color: var(--accent-bright); font-size: 11px; }
.plan-line { display: grid; grid-template-columns: 1fr 38px; gap: 7px; margin-top: 7px; }
.plan-line input { width: 100%; min-width: 0; }
.plan-line button { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--danger); }
.add-exercise { margin-top: 9px; }

.research summary { cursor: pointer; font-weight: 700; }
.research-body { padding-top: 8px; color: var(--text-secondary); font-size: 13px; line-height: 1.55; }
.source-links { display: flex; flex-wrap: wrap; gap: 7px; }
.source-links a,
.food-help summary { color: var(--accent-bright); }

.food-help { margin-top: 13px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.food-help summary { cursor: pointer; font-weight: 700; }
.food-help p { margin: 8px 0 4px; }
.food-help small { display: block; color: var(--muted); }

.toast {
  position: fixed;
  z-index: 100;
  top: calc(env(safe-area-inset-top) + 12px);
  right: 16px;
  left: 16px;
  max-width: 700px;
  margin: auto;
  padding: 13px 16px;
  border: 1px solid rgba(215, 106, 145, .2);
  border-radius: var(--radius-md);
  background: rgba(19, 27, 41, .96);
  color: var(--text);
  box-shadow: var(--shadow), var(--glow);
  font-size: 13px;
  font-weight: 650;
  pointer-events: none;
}
.toast.has-action { display: flex; align-items: center; justify-content: space-between; gap: 14px; pointer-events: auto; }
.toast.has-action button { min-height: 44px; flex: 0 0 auto; padding: 7px 10px; border: 0; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-bright); font-size: 12px; font-weight: 750; }

@media (hover: hover) {
  .card,
  .history-item,
  .schedule-item,
  .icon-btn,
  .secondary-btn { transition: transform .18s ease, border-color .18s ease, background .18s ease; }

  .card:hover,
  .history-item:hover,
  .schedule-item:hover { transform: translateY(-1px); border-color: var(--border); }
  .icon-btn:hover,
  .secondary-btn:hover { border-color: var(--border-active); background: var(--surface-3); }
}

@media (max-width: 370px) {
  .app { padding-right: 11px; padding-left: 11px; }
  .tabs { right: 8px; left: 8px; gap: 2px; padding: 4px; }
  .hero-card,
  .card { padding: 14px; }
  .plan-strip { gap: 4px; }
  .plan-choice { padding: 8px 3px; }
  .sets-head,
  .set-row { gap: 4px; }
  .rest-timer { flex-wrap: wrap; gap: 8px; }
  .rest-actions { margin-left: auto; }
  .app { padding-bottom: calc(env(safe-area-inset-bottom) + 150px); }
}

@media (min-width: 700px) {
  .app { padding-right: 24px; padding-left: 24px; }
  .modal { margin-bottom: 20px; border-radius: var(--radius-xl); }
  .rest-timer { width: calc(100% - 48px); }
}

@media (min-width: 960px) {
  .app {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    column-gap: 24px;
    max-width: 1280px;
    min-height: 100vh;
    padding: 24px 28px 48px;
  }

  .topbar { grid-column: 2; grid-row: 1; margin: 0 0 12px; }
  .tabs {
    position: sticky;
    top: 24px;
    right: auto;
    bottom: auto;
    left: auto;
    grid-column: 1;
    grid-row: 1 / 3;
    display: flex;
    width: 84px;
    height: calc(100vh - 48px);
    max-width: none;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 12px;
    border-radius: var(--radius-xl);
    background: rgba(10, 14, 22, .78);
    box-shadow: var(--shadow);
  }

  .tab { width: 58px; min-height: 58px; flex: 0 0 58px; }
  .tab-icon { width: 22px; height: 22px; }
  main { grid-column: 2; grid-row: 2; }

  #dashboard {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
  }

  #dashboard > .hero-card { grid-column: span 8; min-height: 100%; margin: 0; padding: 24px; }
  #dashboard > .nutrition-block { grid-column: span 4; }
  #dashboard > .weight-block { grid-column: span 4; }
  #dashboard > .schedule-block { grid-column: span 8; }
  #dashboard > .section-block { margin-top: 0; }
  .hero-card h2 { font-size: 34px; }
  .schedule { grid-template-columns: repeat(2, 1fr); }

  #activeWorkout { max-width: 900px; }
  #coachView.active { max-width: 900px; }
  #historyView.active { max-width: 900px; }
  #progressView.view.active { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  #progressView > .section-heading { grid-column: 1 / -1; margin-bottom: 0; }
  #progressView > .card { margin: 0; }
  #progressView > .card:first-of-type { grid-column: 1 / -1; }
  .chart { min-height: 170px; }
  .chart svg { height: 170px; }

  .rest-timer { right: 28px; bottom: 24px; left: 136px; max-width: 720px; }
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { max-height: calc(100vh - 48px); margin: auto; }
}

@media (prefers-reduced-motion: no-preference) {
  .view.active { animation: fade .18s ease; }
  .done-set,
  .primary-btn,
  .plan-choice,
  .tab { transition: transform .14s ease, background .18s ease, border-color .18s ease, color .18s ease; }
  .done-set:active,
  .primary-btn:active,
  .plan-choice:active,
  .tab:active { transform: scale(.98); }
  @keyframes fade { from { opacity: .45; transform: translateY(3px); } }
}
