:root {
  --bg: #0a0a0a;
  --surface: #161616;
  --surface-2: #1f1f1f;
  --border: #2a2a2a;
  --text: #f5f5f5;
  --text-muted: #9a9a9a;
  --accent: #c4ff3d;
  --accent-press: #aee62e;
  --accent-ink: #0a0a0a;
  --danger: #ff5b5b;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 20px;
  --space-2xl: 24px;
  --space-4xl: 32px;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: max(var(--space-xl), env(safe-area-inset-top)) var(--space-lg)
    calc(var(--space-4xl) + env(safe-area-inset-bottom));
}

.app-header {
  margin-bottom: var(--space-2xl);
}
.app-header h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
}
.tagline {
  margin: 2px 0 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.field { display: flex; flex-direction: column; gap: var(--space-sm); }
.field > label,
.flags legend {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0;
}

select {
  appearance: none;
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%239a9a9a' stroke-width='2'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-lg) center;
}

.adr-stepper {
  display: flex;
  align-items: stretch;
  gap: var(--space-sm);
}
.stepper-btn {
  flex: 0 0 56px;
  font-size: 26px;
  font-weight: 600;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
}
.stepper-btn:active { background: var(--surface-2); }
.adr-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-sm);
}
.adr-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.flags {
  border: none;
  margin: 0;
  padding: 0;
}
.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.toggle {
  position: relative;
}
.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.toggle span {
  display: inline-block;
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.toggle input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.toggle input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  width: 100%;
  padding: var(--space-lg);
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary:active { background: var(--accent-press); }
.btn-primary:disabled { opacity: 0.5; cursor: progress; }

.btn-secondary {
  width: 100%;
  margin-top: var(--space-lg);
  padding: var(--space-md);
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary:active { background: rgba(196, 255, 61, 0.1); }

button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.output {
  margin-top: var(--space-2xl);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-xl);
}
.wod-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: var(--space-md);
  margin-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}
.wod-gym {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}
.wod-session {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}
.wod-body {
  font-size: 15px;
  line-height: 1.6;
}

/* Fatigue / session notes above the workout */
.wod-note {
  font-style: italic;
  opacity: 0.5;
  font-size: 14px;
  margin: 0 0 var(--space-md);
}

/* Intro text for S&D / Machine Explorer */
.wod-intro {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 var(--space-lg);
}

/* Footer note */
.wod-footer-note {
  font-size: 13px;
  color: var(--text-muted);
  margin: var(--space-lg) 0 0;
}

/* Workout sections */
.wod-section {
  margin-bottom: var(--space-2xl);
}
.wod-section-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 var(--space-md);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--border);
}

/* Exercise list */
.exercise-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: exercise-counter;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}
.exercise-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  counter-increment: exercise-counter;
}
.exercise-item::before {
  content: counter(exercise-counter) ".";
  color: var(--text-muted);
  font-size: 14px;
  flex-shrink: 0;
  min-width: 18px;
  padding-top: 2px;
}
.exercise-detail {
  flex: 1;
  min-width: 0;
}
.exercise-name {
  font-size: 15px;
  font-weight: 600;
}
.exercise-scheme {
  font-size: 15px;
  color: var(--text-muted);
}
.exercise-note {
  display: block;
  font-style: italic;
  opacity: 0.5;
  font-size: 13px;
  margin-top: 2px;
}

/* Swap button */
.swap-btn {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 14px;
  padding: 1px 7px;
  cursor: pointer;
  line-height: 1.6;
  align-self: flex-start;
  margin-top: 1px;
}
.swap-btn:hover { color: var(--text); border-color: var(--text-muted); }
.swap-btn:active { background: var(--surface-2); }
.swap-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.status {
  margin-top: var(--space-lg);
  min-height: 1.2em;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
}
.status.error { color: var(--danger); }
