:root {
  color-scheme: light;
  --bg: #f5f7f3;
  --surface: #ffffff;
  --surface-soft: #f0f5ef;
  --ink: #17211b;
  --muted: #68746c;
  --line: #dce3dd;
  --accent: #197a61;
  --accent-dark: #0f5845;
  --accent-soft: #dff1ea;
  --energy: #f2b84b;
  --coral: #d96b5f;
  --blue: #4169a8;
  --shadow: 0 18px 48px rgba(23, 33, 27, 0.09);
  --radius: 8px;
  --sidebar: 300px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --webapp-top-space: calc(16px + var(--safe-top));
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: var(--webapp-top-space);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(25, 122, 97, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(242, 184, 75, 0.15), transparent 30%),
    var(--bg);
  overscroll-behavior-y: none;
}

body.webapp-mode {
  min-height: 100dvh;
}

body.webapp-mode .app-shell {
  min-height: 100dvh;
}

body.webapp-mode .workspace {
  padding-bottom: calc(18px + var(--safe-bottom));
}

body.webapp-mode .exercise-card {
  scroll-margin-top: var(--webapp-top-space);
}

body.webapp-mode .client-dialog {
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 28px);
  margin: calc(14px + var(--safe-top)) auto calc(14px + var(--safe-bottom));
  overflow: auto;
}

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

button,
label.import-trigger {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100svh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  grid-template-columns: repeat(3, 8px);
  align-items: end;
  gap: 4px;
  width: 46px;
  height: 46px;
  padding: 9px;
  border: 1px solid #123f34;
  border-radius: var(--radius);
  background: #173f35;
}

.brand-mark span {
  display: block;
  border-radius: 2px 2px 0 0;
  background: var(--energy);
}

.brand-mark span:nth-child(1) {
  height: 15px;
}

.brand-mark span:nth-child(2) {
  height: 25px;
  background: #7fd0b7;
}

.brand-mark span:nth-child(3) {
  height: 19px;
  background: #ff806e;
}

.brand h1,
.brand p,
.client-header h2,
.client-header p,
.panel h3,
.panel p,
.exercise-title h4 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.1;
}

.brand p,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
}

.eyebrow {
  margin: 0 0 6px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.client-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.selected-client-strip {
  display: none;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}

.selected-client-strip strong,
.selected-client-strip small {
  display: block;
}

.selected-client-strip small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mode-switch {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.mode-button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 900;
}

.mode-button.active {
  color: #fff;
  background: var(--accent-dark);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.search-field input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.primary-action,
.ghost-button,
.save-button,
.icon-button,
.client-button,
.delete-session {
  cursor: pointer;
  border: 0;
}

.primary-action,
.ghost-button,
.save-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: var(--radius);
  font-weight: 800;
}

.primary-action {
  padding: 0 13px;
  color: #fff;
  background: var(--accent);
}

.client-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.client-button {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  padding: 12px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink);
  background: transparent;
}

body[data-mode="personal"] .client-list,
body[data-mode="personal"] .search-field,
body[data-mode="personal"] #addClientBtn {
  display: none;
}

.client-button:hover,
.client-button.active {
  border-color: var(--line);
  background: var(--surface);
}

.client-button.active {
  box-shadow: var(--shadow);
}

.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 900;
  background: var(--blue);
}

.client-button:nth-child(3n) .avatar {
  background: var(--coral);
}

.client-button:nth-child(3n + 1) .avatar {
  background: var(--accent);
}

.client-meta {
  min-width: 0;
}

.client-meta strong,
.client-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-meta span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.client-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.client-header h2 {
  font-size: 34px;
  line-height: 1.05;
}

.header-actions {
  display: none;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
}

.icon-button:hover,
.ghost-button:hover {
  background: var(--surface-soft);
}

.import-trigger {
  position: relative;
  display: inline-grid;
}

.import-trigger input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.8);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.1;
}

.metric strong.positive {
  color: var(--accent-dark);
}

.metric strong.negative {
  color: var(--coral);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) minmax(330px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.training-form {
  padding: 20px;
}

.right-column .panel > :not(.panel-summary) {
  margin: 0 20px 20px;
}

.right-column {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.panel-heading.compact {
  margin-bottom: 14px;
}

.panel-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
}

.panel-summary::-webkit-details-marker {
  display: none;
}

.panel-summary::after {
  content: "+";
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--accent-dark);
  background: var(--surface);
  font-weight: 900;
}

details[open] > .panel-summary::after {
  content: "−";
}

.panel h3 {
  font-size: 21px;
}

.ghost-button {
  padding: 0 12px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.split-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  align-items: end;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  padding: 11px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(25, 122, 97, 0.14);
}

.exercise-block,
.notes-field {
  display: block;
  margin-top: 18px;
}

.preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.preset-chip.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px rgba(25, 122, 97, 0.16);
}

.preset-chip.current {
  border-color: var(--accent-dark);
}

.preset-remove {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  color: var(--coral);
  background: #fff3f1;
  cursor: pointer;
}

.exercise-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.exercise-title h4 {
  font-size: 16px;
}

