/* PaceCalc — light "race morning" theme.
   Warm paper surfaces, race-bib red primary (#b91c1c) and running-watch teal
   accent (#115e59 — darkened from teal-600 so small accent text passes AA).
   Lane-line stripes in the tab bar nod to the track. */

:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f3efe9;
  --text: #22262e;
  --text-dim: #5f6572;
  --border: #e4ded4;
  --pc-good: #0e7a4f;
  --pc-warn: #a15c00;
  --pc-lane: rgba(185, 28, 28, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #faf8f5;
    --surface: #ffffff;
    --surface-2: #f3efe9;
    --text: #22262e;
    --text-dim: #5f6572;
    --border: #e4ded4;
  }
}
html {
  color-scheme: light;
}

/* ---------- calculator shell ---------- */
.pcx {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin: 1.4rem 0 1.8rem;
  box-shadow: 0 10px 34px -26px rgba(34, 38, 46, 0.4);
  overflow: hidden;
}
@media (min-width: 54rem) {
  .prose .pcx {
    width: min(62rem, calc(100vw - 2.5rem));
  }
}

/* ---------- mode tabs ---------- */
.pcx-tabs {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background:
    repeating-linear-gradient(
      90deg,
      var(--pc-lane) 0,
      var(--pc-lane) 1px,
      transparent 1px,
      transparent 34px
    ),
    var(--surface-2);
}
.pcx-tabs button {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.pcx-tabs button:hover {
  color: var(--text);
}
.pcx-tabs button.on {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--surface);
}
.pcx-tabs button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.pcx-tabs button,
.pcx select,
.pcx-chip {
  min-height: 44px;
}

/* ---------- panels & fields ---------- */
.pcx-panel {
  padding: 1rem;
}
.pcx-panel > p:first-child {
  margin-top: 0;
}
.pcx-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}
/* :not([hidden]) keeps the class's display rule from overriding the hidden
   attribute on toggleable field wrappers (pitfalls P015). */
.pcx-f:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.pcx-f > span {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.pcx input[type="text"],
.pcx select {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.4rem 0.55rem;
  box-sizing: border-box;
}
.pcx input[type="text"] {
  width: 5.5rem;
}
.pcx input.wide {
  width: 7rem;
}
.pcx input:focus,
.pcx select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent);
}
.pcx-time {
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
}
.pcx-time input[type="text"] {
  width: 3.4rem;
}
.pcx-colon {
  color: var(--text-dim);
  font-weight: 700;
  padding-bottom: 0.5rem;
}
.pcx-timecap {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  display: block;
  margin-bottom: 0.25rem;
}

/* ---------- outputs ---------- */
.pcx-big {
  font-size: 1.9rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0.15rem 0 0.3rem;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.pcx-big .unit {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0;
}
.pcx-sub {
  font-size: 0.92rem;
  color: var(--text-dim);
  margin: 0.2rem 0 0.6rem;
}
.pcx-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.55rem;
  margin: 0.7rem 0;
}
.pcx-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 0.55rem 0.7rem;
}
.pcx-card b {
  display: block;
  font-size: 1.15rem;
  font-weight: 750;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.pcx-card span {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.pcx-note {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 0.5rem 0 0;
}
.pcx-hint {
  font-size: 0.8rem;
  color: var(--pc-warn);
  margin: 0.35rem 0 0;
}
.pcx-hint:empty {
  display: none;
}
.pcx-band {
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--accent);
  margin: 0.15rem 0 0.3rem;
}

/* ---------- tables ---------- */
.pcx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin-top: 0.6rem;
}
.pcx-table th,
.pcx-table td {
  text-align: left;
  padding: 0.38rem 0.55rem;
  border-bottom: 1px solid var(--border);
}
.pcx-table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
}
.pcx-table td {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.pcx-table tr:last-child td {
  border-bottom: none;
}
.pcx-table tr.pc-last td {
  font-weight: 700;
  color: var(--primary);
}
.pcx-scroll {
  max-height: 21rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.pcx-scroll .pcx-table {
  margin-top: 0;
}
.pcx-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
}
.pcx-fintitle {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0.9rem 0 0;
}
.pcx-fintitle:empty {
  display: none;
}

/* ---------- article polish ---------- */
.prose table {
  font-variant-numeric: tabular-nums;
}
.prose table code {
  white-space: nowrap;
}
.prose .pace-tag {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 0.15rem 0.6rem;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}

@media (max-width: 480px) {
  .pcx-panel {
    padding: 0.75rem;
  }
  .pcx-tabs button {
    font-size: 0.76rem;
    padding: 0.65rem 0.6rem;
    min-height: 2.75rem;
  }
  .pcx input[type="text"],
  .pcx select {
    min-height: 2.75rem;
  }
  .pcx-big {
    font-size: 1.5rem;
  }
}
