:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #ffffff;
  --ink: #101820;
  --muted: #697277;
  --line: #d8d3c8;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warm: #c75b39;
  --danger: #b42318;
  --shadow: 0 16px 35px rgba(16, 24, 32, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.14), transparent 280px),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(26px, env(safe-area-inset-bottom));
}

.topbar,
.section-heading,
.exercise-card,
.measurement-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  padding: 6px 0 18px;
}

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

h1 {
  font-size: clamp(2rem, 8vw, 3.4rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1rem;
}

.eyebrow,
.metric-label,
.fine-print {
  color: var(--muted);
  font-size: 0.78rem;
}

.eyebrow {
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.metric-card,
.view,
dialog,
.panel-form,
.measurement-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 86px;
  padding: 14px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.45rem, 8vw, 2rem);
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 18px 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(244, 241, 234, 0.88);
  backdrop-filter: blur(16px);
}

.tab-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab-button.active {
  background: var(--ink);
  color: white;
}

.view {
  display: none;
  padding: 16px;
}

.view.active {
  display: block;
}

.section-heading {
  margin-bottom: 16px;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  background: var(--accent);
  color: white;
  padding: 0 16px;
}

.primary-button:active {
  background: var(--accent-strong);
}

.secondary-button {
  background: #e4dfd4;
  color: var(--ink);
  padding: 0 14px;
}

.danger-button {
  background: #fee4e2;
  color: var(--danger);
  padding: 0 14px;
}

.icon-button {
  width: 44px;
  flex: 0 0 44px;
  background: var(--ink);
  color: white;
  font-size: 1.35rem;
}

select,
input,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.panel-form,
.stack {
  display: grid;
  gap: 12px;
}

.panel-form {
  margin-bottom: 14px;
  padding: 14px;
  box-shadow: none;
}

.inline-input,
.selector-pair,
.settings-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.inline-input select {
  width: 86px;
}

.selector-pair {
  grid-template-columns: 1fr 1fr;
  width: min(320px, 100%);
}

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

.exercise-card,
.check-row,
.measurement-row {
  margin-bottom: 10px;
  padding: 13px;
  box-shadow: none;
}

.exercise-card p,
.check-row p,
.measurement-row p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
}

.check-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

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

.check-row.done h3,
.check-row.done p {
  text-decoration: line-through;
  color: var(--muted);
}

.phase-band {
  margin: 16px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.week-grid {
  display: grid;
  gap: 10px;
}

.compact {
  min-width: 78px;
}

.workout-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.workout-actions button {
  flex: 1;
}

.complete-toggle {
  width: 100%;
  margin-top: 14px;
}

.file-label {
  place-items: center;
}

.file-label input {
  display: none;
}

dialog {
  width: min(680px, calc(100% - 24px));
  border: 1px solid var(--line);
  padding: 0;
}

dialog::backdrop {
  background: rgba(16, 24, 32, 0.48);
}

.dialog-body {
  display: grid;
  gap: 13px;
  padding: 16px;
}

.video-frame {
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101820;
}

.video-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.video-link {
  display: grid;
  place-items: center;
  text-decoration: none;
}

.empty-state {
  padding: 20px 0;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 420px) {
  .app-shell {
    padding-inline: 12px;
  }

  .status-grid {
    gap: 8px;
  }

  .metric-card {
    padding: 10px;
  }

  .tabs {
    gap: 4px;
  }

  .tab-button {
    font-size: 0.82rem;
  }

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

  .selector-pair {
    width: 100%;
  }
}
