:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #edf6f3;
  --line: #dce7e3;
  --text: #183f4c;
  --muted: #6e848b;
  --primary: #2e9f98;
  --primary-dark: #207d78;
  --danger: #b34c4c;
  --shadow: 0 12px 34px rgba(34, 71, 70, 0.09);
  --radius: 20px;
  --header-height: 72px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 85% 0%, rgba(111, 194, 181, 0.12), transparent 28rem),
    var(--bg);
}

body.exercise-mode {
  --header-height: 124px;
}

body.admin-locked > .app-header,
body.admin-locked > #exercise-shell,
body.admin-locked > #complexes-shell,
body.admin-locked > #tests-shell {
  display: none !important;
}

body.admin-locked > #users-shell {
  display: block !important;
}

body.admin-booting > #users-shell {
  display: none !important;
}

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

button {
  color: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  min-height: var(--header-height);
  grid-template-columns: minmax(190px, auto) minmax(420px, 1fr) minmax(150px, auto);
  align-items: center;
  gap: 10px 20px;
  padding: 12px 24px;
  border-bottom: 1px solid rgba(220, 231, 227, 0.9);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
}

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

.brand-logo {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 1px solid rgba(32, 125, 120, 0.16);
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 8px 20px rgba(46, 159, 152, 0.25);
}

.brand div {
  display: grid;
}

.brand strong {
  font-size: 17px;
}

.brand span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

#exercise-header-actions {
  width: 100%;
  justify-content: flex-end;
  grid-column: 1 / -1;
  padding-top: 10px;
  border-top: 1px solid rgba(220, 231, 227, 0.75);
}

.mode-tabs {
  display: flex;
  justify-self: center;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #f4f8f6;
}