.exercise-table {
  display: grid;
  gap: 12px;
}

.exercise-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.exercise-card {
  display: grid;
  overflow: hidden;
  border: 1px solid #cdd8d1;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f8fbf8);
}

.exercise-card.active {
  border-color: var(--accent);
  box-shadow: 0 12px 28px rgba(15, 88, 69, 0.11);
}

.exercise-toggle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 13px 14px;
  border: 0;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.exercise-toggle strong,
.exercise-toggle span {
  display: block;
}

.exercise-toggle small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.exercise-toggle-delta.positive {
  color: var(--accent-dark);
}

.exercise-toggle-delta.negative {
  color: var(--coral);
}

.exercise-toggle::after {
  content: "Открыть";
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 900;
}

.exercise-card.active .exercise-toggle::after {
  content: "Свернуть";
  color: #fff;
  background: var(--accent-dark);
}

.exercise-card-body {
  display: none;
  gap: 12px;
  padding: 0 14px 14px;
}

.exercise-recommendation {
  display: none;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 900;
}

.exercise-recommendation.positive,
.exercise-recommendation.negative {
  display: block;
}

.exercise-recommendation.positive {
  color: var(--accent-dark);
}

.exercise-recommendation.negative {
  color: var(--coral);
}

.exercise-card.active .exercise-card-body {
  display: grid;
}

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

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

.set-row {
  display: grid;
  grid-template-columns: 56px minmax(70px, 0.7fr) minmax(86px, 0.9fr) minmax(150px, 1.6fr) 42px;
  gap: 8px;
  align-items: center;
}

.weight-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.set-trend {
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
  text-align: right;
}

.set-trend.positive {
  color: var(--accent-dark);
}

.set-trend.negative {
  color: var(--coral);
}

.set-row.set-up .set-weight {
  border-color: rgba(25, 122, 97, 0.5);
  background: #f3fbf7;
}

.set-row.set-down .set-weight {
  border-color: rgba(217, 107, 95, 0.5);
  background: #fff7f5;
}

.set-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.set-number {
  display: grid;
  place-items: center;
  height: 42px;
  border-radius: var(--radius);
  color: var(--accent-dark);
  font-weight: 900;
  background: var(--accent-soft);
}

.add-set {
  width: max-content;
  min-height: 38px;
  padding: 0 11px;
}

.exercise-flow-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.remove-exercise {
  color: var(--coral);
}

.remove-set {
  color: var(--coral);
}

.save-button {
  width: 100%;
  margin-top: 18px;
  color: #fff;
  background: var(--accent-dark);
}

.save-button:hover,
.primary-action:hover {
  filter: brightness(1.04);
}

.progress-panel canvas {
  display: block;
  width: 100%;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f7faf7);
}

.history-list {
  display: grid;
  gap: 10px;
  max-height: 458px;
  overflow: auto;
  padding-right: 4px;
}

.history-item {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.history-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.history-top strong,
.history-top span {
  display: block;
}

.history-top span,
.history-summary,
.empty-state {
  color: var(--muted);
  font-size: 13px;
}

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

.history-summary span {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
}

.delta-pill {
  color: var(--accent-dark);
  font-weight: 900;
}

.delta-pill.negative {
  color: var(--coral);
}

.stats-list {
  display: grid;
  gap: 8px;
}

.stat-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfb;
}

.stat-row span {
  color: var(--muted);
  font-size: 13px;
}

.stat-row strong {
  color: var(--ink);
  font-size: 14px;
  text-align: right;
}

.stat-row strong.positive {
  color: var(--accent-dark);
}

.stat-row strong.negative {
  color: var(--coral);
}

.session-table {
  display: grid;
  gap: 7px;
  padding-top: 2px;
}

.session-table-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(170px, 1.5fr) auto;
  gap: 10px;
  align-items: start;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfb;
}

.session-table-row strong {
  font-size: 13px;
}

.session-table-row span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.session-table-row em {
  color: var(--accent-dark);
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.delete-session {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  color: var(--coral);
  background: #fff3f1;
}

.empty-state {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.5);
}

