:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --text: #15181e;
  --muted: #647084;
  --line: #d9dee8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #0f766e;
  --danger: #c2410c;
  --danger-dark: #9a3412;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  background: var(--primary-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button.secondary {
  background: #e7ebf2;
  color: #1f2937;
}

button.secondary:hover {
  background: #d6dce8;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: var(--danger-dark);
}

button.compact {
  min-height: 38px;
  padding: 0 12px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--text);
}

input[type="range"] {
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
}

label span,
.eyebrow {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-shell {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 18px 14px 36px;
}

.auth-view {
  display: grid;
  min-height: 92vh;
  align-content: center;
  gap: 22px;
}

.brand-block h1 {
  margin: 2px 0 0;
  font-size: clamp(2.25rem, 10vw, 4.25rem);
  line-height: 1;
}

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

.auth-panel,
.exercise-form,
.routine-form,
.routine-item-form {
  display: grid;
  gap: 16px;
}

.exercise-weight-reported-as-field,
.weight-reported-as-toggle {
  display: grid;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
}

.weight-reported-as-toggle {
  grid-column: 1 / -1;
}

#workoutMeasureFields .weight-reported-as-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

#workoutMeasureFields .weight-reported-as-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
  gap: 18px;
}

#workoutMeasureFields .weight-reported-as-toggle label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

#workoutMeasureFields .weight-reported-as-toggle input {
  width: 22px;
  height: 22px;
  min-height: 0;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--primary);
}

.auth-panel,
.toolbar {
  padding: 18px;
}

.auth-actions,
.form-actions,
.row-actions {
  display: grid;
  gap: 10px;
}

.section-actions {
  display: grid;
  align-items: center;
  gap: 8px;
  grid-auto-flow: column;
}

.form-message {
  min-height: 1.25rem;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

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

.account-menu {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
}

.site-title {
  display: inline-block;
  width: fit-content;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  text-transform: none;
  cursor: pointer;
}

.site-title:hover {
  background: transparent;
  color: var(--text);
  opacity: 0.84;
}

.site-title:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

.user-label {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  pointer-events: none;
}

.user-label:hover {
  background: transparent;
}

.account-menu-panel {
  top: calc(100% + 10px);
  right: 0;
  min-width: 148px;
}

.toolbar {
  margin-bottom: 22px;
}

.view-title {
  margin-bottom: 14px;
}

.view-title h2 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.tabbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  margin-bottom: 14px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #eef2f7 100%);
  box-shadow: var(--shadow);
}

.tab {
  display: inline-grid;
  place-items: center;
  min-height: 60px;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  color: #526074;
  transition: background 140ms ease-out, color 140ms ease-out, box-shadow 140ms ease-out, transform 140ms ease-out;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.78);
  color: #1f2937;
}

