:root {
  --ink: #17201a;
  --muted: #657267;
  --paper: #f7f5ed;
  --panel: #fffefa;
  --line: #dde4da;
  --green: #2f7d5b;
  --blue: #256b8f;
  --brick: #a64b3c;
  --gold: #d69c35;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: linear-gradient(180deg, #efefe7, var(--paper) 44%, #edf4ef);
}
button, input, select, textarea { font: inherit; }
button:disabled { cursor: not-allowed; opacity: 0.45; transform: none; }

.shell {
  width: min(1220px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 44px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 16px;
}

.hero > div, .snapshot, .toolbar, .day-panel, .history {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(23, 32, 26, 0.09);
}

.hero > div {
  padding: clamp(22px, 4vw, 40px);
  min-height: 260px;
  background:
    linear-gradient(135deg, rgba(47, 125, 91, 0.08), transparent 42%),
    linear-gradient(135deg, #fffefa, #eef6f2);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--blue);
  text-transform: uppercase;
  font-weight: 900;
  font-size: 0.78rem;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: 0;
  max-width: 880px;
}

.subhead {
  margin: 16px 0 0;
  color: #38473d;
  line-height: 1.55;
  max-width: 780px;
  font-size: 1.08rem;
}

.snapshot {
  background: #17201a;
  color: #f8faf5;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.snapshot strong { font-size: 4.6rem; line-height: 1; }
.snapshot span { color: #cbd7ce; font-weight: 800; }

.btn {
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  min-height: 42px;
  background: var(--green);
  color: white;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.btn.secondary {
  background: #eff4ef;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn:hover { filter: brightness(1.04); transform: translateY(-1px); }

.flow-shell {
  width: min(760px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 48px;
}
.flow-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}
.flow-header h1 { font-size: clamp(2.2rem, 7vw, 4rem); }
.flow-header.compact h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); }
.step-track {
  display: grid;
  grid-template-columns: 28px auto 1fr 28px auto 1fr 28px auto;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}
.step-track strong {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 2px solid var(--green);
  color: var(--green);
  background: var(--panel);
}
.step-track strong.done { color: white; background: var(--green); }
.step-track i { height: 2px; background: var(--line); }
.flow-panel, .single-exercise, .finished-state {
  padding: clamp(18px, 4vw, 28px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(23, 32, 26, 0.08);
}
.checkin-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 18px;
  color: var(--blue);
  font-weight: 900;
}
.checkin-meters { gap: 18px; }
.checkin-meters label { display: grid; grid-template-columns: 1fr auto auto; align-items: center; }
.checkin-meters input { grid-column: 1 / -1; margin-top: 8px; }
.flow-field { display: block; margin-top: 20px; }
.flow-field textarea { min-height: 120px; resize: vertical; }
.flow-save { margin: 14px 0 0; text-align: left; }
.flow-next { width: 100%; margin-top: 18px; min-height: 50px; }
.form-error { min-height: 1.2em; color: var(--brick); font-weight: 750; }
.generating {
  min-height: 380px;
  text-align: center;
  display: grid;
  place-content: center;
  justify-items: center;
}
.generating[hidden] { display: none; }
.spinner {
  width: 48px;
  height: 48px;
  border: 5px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.plan-rationale {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--blue);
  background: #f4f8fa;
  color: #3c4d53;
  line-height: 1.5;
}
.plan-rationale:empty { display: none; }
.exercise-position {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-align: right;
}
.single-exercise { padding: 0; overflow: hidden; }
.single-exercise .exercise { border: 0; box-shadow: none; }
.workout-nav {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) auto minmax(100px, 1fr);
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.workout-nav span { color: var(--muted); font-size: 0.82rem; font-weight: 900; text-align: center; }
.completion-summary { padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.completion-summary h2 { font-size: 1.45rem; }
.completion-summary p { margin-bottom: 0; color: var(--muted); }
.finished-state { text-align: center; }
.finished-state p { color: var(--muted); }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px;
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr auto auto auto;
  gap: 10px;
  background: rgba(255, 254, 250, 0.91);
  backdrop-filter: blur(12px);
}
.save-state {
  align-self: center;
  min-width: 74px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

label span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.8rem;
  margin-bottom: 5px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
}
input[type="range"] { padding: 0; accent-color: var(--green); }
input.is-recommended, select.is-recommended {
  border-color: rgba(47, 125, 91, 0.42);
  background: #f4faf6;
  color: #244b38;
  font-weight: 750;
}

.day-panel {
  margin: 16px 0 26px;
  padding: 18px;
}

.day-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
}

.title-input {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 6px 0 10px;
  font-weight: 950;
  font-size: clamp(1.6rem, 3vw, 2.7rem);
  background: transparent;
  resize: none;
  overflow: hidden;
}

.guidance {
  color: var(--muted);
  line-height: 1.5;
  margin: 12px 0 0;
}

.field-help {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
}

.coaching-handoff {
  margin-top: 18px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.handoff-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 12px;
}
.handoff-heading h2 { font-size: 1.25rem; }
.handoff-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.handoff-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.handoff-grid textarea {
  min-height: 100px;
  resize: vertical;
}
.handoff-grid .coach-note textarea {
  border-left: 4px solid var(--blue);
  background: #f5f9fb;
}

.meters {
  display: grid;
  gap: 10px;
}

.meters label {
  color: #334238;
  font-weight: 800;
}

.general-notes {
  margin-top: 16px;
  min-height: 92px;
  resize: vertical;
}

.nutrition-exception { margin-top: 12px; display: block; }

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
}
h2 {
  font-size: clamp(1.5rem, 2.5vw, 2.3rem);
  margin: 0;
}

.exercise-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.exercise-nav {
  display: none;
}
.exercise-nav.workout-nav { display: grid; }
.exercise-nav[hidden] { display: none; }

.exercise {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  min-height: 318px;
  box-shadow: 0 10px 28px rgba(23, 32, 26, 0.07);
}

.media {
  background: #eef3ef;
  border-right: 1px solid var(--line);
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 8px;
}
.media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
}
.media .text-art {
  font-weight: 950;
  color: var(--blue);
  text-align: center;
  font-size: 2rem;
}

.exercise-body {
  padding: 15px;
  display: grid;
  gap: 10px;
}
.exercise-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.exercise h3 { margin: 0; font-size: 1.15rem; }
.tag {
  flex: none;
  background: var(--blue);
  color: white;
  border-radius: 999px;
  padding: 5px 8px;
  font-weight: 900;
  font-size: 0.72rem;
}
.rx-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.rx {
  background: #f5f7f3;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
}
.rx small {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 3px;
}
.rx strong { line-height: 1.15; display: block; }

.cues {
  margin: 0;
  padding-left: 18px;
  color: #455348;
  line-height: 1.45;
}

.log-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}
.log-grid textarea {
  grid-column: 1 / -1;
  resize: vertical;
  min-height: 74px;
}
.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
}
.checkline input {
  width: 19px;
  height: 19px;
  accent-color: var(--green);
}