.client-dialog {
  width: min(430px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.client-dialog::backdrop {
  background: rgba(23, 33, 27, 0.28);
  backdrop-filter: blur(5px);
}

.client-dialog form {
  display: grid;
  gap: 14px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateY(18px);
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--accent-dark);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

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

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .client-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    max-height: none;
    overflow: visible;
  }

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

@media (max-width: 900px) {
  * {
    max-width: 100%;
  }

  .app-shell {
    display: block;
    overflow-x: hidden;
  }

  .sidebar {
    min-height: auto;
    gap: 12px;
    padding: max(14px, env(safe-area-inset-top)) 14px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
  }

  .workspace {
    padding: 14px;
    overflow-x: hidden;
  }

  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
    padding: 8px;
  }

  .brand h1 {
    font-size: 22px;
  }

  .brand p {
    font-size: 14px;
  }

  .selected-client-strip {
    display: flex;
  }

  body:not(.client-picker-open) .client-tools,
  body:not(.client-picker-open) .client-list {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    transition: max-height 180ms ease, opacity 180ms ease;
  }

  body.client-picker-open .client-tools,
  body.client-picker-open .client-list {
    max-height: 300px;
    opacity: 1;
    transition: max-height 180ms ease, opacity 180ms ease;
  }

  .client-tools {
    grid-template-columns: minmax(0, 1fr) 48px;
  }

  .mode-switch {
    grid-column: 1 / -1;
  }

  .primary-action {
    width: 48px;
    padding: 0;
  }

  .primary-action span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .client-list {
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    margin-inline: -14px;
    padding: 0 14px 4px;
    scroll-snap-type: x proximity;
  }

  .client-button {
    grid-template-columns: 36px minmax(126px, 1fr);
    flex: 0 0 min(68vw, 240px);
    padding: 10px;
    scroll-snap-align: start;
    background: var(--surface);
  }

  .avatar {
    width: 36px;
    height: 36px;
    font-size: 13px;
  }

  .client-header {
    display: none;
  }

  .metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }

  .metric {
    padding: 10px;
  }

  .metric span {
    font-size: 12px;
  }

  .metric strong {
    font-size: 18px;
  }

  .content-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .training-form {
    padding: 14px;
  }

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

  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .split-field {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .right-column {
    gap: 10px;
  }

  .right-column .panel > :not(.panel-summary) {
    margin: 0;
    padding: 0 14px 14px;
  }

  .save-button {
    position: static;
    box-shadow: none;
  }
}

@media (max-width: 760px) {
  body {
    background: var(--bg);
  }

  .workspace,
  .sidebar {
    padding: 18px;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    gap: 14px;
    padding-top: max(14px, env(safe-area-inset-top));
    background: rgba(255, 255, 255, 0.94);
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    padding: 7px;
  }

  .client-list {
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    margin-inline: -18px;
    padding: 0 18px 4px;
    scroll-snap-type: x proximity;
  }

  .client-button {
    grid-template-columns: 36px minmax(126px, 1fr);
    flex: 0 0 min(58vw, 220px);
    padding: 10px;
    scroll-snap-align: start;
    background: var(--surface);
  }

  .avatar {
    width: 36px;
    height: 36px;
    font-size: 13px;
  }

  .selected-client-strip {
    display: flex;
  }

  body:not(.client-picker-open) .client-tools,
  body:not(.client-picker-open) .client-list {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    margin: 0;
    padding-top: 0;
    padding-bottom: 0;
    transition: max-height 180ms ease, opacity 180ms ease;
  }

  body.client-picker-open .client-tools,
  body.client-picker-open .client-list {
    max-height: 260px;
    opacity: 1;
    transition: max-height 180ms ease, opacity 180ms ease;
  }

  .client-header {
    align-items: flex-start;
    margin-bottom: 14px;
  }

  .client-header h2 {
    font-size: 28px;
  }

  .metrics-grid,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .set-row {
    grid-template-columns: 48px minmax(68px, 0.7fr) minmax(82px, 0.9fr) minmax(150px, 1.5fr) 42px;
  }

  .history-list {
    max-height: none;
  }

}

@media (max-width: 640px) {
  .metrics-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .client-tools {
    grid-template-columns: minmax(0, 1fr) 48px;
  }

  .split-field {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .mode-switch {
    grid-column: 1 / -1;
  }

  .primary-action {
    width: 48px;
    padding: 0;
  }

  .primary-action .icon {
    font-size: 20px;
    line-height: 1;
  }

  .primary-action span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .exercise-card-body {
    padding: 0 12px 12px;
  }

  .set-row {
    grid-template-columns: 38px minmax(74px, 1fr) minmax(92px, 1fr) 38px;
    gap: 6px;
    align-items: start;
  }

  .set-head {
    display: none;
  }

  .set-comment {
    grid-column: 1 / -1;
    min-height: 44px;
  }

  .remove-set {
    grid-column: 4;
    grid-row: 1;
  }

  .set-number,
  .remove-set {
    height: 38px;
  }

  .weight-cell {
    gap: 3px;
  }

  .set-trend {
    min-height: 14px;
    font-size: 11px;
    text-align: left;
  }

  .exercise-toggle {
    grid-template-columns: minmax(0, 1fr) max-content;
    padding: 12px;
  }

  .exercise-toggle::after {
    padding: 5px 8px;
    font-size: 11px;
  }

  .exercise-card-head {
    grid-template-columns: minmax(0, 1fr) 38px;
  }

  .exercise-flow-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .exercise-flow-actions .ghost-button {
    width: 100%;
    min-width: 0;
    padding-inline: 8px;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .training-form {
    padding: 14px;
  }

  .right-column .panel > :not(.panel-summary) {
    margin: 0;
    padding: 0 14px 14px;
  }

  .client-header {
    flex-direction: column;
  }

  .header-actions {
    width: auto;
  }

  .metric {
    padding: 12px;
  }

  .metric strong {
    font-size: 19px;
  }

  .metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric {
    min-width: 0;
  }

  .progress-panel canvas {
    height: 190px;
  }

  .save-button {
    position: static;
    box-shadow: none;
  }

  .session-table-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .remove-exercise {
    width: 100%;
  }
}
