:root {
  --navy: #061d35;
  --deep: #031827;
  --panel: #153a55;
  --panel-soft: #1e4864;
  --gold: #d7b866;
  --gold-strong: #e3b42f;
  --cream: #fff6e7;
  --muted: rgba(255, 246, 231, 0.64);
  --line: rgba(215, 184, 102, 0.24);
  --red: #ba4646;
  --orange: #d27a32;
  --amber: #d7a739;
  --green: #3f8d66;
  --blue: #2d6fae;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 94% 16%, rgba(0, 100, 150, 0.42), transparent 31%),
    linear-gradient(180deg, #061e30 0%, #031827 58%, #02111d 100%);
  color: var(--cream);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  align-items: center;
  background: rgba(3, 24, 39, 0.94);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 74px;
  padding: 12px clamp(16px, 3vw, 34px);
}

.brand,
.top-actions,
.row-actions,
.brand-mark {
  align-items: center;
  display: flex;
}

.brand {
  gap: 10px;
}

.brand-mark {
  border: 2px solid var(--gold);
  border-radius: 50%;
  box-shadow: inset 0 0 0 7px rgba(215, 184, 102, 0.14);
  height: 34px;
  justify-content: center;
  width: 34px;
}

.brand p {
  color: var(--cream);
  font-size: 13px;
  font-weight: 950;
  letter-spacing: 1.4px;
  margin: 0;
}

.brand span {
  color: var(--gold);
  display: block;
  font-size: 8px;
  font-weight: 950;
  letter-spacing: 3px;
}

.top-actions {
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.nav-pill,
.primary-button,
.ghost-button,
.readiness-pill {
  border-radius: 999px;
  font-weight: 900;
}

.nav-pill,
.ghost-button {
  background: rgba(7, 29, 52, 0.78);
  border: 1px solid var(--line);
  color: rgba(255, 246, 231, 0.8);
  padding: 8px 12px;
}

.button-pill,
.ghost-button {
  cursor: pointer;
}

.nav-pill.active {
  background: rgba(215, 184, 102, 0.18);
  color: var(--gold);
}

.app-shell {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(280px, 350px) minmax(0, 1fr);
  margin: 0 auto;
  max-width: 1580px;
  padding: 24px clamp(16px, 5vw, 88px) 44px;
}

.control-panel,
.page-title,
.readiness-card,
.meta-grid,
.exercise-row,
.modal-panel,
.high-five-card {
  background: linear-gradient(180deg, rgba(31, 63, 86, 0.9), rgba(13, 43, 66, 0.8));
  border: 1px solid var(--line);
}

.control-panel {
  align-self: start;
  border-radius: 10px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.24);
  padding: 18px;
  position: sticky;
  top: 14px;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading p,
.page-title p,
.readiness-card p,
.modal-head p {
  color: var(--gold);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 4px;
  margin: 0 0 10px;
  text-transform: uppercase;
}

.panel-heading h2 {
  color: var(--cream);
  font-size: 32px;
  line-height: 1;
  margin: 0;
}

.field,
.pain-field {
  border: 0;
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
}

.field span,
.pain-field legend {
  color: rgba(255, 246, 231, 0.75);
  font-size: 13px;
  font-weight: 850;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  appearance: none;
  background: rgba(4, 26, 44, 0.84);
  border: 1px solid rgba(215, 184, 102, 0.42);
  border-radius: 10px;
  color: var(--cream);
  min-height: 48px;
  padding: 0 14px;
}

input[type="range"] {
  accent-color: var(--gold);
}

.range-labels {
  color: rgba(255, 246, 231, 0.56);
  display: flex;
  font-size: 11px;
  justify-content: space-between;
}

.segmented {
  background: rgba(4, 26, 44, 0.82);
  border: 1px solid rgba(215, 184, 102, 0.28);
  border-radius: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}

.segmented label {
  align-items: center;
  cursor: pointer;
  display: flex;
  font-weight: 850;
  gap: 8px;
  justify-content: center;
  min-height: 42px;
}

.pain-notice,
.warning,
.message,
.safety-note {
  border-radius: 8px;
  line-height: 1.45;
  margin: 0 0 12px;
  padding: 11px 12px;
}

.pain-notice,
.warning {
  background: rgba(210, 122, 50, 0.16);
  border: 1px solid rgba(210, 122, 50, 0.42);
}

.message {
  background: rgba(215, 184, 102, 0.13);
  border: 1px solid rgba(215, 184, 102, 0.24);
}

.safety-note {
  background: rgba(3, 24, 39, 0.86);
  border: 1px solid rgba(215, 184, 102, 0.18);
  margin-top: 14px;
}

.primary-button {
  background: var(--gold);
  border: 0;
  color: #071d35;
  cursor: pointer;
  min-height: 50px;
  width: 100%;
}

.workout-area {
  min-width: 0;
}

.page-title {
  align-items: end;
  border-radius: 10px 10px 0 0;
  display: flex;
  justify-content: space-between;
  min-height: 150px;
  padding: 32px;
  position: sticky;
  top: 0;
  transition: min-height 180ms ease, padding 180ms ease;
  z-index: 5;
}

.page-title h1 {
  color: var(--cream);
  font-size: clamp(42px, 5.4vw, 76px);
  line-height: 0.95;
  margin: 0;
  transition: font-size 180ms ease;
}

.page-title > div > span {
  color: var(--muted);
  display: block;
  font-size: 15px;
  font-weight: 750;
  margin-top: 12px;
}

.page-title.is-compact {
  align-items: center;
  border-radius: 10px;
  min-height: 82px;
  padding: 14px 22px;
}

.page-title.is-compact p {
  font-size: 10px;
  margin-bottom: 5px;
}

.page-title.is-compact h1 {
  font-size: clamp(26px, 3.2vw, 40px);
}

.page-title.is-compact > div > span {
  display: none;
}

.readiness-pill {
  background: var(--amber);
  color: #071d35;
  min-width: 98px;
  padding: 8px 11px;
  text-align: center;
}

.readiness-pill.red,
.readiness-card.red {
  background: var(--red);
  color: #fff;
}

.readiness-pill.orange,
.readiness-card.orange {
  background: var(--orange);
  color: #fff;
}

.readiness-pill.green,
.readiness-card.green {
  background: var(--green);
  color: #fff;
}

.readiness-pill.blue,
.readiness-card.blue {
  background: var(--blue);
  color: #fff;
}

.readiness-card {
  align-items: center;
  border-radius: 0;
  display: flex;
  justify-content: space-between;
  min-height: 158px;
  padding: 28px 32px;
}

.readiness-card h2 {
  color: var(--cream);
  font-size: clamp(36px, 4.8vw, 70px);
  line-height: 0.98;
  margin: 16px 0 0;
}

.readiness-card > span {
  color: var(--gold);
  font-size: clamp(56px, 7vw, 92px);
  font-weight: 950;
}

.meta-grid {
  border-radius: 0 0 10px 10px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
  padding: 16px;
}

.meta-grid div {
  background: rgba(7, 29, 58, 0.52);
  border: 1px solid rgba(215, 184, 102, 0.16);
  border-radius: 10px;
  padding: 10px 11px;
}

.meta-grid span {
  color: rgba(255, 246, 231, 0.62);
  display: block;
  font-size: 11px;
  font-weight: 850;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.meta-grid strong {
  color: var(--cream);
}

.table-head,
.exercise-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 42px 92px minmax(150px, 1.1fr) minmax(126px, 0.72fr) minmax(210px, 1.35fr) 160px;
}

.table-head {
  display: none;
}

.exercise-list {
  display: grid;
  gap: 10px;
}

.exercise-row {
  align-items: start;
  border-radius: 10px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.16);
  padding: 16px;
  transition: opacity 180ms ease, padding 180ms ease, transform 180ms ease;
}

.exercise-row.completed {
  opacity: 0.72;
  padding: 10px 14px;
  transform: scale(0.992);
}

.exercise-row.completed .category,
.exercise-row.completed .load-cue,
.exercise-row.completed .row-actions,
.exercise-row.completed .circuit-panel {
  display: none;
}

.complete-check {
  align-items: center;
  background: rgba(7, 29, 58, 0.62);
  border: 2px solid rgba(215, 184, 102, 0.7);
  border-radius: 50%;
  color: #071d35;
  cursor: pointer;
  display: inline-flex;
  font-size: 19px;
  font-weight: 950;
  height: 34px;
  justify-content: center;
  line-height: 1;
  width: 34px;
}

.exercise-row.completed .complete-check {
  background: var(--gold);
}

.slot-tag {
  background: rgba(215, 184, 102, 0.18);
  border: 1px solid rgba(215, 184, 102, 0.32);
  border-radius: 8px;
  color: var(--gold);
  display: inline-block;
  font-size: 12px;
  font-weight: 950;
  padding: 7px 9px;
}

.exercise-name {
  color: var(--cream);
  font-size: 20px;
  font-weight: 950;
  margin: 0 0 5px;
}

.exercise-row.completed .exercise-name {
  font-size: 16px;
  margin-bottom: 0;
}

.category {
  color: rgba(255, 246, 231, 0.56);
  font-size: 12px;
  font-weight: 850;
  margin: 0;
  text-transform: uppercase;
}

.prescription,
.load-cue {
  color: rgba(255, 246, 231, 0.78);
  line-height: 1.4;
  margin: 0;
}

.exercise-row.completed .prescription {
  font-size: 13px;
}

.load-cue p {
  margin: 0 0 8px;
}

.cue-tab,
.row-actions button,
.circuit-item > button,
.edit-actions button,
.swap-card button {
  border-radius: 8px;
  cursor: pointer;
  font-weight: 850;
  min-height: 32px;
}

.cue-tab {
  background: rgba(215, 184, 102, 0.17);
  border: 1px solid rgba(215, 184, 102, 0.45);
  border-radius: 999px;
  color: var(--gold);
  font-size: 12px;
  padding: 4px 11px;
}

.cue-panel {
  border-left: 2px solid rgba(215, 184, 102, 0.48);
  color: rgba(255, 246, 231, 0.62);
  font-size: 13px;
  margin-top: 7px;
  padding-left: 10px;
}

.cue-panel[hidden],
.circuit-panel[hidden],
.modal[hidden],
.high-five-overlay[hidden],
.toast[hidden] {
  display: none;
}

.row-actions {
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.row-actions button,
.circuit-item > button,
.edit-actions button {
  background: rgba(7, 29, 58, 0.6);
  border: 1px solid rgba(215, 184, 102, 0.22);
  color: var(--cream);
  padding: 6px 10px;
}

.row-actions button:first-child,
.edit-actions button:first-child,
.swap-card button {
  background: var(--gold);
  border-color: var(--gold);
  color: #071d35;
}

.circuit-row {
  border-color: rgba(215, 184, 102, 0.36);
}

.circuit-panel {
  background: rgba(7, 29, 58, 0.34);
  border: 1px solid rgba(215, 184, 102, 0.16);
  border-radius: 10px;
  display: grid;
  gap: 9px;
  grid-column: 1 / -1;
  padding: 10px;
}

.circuit-item {
  align-items: start;
  background: rgba(3, 24, 39, 0.36);
  border: 1px solid rgba(215, 184, 102, 0.14);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 32px minmax(150px, 1fr) minmax(220px, 1.35fr) auto;
  padding: 10px;
}

.circuit-number {
  align-items: center;
  background: rgba(215, 184, 102, 0.2);
  border-radius: 50%;
  color: var(--gold);
  display: inline-flex;
  font-size: 13px;
  font-weight: 950;
  height: 28px;
  justify-content: center;
  width: 28px;
}

.circuit-item p {
  color: var(--cream);
  font-weight: 850;
  margin: 0 0 5px;
}

.circuit-item span {
  color: rgba(255, 246, 231, 0.62);
  font-size: 12px;
  font-weight: 800;
}

.edit-form {
  display: grid;
  gap: 8px;
  grid-column: 1 / -1;
  grid-template-columns: 1fr 100px 120px 110px;
}

.edit-form label {
  display: grid;
  gap: 5px;
}

.edit-form span {
  color: rgba(255, 246, 231, 0.6);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.edit-form input,
.edit-form textarea {
  background: rgba(4, 26, 44, 0.84);
  border: 1px solid rgba(215, 184, 102, 0.26);
  border-radius: 8px;
  color: var(--cream);
  min-height: 38px;
  padding: 8px 10px;
}

.edit-form textarea {
  grid-column: span 2;
  min-height: 78px;
  resize: vertical;
}

.edit-actions {
  align-items: end;
  display: grid;
  gap: 7px;
}

.modal,
.high-five-overlay {
  align-items: center;
  background: rgba(3, 24, 39, 0.76);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 30;
}

.modal-panel {
  border-radius: 10px;
  max-height: min(760px, 92vh);
  max-width: 860px;
  overflow: auto;
  padding: 18px;
  width: 100%;
}

.modal-head {
  align-items: center;
  border-bottom: 1px solid rgba(215, 184, 102, 0.18);
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
}

.modal-head h2 {
  margin: 0;
}

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

.swap-card {
  background: rgba(7, 29, 58, 0.56);
  border: 1px solid rgba(215, 184, 102, 0.2);
  border-radius: 8px;
  padding: 13px;
}

.swap-card h3 {
  color: var(--cream);
  margin: 0 0 6px;
}

.swap-card p {
  color: rgba(255, 246, 231, 0.66);
  font-size: 13px;
  line-height: 1.35;
  margin: 0 0 10px;
}

.swap-card button {
  border: 0;
  padding: 8px 12px;
}

.high-five-card {
  border-radius: 10px;
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.42);
  max-width: 460px;
  padding: 34px;
  text-align: center;
  width: 100%;
}

.high-five-card > div {
  font-size: 118px;
  line-height: 1;
}

.high-five-card h2 {
  color: var(--gold);
  font-size: 42px;
  margin: 10px 0 8px;
}

.high-five-card p {
  color: var(--muted);
  margin: 0 0 20px;
}

.toast {
  background: var(--navy);
  border: 1px solid var(--gold);
  border-radius: 8px;
  bottom: 22px;
  color: var(--cream);
  font-weight: 850;
  padding: 12px 14px;
  position: fixed;
  right: 22px;
  z-index: 40;
}

@media (max-width: 1060px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }

  .exercise-row {
    grid-template-columns: 1fr;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .circuit-item {
    grid-template-columns: 32px 1fr;
  }

  .circuit-item > div:nth-child(3),
  .circuit-item > button {
    grid-column: 2;
  }
}

@media (max-width: 720px) {
  .topbar,
  .page-title,
  .readiness-card {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .top-actions,
  .top-actions > * {
    width: 100%;
  }

  .meta-grid,
  .swap-options,
  .edit-form {
    grid-template-columns: 1fr;
  }

  .edit-form textarea {
    grid-column: auto;
  }

  .page-title {
    padding: 22px;
  }

  .page-title.is-compact {
    min-height: 104px;
  }
}