.mode-tab {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.mode-tab.active {
  color: var(--primary-dark);
  background: white;
  box-shadow: 0 3px 10px rgba(34, 71, 70, 0.08);
  font-weight: 700;
}

.admin-global-session {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.admin-global-session > span {
  max-width: 180px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.users-shell {
  min-height: calc(100dvh - var(--header-height));
  padding: 28px;
}

.admin-login {
  display: grid;
  width: min(880px, 100%);
  min-height: 420px;
  margin: 7dvh auto 0;
  overflow: hidden;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: white;
  box-shadow: var(--shadow);
}

.admin-login-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 52px;
  color: white;
  background: linear-gradient(145deg, #217f79, #3fa99e);
}

.admin-login-copy h1 {
  max-width: 420px;
  margin: 10px 0 16px;
  font-size: 34px;
  line-height: 1.1;
}

.admin-login-copy p {
  max-width: 420px;
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.55;
}

.admin-login-copy .eyebrow {
  color: #d8fff8;
}

.admin-login-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 40px;
}

.admin-login-form > .button {
  width: 100%;
}

.admin-code-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.admin-code-row input {
  letter-spacing: 4px;
  text-align: center;
}

.admin-api-settings {
  color: var(--muted);
  font-size: 13px;
}

.admin-api-settings summary {
  cursor: pointer;
}

.admin-api-settings .field {
  margin-top: 12px;
}

.admin-message {
  min-height: 20px;
  margin: 0;
  color: var(--primary-dark);
  font-size: 13px;
}

.admin-message.error {
  color: var(--danger);
}

.admin-dashboard {
  width: min(1480px, 100%);
  margin: 0 auto;
}

.admin-toolbar,
.admin-users-tools,
.admin-pagination,
.admin-pagination > div {
  display: flex;
  align-items: center;
}

.admin-toolbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.admin-toolbar h1 {
  margin: 4px 0 0;
  font-size: 30px;
}

.admin-summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
}

.admin-summary article {
  display: grid;
  min-height: 94px;
  align-content: center;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.admin-summary strong {
  color: var(--primary-dark);
  font-size: 27px;
}

.admin-summary span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.admin-users-panel,
.admin-invitations-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 8px 26px rgba(34, 71, 70, 0.06);
}

.admin-panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.admin-panel-heading h2 {
  margin: 0;
  font-size: 18px;
}

.admin-panel-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.admin-invitation-form {
  display: grid;
  width: min(700px, 65%);
  grid-template-columns: minmax(240px, 1fr) 130px auto;
  align-items: end;
  gap: 10px;
}

.admin-invitation-form .field {
  min-width: 0;
}

.admin-invitation-duration select {
  min-width: 0;
}

.admin-invitations-table td:first-child {
  min-width: 240px;
  font-weight: 600;
}

.admin-invitations-table td:last-child {
  text-align: right;
}

.admin-status.invitation-consumed,
.admin-status.invitation-revoked,
.admin-status.invitation-expired {
  color: var(--muted);
  background: #f1f3f2;
}

.admin-empty {
  margin: 0;
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
}

.admin-users-tools {
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.admin-user-search {
  width: min(420px, 55%);
}

.admin-status-filter {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-status-filter select {
  min-width: 200px;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-users-table th,
.admin-users-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #eaf0ed;
  text-align: left;
  vertical-align: middle;
}

.admin-users-table th {
  color: var(--muted);
  background: #f8faf9;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.admin-users-table tbody tr:hover {
  background: #fbfdfc;
}

.admin-users-table td:first-child {
  min-width: 210px;
}

.admin-users-table td:first-child strong,
.admin-users-table td:first-child span {
  display: block;
}

.admin-users-table td:first-child span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.admin-users-table td:first-child .admin-role-label {
  width: fit-content;
  margin-top: 6px;
  padding: 3px 7px;
  border-radius: 9px;
  color: #176b52;
  background: #dff6e8;
  font-size: 10px;
  font-weight: 700;
}

.admin-status {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border-radius: 13px;
  color: #45645e;
  background: #edf4f1;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
}

.admin-status.online {
  color: #176b52;
  background: #dff6e8;
}

.admin-status.blocked,
.admin-status.pending_deletion {
  color: #97433e;
  background: #fff0ec;
}

.admin-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
}

.admin-current-account {
  color: var(--muted);
  font-size: 11px;
}

.admin-action {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  cursor: pointer;
  font-size: 11px;
}

.admin-action:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.admin-action.danger {
  border-color: #efd5d5;
  color: var(--danger);
}

.admin-motion-access {
  min-width: 155px;
}

.admin-motion-access .admin-status {
  margin-right: 7px;
}

.admin-status.motion-active {
  color: #176b52;
  background: #dff6e8;
}

.admin-status.motion-suspended {
  color: #9b5147;
  background: #fff0ec;
}

.admin-status.motion-none {
  color: #61726f;
  background: #f1f3f2;
}

.admin-pagination {
  justify-content: space-between;
  min-height: 62px;
  padding: 10px 16px;
  color: var(--muted);
  font-size: 13px;
}

.admin-pagination > div {
  gap: 8px;
}

.admin-dashboard > .admin-message {
  margin-top: 10px;
}

.admin-diagnostics-heading {
  align-items: center;
}

.admin-diagnostics-tools {
  display: flex;
  width: min(720px, 62%);
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.admin-diagnostics-tools .search-box {
  width: min(430px, 64%);
}

.admin-diagnostics-table td:first-child {
  min-width: 150px;
  color: var(--muted);
  font-size: 12px;
}

.admin-diagnostics-table td:nth-child(2),
.admin-diagnostics-table td:nth-child(3),
.admin-diagnostics-table td:nth-child(4) {
  min-width: 190px;
}

.admin-diagnostics-table td:nth-child(2) strong,
.admin-diagnostics-table td:nth-child(3) strong,
.admin-diagnostics-table td:nth-child(3) span,
.admin-diagnostics-table td:nth-child(4) strong,
.admin-diagnostics-table td:nth-child(4) span {
  display: block;
}

.admin-diagnostics-table td:nth-child(2) strong {
  margin-top: 7px;
}

.admin-diagnostics-table td:nth-child(3) span,
.admin-diagnostics-table td:nth-child(4) span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.admin-status.diagnostic-level-error {
  color: #9b3f39;
  background: #ffe9e4;
}

.admin-status.diagnostic-level-warning {
  color: #8b5b21;
  background: #fff1d2;
}

.admin-status.diagnostic-level-info {
  color: #176b6d;
  background: #e2f4f3;
}

.admin-diagnostics-table td:last-child {
  min-width: 260px;
  max-width: 420px;
}

.admin-diagnostics-table td:last-child p {
  margin: 0 0 7px;
  color: var(--primary-dark);
  line-height: 1.4;
}

.admin-diagnostics-table details summary {
  color: var(--primary);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.admin-diagnostics-table pre {
  max-height: 220px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 9px;
  border-radius: 6px;
  color: #435a5b;
  background: #f4f7f6;
  font-size: 10px;
  white-space: pre-wrap;
}

@media (max-width: 1180px) {
  .app-header {
    grid-template-columns: minmax(170px, auto) minmax(390px, 1fr) minmax(120px, auto);
    gap: 10px 12px;
    padding-inline: 16px;
  }

  .mode-tab {
    padding-inline: 10px;
  }

  .admin-summary {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }
}

@media (max-width: 760px) {
  .users-shell {
    padding: 16px;
  }

  .admin-diagnostics-heading,
  .admin-diagnostics-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-diagnostics-tools,
  .admin-diagnostics-tools .search-box {
    width: 100%;
  }

  .admin-login {
    margin-top: 16px;
    grid-template-columns: 1fr;
  }

  .admin-login-copy,
  .admin-login-form {
    padding: 28px;
  }

  .admin-toolbar,
  .admin-users-tools,
  .admin-panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-invitation-form {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .admin-summary {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .admin-user-search {
    width: 100%;
  }

  .admin-status-filter {
    justify-content: space-between;
  }
}

.save-status {
  margin-right: 8px;
  color: var(--muted);
  font-size: 13px;
}

.save-status.dirty {
  color: #9b6d18;
}

.button {
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 650;
  transition: 160ms ease;
}

.button:disabled {
  cursor: default;
  opacity: 0.45;
}

.button-primary {
  color: white;
  background: var(--primary);
}

.button-primary:not(:disabled):hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.button-secondary {
  border-color: var(--line);
  background: white;
}

.button-secondary:not(:disabled):hover {
  border-color: #aecbc4;
  background: var(--surface-soft);
}

.button-danger {
  border-color: #efd5d5;
  color: var(--danger);
  background: #fff7f7;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 0;
  border-radius: 11px;
  color: white;
  background: var(--primary);
  cursor: pointer;
  font-size: 22px;
}

.app-shell {
  display: grid;
  min-height: calc(100dvh - var(--header-height));
  grid-template-columns: 330px minmax(0, 1fr);
}

.catalog-panel {
  position: sticky;
  display: flex;
  flex-direction: column;
  top: var(--header-height);
  height: calc(100dvh - var(--header-height));
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: rgba(250, 252, 251, 0.94);
}

.catalog-tools {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

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

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(46, 159, 152, 0.12);
}

.search-box span {
  color: var(--muted);
  font-size: 23px;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.filter-button {
  min-width: 0;
  padding: 7px 6px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.filter-button.active {
  color: var(--primary-dark);
  background: #dff2ee;
  font-weight: 650;
}

.compact-filter {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.compact-filter select {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: white;
}

.catalog-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.catalog-summary strong {
  color: var(--text);
}

.exercise-navigation {
  display: flex;
  gap: 5px;
}

.exercise-navigation button {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  padding: 0;
  border: 1px solid #bfd4cf;
  border-radius: 7px;
  color: var(--primary-dark);
  background: white;
  font-size: 15px;
  font-weight: 750;
  cursor: pointer;
}

.exercise-navigation button:hover:not(:disabled) {
  border-color: var(--primary);
  background: #e4f4f0;
}

.exercise-navigation button:disabled {
  color: #9caeaa;
  background: #edf2f0;
  cursor: default;
  opacity: 0.65;
}

.exercise-navigation .add-exercise-button {
  border-color: var(--primary);
  color: white;
  background: var(--primary);
  font-size: 20px;
}

.exercise-navigation .add-exercise-button:hover:not(:disabled) {
  color: white;
  background: var(--primary-dark);
}

.exercise-list {
  flex: 1;
  min-height: 0;
  height: auto;
  overflow-y: auto;
  padding: 10px;
}

.exercise-item {
  display: grid;
  width: 100%;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 7px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 14px;
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.exercise-item:hover {
  background: white;
}

.exercise-item.active {
  border-color: #4da89d;
  color: #174f4b;
  background: #d9f1eb;
  box-shadow: inset 4px 0 0 var(--primary), 0 6px 18px rgba(34, 107, 99, 0.16);
}

.exercise-item.active .exercise-thumb {
  box-shadow: 0 0 0 2px rgba(46, 159, 152, 0.42);
}

.exercise-item.active .exercise-item-title {
  color: #165c56;
  font-weight: 750;
}

.exercise-item.active .exercise-item-meta {
  color: #3c716c;
}

.exercise-thumb {
  width: 84px;
  height: 58px;
  object-fit: cover;
  border-radius: 10px;
  background: #e8efec;
}

.exercise-thumb.empty {
  background: #e5eeeb;
  box-shadow: inset 0 0 0 1px #cfddd8;
}

.exercise-item-copy {
  min-width: 0;
  align-self: center;
}

.exercise-item-title {
  display: block;
  overflow: hidden;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exercise-item-meta {
  display: flex;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.editor-panel {
  width: min(1460px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 80px;
}

.editor-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.editor-heading-note {
  color: var(--muted);
  font-size: 12px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(380px, 0.9fr) minmax(500px, 1.1fr);
  align-items: start;
  gap: 20px;
}

.media-column,
.parameters-column {
  min-width: 0;
}

.media-column {
  display: grid;
  gap: 14px;
}

.media-card {
  overflow: hidden;
  border: 1px solid rgba(220, 231, 227, 0.9);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 7px 24px rgba(34, 71, 70, 0.06);
}

.media-card-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.media-card-heading h2 {
  font-size: 15px;
}

.media-index {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 9px;
  color: var(--primary-dark);
  background: var(--surface-soft);
  font-size: 10px;
  font-weight: 750;
}

.media-card > img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 520px;
  margin: 0 auto;
  object-fit: contain;
  background: linear-gradient(135deg, #edf5f2, #faf7f1);
}

.video-preview-stage {
  display: grid;
  width: min(100%, 360px);
  aspect-ratio: 9 / 16;
  margin: 0 auto;
  place-items: center;
  overflow: hidden;
  background: #eef1ed;
}

.video-preview-stage video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #eef1ed;
}

.inline-audio {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr);
  align-items: center;
  gap: 12px;
  padding: 10px 14px 13px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.inline-audio audio {
  width: 100%;
  height: 34px;
}

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

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1.12;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

h3 {
  margin-bottom: 0;
  font-size: 15px;
}

.form-card {
  margin-bottom: 16px;
  padding: 22px;
  border: 1px solid rgba(220, 231, 227, 0.8);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 7px 24px rgba(34, 71, 70, 0.05);
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

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

.field {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.field-wide {
  grid-column: span 2;
}

.field-side {
  grid-column: span 2;
}

.equipment-field {
  margin: 0;
  padding: 0;
  border: 0;
}

.equipment-field legend {
  margin-bottom: 7px;
  padding: 0;
  color: #587178;
  font-size: 12px;
  font-weight: 650;
}

.equipment-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfdfd;
}

.equipment-options label {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
}

.equipment-options input[type="checkbox"] {
  flex: 0 0 16px;
  width: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
}

.status-toggle {
  display: flex;
  align-items: center;
  min-height: 43px;
  gap: 9px;
  color: #587178;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.toggle-control {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  cursor: pointer;
}

.toggle-control input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
}

.toggle-control > span {
  width: 42px;
  height: 24px;
  border: 1px solid #b9cac6;
  border-radius: 12px;
  background: #dfe8e5;
  transition: 140ms ease;
}

.toggle-control > span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(28, 62, 59, 0.25);
  transition: 140ms ease;
}

.toggle-control input:checked + span {
  border-color: var(--primary);
  background: var(--primary);
}

.toggle-control input:checked + span::after {
  transform: translateX(18px);
}

.toggle-control input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(46, 159, 152, 0.18);
}

.field > span {
  color: #587178;
  font-size: 12px;
  font-weight: 650;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  color: var(--text);
  background: #fcfdfd;
  transition: 140ms ease;
}

.field input,
.field select {
  min-height: 43px;
  padding: 0 12px;
}

.field textarea {
  min-height: 76px;
  padding: 11px 12px;
  line-height: 1.5;
  resize: vertical;
}

.asset-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.asset-input-row .asset-picker-button {
  min-height: 43px;
  padding: 0 13px;
  border-radius: 8px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px rgba(46, 159, 152, 0.1);
}

.field input[readonly] {
  color: var(--muted);
  background: #f0f4f2;
}

.text-fields {
  display: grid;
  gap: 15px;
}

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

.body-region-editor {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(0, 1.3fr);
  gap: 14px;
  margin-bottom: 14px;
}

.body-region-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.body-region-field legend {
  margin-bottom: 7px;
  padding: 0;
  color: #587178;
  font-size: 12px;
  font-weight: 650;
}

.body-region-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfdfd;
}

.body-region-options label {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
}

.body-region-options input[type="checkbox"] {
  flex: 0 0 16px;
  width: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
}

.clinical-group {
  padding: 14px;
  border: 1px solid #dce9e5;
  border-radius: 13px;
  background: #f8fbfa;
}

.clinical-group-title {
  display: block;
  margin-bottom: 9px;
  color: #587178;
  font-size: 12px;
  font-weight: 700;
}

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

.clinical-chip {
  padding: 6px 9px;
  border-radius: 999px;
  color: #285e5b;
  background: #e3f2ee;
  font-size: 12px;
  line-height: 1.2;
}

.clinical-group-screening {
  grid-column: 1 / -1;
  border-color: #ecdcb9;
  background: #fffaf0;
}

.clinical-group-screening .clinical-chip {
  color: #70561d;
  background: #f8eccd;
}

.clinical-divider {
  height: 1px;
  margin: 22px 0;
  background: var(--line);
}

.clinical-form-heading {
  margin-bottom: 14px;
}

.clinical-form-heading h3 {
  margin: 3px 0 0;
  font-size: 17px;
}

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

.runtime-grid {
  grid-template-columns: repeat(2, minmax(0, 220px));
}

.timeline-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
  margin-bottom: 10px;
}

.text-button {
  padding: 6px 8px;
  border: 0;
  color: var(--primary-dark);
  background: transparent;
  cursor: pointer;
  font-weight: 650;
}

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

.timeline-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 150px 38px;
  align-items: center;
  gap: 10px;
}

.timeline-number {
  color: var(--muted);
  font-size: 12px;
}

.timeline-row input {
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
}

.timeline-row input:focus {
  border-color: var(--primary);
}

.timeline-sound-picker {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.timeline-sound-picker .timeline-audio-picker {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
}

.timeline-sound-picker input[readonly] {
  min-width: 0;
  color: #486269;
  background: #f5f8f7;
}

.remove-timeline {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  border-radius: 10px;
  color: var(--danger);
  background: #fff1f1;
  cursor: pointer;
}

.timeline-empty {
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.details-card {
  padding: 0;
}

.details-card summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 19px 22px;
  cursor: pointer;
  list-style: none;
}

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

.details-card summary strong {
  display: block;
  font-size: 16px;
}

.details-chevron {
  color: var(--muted);
  font-size: 20px;
  transition: transform 150ms ease;
}

.details-card[open] .details-chevron {
  transform: rotate(180deg);
}

.details-content {
  margin: 0 22px 22px;
}

.source-data {
  overflow: auto;
  padding: 15px;
  border-radius: 12px;
  color: #486269;
  background: #f1f5f3;
  font-size: 12px;
  line-height: 1.55;
}

.complexes-shell {
  min-height: calc(100dvh - var(--header-height));
  grid-template-columns: 270px minmax(0, 1fr);
}

.complexes-shell:not([hidden]) {
  display: grid;
}

.complex-sidebar {
  position: sticky;
  top: var(--header-height);
  height: calc(100dvh - var(--header-height));
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: rgba(250, 252, 251, 0.94);
}

.complex-sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--line);
}

.complex-sidebar-heading h2,
.palette-heading h2,
.stages-heading h2 {
  margin: 3px 0 0;
}

.complex-list {
  display: grid;
  gap: 7px;
  padding: 10px;
}

.complex-list-item {
  display: grid;
  gap: 4px;
  padding: 13px;
  border: 1px solid transparent;
  border-radius: 13px;
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.complex-list-item:hover {
  border-color: var(--line);
  background: white;
}

.complex-list-item.active {
  border-color: #4da89d;
  color: #174f4b;
  background: #d9f1eb;
  box-shadow: inset 4px 0 0 var(--primary), 0 6px 18px rgba(34, 107, 99, 0.16);
}

.complex-list-item.active strong {
  color: #165c56;
}

.complex-list-item.active span {
  color: #3c716c;
}

.complex-list-item span {
  color: var(--muted);
  font-size: 12px;
}

.tests-shell {
  min-height: calc(100dvh - var(--header-height));
  grid-template-columns: 270px minmax(0, 1fr);
}

.tests-shell:not([hidden]) {
  display: grid;
}

.test-sidebar {
  position: sticky;
  top: var(--header-height);
  height: calc(100dvh - var(--header-height));
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: rgba(250, 252, 251, 0.94);
}

.test-list {
  display: grid;
  gap: 7px;
  padding: 10px;
}

.test-list-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.test-list-item:hover {
  border-color: var(--line);
  background: white;
}

.test-list-item.active {
  border-color: #4da89d;
  color: #174f4b;
  background: #d9f1eb;
  box-shadow: inset 4px 0 0 var(--primary), 0 6px 18px rgba(34, 107, 99, 0.16);
}

.test-list-item.active strong {
  color: #165c56;
}

.test-list-item.active span {
  color: #3c716c;
}

.test-list-item span {
  color: var(--muted);
  font-size: 10px;
}

.test-editor-panel {
  min-width: 0;
  padding: 16px;
}

.test-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: start;
  gap: 12px;
}

.test-form-column {
  display: grid;
  gap: 12px;
}

.test-form-card {
  padding: 14px 16px;
}

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

.test-fields-grid .field-wide {
  grid-column: span 2;
}

.checkbox-field {
  display: flex;
  min-height: 40px;
  align-items: center;
  flex-direction: row;
  gap: 8px;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.test-preview-panel {
  position: sticky;
  top: 88px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  box-shadow: var(--shadow);
}

.test-preview-heading {
  padding: 16px 16px 8px;
}

.test-preview-heading h2 {
  margin: 3px 0 0;
}

#test-preview-content {
  padding: 0 16px 12px;
}

.test-preview-description {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.test-preview-media {
  display: grid;
  place-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px;
  border-radius: 11px;
  background: #e9f1ef;
}

.test-preview-media img,
.test-preview-media video {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(56vh, 460px);
  border-radius: 11px;
  object-fit: contain;
}

.test-preview-setup {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 11px;
  background: #eef8f5;
  font-size: 11px;
}

.test-preview-steps {
  display: grid;
  gap: 7px;
  padding-left: 24px;
  font-size: 12px;
  line-height: 1.4;
}

.test-stop-details {
  padding: 8px 10px;
  border: 1px solid #f0d4ba;
  border-radius: 10px;
  color: #74400e;
  background: #fff8ef;
  font-size: 11px;
}

.test-stop-details ul {
  padding-left: 18px;
}

.test-runner {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f7fbfa;
}

.runner-side {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
}

.runner-side select {
  min-height: 34px;
  padding: 0 9px;
}

.test-start-button,
.test-stop-button {
  width: 100%;
}

.test-countdown,
.test-live-value {
  padding: 10px;
  color: var(--primary-dark);
  text-align: center;
  font-size: 42px;
  font-weight: 800;
}

.test-live-value.finished {
  font-size: 32px;
}

.test-feedback-form {
  display: grid;
  gap: 8px;
  font-size: 11px;
}

.test-feedback-form > label:not(.field) {
  display: flex;
  align-items: center;
  gap: 7px;
}

.test-feedback-form input[type="checkbox"] {
  accent-color: var(--primary);
}

.test-history-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 6px;
}

.test-history-heading h3 {
  margin: 0;
  font-size: 13px;
}

.test-history {
  display: grid;
  gap: 6px;
  padding: 0 16px 16px;
}

.test-trend-message {
  padding: 9px;
  border-radius: 9px;
  color: var(--primary-dark);
  background: #e7f5f1;
  font-size: 11px;
  font-weight: 700;
}

.test-history-row {
  display: grid;
  gap: 2px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.test-history-row span {
  color: var(--muted);
  font-size: 10px;
}

.complex-editor-panel {
  min-width: 0;
  padding: 16px;
}

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

.complex-toolbar {
  display: grid;
  gap: 13px;
  margin-bottom: 14px;
  padding: 2px 0 13px;
  border-bottom: 1px solid var(--line);
}

.complex-toolbar-title {
  min-width: 0;
}

.complex-toolbar h1 {
  margin: 3px 0 0;
  font-size: 27px;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.complex-toolbar-controls {
  display: grid;
  grid-template-columns: minmax(270px, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.complex-toolbar-statuses {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.complex-toolbar .save-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  margin: 0;
  white-space: nowrap;
}

.complex-toolbar .save-status::before {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #4d9b83;
  content: "";
}

.complex-toolbar .save-status.dirty::before {
  background: #d29227;
}

.complex-toolbar-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.complex-toolbar-actions .button {
  min-height: 38px;
  padding: 0 14px;
  white-space: nowrap;
}

.button-publish {
  border-color: #28766d;
  color: white;
  background: #28766d;
}

.button-publish:hover:not(:disabled) {
  background: #1f625b;
}

.release-type-control {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f8f6;
}

.release-type-auto {
  padding: 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.release-type-auto.is-compatible {
  color: #1f625b;
  background: #dff1eb;
}

.release-type-auto.is-program {
  color: #8a4434;
  background: #ffe3d8;
}

.release-type-auto.is-pending {
  color: var(--muted);
  background: transparent;
}

.release-type-control span {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.release-history-dialog {
  width: min(540px, calc(100vw - 24px));
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  color: var(--text);
  background: var(--surface);
  box-shadow: -18px 0 44px rgba(24, 63, 76, 0.16);
}

.release-history-dialog[open] {
  animation: release-history-enter 180ms ease-out;
}

.release-history-dialog::backdrop {
  background: rgba(20, 46, 53, 0.36);
  backdrop-filter: blur(2px);
}

@keyframes release-history-enter {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.release-history-sheet {
  display: grid;
  height: 100%;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.release-history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.release-history-header h2 {
  margin: 4px 0 0;
  font-size: 24px;
}

.release-history-close {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: white;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.release-history-close:hover {
  color: var(--text);
  border-color: #b9d3cc;
  background: var(--surface-soft);
}

.release-history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: #f7faf9;
}

.release-history-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.release-history-content {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow-y: auto;
  padding: 14px 22px 24px;
  overscroll-behavior: contain;
}

.release-history-state {
  display: grid;
  min-height: 240px;
  place-content: center;
  justify-items: center;
  gap: 9px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.release-history-state p {
  max-width: 320px;
  margin: 0;
  line-height: 1.5;
}

.release-history-state.is-error strong {
  color: var(--danger);
}

.release-history-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #d9ece7;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.release-history-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.release-history-card.is-unavailable {
  background: #fbf9f8;
}

.release-history-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.release-history-version-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.release-history-version {
  font-size: 18px;
}

.release-history-card time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.release-history-latest,
.release-history-badge,
.release-change {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
}

.release-history-latest {
  color: #32695d;
  background: #e2f1ec;
}

.release-history-badge {
  max-width: 190px;
  text-align: center;
}

.release-history-badge.is-materials,
.release-change.is-compatible {
  color: #286b5e;
  background: #dff1eb;
}

.release-history-badge.is-program,
.release-change.is-program {
  color: #8a4434;
  background: #ffe3d8;
}

.release-history-badge.is-legacy,
.release-history-badge.is-unavailable {
  color: #66767b;
  background: #e9efed;
}

.release-change.is-added {
  color: #61548e;
  background: #eee9fb;
}

.release-history-relation,
.release-history-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.release-history-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 12px;
  padding: 10px 0;
  border-top: 1px solid #edf2f0;
  border-bottom: 1px solid #edf2f0;
  color: var(--muted);
  font-size: 11px;
}

.release-history-counts strong {
  color: var(--text);
  font-size: 13px;
}

.release-history-details {
  margin-top: 12px;
}

.release-history-details summary {
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.release-history-details ul {
  display: grid;
  gap: 7px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.release-history-details li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding-top: 7px;
  border-top: 1px solid #edf2f0;
}

.release-history-details li strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.release-history-details > p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: var(--text);
  font-size: 13px;
}

.checkbox-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.complex-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: start;
  gap: 12px;
}

.complex-content {
  display: grid;
  min-width: 0;
  gap: 12px;
}

.complex-overview-card {
  padding: 14px 16px;
}

.complex-overview-card .form-card-heading {
  margin-bottom: 10px;
}

.complex-overview-fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px 12px;
}

.complex-overview-fields .field:last-child {
  grid-column: 1 / -1;
}

.complex-overview-fields textarea {
  min-height: 56px;
}

.exercise-palette {
  position: sticky;
  top: 94px;
  max-height: calc(100vh - 116px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  box-shadow: var(--shadow);
}

.palette-heading {
  padding: 18px 18px 10px;
}

.palette-heading p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.palette-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.palette-heading-row p {
  flex: 1;
}

.palette-navigation {
  flex: 0 0 auto;
}

.palette-search {
  margin: 0 14px 10px;
}

.palette-region-filter {
  margin: 0 14px 10px;
}

.exercise-palette-list {
  max-height: calc(100vh - 285px);
  overflow-y: auto;
  padding: 0 10px 12px;
}

.palette-exercise {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 6px;
  width: 100%;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text);
  text-align: left;
  background: #f8fbfa;
  cursor: grab;
  font: inherit;
}

.palette-exercise:hover {
  border-color: var(--line);
  background: white;
}

.palette-exercise:focus-visible {
  outline: 3px solid rgba(46, 159, 152, 0.2);
  outline-offset: 1px;
}

.palette-exercise.active {
  border-color: #4da89d;
  color: #174f4b;
  background: #d9f1eb;
  box-shadow: inset 4px 0 0 var(--primary), 0 6px 18px rgba(34, 107, 99, 0.16);
}

.palette-exercise.active strong {
  color: #165c56;
}

.palette-exercise.active span {
  color: #3c716c;
}

.palette-exercise:active {
  cursor: grabbing;
}

.palette-exercise img {
  width: 64px;
  height: 50px;
  object-fit: cover;
  border-radius: 9px;
}

.palette-exercise img.empty {
  background: #e5eeeb;
  box-shadow: inset 0 0 0 1px #cfddd8;
}

.palette-exercise strong {
  display: block;
  font-size: 13px;
}

.palette-exercise span {
  color: var(--muted);
  font-size: 11px;
}

.stage-list {
  display: grid;
  gap: 18px;
}

.stage-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  box-shadow: var(--shadow);
}

.stage-card-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f9fcfb;
}

.stage-number {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  color: var(--primary-dark);
  background: #dff2ee;
  font-weight: 800;
}

.stage-title-input {
  min-width: 0;
  flex: 1;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 700;
}

.stage-action {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: #edf4f2;
  cursor: pointer;
}

.stage-action.danger {
  color: var(--danger);
  background: #fff0f0;
}

.stage-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 0.8fr)) minmax(220px, 1.2fr) minmax(150px, 0.8fr);
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.stage-settings .field-wide {
  grid-column: 1 / -1;
}

.stage-duration-summary {
  display: grid;
  min-width: 0;
  align-content: center;
  gap: 2px;
  padding: 7px 10px;
  border: 1px solid #cfe3de;
  border-radius: 9px;
  background: #f0f8f6;
}

.stage-duration-summary > span {
  color: var(--muted);
  font-size: 11px;
}

.stage-duration-summary > strong {
  color: var(--primary-dark);
  font-size: 15px;
}

.stage-duration-summary > small {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.stage-criteria {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f7fbfa;
}

.criteria-editor {
  min-width: 0;
  padding: 9px;
  border: 1px solid #d5e5e1;
  border-radius: 11px;
  background: white;
}

.criteria-editor.compact {
  grid-column: 1 / -1;
  background: #fdfefe;
}

.criteria-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 11px;
}

.criteria-heading .text-button {
  font-size: 10px;
}

.criteria-rows {
  display: grid;
  gap: 6px;
}

.criterion-row {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr) minmax(76px, 0.55fr) minmax(0, 0.9fr);
  align-items: end;
  gap: 6px;
}

.criterion-row .field > span {
  font-size: 9px;
}

.criterion-row input,
.criterion-row select {
  min-height: 32px;
  padding: 0 7px;
  font-size: 11px;
}

.criterion-required {
  display: flex;
  min-height: 32px;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  grid-column: 1 / -2;
}

.criterion-row > .stage-action {
  grid-column: -2 / -1;
  justify-self: end;
}

.criterion-required input {
  min-height: auto;
  accent-color: var(--primary);
}

.criteria-empty {
  padding: 5px 0;
  color: var(--muted);
  font-size: 11px;
}

.stage-settings .field > span,
.complex-item-fields .field > span {
  font-size: 11px;
}

.stage-settings .field input,
.stage-settings .field select,
.complex-item-fields .field input,
.complex-item-fields .field select {
  min-height: 36px;
  padding: 0 9px;
  border-radius: 9px;
}

.stage-settings .field textarea,
.complex-item-fields .field textarea {
  min-height: 54px;
  padding: 8px 9px;
  border-radius: 9px;
  line-height: 1.35;
}

.weekly-planner {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fbfdfc;
}

.weekly-planner-heading,
.day-plan-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.weekly-planner-heading span {
  color: var(--muted);
  font-size: 11px;
}

.day-plan-tabs {
  display: grid;
  grid-template-columns: repeat(7, minmax(54px, 1fr));
  gap: 6px;
  margin: 8px 0;
}

.day-plan-tab {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: white;
  cursor: pointer;
}

.day-plan-tab span {
  display: grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 7px;
  color: #874b12;
  background: #ffe0a8;
  font-size: 10px;
  font-weight: 800;
}

.day-plan-tab.enabled {
  border-color: #afd5ce;
  color: var(--primary-dark);
  background: #eef8f5;
}

.day-plan-tab.active {
  border-color: var(--primary);
  color: white;
  background: var(--primary);
  box-shadow: 0 3px 10px rgba(36, 112, 105, 0.2);
}

.day-plan-tab.active span {
  color: #74400e;
  background: #ffc968;
}

.day-plan-toolbar {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) minmax(220px, 300px);
  justify-content: stretch;
}

.day-plan-toolbar .field > span {
  font-size: 10px;
}

.day-plan-toolbar input,
.day-plan-toolbar select {
  min-height: 34px;
  padding: 0 9px;
}

.day-title-field {
  min-width: 0;
}

.inline-select-field {
  display: grid;
  width: auto;
  min-width: 0;
  gap: 7px;
}

.inline-select-field > span {
  min-width: 0;
  white-space: normal;
}

.inline-select-field select {
  min-width: 0;
}

.day-enabled-toggle {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
}

.day-enabled-toggle input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
}

.stage-dropzone {
  display: grid;
  min-width: 0;
  min-height: 110px;
  align-content: start;
  gap: 12px;
  padding: 10px;
  background: #edf4f2;
  transition: 150ms ease;
}

.stage-card.drag-over {
  border-color: #75bdb2;
  background: #eaf7f3;
  box-shadow: 0 0 0 3px rgba(46, 159, 152, 0.18), var(--shadow);
}

.stage-card.drag-over .stage-dropzone {
  background: #eaf7f3;
}

.drop-placeholder {
  display: grid;
  min-height: 82px;
  place-items: center;
  border: 1px dashed #b8d5ce;
  border-radius: 13px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.complex-exercise-item {
  display: grid;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  grid-template-columns: clamp(180px, 24%, 210px) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #b9d2cc;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 5px 14px rgba(31, 77, 72, 0.1);
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.complex-exercise-item:hover {
  border-color: #68aaa1;
  box-shadow: 0 8px 20px rgba(31, 77, 72, 0.15);
  transform: translateY(-1px);
}

.complex-item-media {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 8px;
  padding: 10px;
  border-right: 1px solid #d2e2de;
  background: #ffffff;
  cursor: grab;
}

.drag-handle {
  color: #9aaca9;
  cursor: grab;
  font-size: 20px;
}

.complex-item-title-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 6px;
}

.complex-item-title-row > div {
  min-width: 0;
}

.complex-item-media img {
  width: 100%;
  height: auto;
  aspect-ratio: 1517 / 1037;
  object-fit: contain;
  border-radius: 11px;
  background: #eef3f1;
}

.complex-item-title-row strong,
.complex-item-title-row span {
  display: block;
}

.complex-item-title-row strong {
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.complex-item-title-row span {
  color: var(--muted);
  font-size: 10px;
}

.complex-item-fields {
  display: grid;
  min-width: 0;
  max-width: 100%;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-content: start;
  gap: 8px;
  padding: 10px;
  background: #f7fbf9;
}

.complex-item-fields .field-wide {
  grid-column: span 2;
}

.empty-state {
  display: grid;
  min-height: calc(100vh - 72px);
  place-content: center;
  justify-items: center;
  padding: 30px;
  text-align: center;
}

.empty-state h1 {
  margin: 20px 0 8px;
  font-size: 24px;
}

.empty-state p {
  color: var(--muted);
}

.spinner {
  width: 38px;
  height: 38px;
  border: 4px solid #cfe7e1;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 48px));
  padding: 13px 17px;
  border-radius: 13px;
  color: white;
  background: #244d55;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 180ms ease;
}

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

.toast.error {
  background: #9c4545;
}

.toast.has-action {
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: auto;
}

.toast.has-action span {
  flex: 1;
}

.toast.has-action button {
  min-height: 32px;
  flex: 0 0 auto;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  color: white;
  background: rgba(255, 255, 255, 0.1);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

@media (min-width: 1251px) and (max-width: 1800px) and (max-height: 1200px) {
  :root {
    --header-height: 64px;
  }

  body.exercise-mode {
    --header-height: 112px;
  }

  .app-header {
    gap: 16px;
    padding: 8px 18px;
  }

  .brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 11px;
  }

  .save-status {
    display: none;
  }

  .complex-toolbar .save-status {
    display: inline-flex;
  }

  .app-shell {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .catalog-tools {
    padding: 14px;
  }

  .exercise-list {
    height: auto;
  }

  .editor-panel {
    width: calc(100% - 28px);
    padding: 14px 0 48px;
  }

  .editor-heading {
    margin-bottom: 12px;
  }

  .editor-heading h1 {
    font-size: 30px;
  }

  .workspace-grid {
    grid-template-columns: minmax(340px, 0.85fr) minmax(480px, 1.15fr);
    gap: 14px;
  }

  .media-column {
    position: sticky;
    top: calc(var(--header-height) + 12px);
    max-height: calc(100dvh - var(--header-height) - 24px);
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-gutter: stable;
  }

  .media-card-heading {
    padding: 9px 11px;
  }

  .media-card-heading h2 {
    font-size: 13px;
  }

  .media-index {
    width: 25px;
    height: 25px;
  }

  .inline-audio {
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 7px 9px 9px;
  }

  .complexes-shell,
  .tests-shell {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .test-workspace {
    grid-template-columns: minmax(0, 1fr) 330px;
  }

  .test-preview-panel {
    top: calc(var(--header-height) + 12px);
    max-height: calc(100dvh - var(--header-height) - 24px);
    overflow-y: auto;
  }

  .complex-workspace {
    grid-template-columns: minmax(0, 1fr) 280px;
  }

  .exercise-palette {
    top: calc(var(--header-height) + 16px);
    max-height: calc(100dvh - var(--header-height) - 32px);
  }

  .exercise-palette-list {
    max-height: calc(100dvh - var(--header-height) - 200px);
  }
}

@media (max-width: 1250px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .complex-workspace {
    grid-template-columns: 1fr;
  }

  .test-workspace {
    grid-template-columns: 1fr;
  }

  .test-preview-panel {
    position: static;
  }

  .exercise-palette {
    position: static;
    max-height: none;
  }

  .exercise-palette-list {
    display: grid;
    max-height: 360px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .complex-toolbar-controls {
    grid-template-columns: 1fr;
  }

  .complex-toolbar-actions {
    justify-content: flex-start;
  }

  .stage-settings,
  .complex-item-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stage-settings .field-wide,
  .complex-item-fields .field-wide {
    grid-column: 1 / -1;
  }

  .day-plan-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .day-enabled-toggle {
    grid-column: 1 / -1;
  }
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }

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

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

  .stage-settings,
  .complex-item-fields,
  .complex-overview-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stage-criteria {
    grid-template-columns: 1fr;
  }

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

  .complex-overview-fields .field:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .body-region-editor,
  .body-region-options {
    grid-template-columns: 1fr;
  }
  .app-header {
    position: static;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 12px;
  }

  .mode-tabs {
    width: 100%;
    grid-column: 1 / -1;
    overflow-x: auto;
  }

  .mode-tab {
    min-width: max-content;
    flex: 1;
  }

  #exercise-header-actions {
    grid-column: 1 / -1;
  }

  .admin-global-session > span {
    display: none;
  }

  .admin-global-session .button-secondary {
    display: inline-flex;
  }

  .save-status,
  .button-secondary {
    display: none;
  }

  .button-primary {
    min-height: 40px;
    padding: 0 13px;
  }

  .app-shell {
    display: block;
  }

  .complexes-shell:not([hidden]) {
    display: block;
  }

  .tests-shell:not([hidden]) {
    display: block;
  }

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

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

  .test-list {
    display: flex;
    overflow-x: auto;
  }

  .test-list-item {
    flex: 0 0 220px;
  }

  .test-editor-panel {
    padding: 14px;
  }

  .complex-list {
    display: flex;
    overflow-x: auto;
  }

  .complex-list-item {
    flex: 0 0 210px;
  }

  .complex-editor-panel {
    padding: 14px;
  }

  .stages-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .complex-toolbar-controls,
  .complex-toolbar .header-actions {
    width: 100%;
  }

  .complex-toolbar .save-status,
  .complex-toolbar-actions .button-secondary {
    display: inline-flex;
  }

  .release-history-dialog {
    width: 100vw;
  }

  .release-history-header {
    padding: 18px 16px 14px;
  }

  .release-history-toolbar {
    padding: 10px 16px;
  }

  .release-history-content {
    padding: 12px 12px 24px;
  }

  .release-history-card-heading,
  .release-history-details li {
    align-items: flex-start;
    flex-direction: column;
  }

  .release-history-badge {
    max-width: none;
  }

  .catalog-panel {
    position: static;
    width: 100%;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .exercise-list {
    display: flex;
    height: auto;
    overflow-x: auto;
    padding: 10px 14px 14px;
  }

  .exercise-item {
    flex: 0 0 205px;
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .exercise-thumb {
    width: 64px;
    height: 52px;
  }

  .editor-panel {
    width: calc(100% - 24px);
    padding-top: 18px;
  }

  .editor-heading,
  .form-card-heading {
    display: grid;
  }

  .editor-heading-note {
    display: none;
  }

  .form-card {
    padding: 17px;
  }

  .form-grid,
  .runtime-grid,
  .clinical-summary,
  .clinical-fields {
    grid-template-columns: 1fr;
  }

  .test-fields-grid {
    grid-template-columns: 1fr;
  }

  .test-fields-grid .field-wide {
    grid-column: auto;
  }

  .stage-settings,
  .complex-item-fields,
  .exercise-palette-list {
    grid-template-columns: 1fr;
  }

  .day-plan-tabs {
    grid-template-columns: repeat(4, minmax(54px, 1fr));
  }

  .day-plan-toolbar {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .day-plan-toolbar .field {
    width: 100%;
    min-width: 0;
  }

  .inline-select-field {
    display: grid;
  }

  .stage-settings .field-wide,
  .complex-item-fields .field-wide {
    grid-column: auto;
  }

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

  .complex-item-media {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .clinical-group-screening {
    grid-column: auto;
  }

  .field-wide {
    grid-column: auto;
  }

  .field-side {
    grid-column: auto;
  }

  .inline-audio {
    grid-template-columns: 1fr;
  }

  .timeline-row {
    grid-template-columns: 28px minmax(0, 1fr) 85px 34px;
    gap: 6px;
  }
}