.tab.active {
  background: #ffffff;
  color: #ffffff;
  color: var(--text);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.tab-icon {
  width: 28px;
  height: 28px;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.view.active > :first-child.panel,
.view.active > :first-child.exercise-section,
.view.active > :first-child.routine-layout,
.view.active > :first-child.history-layout {
  margin-top: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.section-heading h2 {
  margin: 0;
  font-size: 1.2rem;
}

.count-pill,
.type-badge,
.detail-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: #e7f4f2;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 850;
}

.detail-badge {
  background: #eef2f7;
  color: #455166;
}

.rpe-badge {
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.history-set-pill {
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

.history-set-pill:hover,
.history-set-pill:focus-visible {
  background: #dbe7ef;
  color: #263444;
}

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

.exercise-list,
.routine-list,
.routine-item-list,
.routine-layout,
.workout-history-list,
.history-layout,
.history-workout-exercises {
  display: grid;
  gap: 10px;
}

.history-calendar-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
  padding: 16px;
}

.history-export-actions {
  display: flex;
  justify-content: center;
  margin-top: 28px;
}

.history-export-actions button {
  width: 100%;
  max-width: 1000px;
}

.history-export-actions .export-history-button,
.history-export-actions .export-history-button:disabled {
  background: #2563eb;
  color: #ffffff;
}

.history-export-actions .export-history-button:hover {
  background: #1d4ed8;
}

.history-calendar-header {
  margin-bottom: 0;
  align-items: center;
}

.history-calendar-nav {
  display: grid;
  grid-template-columns: auto minmax(0, max-content) auto;
  gap: 8px;
  align-items: center;
}

.history-calendar-month {
  margin: 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

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

.history-calendar-weekday {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.history-calendar-cell {
  display: grid;
  align-content: space-between;
  justify-items: start;
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  text-align: left;
}

.history-calendar-cell:disabled {
  background: #f5f7fb;
  color: var(--muted);
  cursor: default;
  opacity: 0.75;
}

.history-calendar-cell.has-workouts {
  background: linear-gradient(180deg, #eef4ff 0%, #ffffff 100%);
  border-color: rgba(37, 99, 235, 0.25);
}

.history-calendar-cell.today {
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.32);
}

.history-calendar-cell.selected {
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.12);
}

.history-calendar-cell:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.history-calendar-cell-empty {
  min-height: 64px;
  border: 1px dashed transparent;
  background: transparent;
}

.history-calendar-day-number {
  font-size: 0.95rem;
  font-weight: 800;
}

.history-calendar-count {
  justify-self: end;
  min-width: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 22px;
  text-align: center;
}

.workout-day-chooser-modal {
  width: min(100%, 460px);
}

.workout-day-chooser-date {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.workout-day-chooser-list {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.workout-day-choice {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  background: #f7f9fc;
  color: var(--text);
  text-align: left;
}

.workout-day-choice:hover {
  background: #eef3fb;
}

.workout-day-choice-title {
  font-size: 0.98rem;
  font-weight: 800;
}

.workout-day-choice-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.exercise-row,
.routine-card,
.routine-item-row,
.workout-history-card {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.routine-card,
.workout-history-card {
  cursor: pointer;
}

.workout-history-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.routine-card.selected,
.workout-history-card.selected {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 18px 45px rgba(37, 99, 235, 0.12);
}

.routine-editor,
.workout-history-detail {
  padding: 16px;
}

.workout-history-form,
.history-set-grid {
  display: grid;
  gap: 14px;
}

.history-set-grid {
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  align-items: stretch;
}

.history-exercise-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.history-exercise-card .section-heading {
  margin-bottom: 0;
  gap: 10px;
  align-items: start;
}

.history-exercise-card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.history-exercise-title-block {
  display: grid;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

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

.history-exercise-title-copy {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25em;
  min-width: 0;
  flex: 1 1 auto;
}

.history-exercise-edit-button {
  min-width: 38px;
  width: 38px;
  padding: 0;
  flex: 0 0 auto;
}

.history-exercise-card h3 {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}

.history-exercise-title-row h3 {
  margin: 0;
  min-width: 0;
  flex: 0 0 auto;
  width: fit-content;
}

.history-exercise-rpe-inline {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}

.history-exercise-notes {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.history-set-row {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.history-set-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

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

.history-set-summary .detail-badge,
.history-set-summary .type-badge {
  white-space: nowrap;
}

.history-rpe-display {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.history-rpe-value {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  background: #eef2f7;
  color: var(--text);
  font-weight: 800;
}

.history-exercise-edit-form {
  display: grid;
  gap: 14px;
}

.history-exercise-edit-fields {
  display: grid;
  gap: 14px;
}

.history-exercise-edit-modal {
  width: min(100%, 720px);
}

.rpe-field {
  display: grid;
  gap: 8px;
}

.rpe-slider-row {
  --rpe-value-width: 48px;
  --rpe-row-gap: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--rpe-value-width);
  align-items: center;
  gap: var(--rpe-row-gap);
}

.rpe-slider {
  accent-color: var(--primary);
}

.rpe-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  background: #eef2f7;
  color: var(--text);
  font-weight: 850;
}

.rpe-scale {
  position: relative;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  align-items: start;
  width: calc(100% - 60px);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  padding-bottom: 18px;
}

.rpe-scale::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 13px;
  background:
    linear-gradient(
      90deg,
      #16a34a 0%,
      #16a34a 10%,
      #65a30d 10%,
      #65a30d 20%,
      #84cc16 20%,
      #84cc16 30%,
      #eab308 30%,
      #eab308 40%,
      #f59e0b 40%,
      #f59e0b 50%,
      #fb923c 50%,
      #fb923c 60%,
      #f97316 60%,
      #f97316 70%,
      #ef4444 70%,
      #ef4444 80%,
      #dc2626 80%,
      #dc2626 90%,
      #b91c1c 90%,
      #b91c1c 100%
    );
  clip-path: polygon(0 100%, 100% 0, 100% 100%);
  border-radius: 2px;
}

.rpe-scale span {
  display: flex;
  justify-content: center;
  position: relative;
  min-width: 0;
}

.workout-rpe-field {
  --selected-rpe: 5;
  --rpe-fill-percent: 44.444444%;
  gap: 10px;
}

.workout-notes-field label {
  display: grid;
  gap: 6px;
}

.workout-notes-field textarea {
  min-height: 76px;
  resize: vertical;
  font: inherit;
  line-height: 1.45;
  white-space: pre-wrap;
}

.workout-rpe-value {
  display: block;
  text-align: left;
  color: #111111;
  font-size: clamp(2.25rem, 7vw, 3.25rem);
  font-weight: 900;
  line-height: 1;
}

.workout-rpe-slider {
  position: relative;
  width: 100%;
  padding-block: 14px 6px;
}

.workout-rpe-track,
.workout-rpe-track-fill {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 18px;
  border-radius: 999px;
  transform: translateY(-50%);
  pointer-events: none;
}

.workout-rpe-track {
  z-index: 0;
  background: #e5e7eb;
  border: 1px solid rgba(21, 24, 30, 0.1);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
}

.workout-rpe-track-fill {
  z-index: 1;
  background: linear-gradient(
    90deg,
    #16a34a 0%,
    #65a30d 14%,
    #84cc16 28%,
    #eab308 42%,
    #f59e0b 58%,
    #fb923c 72%,
    #f97316 84%,
    #ef4444 93%,
    #b91c1c 100%
  );
  border: 1px solid rgba(21, 24, 30, 0.1);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.08);
  clip-path: inset(0 calc(100% - var(--rpe-fill-percent)) 0 0 round 999px);
}

.workout-rpe-range {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  z-index: 2;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

.workout-rpe-range:focus {
  outline: none;
}

.workout-rpe-range::-webkit-slider-runnable-track {
  height: 18px;
  background: transparent;
}

.workout-rpe-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 30px;
  height: 30px;
  margin-top: -7px;
  border: 2px solid #111111;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.16);
}

.workout-rpe-range::-moz-range-track {
  height: 18px;
  background: transparent;
  border: 0;
}

.workout-rpe-range::-moz-range-progress {
  height: 18px;
  background: transparent;
  border: 0;
}

.workout-rpe-range::-moz-range-thumb {
  width: 30px;
  height: 30px;
  border: 2px solid #111111;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.16);
}

.workout-rpe-range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18), 0 4px 10px rgba(15, 23, 42, 0.16);
}

.workout-rpe-range:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18), 0 4px 10px rgba(15, 23, 42, 0.16);
}

.history-rpe-field {
  max-width: 420px;
}

.routine-item-list {
  margin-top: 14px;
}

.routine-item-row {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  box-shadow: none;
}

.routine-item-row[draggable="true"] {
  cursor: grab;
}

.routine-item-row.dragging {
  opacity: 0.55;
  cursor: grabbing;
}

.routine-item-row.drag-over-before::before,
.routine-item-row.drag-over-after::after {
  position: absolute;
  right: 12px;
  left: 12px;
  height: 3px;
  border-radius: 999px;
  background: var(--primary);
  content: "";
}

.routine-item-row.drag-over-before::before {
  top: -9px;
}

.routine-item-row.drag-over-after::after {
  bottom: -9px;
}

.workout-start-form,
.workout-set-form {
  display: grid;
  gap: 16px;
}

.workout-session,
.workout-rest,
.workout-complete {
  padding: 18px;
}

.workout-session {
  position: relative;
}

.workout-rest {
  display: grid;
  justify-items: center;
  gap: 18px;
  text-align: center;
}

.workout-rest-next {
  margin: -2px 0 0;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 850;
  line-height: 1.35;
}

.workout-rest-history-preview {
  width: min(100%, 420px);
  text-align: left;
}

.workout-rest-history-preview .workout-history-preview {
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.rest-pie {
  --rest-progress: 0deg;
  display: grid;
  place-items: center;
  width: min(62vw, 260px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--primary) 0deg var(--rest-progress), #e7ebf2 var(--rest-progress) 360deg);
  box-shadow: inset 0 0 0 12px #ffffff, var(--shadow);
}

.rest-pie span {
  display: grid;
  place-items: center;
  width: 52%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #ffffff;
  color: var(--text);
  font-size: 3rem;
  font-weight: 900;
}

.set-timer-panel {
  display: grid;
  gap: 12px;
  align-content: end;
}

.set-timer-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 12px;
  align-items: end;
}

.set-timer-input-row label {
  min-width: 0;
}

.set-timer-button {
  display: inline-grid;
  place-items: center;
  min-height: 58px;
  width: 58px;
  min-width: 58px;
  padding: 0;
}

.icon-timer {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.set-timer-display {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.set-timer-pie {
  width: min(46vw, 150px);
  box-shadow: inset 0 0 0 8px #ffffff, 0 10px 26px rgba(15, 23, 42, 0.08);
}

.set-timer-pie span {
  font-size: 1.75rem;
}

.workout-session-header {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.workout-progress-group {
  display: grid;
  gap: 2px;
}

.workout-session-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.workout-session-menu {
  display: flex;
  position: relative;
  flex: 0 0 auto;
  align-items: center;
}

.workout-session-header h2 {
  margin: 4px 0 0;
  min-width: 0;
  flex: 1 1 auto;
  font-size: 1.95rem;
}

.workout-exercise-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  height: 42px;
  min-height: 42px;
  width: 42px;
  min-width: 42px;
  padding: 0;
  border-radius: 10px;
}

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

.icon-chevron {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

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

.workout-exercise-progress {
  --progress-segment-size: 100%;
  --progress-slant: 16deg;
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 16px;
  margin: 0;
  border-radius: 0;
  background: #e5e7eb;
  box-shadow: inset 0 0 0 1px rgba(21, 24, 30, 0.06);
  transform: skewX(calc(var(--progress-slant) * -1));
  transform-origin: left center;
}

.workout-exercise-progress::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc(var(--progress-segment-size) - 2px),
    rgba(255, 255, 255, 0.92) calc(var(--progress-segment-size) - 2px),
    rgba(255, 255, 255, 0.92) var(--progress-segment-size)
  );
  pointer-events: none;
}

.workout-exercise-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb 0%, #3b82f6 100%);
  transition: width 180ms ease-out;
}

.workout-set-progress .workout-exercise-progress-fill {
  background: linear-gradient(90deg, #0f766e 0%, #14b8a6 100%);
}

.workout-progress {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.workout-hint,
.workout-complete-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.workout-history-preview {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(217, 222, 232, 0.9);
  border-radius: 12px;
  background: #fbfcfe;
}

.workout-history-preview-header {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workout-history-preview-header h3 {
  color: var(--text);
  font-size: 1rem;
  font-weight: 850;
}

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

.workout-history-preview-summary .history-set-pill {
  min-height: 24px;
  padding: 0 8px;
  font-size: 0.88rem;
  line-height: 1;
}

.workout-history-preview-summary .history-set-pill-preview {
  font-size: 0.88rem;
}

.workout-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  min-width: 176px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.14);
}

.workout-session-menu .workout-menu-panel {
  display: grid;
  gap: 5px;
}

.workout-menu-item {
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.workout-menu-item:hover {
  background: #f3f5f9;
}

.workout-menu-item.active {
  background: #e7ebf2;
  color: var(--text);
}

.danger-text,
.danger-text:hover {
  color: var(--danger);
}

#workoutContinueButton {
  min-height: 122px;
  font-size: 1.15rem;
}

.workout-loading-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: 8px;
  background: rgba(245, 246, 248, 0.78);
  backdrop-filter: blur(3px);
}

.workout-loading-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(100%, 380px);
  padding: 16px 18px;
  border: 1px solid rgba(217, 222, 232, 0.9);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 20px 42px rgba(15, 23, 42, 0.14);
}

.workout-loading-spinner {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 4px solid #dbe3ef;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: workout-spin 0.85s linear infinite;
}

.workout-loading-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.workout-loading-title {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 850;
}

.workout-loading-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.35;
}

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

.workout-hint + .form-message {
  margin-top: 8px;
}

.workout-measure-fields {
  display: grid;
  gap: 12px;
}

.freeform-exercise-picker,
.freeform-exercise-form {
  display: grid;
  gap: 12px;
}

.freeform-exercise-picker {
  grid-column: 1 / -1;
}

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

.workout-weighted-fields .weight-reported-as-toggle {
  grid-column: 1 / -1;
}

.workout-measure-fields input {
  min-height: 58px;
  font-size: 1.15rem;
}

.workout-set-log {
  display: grid;
  grid-template-columns: repeat(var(--workout-set-columns, 1), minmax(110px, 1fr));
  gap: 10px;
  margin-top: 16px;
  overflow-x: auto;
}

.workout-set-chip {
  display: grid;
  justify-items: start;
  align-content: start;
  gap: 4px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--text);
  font-size: 0.92rem;
  text-align: left;
}