.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  color: #3f4f44;
  line-height: 1.5;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 24px 0;
}
.page-header h1 { font-size: 3rem; line-height: 1; }
.history-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.history-summary div {
  display: grid;
  gap: 3px;
  padding: 18px;
  background: var(--panel);
}
.history-summary strong { font-size: 2rem; }
.history-summary span { color: var(--muted); font-weight: 800; }
.history-days { margin-top: 18px; display: grid; gap: 14px; }
.history-day {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(23, 32, 26, 0.07);
}
.history-day > header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.history-day time { color: var(--blue); font-weight: 900; }
.history-day h2 { margin-top: 4px; font-size: 1.5rem; }
.history-metrics { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; align-items: center; }
.history-metrics span, .history-metrics b {
  padding: 6px 8px;
  background: #f3f6f2;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 0.78rem;
}
.history-coaching { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px 0; }
.history-coaching p { margin: 0; line-height: 1.45; }
.history-coaching b { display: block; color: var(--blue); font-size: 0.78rem; }
.history-note { color: var(--muted); line-height: 1.5; }
.history-exercises > div {
  display: grid;
  grid-template-columns: 54px minmax(160px, 0.8fr) minmax(180px, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.history-exercises small { grid-column: 2 / -1; color: var(--muted); }
.history-check { color: var(--green); font-size: 0.75rem; font-weight: 900; text-transform: uppercase; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #edf4ef;
}
.login-shell {
  width: min(420px, 100%);
  padding: 30px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(23, 32, 26, 0.12);
}
.login-shell h1 {
  font-size: 2.25rem;
  line-height: 1.05;
}
.login-mark {
  width: 54px;
  height: 54px;
  margin-bottom: 22px;
}
.login-form {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}
.login-form .btn { margin-top: 4px; }
.login-error {
  min-height: 1.3em;
  margin: 0;
  color: var(--brick);
  font-weight: 750;
}

@media (max-width: 940px) {
  .hero, .day-head, .exercise-grid { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .exercise { grid-template-columns: 1fr; }
  .media { min-height: 230px; border-right: 0; border-bottom: 1px solid var(--line); }
  .exercise-nav {
    position: static;
    display: grid;
    grid-template-columns: minmax(92px, 1fr) auto minmax(92px, 1fr);
    gap: 10px;
    align-items: center;
    margin-top: 12px;
    padding: 8px;
    background: rgba(255, 254, 250, 0.94);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(23, 32, 26, 0.13);
  }
  .exercise-nav span {
    min-width: 58px;
    text-align: center;
    color: var(--muted);
    font-weight: 900;
    font-size: 0.82rem;
  }
  .exercise:not(.is-active) { display: none; }
  .exercise { scroll-margin-top: 12px; }
}

@media (max-width: 620px) {
  .flow-shell { width: min(100% - 20px, 760px); padding-top: 14px; }
  .flow-header { align-items: flex-start; }
  .flow-header .btn { min-height: 38px; padding: 8px 10px; }
  .step-track { grid-template-columns: 26px 1fr 26px 1fr 26px; gap: 6px; }
  .step-track strong { width: 26px; height: 26px; }
  .step-track span { display: none; }
  .single-exercise .exercise { min-height: 0; }
  .workout-nav { display: grid; grid-template-columns: 1fr auto 1fr; }
  .workout-nav .btn { padding-inline: 10px; }
  .shell { width: min(100% - 20px, 1220px); padding-top: 10px; }
  .toolbar { grid-template-columns: 1fr; position: static; }
  .rx-grid, .log-grid { grid-template-columns: 1fr; }
  .section-title { align-items: stretch; flex-direction: column; }
  .hero { gap: 10px; }
  .hero > div { display: none; }
  .snapshot {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 12px;
  }
  .snapshot strong { font-size: 2.2rem; }
  .snapshot .btn { padding-inline: 10px; }
  .day-panel { padding: 14px; }
  .title-input { font-size: 1.45rem; line-height: 1.15; min-height: 3.2rem; }
  .media { min-height: 210px; max-height: 280px; }
  .log-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .log-grid textarea { grid-column: 1 / -1; }
  .login-shell { padding: 24px 20px; }
  .login-shell h1 { font-size: 2rem; }
  .handoff-heading { display: block; }
  .handoff-heading p { margin-top: 5px; }
  .handoff-grid { grid-template-columns: 1fr; }
  .page-header h1 { font-size: 2rem; }
  .history-summary { grid-template-columns: 1fr; }
  .history-day > header { display: block; }
  .history-metrics { justify-content: flex-start; margin-top: 12px; }
  .history-coaching { grid-template-columns: 1fr; }
  .history-exercises > div { grid-template-columns: 48px 1fr; }
  .history-exercises > div > span:nth-of-type(2) { grid-column: 2; }
  .history-exercises small { grid-column: 2; }
}
