:root {
  --ink: #182230;
  --muted: #667085;
  --line: #d7dde8;
  --paper: #f4f7f6;
  --panel: #ffffff;
  --green: #1f8a70;
  --green-dark: #125b4a;
  --coral: #d94f38;
  --gold: #c58a22;
  --blue: #315c9c;
  --navy: #111827;
  --navy-soft: #1f2937;
  --surface-soft: #edf3f2;
  --success-soft: #dff3ed;
  --warning-soft: #f5ead6;
  --danger-soft: #f7ded8;
  --shadow: 0 16px 40px rgba(17, 24, 39, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: var(--navy);
  color: #f9fafb;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 20px;
}

.mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--green);
  border-radius: 8px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  text-align: left;
  color: #d8dee9;
  background: transparent;
  padding: 12px;
  border-radius: 8px;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.account {
  margin-top: auto;
  color: #b8c2d0;
  font-size: 13px;
  display: grid;
  gap: 10px;
}

.content {
  padding: 30px;
  display: grid;
  gap: 24px;
  align-content: start;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.eyebrow {
  color: var(--green);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.02;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 16px;
}

.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.card,
.auth-box,
.modal-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.card {
  padding: 16px;
}

.stat {
  display: grid;
  gap: 8px;
}

.stat strong {
  font-size: 28px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  background: var(--green);
  font-weight: 700;
}

.btn.secondary {
  color: var(--ink);
  background: var(--surface-soft);
}

.btn.warn {
  background: var(--coral);
}

.btn.ghost {
  color: var(--green-dark);
  background: transparent;
  border: 1px solid var(--line);
}

.back-action {
  width: auto;
  min-height: 40px;
  margin-bottom: 12px;
  padding: 0 12px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 800;
}

.form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

.list {
  display: grid;
  gap: 12px;
}

.workout-row,
.activity-row,
.session-row {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.workout-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.chip.green {
  background: var(--success-soft);
  color: var(--green-dark);
}

.chip.gold {
  background: var(--warning-soft);
  color: #7a4f08;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(340px, 520px) 1fr;
}

.auth-box {
  margin: auto;
  width: min(88vw, 440px);
  padding: 28px;
  display: grid;
  gap: 18px;
}

.auth-art {
  min-height: 100vh;
  background:
    linear-gradient(rgba(17, 24, 39, 0.16), rgba(17, 24, 39, 0.4)),
    url("https://images.unsplash.com/photo-1581009146145-b5ef050c2e1e?auto=format&fit=crop&w=1400&q=80")
      center/cover;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 4px;
}

.tabs button {
  min-height: 36px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tabs button.active {
  background: #fff;
  color: var(--ink);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 380px;
  padding: 14px 16px;
  background: var(--navy);
  color: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 20;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.42);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 10;
}

.modal-panel {
  width: min(900px, 96vw);
  max-height: 90vh;
  overflow: auto;
  padding: 20px;
  display: grid;
  gap: 16px;
}

.activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.custom-activity-form {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.custom-activity-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.custom-activity-head .btn {
  min-height: 40px;
}

.muscle-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.muscle-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.muscle-option input {
  width: auto;
  min-height: auto;
}

.activity-pick {
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  padding: 12px;
  border-radius: 8px;
}

.activity-pick:hover {
  border-color: var(--green);
}

.manage-topbar h1 {
  margin-top: 4px;
}

.manage-workout-panel {
  gap: 18px;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-size: clamp(42px, 9vw, 82px);
  line-height: 1;
  font-weight: 900;
}

.exercise-log {
  display: grid;
  grid-template-columns: 1.3fr repeat(4, minmax(88px, 1fr));
  gap: 10px;
  align-items: end;
}

.body-wrap {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 18px;
  align-items: center;
}

.body-svg {
  width: 150px;
  height: 300px;
}

.muscle {
  fill: #dfe5ec;
  stroke: #fff;
  stroke-width: 2;
}

.muscle.intensity-1 {
  fill: #f4c9a4;
}

.muscle.intensity-2 {
  fill: #eba06b;
}

.muscle.intensity-3 {
  fill: #df6b3d;
}

.muscle.intensity-4 {
  fill: #b93a24;
}

.summary-lines {
  display: grid;
  gap: 8px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 26px;
  color: var(--muted);
  text-align: center;
  background: #fff;
}

@media (max-width: 920px) {
  .shell,
  .auth-page,
  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .auth-art {
    display: none;
  }

  .topbar,
  .workout-row,
  .exercise-log,
  .body-wrap {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }
}

/* Mobile-first usability layer */
body {
  -webkit-text-size-adjust: 100%;
}

.shell {
  min-height: 100svh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
}

.mobile-header {
  position: sticky;
  top: 0;
  z-index: 8;
  min-height: 64px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  color: #f9fafb;
  background: var(--navy);
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.18);
}

.mobile-header .brand {
  min-width: 0;
  font-size: 17px;
}

.mobile-header .account {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d8dee9;
}

.mobile-header .account strong {
  display: none;
}

.mobile-header .account .btn {
  min-height: 38px;
  padding: 0 10px;
  white-space: nowrap;
}

.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 9;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.bottom-nav button {
  min-height: 52px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.bottom-nav button.active {
  background: var(--success-soft);
  color: var(--green-dark);
}

.content {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 14px 92px;
  gap: 16px;
}

.topbar,
.session-topbar {
  display: grid;
  gap: 12px;
}

.topbar .btn,
.primary-action {
  width: 100%;
}

.topbar .back-action {
  width: auto;
  justify-self: start;
}

.header-add {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-size: 26px;
  font-weight: 500;
  line-height: 1;
  flex: 0 0 auto;
}

h1 {
  font-size: 30px;
  line-height: 1.04;
}

h2 {
  font-size: 19px;
}

.eyebrow {
  font-size: 11px;
}

.grid.two,
.grid.three {
  grid-template-columns: 1fr;
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.panel,
.card,
.auth-box,
.modal-panel {
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.07);
}

.panel {
  padding: 14px;
}

.stat {
  min-height: 86px;
  align-content: center;
}

.stat strong {
  font-size: 24px;
}

.stat .muted {
  font-size: 12px;
}

.btn {
  min-height: 48px;
  padding: 0 16px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr;
}

.toolbar .btn,
.toolbar .icon-btn {
  width: 100%;
}

.icon-btn {
  min-width: 46px;
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-items: center;
}

.edit-icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

input,
select,
textarea {
  min-height: 48px;
  font-size: 16px;
}

.workout-row,
.activity-row,
.session-row,
.history-row {
  padding: 14px;
  border-radius: 8px;
}

.exercise-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.trend-badge {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 10px;
  white-space: nowrap;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.trend-badge.up {
  background: var(--success-soft);
  color: var(--green-dark);
}

.trend-badge.down {
  background: var(--danger-soft);
  color: #9b3322;
}

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

.swipe-workout,
.swipe-activity,
.swipe-session,
.swipe-library {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: var(--coral);
  touch-action: pan-y;
}

.swipe-workout .workout-row,
.swipe-activity .activity-row,
.swipe-session .history-row,
.swipe-library .library-card {
  position: relative;
  z-index: 1;
  min-height: 96px;
  transition: transform 180ms ease;
}

.swipe-workout.open .workout-row,
.swipe-activity.open .activity-row,
.swipe-session.open .history-row,
.swipe-library.open .library-card {
  transform: translateX(-96px);
}

.library-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  gap: 10px;
  align-items: start;
}

.library-edit {
  justify-self: end;
}

.library-lock {
  justify-self: end;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 0 10px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.swipe-library.locked {
  background: transparent;
}

.workout-tap-row {
  cursor: pointer;
  user-select: none;
}

.row-chevron {
  justify-self: end;
  align-self: center;
  color: var(--muted);
  font-size: 28px;
  font-weight: 300;
}

.history-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto 20px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.history-body-map {
  width: 46px;
  height: 86px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.history-body-map .body-svg {
  width: 42px;
  height: 84px;
}

.history-meta {
  display: grid;
  justify-items: end;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.swipe-delete {
  position: absolute;
  inset: 0 0 0 auto;
  width: 96px;
  display: grid;
  place-items: center;
  background: var(--coral);
  color: #fff;
  font-weight: 900;
}

.workout-row .toolbar,
.activity-row .toolbar {
  grid-template-columns: 1fr 46px 46px;
  align-items: center;
}

.activity-row .toolbar {
  grid-template-columns: 1fr 46px;
}

.template-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.template-field {
  gap: 5px;
}

.template-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.template-field input {
  min-height: 44px;
  padding: 8px;
  text-align: center;
  font-weight: 850;
}

.library-default {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 850;
}

.chips {
  gap: 6px;
  overflow: hidden;
}

.chip {
  font-size: 11px;
  padding: 5px 8px;
}

.auth-page {
  min-height: 100svh;
  display: grid;
  grid-template-columns: 1fr;
  padding: 14px;
  background:
    linear-gradient(rgba(17, 24, 39, 0.18), rgba(17, 24, 39, 0.5)),
    url("https://images.unsplash.com/photo-1581009146145-b5ef050c2e1e?auto=format&fit=crop&w=900&q=80")
      center/cover;
}

.auth-box {
  width: 100%;
  margin: auto 0;
  padding: 18px;
}

.auth-art {
  display: none;
}

.tabs button {
  min-height: 44px;
}

.toast {
  right: 12px;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 12px;
  max-width: none;
}

.modal {
  align-items: end;
  padding: 12px;
}

.modal-panel {
  width: 100%;
  max-height: 84svh;
  padding: 16px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

.activity-grid {
  grid-template-columns: 1fr;
}

.activity-pick {
  min-height: 68px;
}

.start-panel {
  position: sticky;
  top: 78px;
}

.session-topbar {
  position: sticky;
  top: 64px;
  z-index: 7;
  margin: -18px -14px 0;
  padding: 14px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.timer {
  justify-self: start;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-size: 42px;
}

.exercise-log {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.set-table {
  display: grid;
  gap: 8px;
}

.set-head,
.set-row {
  display: grid;
  grid-template-columns: 56px minmax(64px, 0.9fr) 38px minmax(54px, 1fr) minmax(54px, 1fr);
  gap: 8px;
  align-items: center;
}

.set-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.set-number {
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-soft);
  font-weight: 900;
}

.last-set {
  min-height: 48px;
  display: grid;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.set-complete {
  min-height: 40px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.set-complete.complete {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.set-input input {
  min-height: 48px;
  padding-right: 6px;
  padding-left: 6px;
  text-align: center;
  font-weight: 850;
}

.readonly-set-table {
  gap: 6px;
}

.readonly-set-head,
.readonly-set-row {
  grid-template-columns: 48px repeat(2, minmax(54px, 1fr)) 64px;
}

.readonly-value,
.readonly-done {
  min-height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f4f7fb;
  font-weight: 850;
}

.readonly-done {
  color: var(--green-dark);
}

.session-actions {
  position: sticky;
  bottom: calc(72px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr 104px;
  gap: 8px;
  padding: 10px;
  margin: 0 -10px -8px;
  background: rgba(244, 247, 246, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(16px);
}

.body-wrap {
  grid-template-columns: 96px 1fr;
  gap: 12px;
}

.body-svg {
  width: 96px;
  height: 192px;
}

.summary-lines {
  font-size: 14px;
}

@media (min-width: 720px) {
  .content {
    max-width: 980px;
    padding: 28px 24px 104px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    align-items: start;
  }

  .topbar .btn,
  .primary-action {
    width: auto;
  }

  .grid.two {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  }

  .toolbar {
    display: flex;
  }

  .toolbar .btn {
    width: auto;
  }

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

  .workout-row .toolbar,
  .activity-row .toolbar {
    display: flex;
  }

  .exercise-log {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .activity-grid {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  }

  .modal {
    place-items: center;
  }

  .modal-panel {
    max-width: 820px;
    border-radius: 8px;
  }

  .mobile-header .account strong {
    display: inline;
  }
}

@media (min-width: 1100px) {
  .content {
    max-width: 1120px;
  }
}