button.workout-set-chip:hover {
  background: #f3f6fb;
}

button.workout-set-chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.workout-set-chip span:first-child {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.2;
}

.workout-set-chip span:last-child {
  color: var(--text);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
}

.workout-notes-chip span:last-child {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.38);
  overflow: auto;
  overscroll-behavior: contain;
}

.modal-card {
  width: min(100%, 460px);
  padding: 18px;
  max-height: calc(100dvh - 36px);
}

.workout-set-edit-modal,
.freeform-exercise-modal,
.freeform-workout-rest-modal,
.history-exercise-edit-modal {
  width: min(100%, 720px);
  max-height: calc(100dvh - 36px);
  overflow: auto;
}

.workout-history-modal {
  width: min(100%, 920px);
  max-height: min(calc(100dvh - 36px), 920px);
  overflow: auto;
}

.exercise-progress-modal {
  width: min(100%, 920px);
  max-height: min(calc(100dvh - 36px), 920px);
  overflow: auto;
}

.exercise-progress-description {
  margin: 8px 0 14px;
  color: var(--muted);
  line-height: 1.5;
}

.exercise-progress-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.exercise-progress-chart {
  position: relative;
}

.exercise-progress-chart-frame {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfcfe;
}

.exercise-progress-chart-svg {
  display: block;
  width: 100%;
  max-width: 100%;
}

