:root {
  --phoenix-orange: #E8620A;
  --forge-gold: #D4A017;
  --deep-ember: #8B2500;
  --forge-black: #0A0A0A;
  --off-white: #F5F5F5;
  --slate-gray: #444444;
  --slate-light: #777777;
  --line: #e5e5e5;
  --line-soft: #efefef;
  --bg: #fafafa;
  --surface: #ffffff;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 6px;
  --max-width: 720px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--slate-gray);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wordmark {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--forge-black);
}

.tagline {
  margin: 0;
  font-size: 14px;
  color: var(--slate-light);
}

.header-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.unit-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.unit-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 6px 12px;
  font: inherit;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--slate-light);
  cursor: pointer;
}

.unit-btn.is-active {
  background: var(--forge-black);
  color: var(--off-white);
}

.unit-btn:focus-visible {
  outline: 2px solid var(--phoenix-orange);
  outline-offset: -2px;
}

.ghost-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--slate-gray);
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  border-radius: var(--radius);
  cursor: pointer;
}

.ghost-btn:hover {
  border-color: var(--slate-light);
  color: var(--forge-black);
}

.ghost-btn:focus-visible {
  outline: 2px solid var(--phoenix-orange);
  outline-offset: 2px;
}

.site-main {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 16px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  flex: 1;
}

.section-heading {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate-light);
}

.entry-section,
.summary-section,
.rides-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.ride-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-gray);
  letter-spacing: 0.01em;
}

.unit-suffix {
  font-family: var(--font-mono);
  font-weight: 400;
  color: var(--slate-light);
  margin-left: 2px;
}

.text-input {
  appearance: none;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--forge-black);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 16px;
  padding: 10px 12px;
}

.text-input::placeholder {
  color: #b8b8b8;
}

.text-input:hover {
  border-color: var(--slate-light);
}

.text-input:focus {
  outline: none;
  border-color: var(--phoenix-orange);
  box-shadow: 0 0 0 3px rgba(232, 98, 10, 0.15);
}

/* RPE slider — visual hero of the form. */
.rpe-field {
  gap: 10px;
}

.rpe-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.rpe-value {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
  font-size: 32px;
  font-weight: 600;
  color: var(--forge-black);
  line-height: 1;
}

.rpe-slider {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 14px;
  margin: 6px 0 0;
  padding: 0;
  background: linear-gradient(
    to right,
    #d8d8d8 0%,
    var(--slate-light) 35%,
    var(--deep-ember) 75%,
    var(--phoenix-orange) 100%
  );
  border-radius: 999px;
  border: 1px solid var(--line);
  outline: none;
  cursor: pointer;
}

.rpe-slider::-webkit-slider-runnable-track {
  height: 14px;
  background: transparent;
  border-radius: 999px;
}

.rpe-slider::-moz-range-track {
  height: 14px;
  background: transparent;
  border-radius: 999px;
  border: none;
}

.rpe-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--forge-black);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.rpe-slider::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--forge-black);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(0, 0, 0, 0.15);
  cursor: pointer;
}

.rpe-slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 1px var(--line), 0 0 0 4px rgba(232, 98, 10, 0.35);
}

.rpe-slider:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 1px var(--line), 0 0 0 4px rgba(232, 98, 10, 0.35);
}

.rpe-scale {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--slate-light);
  margin-top: 4px;
}

.rpe-end-high {
  color: var(--phoenix-orange);
}

.form-error {
  margin: 0;
  font-size: 13px;
  color: var(--deep-ember);
  background: #fbeee6;
  border: 1px solid #f3d4bf;
  border-radius: var(--radius);
  padding: 8px 12px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.primary-btn {
  appearance: none;
  border: 0;
  background: var(--phoenix-orange);
  color: var(--off-white);
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  padding: 10px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  min-width: 120px;
  transition: background-color 120ms ease;
}

.primary-btn:hover {
  background: #d65808;
}

.primary-btn:focus-visible {
  outline: 2px solid var(--forge-black);
  outline-offset: 2px;
}

.primary-btn.is-saved {
  background: var(--forge-black);
}

.weekly-summary {
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
}

.ride-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-feature-settings: "tnum" 1;
}

.site-footer {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 40px;
  border-top: 1px solid var(--line-soft);
}

.footer-line {
  margin: 0;
  font-size: 13px;
  color: var(--slate-gray);
}

.footer-line.muted {
  color: var(--slate-light);
  margin-top: 4px;
}

@media (max-width: 480px) {
  .site-header {
    padding: 24px 16px 12px;
  }
  .site-main {
    padding: 12px 16px 24px;
    gap: 24px;
  }
  .entry-section,
  .summary-section,
  .rides-section {
    padding: 16px;
  }
  .field-row {
    grid-template-columns: 1fr;
  }
  .form-actions {
    justify-content: stretch;
  }
  .primary-btn {
    width: 100%;
  }
  .site-footer {
    padding: 20px 16px 32px;
  }
}