:root {
  color-scheme: light;
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #eef5f1;
  --ink: #202520;
  --muted: #6d756d;
  --line: #d9ddd6;
  --accent: #1f7a5a;
  --accent-2: #0f5d7a;
  --warn: #b06126;
  --danger: #b43636;
  --shadow: 0 18px 55px rgba(24, 34, 28, 0.11);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

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

.auth-panel {
  width: min(100%, 360px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.auth-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 7px;
}

.auth-row input {
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

.auth-status {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.auth-status.error {
  color: var(--danger);
  font-weight: 800;
}

#authSignedIn {
  display: grid;
  gap: 6px;
}

#authSignedIn strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.topbar h1 {
  font-size: clamp(1.55rem, 3vw, 2.55rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.app-tab {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 900;
}

.app-tab.active {
  background: #15201b;
  border-color: #15201b;
  color: #fff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 1.25fr);
  gap: 16px;
}

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

.trainer-panel,
.progress-panel {
  grid-column: span 1;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head h2 {
  font-size: 1.25rem;
  letter-spacing: 0;
}

.trainer-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.badge,
.level-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 5px 11px;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

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

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

.progress-panel {
  transition: box-shadow 180ms ease, border-color 180ms ease;
}

.progress-panel.is-workout-active {
  cursor: pointer;
}

.progress-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.progress-toggle {
  min-height: 30px;
  width: 34px;
  font-size: 1rem;
  line-height: 1;
}

.progress-collapsed-line {
  display: none;
  color: var(--ink);
  line-height: 1.35;
}

.progress-panel.collapsed {
  padding-block: 14px;
}

.progress-panel.collapsed .section-head {
  align-items: center;
  margin-bottom: 0;
}

.progress-panel.collapsed .progress-body {
  display: none;
}

.progress-panel.collapsed .progress-collapsed-line {
  display: block;
  margin-top: 8px;
}

.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 3px;
}

.metric strong {
  display: block;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.progress-track {
  height: 10px;
  background: #e5e5df;
  border-radius: 999px;
  overflow: hidden;
  margin: 16px 0;
}

.progress-track div {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 220ms ease;
}

.next-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: #f7f8f5;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.next-card h3 {
  margin: 2px 0 4px;
}

.next-card p:last-child,
.exercise-card p,
.empty-state p,
.technique-box p,
.details-box li,
.history-list p {
  color: var(--muted);
  line-height: 1.45;
}

.primary-button,
.ghost-button,
.icon-button,
.danger-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 15px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--accent);
}

.ghost-button,
.icon-button {
  color: var(--ink);
  background: #edf0eb;
  border: 1px solid var(--line);
}

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

.danger-button.subtle {
  color: var(--danger);
  background: #fbefef;
  border: 1px solid rgba(180, 54, 54, 0.24);
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 1.35rem;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.tab-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8f5;
  color: var(--muted);
  font-weight: 800;
}

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

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

.exercise-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.exercise-card h3 {
  font-size: 1rem;
  margin-bottom: 4px;
}

.exercise-card span {
  color: var(--accent-2);
  font-weight: 800;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  place-items: start;
  gap: 8px;
  min-height: 280px;
  align-content: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 22px;
  background: #fafaf8;
}

.hidden {
  display: none !important;
}

.trainer-active {
  display: grid;
  gap: 14px;
}

.current-exercise {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.current-exercise h3 {
  font-size: 1.35rem;
  margin: 3px 0 4px;
}

.timer-box {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  background: #15201b;
  color: #fff;
  padding: 14px;
}

.timer-box span {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 700;
}

.timer-box strong {
  font-size: 2.2rem;
  letter-spacing: 0;
}

.timer-actions {
  display: flex;
  gap: 8px;
  grid-column: 1 / -1;
}

.timer-actions .ghost-button {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

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

.set-row {
  display: grid;
  grid-template-columns: 70px 1fr 120px 92px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.set-row strong {
  white-space: nowrap;
}

.set-row span {
  color: var(--muted);
}

.set-row input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 9px;
}

.set-row button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--accent-2);
  color: #fff;
  font-weight: 800;
}

.set-row.done {
  border-color: rgba(31, 122, 90, 0.45);
  background: #f2faf6;
}

.session-notice {
  border: 1px solid rgba(15, 93, 122, 0.22);
  border-radius: 8px;
  padding: 12px;
  background: #eef7fa;
  color: #17495b;
  font-weight: 800;
  line-height: 1.4;
}

.set-technique {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: grid;
  gap: 8px;
  background: #fbfbf9;
  border-radius: 8px;
  padding: 12px;
}

.set-technique .check-row {
  margin-bottom: 0;
  align-items: flex-start;
  font-weight: 800;
}

.set-technique p {
  color: var(--muted);
  line-height: 1.42;
}

.set-criteria-title {
  color: var(--ink);
  font-size: 0.88rem;
}

.work-timer-button {
  justify-self: start;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: #244f85;
  color: #fff;
  font-weight: 800;
}

.next-step-hint {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fbfbf9;
}

.next-step-hint span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.next-step-hint strong {
  color: var(--ink);
  line-height: 1.35;
}

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

.routine-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #f7f8f5;
}

.routine-item strong {
  display: block;
  margin-bottom: 3px;
}

.routine-item span {
  color: var(--muted);
  line-height: 1.4;
}

.routine-details {
  margin-top: 8px;
}

.routine-details summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 900;
}

.routine-technique {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.routine-technique p {
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.42;
}

.routine-technique b {
  color: var(--ink);
}

.technique-box,
.details-box,
.exercise-note-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfbf9;
}

.exercise-note-box {
  display: grid;
  gap: 8px;
}

.exercise-note-box label {
  color: var(--ink);
  font-weight: 900;
}

.exercise-note-box textarea {
  width: 100%;
  min-height: 74px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  line-height: 1.4;
}

.history-note {
  margin-top: 6px;
  color: var(--muted);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  margin-bottom: 6px;
}

.check-row input {
  width: 19px;
  height: 19px;
  accent-color: var(--accent);
}

.details-box summary {
  cursor: pointer;
  font-weight: 900;
}

.details-box ul {
  margin: 10px 0 0;
  padding-left: 20px;
}

.details-box h4 {
  margin: 12px 0 6px;
}

.trainer-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.history-item h3 {
  font-size: 1rem;
  margin-bottom: 4px;
}

.history-item ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

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

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 12px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-panel {
    width: 100%;
  }

  .panel {
    padding: 14px;
  }

  .progress-grid,
  .tabs {
    grid-template-columns: 1fr;
  }

  .app-tabs {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .app-tab {
    min-height: 40px;
    padding: 0 6px;
    font-size: 0.9rem;
  }

  .next-card,
  .current-exercise,
  .trainer-actions {
    flex-direction: column;
    align-items: stretch;
  }

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

  .set-row button {
    grid-column: 1 / -1;
  }

  .timer-box {
    grid-template-columns: 1fr;
  }

  .section-head {
    flex-direction: column;
  }

  .trainer-status {
    justify-content: flex-start;
  }

  .danger-button {
    width: 100%;
  }
}