.progress-chart-grid {
  stroke: #dfe5ee;
  stroke-width: 1;
}

.progress-chart-axis {
  stroke: #8490a3;
  stroke-width: 1.5;
}

.progress-chart-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.progress-chart-point {
  fill: var(--primary);
  stroke: #ffffff;
  stroke-width: 3;
  cursor: pointer;
}

.progress-chart-point:focus,
.progress-chart-point:hover {
  fill: var(--accent);
  stroke: #c9f3ee;
  stroke-width: 5;
  outline: none;
}

.progress-chart-y-label,
.progress-chart-x-label,
.progress-chart-axis-title {
  fill: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 750;
}

.progress-chart-axis-title {
  fill: var(--text);
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
}

.exercise-progress-point-detail {
  position: absolute;
  z-index: 2;
  width: min(280px, calc(100% - 16px));
  max-height: 280px;
  overflow: auto;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.2);
  transform: translate(-50%, -100%);
}

.exercise-progress-point-detail.below {
  transform: translateX(-50%);
}

.exercise-progress-point-detail-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.exercise-progress-point-detail-header span,
.exercise-progress-point-detail-header strong {
  display: block;
}

.exercise-progress-point-detail-header span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.exercise-progress-point-detail-header strong {
  margin-top: 2px;
  font-size: 1rem;
}

