:root {
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e6e6e2;
  --accent: #c0392b;
  --accent-soft: #fbecea;
  --paper: #ffffff;
  --tint: #f7f6f2;
  --shadow: 0 1px 2px rgba(20, 20, 20, 0.04), 0 8px 24px rgba(20, 20, 20, 0.06);
  --sans: "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background: var(--tint);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

header {
  max-width: 840px;
  margin: 2.5rem auto 0;
  padding: 2rem 2rem 1.75rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 5px solid var(--accent);
  border-radius: 10px 10px 0 0;
  box-shadow: var(--shadow);
}

header .eyebrow {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.6rem;
}

header h1 {
  margin: 0 0 0.5rem;
  font-size: 2.15rem;
  line-height: 1.15;
  letter-spacing: -0.015em;
  font-weight: 700;
}

.sub {
  margin: 0;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
  max-width: 60ch;
}

.sub-2 {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 60ch;
}

main {
  max-width: 840px;
  margin: 0 auto;
  padding: 1.25rem 0 2rem;
  display: grid;
  gap: 1.25rem;
}

section {
  padding: 1.75rem 2rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

h2 {
  margin: 0 0 1.25rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
}

h2::before {
  content: attr(data-num);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--paper);
  background: var(--accent);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

h3 {
  margin: 1.5rem 0 0.75rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ---- inputs header + unit toggle ---- */
.inputs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
}

.inputs-head h2 {
  margin: 0;
  padding: 0;
  border: none;
}

.unit-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  font-family: var(--sans);
}

.unit-toggle label {
  margin: 0;
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  background: var(--tint);
}

.unit-toggle label:first-child {
  border-right: 1px solid var(--line);
}

.unit-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}

.unit-toggle label:has(input:checked) {
  background: var(--accent);
  color: var(--paper);
}

/* ---- efforts ---- */
.effort-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.effort {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.1rem 1.1rem 1.2rem;
  background: var(--tint);
  position: relative;
}

.effort-tag {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--paper);
  background: var(--ink);
  border-radius: 4px;
}

label {
  display: block;
  margin-top: 0.9rem;
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

input,
select {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.5rem 0.6rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 1.05rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---- threshold field ---- */
.threshold-field {
  display: block;
  margin-top: 1rem;
  max-width: 220px;
}

/* ---- advanced settings ---- */
.advanced {
  margin-top: 1.25rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.advanced > summary {
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  list-style: revert;
}

.advanced-body {
  margin-top: 1rem;
  display: grid;
  gap: 0.5rem;
  max-width: 420px;
}

.field-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
  font-family: var(--sans);
}

label.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

label.check input {
  width: auto;
  margin: 0;
}

/* ---- confidence ---- */
.confidence {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 6px;
  background: var(--tint);
  font-family: var(--sans);
  font-size: 0.85rem;
}

.confidence .conf-badge {
  font-weight: 700;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.confidence .conf-msg {
  color: var(--muted);
}

.confidence.high {
  border-left-color: #2e7d32;
}
.confidence.high .conf-badge {
  color: #2e7d32;
}
.confidence.medium {
  border-left-color: #b8860b;
}
.confidence.medium .conf-badge {
  color: #b8860b;
}
.confidence.low,
.confidence.warn {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}
.confidence.low .conf-badge,
.confidence.warn {
  color: var(--accent);
}

.hint {
  color: var(--muted);
  font-size: 0.8rem;
  font-family: var(--sans);
  margin: 0.9rem 0 0;
}

/* ---- metrics ---- */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.metric {
  padding: 0.9rem 1rem;
  background: var(--tint);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
}

.metric .value {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.1;
}

.metric .name {
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* ---- tables ---- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.96rem;
}

th,
td {
  text-align: left;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

thead th {
  font-family: var(--sans);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--ink);
}

tbody tr:nth-child(even) {
  background: var(--tint);
}

tbody tr:hover {
  background: var(--accent-soft);
}

tbody td:first-child {
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: none;
}

.rng {
  display: block;
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* ---- planner ---- */
.planner-tabs {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.ptab {
  border: none;
  background: var(--tint);
  padding: 0.5rem 1rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}

.ptab + .ptab {
  border-left: 1px solid var(--line);
}

.ptab.active {
  background: var(--accent);
  color: var(--paper);
}

.planner-race {
  max-width: 220px;
}

.planner-mode {
  margin-top: 1rem;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.slider-row input[type="range"] {
  flex: 1;
  padding: 0;
  accent-color: var(--accent);
}

#plannerPowerVal {
  font-size: 1.3rem;
  font-weight: 700;
  min-width: 4.5rem;
  text-align: right;
}

.planner-result {
  margin-top: 1.25rem;
}

.plan-out {
  display: flex;
  gap: 3rem;
  flex-wrap: wrap;
}

.po-label {
  font-family: var(--sans);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.po-val {
  font-size: 1.7rem;
  font-weight: 700;
  margin-top: 0.2rem;
}

/* ---- advanced analysis section ---- */
.adv-analysis {
  margin: 0;
  border: none;
  padding: 0;
}

.adv-summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink);
}

.adv-summary .adv-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--paper);
  background: var(--accent);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

.advanced-analysis {
  margin-top: 1.5rem;
}

footer {
  max-width: 840px;
  margin: 0 auto 2.5rem;
  padding: 1.1rem 2rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.76rem;
  text-align: center;
}

footer p {
  margin: 0.35rem 0;
}

footer .source {
  font-size: 0.72rem;
  opacity: 0.85;
}
