:root {
  color-scheme: dark;
  --bg: #050b14;
  --bg-soft: #08111d;
  --surface: #0b1725;
  --surface-2: #101f30;
  --surface-3: #15283a;
  --line: #1b3549;
  --line-bright: #28536c;
  --text: #effaff;
  --muted: #8ba8b8;
  --dim: #688898;
  --cyan: #20d9f5;
  --cyan-soft: #0d8398;
  --teal: #35e1b4;
  --amber: #ffc45b;
  --red: #ff6b74;
  --purple: #a98cff;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 18px 60px #0008;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 10% -10%, #0a6b7d33, transparent 38rem),
    radial-gradient(circle at 95% 20%, #40327425, transparent 32rem);
  z-index: 0;
}

.center-screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 28px;
  text-align: center;
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid var(--cyan-soft);
  border-radius: 19px;
  background: #0b2130;
  box-shadow: inset 0 0 22px #20d9f515, 0 0 24px #20d9f51c;
  transform: rotate(45deg);
}
.brand-mark span { color: var(--cyan); font-weight: 900; font-size: 25px; transform: rotate(-45deg); }
.center-screen .brand-mark { margin-bottom: 26px; }
.eyebrow { margin: 0 0 8px; color: var(--cyan); font-size: 11px; font-weight: 800; letter-spacing: .18em; }
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0; font-size: clamp(28px, 8vw, 48px); line-height: 1.02; letter-spacing: -.04em; }
h2 { margin: 0; font-size: clamp(24px, 6vw, 34px); line-height: 1.05; letter-spacing: -.035em; }
h3 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.lede { max-width: 470px; margin: 16px auto 26px; color: var(--muted); line-height: 1.6; }
.muted { color: var(--muted); line-height: 1.5; }
.fine-print { color: var(--dim); font-size: 12px; line-height: 1.5; }
.loader { width: min(260px, 65vw); height: 3px; margin-top: 30px; overflow: hidden; background: var(--line); border-radius: 99px; }
.loader span { display: block; width: 42%; height: 100%; background: var(--cyan); animation: load 1.2s ease-in-out infinite; }
@keyframes load { 0% { transform: translateX(-110%); } 100% { transform: translateX(340%); } }

.glass, .card {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 12px 45px #0003;
}
.auth-card { width: min(520px, 100%); padding: 36px; border-radius: 28px; text-align: left; }
.auth-card .brand-mark { margin-left: 4px; }
.auth-card h1 { font-size: clamp(30px, 8vw, 44px); }
label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: 0;
  background: #07111c;
  color: var(--text);
  padding: 12px 14px;
  font-size: 16px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--cyan-soft); box-shadow: 0 0 0 3px #20d9f515; }
.field-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.form-error { min-height: 20px; color: var(--red); font-size: 13px; }