.exercise-progress-point-detail-header button {
  min-width: 34px;
  min-height: 34px;
  padding: 0 8px;
}

.exercise-progress-point-detail table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.exercise-progress-point-detail th,
.exercise-progress-point-detail td {
  padding: 7px 6px;
  border-top: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.exercise-progress-point-detail th {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.exercise-progress-point-detail th:first-child,
.exercise-progress-point-detail td:first-child {
  text-align: left;
}

.exercise-progress-point-detail td span {
  color: var(--muted);
  font-size: 0.72rem;
}

.exercise-progress-details {
  margin-top: 18px;
}

.exercise-progress-details h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.exercise-progress-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.exercise-progress-table th,
.exercise-progress-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.exercise-progress-table th {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.exercise-progress-table th:first-child,
.exercise-progress-table td:first-child {
  width: 28%;
  white-space: nowrap;
}

.exercise-progress-table th:nth-child(2),
.exercise-progress-table td:nth-child(2) {
  overflow-wrap: anywhere;
}

.exercise-progress-table th:last-child,
.exercise-progress-table td:last-child {
  width: 30%;
  text-align: right;
  white-space: nowrap;
}

.exercise-progress-table tbody tr:last-child td {
  border-bottom: 0;
}

#historyExerciseEditModal {
  z-index: 50;
}

.workout-history-modal-header {
  margin-bottom: 0;
  align-items: start;
}

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

.workout-set-edit-form {
  display: grid;
  gap: 14px;
}

.freeform-workout-rest-form {
  display: grid;
  gap: 14px;
}

.freeform-workout-rest-modal {
  width: min(100%, 460px);
}

.freeform-workout-rest-none {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
}

.freeform-workout-rest-none input {
  width: auto;
  min-width: 18px;
  min-height: 18px;
  margin: 0;
}

.history-notes-field {
  display: grid;
  gap: 6px;
}

.history-notes-field textarea {
  min-height: 76px;
  resize: vertical;
  font: inherit;
  line-height: 1.45;
  white-space: pre-wrap;
}

.exercise-main {
  min-width: 0;
}

.exercise-main h3 {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
  font-size: 1.05rem;
}

.empty-state {
  margin: 18px 0;
  color: var(--muted);
  font-weight: 700;
}

@media (min-width: 680px) {
  .auth-view {
    grid-template-columns: minmax(0, 0.95fr) minmax(320px, 0.75fr);
    align-items: center;
  }

  .exercise-form {
    grid-template-columns: minmax(0, 1fr) minmax(180px, 0.35fr) minmax(180px, 0.35fr) auto;
    align-items: end;
  }

  .form-actions {
    grid-auto-flow: column;
    align-items: end;
  }

  .exercise-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .routine-layout {
    grid-template-columns: minmax(260px, 0.8fr) minmax(0, 1.2fr);
    align-items: start;
    gap: 14px;
  }

  .routine-form {
    grid-template-columns: minmax(0, 1fr) minmax(170px, 0.35fr) auto;
    align-items: end;
  }

  .routine-item-form {
    grid-template-columns: minmax(0, 1fr) minmax(96px, 0.25fr) minmax(96px, 0.25fr) auto;
    align-items: end;
  }

  .routine-card,
  .routine-item-row,
  .workout-history-card {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .history-set-row {
    grid-template-columns: 70px repeat(2, minmax(0, 1fr));
    align-items: end;
  }

  .workout-start-form {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 0.8fr) auto;
    align-items: end;
  }

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

  .freeform-exercise-picker {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .row-actions {
    grid-auto-flow: column;
  }
}