.button {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-bright);
  border-radius: 14px;
  padding: 12px 18px;
  cursor: pointer;
  background: var(--surface-2);
  font-weight: 850;
}
.button.primary { border-color: var(--cyan); background: var(--cyan); color: #001219; box-shadow: 0 8px 30px #20d9f52d; }
.button.secondary { border-color: var(--line-bright); background: var(--surface-3); color: var(--text); }
.button.ghost { background: transparent; color: var(--cyan); }
.button.danger { border-color: #863942; background: #2c1017; color: #ffadb3; }
.button.compact { min-height: 42px; padding: 8px 13px; font-size: 13px; }
.button.wide { width: 100%; }
.button:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.icon-button {
  min-width: 48px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  font-size: 20px;
}

.app-shell { position: relative; z-index: 1; min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) 10px max(18px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid #183246aa;
  background: #050b14e8;
  backdrop-filter: blur(18px);
}
.identity { display: flex; align-items: center; gap: 11px; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.identity img { width: 42px; height: 42px; border-radius: 13px; object-fit: cover; object-position: 50% 20%; border: 1px solid var(--line-bright); }
.identity span { display: grid; gap: 3px; }
.identity b { font-size: 13px; letter-spacing: .09em; }
.identity small { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .09em; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.sync-pill { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 750; }
.sync-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 10px var(--teal); }
.sync-pill.offline i { background: var(--amber); box-shadow: none; }
.sync-pill.error i { background: var(--red); box-shadow: none; }

#mainView {
  width: min(1180px, 100%);
  min-height: calc(100vh - 160px);
  margin: 0 auto;
  padding: 22px 18px calc(104px + var(--safe-bottom));
  outline: none;
}
.view-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin: 5px 0 22px; }
.view-head p { margin: 7px 0 0; color: var(--muted); }
.view-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.date-label { color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; }

.bottom-nav {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: max(10px, var(--safe-bottom));
  transform: translateX(-50%);
  width: min(620px, calc(100% - 24px));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 21px;
  background: #08121df2;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}
.bottom-nav button {
  min-height: 55px;
  display: grid;
  place-items: center;
  gap: 2px;
  border: 0;
  border-radius: 15px;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
}
.bottom-nav button span { font-size: 18px; line-height: 1; }
.bottom-nav button small { font-size: 10px; font-weight: 800; }
.bottom-nav button.active { background: #102738; color: var(--cyan); }

.hero-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(270px, .75fr); gap: 16px; }
.hero-card { position: relative; overflow: hidden; min-height: 320px; padding: 28px; border-radius: var(--radius); background: #0b1e2c; }
.hero-card::after { content: ""; position: absolute; width: 220px; height: 220px; right: -80px; top: -80px; border: 1px solid #20d9f523; border-radius: 50%; box-shadow: 0 0 0 34px #20d9f509, 0 0 0 72px #20d9f506; }
.hero-card > * { position: relative; z-index: 1; }
.status-line { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.status-badge { display: inline-flex; align-items: center; gap: 7px; min-height: 28px; padding: 5px 10px; border: 1px solid var(--line-bright); border-radius: 99px; color: var(--cyan); background: #071620; font-size: 10px; font-weight: 850; letter-spacing: .1em; }
.hero-card h2 { max-width: 570px; font-size: clamp(37px, 8vw, 68px); }
.hero-card .hero-copy { max-width: 530px; margin: 12px 0 26px; color: var(--muted); line-height: 1.55; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.hero-meta span { padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 12px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.metric-stack { display: grid; gap: 12px; }
.metric-card { min-height: 98px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 18px; border-radius: 18px; }
.metric-card small { display: block; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .05em; }
.metric-card strong { display: block; margin-top: 5px; font-size: 24px; line-height: 1; letter-spacing: -.04em; }
.metric-card .metric-note { color: var(--dim); font-size: 11px; }
.ring { --value: 0; width: 54px; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--cyan) calc(var(--value) * 1%), #173247 0); }
.ring::after { content: ""; width: 42px; aspect-ratio: 1; border-radius: 50%; background: var(--surface); }
.ring.teal { background: conic-gradient(var(--teal) calc(var(--value) * 1%), #173247 0); }

.section-block { margin-top: 24px; }
.section-title { display: flex; justify-content: space-between; align-items: end; gap: 14px; margin-bottom: 12px; }
.section-title h3 { font-size: 21px; }
.section-title p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.text-button { border: 0; background: none; color: var(--cyan); padding: 8px; font-weight: 800; cursor: pointer; }
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick-action { min-height: 92px; display: grid; align-content: space-between; gap: 14px; padding: 15px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); text-align: left; cursor: pointer; }
.quick-action i { color: var(--cyan); font-style: normal; font-size: 20px; }
.quick-action span { font-size: 13px; font-weight: 800; }

.insight-list { display: grid; gap: 10px; }
.insight { position: relative; display: grid; grid-template-columns: 5px 1fr; gap: 14px; padding: 18px; border-radius: 17px; }
.insight > i { border-radius: 99px; background: var(--cyan); }
.insight.green > i { background: var(--teal); }
.insight.amber > i { background: var(--amber); }
.insight.red > i { background: var(--red); }
.insight.neutral > i { background: var(--dim); }
.insight h3 { font-size: 16px; }
.insight p { margin: 6px 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.insight small { color: var(--dim); font-size: 11px; }

.template-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.template-card { position: relative; min-height: 230px; display: grid; align-content: space-between; padding: 22px; overflow: hidden; border-radius: var(--radius); cursor: pointer; text-align: left; }
.template-card.next { border-color: var(--cyan-soft); box-shadow: inset 0 0 28px #20d9f50a; }
.template-card .code { color: var(--cyan); font-size: 11px; font-weight: 850; letter-spacing: .15em; }
.template-card h3 { margin-top: 10px; font-size: 31px; }
.template-card p { color: var(--muted); line-height: 1.45; }
.template-card footer { display: flex; justify-content: space-between; align-items: center; color: var(--dim); font-size: 12px; }
.template-card footer b { color: var(--text); }

.macro-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.macro-card { padding: 24px; border-radius: var(--radius); }
.macro-card strong { display: block; margin-top: 8px; font-size: clamp(34px, 9vw, 58px); letter-spacing: -.06em; }
.macro-card strong span { color: var(--dim); font-size: .42em; letter-spacing: 0; }
.progress-track { height: 7px; margin-top: 18px; overflow: hidden; border-radius: 99px; background: #173044; }
.progress-track i { display: block; height: 100%; border-radius: inherit; background: var(--cyan); }
.macro-card.protein .progress-track i { background: var(--teal); }
.food-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.food-card { display: grid; align-content: space-between; min-height: 220px; padding: 20px; border-radius: 19px; }
.food-card .tag { color: var(--amber); font-size: 10px; font-weight: 850; letter-spacing: .12em; }
.food-card h3 { margin: 9px 0; }
.food-card p { color: var(--muted); font-size: 13px; line-height: 1.45; }
.food-card small { color: var(--teal); }
.entry-list { display: grid; gap: 8px; }
.entry-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; min-height: 68px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.entry-row b { display: block; }
.entry-row small { color: var(--muted); }
.entry-row .macro { color: var(--teal); font-weight: 800; white-space: nowrap; }
.delete-button { min-width: 44px; min-height: 44px; border: 0; border-radius: 12px; background: #29131a; color: var(--red); cursor: pointer; }

.activity-filters { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(150px, .7fr) auto; gap: 12px; align-items: end; padding: 16px; border-radius: 18px; }
.activity-filters select { min-height: 48px; }
.activity-count { margin: 16px 2px; color: var(--muted); font-size: 13px; font-weight: 750; }
.activity-days { display: grid; gap: 25px; }
.activity-more { margin-top: 18px; }
.activity-day > h2 { display: flex; align-items: center; gap: 9px; margin: 0 0 10px; font-size: 18px; letter-spacing: -.02em; }
.activity-day > h2 span { min-width: 25px; min-height: 25px; display: inline-grid; place-items: center; padding: 3px 7px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: 11px; }
.activity-list { display: grid; gap: 9px; }
.activity-entry { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 13px; align-items: center; min-height: 86px; padding: 14px; border-radius: 17px; }
.activity-icon { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line-bright); border-radius: 13px; background: #0b2533; color: var(--cyan); font-size: 18px; }
.activity-copy { min-width: 0; }
.activity-copy small { color: var(--teal); font-size: 10px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.activity-copy h3 { margin-top: 4px; font-size: 16px; }
.activity-copy p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.activity-copy span { display: block; margin-top: 6px; color: var(--dim); font-size: 10px; font-weight: 700; }
.activity-delete { min-width: 76px; min-height: 44px !important; }

.progress-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, .7fr); gap: 14px; }
.chart-card, .summary-card { padding: 22px; border-radius: var(--radius); }
.chart-card header, .summary-card header { display: flex; justify-content: space-between; gap: 15px; align-items: start; }
.chart-card svg { width: 100%; height: 220px; margin-top: 20px; overflow: visible; }
.chart-card .empty-chart { min-height: 220px; display: grid; place-items: center; color: var(--dim); text-align: center; }
.chart-label { fill: var(--dim); font-size: 10px; }
.chart-line { fill: none; stroke: var(--cyan); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: #20d9f511; }
.chart-dot { fill: var(--bg); stroke: var(--cyan); stroke-width: 3; }
.summary-stat { padding: 16px 0; border-bottom: 1px solid var(--line); }
.summary-stat:last-child { border: 0; }
.summary-stat small { color: var(--muted); }
.summary-stat strong { display: block; margin-top: 5px; font-size: 25px; }
.health-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.health-grid.composition-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.health-card { padding: 17px; border-radius: 17px; }
.health-card small { color: var(--muted); }
.health-card strong { display: block; margin-top: 8px; font-size: 23px; }
.health-card p { margin: 8px 0 0; }
.workout-history { display: grid; gap: 9px; }
.history-session { overflow: hidden; border-radius: 17px; }
.history-session > summary { min-height: 72px; display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 15px 18px; cursor: pointer; list-style-position: inside; }
.history-session > summary span:first-of-type { flex: 1; display: inline-grid; gap: 4px; }
.history-session > summary small { color: var(--muted); }
.history-total { color: var(--teal); font-size: 13px; font-weight: 850; white-space: nowrap; }
.history-exercises { display: grid; gap: 1px; padding: 0 12px 12px; }
.history-exercise { padding: 14px 8px; border-top: 1px solid var(--line); }
.history-exercise header { display: flex; justify-content: space-between; gap: 12px; }
.history-exercise header div { display: grid; gap: 3px; }
.history-exercise header small, .history-exercise header span, .history-exercise p { color: var(--muted); font-size: 12px; }
.history-exercise p { margin: 7px 0 0; }
.history-sets { display: grid; gap: 6px; margin-top: 10px; }
.history-sets > div { display: grid; grid-template-columns: 58px 1fr auto; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 10px; background: var(--surface-2); font-size: 12px; }
.history-sets small { color: var(--muted); text-align: right; }

.chat-shell { min-height: calc(100dvh - 220px); display: grid; grid-template-rows: auto 1fr auto; gap: 16px; }
.coach-intro { padding: 20px; border-radius: var(--radius); display: grid; grid-template-columns: auto 1fr; gap: 15px; align-items: center; }
.coach-orb { width: 54px; height: 54px; display: grid; place-items: center; border: 1px solid var(--cyan-soft); border-radius: 50%; color: var(--cyan); font-size: 22px; box-shadow: inset 0 0 25px #20d9f51c, 0 0 22px #20d9f51f; }
.coach-intro p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.messages { display: flex; flex-direction: column; gap: 10px; min-height: 260px; }
.message { max-width: min(680px, 90%); padding: 14px 16px; border: 1px solid var(--line); border-radius: 17px 17px 17px 5px; background: var(--surface); line-height: 1.55; white-space: pre-wrap; }
.message.user { align-self: end; border-color: #235b70; border-radius: 17px 17px 5px 17px; background: #0b2634; }
.message small { display: block; margin-top: 7px; color: var(--dim); font-size: 10px; }
.message.thinking { color: var(--muted); }
.message-view-button { min-height: 44px !important; margin-top: 12px; }
.coach-action { display: grid; gap: 10px; margin: 14px -5px -5px; padding: 15px; border: 1px solid #74562b; border-radius: 14px; background: #20190e; white-space: normal; }
.coach-action .eyebrow { margin: 0; color: var(--amber); }
.coach-action h3 { font-size: 17px; }
.coach-action > p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.coach-action-records { display: grid; gap: 7px; max-height: 330px; margin: 0; padding: 0; overflow: auto; list-style: none; }
.coach-action-records li { display: grid; gap: 4px; padding: 10px 11px; border: 1px solid #4a3a22; border-radius: 11px; background: #0d1117; }
.coach-action-records li span { display: flex; align-items: baseline; gap: 8px; }
.coach-action-records li b { flex: 0 0 auto; color: var(--amber); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; }
.coach-action-records li strong { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.coach-action-records li small { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.coach-action-buttons { display: flex; justify-content: end; gap: 8px; }
.coach-action-buttons .button { min-height: 44px; }
.coach-action.confirmed { border-color: #2b725a; background: #0d241e; }
.coach-action.cancelled, .coach-action.expired { border-color: var(--line); background: var(--surface-2); }
.action-status { display: block; padding-top: 4px; color: var(--muted); font-size: 12px; }
.action-status.confirmed { color: var(--teal); }
.action-status.expired { color: var(--amber); }
.prompt-chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 3px; scrollbar-width: none; }
.prompt-chip { flex: 0 0 auto; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); cursor: pointer; color: var(--muted); font-size: 12px; }
.chat-compose { position: sticky; bottom: calc(80px + var(--safe-bottom)); padding: 9px; border: 1px solid var(--line); border-radius: 18px; background: #08121df2; backdrop-filter: blur(18px); }
.chat-compose form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.chat-compose input { border: 0; background: transparent; }

/* Focused workout */
body.workout-mode .topbar { position: fixed; width: 100%; background: #050b14f4; }
body.workout-mode #mainView { width: min(760px, 100%); min-height: 100dvh; padding: calc(92px + env(safe-area-inset-top, 0px)) 14px calc(102px + var(--safe-bottom)); }
body.workout-mode .bottom-nav { display: none; }
body.workout-mode .identity small { display: none; }
.workout-dock {
  position: fixed;
  z-index: 32;
  left: 50%;
  bottom: max(10px, var(--safe-bottom));
  transform: translateX(-50%);
  width: min(420px, calc(100% - 24px));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #08121df5;
  box-shadow: var(--shadow);
}
.workout-dock button { min-height: 55px; display: grid; place-items: center; gap: 2px; border: 0; border-radius: 14px; background: transparent; color: var(--muted); cursor: pointer; }
.workout-dock button span { color: var(--cyan); font-size: 19px; }
.workout-dock small { font-weight: 800; }
.workout-progress { display: grid; gap: 12px; margin-bottom: 14px; }
.workout-progress header { display: flex; justify-content: space-between; align-items: center; }
.workout-progress header b { font-size: 13px; }
.workout-progress header span { color: var(--muted); font-size: 12px; }
.segments { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.segments > * { position: relative; min-height: 44px; padding: 0; border: 0; background: transparent; }
.segments > *::after { content: ""; position: absolute; inset: 19px 0 auto; height: 5px; border-radius: 99px; background: var(--line); }
.segments button { cursor: pointer; }
.segments button.complete::after { background: var(--teal); }
.segments button.current::after { background: var(--cyan); box-shadow: 0 0 10px #20d9f54f; }
.exercise-card { overflow: hidden; border-radius: 24px; }
.movement-visual { position: relative; width: 100%; aspect-ratio: 3.25 / 1; background-repeat: no-repeat; background-size: 100% 500%; background-color: #eef1f3; }
.movement-visual::after { content: "START                               FINISH"; position: absolute; inset: auto 10px 8px; display: flex; justify-content: space-between; color: #20313d; font-size: 9px; font-weight: 900; letter-spacing: .12em; white-space: pre; opacity: .72; }
.exercise-body { padding: 21px; }
.exercise-heading { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.exercise-heading h1 { margin-top: 7px; font-size: clamp(30px, 8vw, 46px); }
.exercise-position { color: var(--cyan); font-size: 10px; font-weight: 850; letter-spacing: .14em; }
.substitute-pill { display: inline-flex; margin-top: 9px; padding: 5px 8px; border: 1px solid #80642a; border-radius: 99px; color: var(--amber); font-size: 10px; font-weight: 800; }
.exercise-targets { display: flex; flex-wrap: wrap; gap: 7px; margin: 17px 0; }
.exercise-targets span { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 12px; }
.recommendation { padding: 17px; border: 1px solid #1b5267; border-radius: 16px; background: #091e2b; }
.recommendation small { color: var(--cyan); font-weight: 850; letter-spacing: .08em; }
.recommendation strong { display: block; margin: 7px 0; font-size: 25px; }
.recommendation p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.assistance-note { display: inline-block; margin-top: 9px; color: var(--amber); font-size: 12px; font-weight: 750; }
.set-tabs { display: flex; gap: 8px; margin: 18px 0 14px; }
.set-tab { flex: 1; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 800; }
.set-tab.done { border-color: #26654f; background: #0f2d26; color: var(--teal); }
.set-tab.active { border-color: var(--cyan); background: #0b2937; color: var(--cyan); }
.set-tab:focus-visible, .segments button:focus-visible { outline: 3px solid var(--text); outline-offset: 2px; }
.set-form { display: grid; gap: 14px; }
.set-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.stepper { display: grid; grid-template-columns: 48px 1fr 48px; align-items: stretch; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #07111c; }
.stepper button { min-height: 64px; border: 0; background: var(--surface-2); color: var(--cyan); font-size: 24px; cursor: pointer; }
.stepper input { min-width: 0; min-height: 64px; padding: 6px; border: 0; border-radius: 0; text-align: center; font-size: 24px; font-weight: 850; }
.set-field > small { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 750; }
.rir-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.rir-fieldset legend { margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 750; }
.rir-control { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.rir-control label { display: block; }
.rir-control input { position: absolute; opacity: 0; pointer-events: none; }
.rir-control span { min-height: 48px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--muted); cursor: pointer; }
.rir-control input:checked + span { border-color: var(--cyan); background: #0b2937; color: var(--cyan); font-weight: 900; }
.rir-control input:focus-visible + span, .readiness input:focus-visible + span { outline: 3px solid var(--text); outline-offset: 2px; }
.clean-toggle { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 50px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 13px; color: var(--muted); }
.clean-toggle input { width: 24px; min-height: 24px; accent-color: var(--teal); }
.exercise-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 14px; }
.next-exercise { margin-top: 12px; }

.rest-timer {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: calc(82px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(520px, calc(100% - 24px));
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 9px;
  padding: 12px 13px;
  border: 1px solid var(--cyan-soft);
  border-radius: 18px;
  background: #071621f5;
  box-shadow: var(--shadow);
}
.rest-timer small { display: block; color: var(--muted); font-size: 9px; font-weight: 850; letter-spacing: .12em; }
.rest-timer strong { display: block; margin-top: 2px; color: var(--cyan); font-size: 25px; letter-spacing: -.04em; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(94px + var(--safe-bottom)); transform: translate(-50%, 18px); width: max-content; max-width: calc(100% - 32px); padding: 12px 16px; border: 1px solid var(--line-bright); border-radius: 14px; background: #10202ced; color: var(--text); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

dialog { padding: 0; border: 0; background: transparent; color: var(--text); }
dialog::backdrop { background: #01040acc; backdrop-filter: blur(5px); }
.sheet { width: min(620px, 100%); max-height: 94dvh; margin: auto auto 0; }
.sheet-card { max-height: 92dvh; overflow: auto; padding: 18px 20px calc(24px + var(--safe-bottom)); border: 1px solid var(--line); border-bottom: 0; border-radius: 26px 26px 0 0; background: #09131f; box-shadow: var(--shadow); }
.sheet-card header { display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 14px; }
.sheet-card h2 { font-size: 28px; }
.sheet-handle { width: 42px; height: 4px; margin: 0 auto 19px; border-radius: 99px; background: var(--line-bright); }
.sheet-card label { margin-top: 14px; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
details { margin-top: 13px; color: var(--muted); }
details summary { cursor: pointer; font-size: 13px; font-weight: 750; }
.detail-fields { margin-top: 9px; }
.optional-fields > .fine-print { margin: 10px 0 0; }
.optional-fields > summary { min-height: 44px; display: flex; align-items: center; padding: 8px 2px; }
.nutrition-fields { display: grid; gap: 2px; }
.meal-estimator { display: grid; gap: 11px; margin-top: 14px; padding: 15px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
.meal-estimator label { margin: 0; }
.meal-estimator p { margin: 0; }
.estimate-status { min-height: 19px; color: var(--cyan); font-size: 12px; font-weight: 750; }
.estimate-review { display: grid; gap: 8px; padding: 13px; border: 1px solid #2d765f; border-radius: 13px; background: #0d2922; }
.estimate-review.stale { border-color: #86682d; background: #251e11; }
.estimate-review-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.estimate-review-head h3 { font-size: 16px; }
.estimate-review p, .estimate-review li { color: var(--muted); font-size: 12px; line-height: 1.45; }
.estimate-review ul { display: grid; gap: 4px; margin: 0; padding-left: 19px; }
.estimate-badge { flex: 0 0 auto; padding: 5px 8px; border: 1px solid #2d765f; border-radius: 99px; color: var(--teal); font-size: 10px; font-weight: 850; letter-spacing: .05em; text-transform: uppercase; }
.estimate-review.stale .estimate-badge { border-color: #86682d; color: var(--amber); }
.sheet-card > .button.wide { margin-top: 16px; }
.delete-record-preview { display: grid; gap: 7px; margin: 17px 0; padding: 16px; border: 1px solid #70404a; border-radius: 16px; background: #211118; }
.delete-record-preview small { color: var(--red); font-size: 10px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.delete-record-preview strong { font-size: 18px; }
.delete-record-preview p { margin: 0; color: var(--muted); line-height: 1.45; }
.delete-record-preview time { color: var(--dim); font-size: 12px; font-weight: 750; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 18px; }
.readiness-options { display: grid; gap: 9px; }
.readiness { position: relative; margin: 0 !important; }
.readiness input { position: absolute; opacity: 0; }
.readiness span { min-height: 72px; display: grid; align-content: center; gap: 4px; padding: 13px 15px 13px 47px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); cursor: pointer; }
.readiness span::before { content: ""; position: absolute; left: 18px; top: 50%; width: 13px; height: 13px; transform: translateY(-50%); border: 2px solid var(--dim); border-radius: 50%; }
.readiness small { color: var(--muted); font-weight: 500; }
.readiness input:checked + span { border-color: var(--cyan-soft); background: #0c2130; }
.readiness input:checked + span::before { border-color: var(--cyan); background: var(--cyan); box-shadow: inset 0 0 0 3px #0c2130; }
.readiness.amber input:checked + span { border-color: #916d2c; background: #211b10; }
.readiness.amber input:checked + span::before { border-color: var(--amber); background: var(--amber); box-shadow: inset 0 0 0 3px #211b10; }
.readiness.red input:checked + span { border-color: #7d3740; background: #241118; }
.readiness.red input:checked + span::before { border-color: var(--red); background: var(--red); box-shadow: inset 0 0 0 3px #241118; }
.menu-row { width: 100%; min-height: 72px; display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 13px 3px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.menu-row span { display: grid; gap: 5px; }
.menu-row small { color: var(--muted); }
.menu-row i { color: var(--cyan); font-style: normal; }
.danger-row b, .danger-row i { color: var(--red); }
.alternative-list, .exercise-list { display: grid; gap: 9px; }
.alternative-option, .exercise-option { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; min-height: 76px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); text-align: left; cursor: pointer; }
.alternative-option small, .exercise-option small { display: block; margin-top: 4px; color: var(--muted); line-height: 1.35; }
.exercise-option .state { color: var(--dim); font-size: 11px; font-weight: 800; }
.exercise-option.complete .state { color: var(--teal); }
.exercise-option.current { border-color: var(--cyan-soft); }
.technique-visual { margin: 4px -2px 18px; border-radius: 17px; overflow: hidden; }
.technique-block { padding: 15px 0; border-top: 1px solid var(--line); }
.technique-block b { display: block; margin-bottom: 7px; color: var(--teal); font-size: 11px; letter-spacing: .09em; }
.technique-block.avoid b { color: var(--red); }
.technique-block p { margin: 0; color: var(--muted); line-height: 1.55; }
.completion-hero { padding: 24px 0; text-align: center; }
.completion-check { width: 72px; height: 72px; display: grid; place-items: center; margin: 0 auto 19px; border: 1px solid #2c795e; border-radius: 50%; color: var(--teal); background: #0e2a22; font-size: 34px; box-shadow: 0 0 30px #35e1b423; }
.completion-hero p { color: var(--muted); }
.completion-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; }
.completion-stats div { padding: 14px 7px; border: 1px solid var(--line); border-radius: 14px; text-align: center; }
.completion-stats strong { display: block; font-size: 20px; }
.completion-stats small { color: var(--muted); }

@media (min-width: 900px) {
  .app-shell { padding-left: 100px; }
  .topbar { padding-left: 28px; }
  .bottom-nav { left: 14px; top: 92px; bottom: auto; width: 72px; transform: none; grid-template-columns: 1fr; }
  .bottom-nav button { min-height: 64px; }
  body.workout-mode .app-shell { padding-left: 0; }
  body.workout-mode .topbar { padding-left: 22px; }
}

@media (max-width: 760px) {
  .hero-grid, .progress-grid { grid-template-columns: 1fr; }
  .activity-filters { grid-template-columns: 1fr 1fr; }
  .activity-filters .button { grid-column: 1 / -1; }
  .metric-stack { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 88px; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .template-grid { grid-template-columns: 1fr; }
  .macro-hero { grid-template-columns: 1fr 1fr; }
  .food-grid { grid-template-columns: 1fr; }
  .food-card { min-height: 175px; }
  .health-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .auth-card { padding: 27px 20px; }
  .field-row { grid-template-columns: 1fr; }
  .topbar { min-height: 68px; }
  .sync-pill span { display: none; }
  #mainView { padding-left: 14px; padding-right: 14px; }
  .view-head { align-items: start; flex-direction: column; }
  .view-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .hero-card { min-height: 340px; padding: 22px 18px; }
  .hero-actions { display: grid; }
  .metric-stack { grid-template-columns: 1fr 1fr; }
  .metric-card { padding: 14px; grid-template-columns: 1fr; }
  .metric-card .ring { display: none; }
  .macro-hero { grid-template-columns: 1fr; }
  .macro-card { padding: 19px; }
  .two-fields { grid-template-columns: 1fr; }
  .set-fields { grid-template-columns: 1fr 1fr; }
  .stepper { grid-template-columns: 42px 1fr 42px; }
  .exercise-body { padding: 18px 15px; }
  .exercise-heading { display: block; }
  .exercise-heading .button { margin-top: 10px; }
  .exercise-actions { grid-template-columns: 1fr; }
  .rest-timer { grid-template-columns: 1fr auto auto; }
  .rest-timer .button { font-size: 0; min-width: 46px; }
  .rest-timer .button::after { font-size: 17px; }
  #addRestButton::after { content: "+30"; }
  #skipRestButton::after { content: "✓"; }
  .completion-stats { grid-template-columns: repeat(3, 1fr); }
  .history-sets > div { grid-template-columns: 52px 1fr; }
  .history-sets small { grid-column: 1 / -1; text-align: left; }
  .entry-row { grid-template-columns: 1fr auto; }
  .entry-row .macro { grid-column: 1 / -1; grid-row: 2; white-space: normal; }
  .activity-filters { grid-template-columns: 1fr; }
  .activity-filters .button { grid-column: auto; }
  .activity-entry { grid-template-columns: 42px minmax(0, 1fr); align-items: start; }
  .activity-delete { grid-column: 2; width: 100%; }
  .coach-action-buttons { display: grid; grid-template-columns: 1fr; }
  .dialog-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (forced-colors: active) {
  .ring { border: 2px solid CanvasText; background: Canvas; }
  .insight > i { border: 2px solid CanvasText; }
}
