/* ---------- Tokens ---------- */
/* Dark grey is the house look and the default for every visitor; the light
   theme only applies when someone picks it with the toggle. */
:root {
  color-scheme: dark;
  --bg: #1b1c1e;
  --surface: #242628;
  --surface-2: #2c2e31;
  --surface-3: #373a3d;
  --border: #3a3d41;
  --border-strong: #53575c;
  --grid: #303336;
  --grid-strong: #3f4347;
  --text: #eef0f2;
  --text-2: #c1c5c9;
  --muted: #8e949a;
  --path: #6bb8f5; /* light blue: trajectory and primary accent */
  --track: #7ed99a; /* light green: within ±1 in */
  --track-wash: rgba(126, 217, 154, 0.1);
  --track-edge: rgba(126, 217, 154, 0.36);
  --los: #7b8187;
  --zone: rgba(255, 255, 255, 0.022);
  --danger: #ff8d7e;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.035) inset, 0 16px 34px -24px rgba(0, 0, 0, 0.75);
  --font: 'Barlow', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-cond: 'Barlow Condensed', 'Barlow', ui-sans-serif, system-ui, sans-serif;
  --radius: 14px;
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #eceef0;
  --surface: #fbfcfc;
  --surface-2: #f2f4f5;
  --surface-3: #e5e8ea;
  --border: #d8dcdf;
  --border-strong: #b9bfc4;
  --grid: #e8ebed;
  --grid-strong: #d5d9dc;
  --text: #1b1d1f;
  --text-2: #464b50;
  --muted: #6f767c;
  --path: #1f7fc4;
  --track: #1f9d57;
  --track-wash: rgba(31, 157, 87, 0.1);
  --track-edge: rgba(31, 157, 87, 0.4);
  --los: #8b9197;
  --zone: rgba(0, 0, 0, 0.02);
  --danger: #c0392b;
  --shadow: 0 14px 34px -26px rgba(30, 34, 40, 0.45);
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
p {
  margin: 0;
}
[hidden] {
  display: none !important;
}

.masthead,
main,
.footnote {
  width: 100%;
  max-width: 1880px;
  margin: 0 auto;
  padding-inline: clamp(14px, 2.2vw, 36px);
}

/* ---------- Masthead ---------- */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 18px 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-mark {
  width: 46px;
  height: 32px;
  flex: none;
  overflow: visible;
}
.brand-los {
  stroke: var(--los);
  stroke-width: 1.5;
}
.brand-arc {
  fill: none;
  stroke: var(--path);
  stroke-width: 2.6;
  stroke-linecap: round;
}
.brand h1 {
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: 27px;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}
.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.theme-toggle:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding-bottom: 10px;
}

/* ---------- Settings ---------- */
.settings {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px 16px;
  padding: 18px 20px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  grid-column: span 3;
}
.f-caliber {
  grid-column: span 4;
}
.f-barrel {
  grid-column: span 2;
}
.field > label,
.field > legend {
  display: block;
  padding: 0;
  margin-bottom: 7px;
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.soft {
  color: var(--muted);
  font-weight: 500;
}
.combo {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.combo select {
  flex: 1 1 120px;
}

select,
.custom {
  height: 42px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background-color: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
select {
  min-width: 0;
  width: 100%;
  padding: 0 34px 0 12px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1.5 1.5 6 6l4.5-4.5' fill='none' stroke='%238e949a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px;
  cursor: pointer;
  text-overflow: ellipsis;
}
select:hover,
.custom:hover {
  border-color: var(--border-strong);
}
select:focus-visible,
.custom:focus-within,
.theme-toggle:focus-visible,
.chart:focus-visible {
  outline: none;
  border-color: var(--path);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--path) 28%, transparent);
}
.custom {
  flex: 1 1 96px;
  display: flex;
  align-items: center;
  padding-right: 11px;
  min-width: 0;
}
.custom input {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0 6px 0 12px;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-variant-numeric: tabular-nums;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
.custom input::-webkit-outer-spin-button,
.custom input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.unit {
  color: var(--muted);
  font-size: 13px;
}
.field.invalid .custom {
  border-color: var(--danger);
}
.error {
  margin-top: 6px;
  color: var(--danger);
  font-size: 12.5px;
}

/* Segmented control */
.segmented {
  display: flex;
  height: 42px;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.segmented label {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: grid;
  place-items: center;
  border-radius: 7px;
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.segmented input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: inherit;
}
.segmented label:hover {
  color: var(--text);
}
.segmented label:has(input:checked) {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border-strong), 0 2px 6px -3px rgba(0, 0, 0, 0.5);
}
.segmented label:has(input:checked)::after {
  content: '';
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: 3px;
  height: 2px;
  border-radius: 2px;
  background: var(--path);
}
.segmented label:has(input:focus-visible) {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--path) 28%, transparent), 0 0 0 1px var(--path);
}
.segmented label:has(input:disabled) {
  color: var(--muted);
  opacity: 0.5;
  cursor: not-allowed;
}
.segmented .narrow {
  display: none;
}
.segmented.small {
  height: 34px;
  font-size: 13.5px;
}
.segmented.small label {
  flex: 0 0 auto;
  padding-inline: 14px;
}
.segmented.small label:has(input:checked)::after {
  display: none;
}

/* ---------- Tiles ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}
.tile {
  min-width: 0;
  padding: 14px 18px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.tile-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-2);
}
.tile-label i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}
.tile-label i.dot-path {
  background: var(--path);
}
.tile-label i.dot-track {
  background: var(--track);
}
.tile-label i.dot-ring {
  border: 2px solid var(--text);
}
.tile-value {
  margin-top: 6px;
  font-size: clamp(22px, 1.9vw, 30px);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.tile-value small {
  font-size: 0.56em;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0;
  margin-left: 3px;
}
.tile-value .sep {
  color: var(--muted);
  font-weight: 400;
  margin-inline: 2px;
}
.tile-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.chart-card {
  padding: 18px 8px 8px;
}
.chart-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-inline: 14px;
}
.card h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.chart-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13.5px;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: 12px 0 0;
  padding: 0 14px;
  list-style: none;
  color: var(--text-2);
  font-size: 13px;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.key {
  display: inline-block;
  width: 22px;
  border-radius: 3px;
}
.key-path {
  height: 2px;
  background: var(--path);
}
.key-track {
  height: 5px;
  background: var(--track);
}
.key-los {
  height: 1.5px;
  background: var(--los);
}
.legend-note {
  margin-left: auto;
  color: var(--muted);
}

/* ---------- Chart ---------- */
.chart {
  position: relative;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid transparent;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.chart svg {
  display: block;
  width: 100%;
  overflow: visible;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}
.chart .zone {
  fill: var(--zone);
}
.chart .grid {
  stroke: var(--grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}
.chart .grid-strong {
  stroke: var(--grid-strong);
  stroke-width: 1;
  shape-rendering: crispEdges;
}
.chart .tick {
  fill: var(--muted);
  font-size: 12px;
}
.chart .axis-title {
  fill: var(--muted);
  font-family: var(--font-cond);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.chart .zone-label {
  fill: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}
.chart .band {
  fill: var(--track-wash);
}
.chart .band-edge {
  stroke: var(--track-edge);
  stroke-width: 1;
  shape-rendering: crispEdges;
}
.chart .los {
  stroke: var(--los);
  stroke-width: 1.5;
}
.chart .path {
  fill: none;
  stroke: var(--path);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart .track {
  fill: none;
  stroke: var(--track);
  stroke-width: 5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart .track-drop {
  stroke: var(--track-edge);
  stroke-width: 1;
}
.chart .strip {
  fill: var(--track);
}
.chart .strip-label {
  fill: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  text-anchor: middle;
}
.chart .marker {
  fill: var(--surface);
  stroke: var(--text);
  stroke-width: 2;
}
.chart .marker-apex {
  fill: var(--path);
  stroke: var(--surface);
  stroke-width: 2;
}
.chart .leader {
  stroke: var(--border-strong);
  stroke-width: 1;
}
.chart .end-dot {
  fill: var(--path);
  stroke: var(--surface);
  stroke-width: 2;
}
.chart .end-label {
  fill: var(--text);
  font-size: 13px;
  font-weight: 600;
}
.chart .end-sub {
  fill: var(--muted);
  font-size: 11.5px;
}
.chart .cross {
  stroke: var(--text-2);
  stroke-width: 1;
  opacity: 0.55;
}
.chart .cross-dot {
  fill: var(--path);
  stroke: var(--surface);
  stroke-width: 2;
}
.chart .cross-dot.in-track {
  fill: var(--track);
}

.callout {
  position: absolute;
  padding: 4px 9px 5px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1.2;
}
.callout b {
  display: block;
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
}
.callout span {
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tooltip {
  position: absolute;
  z-index: 3;
  min-width: 172px;
  padding: 10px 12px 11px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  box-shadow: 0 14px 30px -14px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.tooltip h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
}
.tooltip h3 em {
  float: right;
  margin-left: 12px;
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--track-wash);
  border: 1px solid var(--track-edge);
  color: var(--text);
  font-style: normal;
  font-size: 11.5px;
  font-weight: 500;
}
.tooltip dl {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 16px;
  margin: 0;
  font-size: 13.5px;
}
.tooltip dt {
  color: var(--text-2);
}
.tooltip dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
}

.chart-status {
  margin: 10px 14px 8px;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--text);
  font-size: 14px;
}

/* ---------- Table ---------- */
.table-card {
  padding: 18px 0 6px;
}
.table-head {
  padding-inline: 22px;
}
.table-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13.5px;
}
.table-scroll {
  margin-top: 12px;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
th,
td {
  padding: 9px 22px;
  text-align: right;
  white-space: nowrap;
}
th:first-child,
td:first-child {
  text-align: left;
}
thead th {
  border-bottom: 1px solid var(--border);
  font-family: var(--font-cond);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-2);
}
thead th span {
  color: var(--muted);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0.04em;
}
tbody td {
  border-bottom: 1px solid var(--grid);
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody td:first-child {
  font-weight: 600;
}
tbody tr.split td {
  border-top: 1px solid var(--border-strong);
}
tbody tr:hover td {
  background: var(--surface-2);
}
td .pip {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--track);
  vertical-align: 1px;
}
td.dim {
  color: var(--muted);
}

/* ---------- Footer ---------- */
.footnote {
  padding-block: 12px 34px;
  color: var(--muted);
  font-size: 13px;
}
.footnote p {
  max-width: 100ch;
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .settings {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .field {
    grid-column: span 3;
  }
  .f-caliber {
    grid-column: span 6;
  }
  .f-load,
  .f-velocity,
  .f-bc {
    grid-column: span 2;
  }
  .f-platform,
  .f-barrel,
  .f-zero,
  .f-sight {
    grid-column: span 3;
  }
  .f-load,
  .f-velocity,
  .f-bc {
    grid-column: span 2;
  }
  .tiles {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .tile {
    grid-column: span 2;
  }
  .tile:nth-child(n + 4) {
    grid-column: span 3;
  }
}
@media (max-width: 760px) {
  .settings {
    padding: 14px;
    gap: 12px;
  }
  .f-load,
  .f-velocity,
  .f-bc {
    grid-column: span 6;
  }
  .f-velocity,
  .f-bc {
    grid-column: span 3;
  }
  .f-bc .soft {
    display: none;
  }
  .chart-head {
    flex-direction: column;
  }
  .legend-note {
    margin-left: 0;
    flex-basis: 100%;
  }
  .tiles {
    gap: 10px;
  }
  .tile {
    grid-column: span 3;
    padding: 12px 14px;
  }
  .tile:first-child {
    grid-column: span 6;
  }
  th,
  td {
    padding: 8px 14px;
  }
  .table-head {
    padding-inline: 14px;
  }
  .chart-card {
    padding-inline: 2px;
  }
}
@media (max-width: 520px) {
  .segmented .wide {
    display: none;
  }
  .segmented .narrow {
    display: inline;
  }
}
@media (max-width: 420px) {
  .segmented {
    font-size: 14px;
  }
  .brand h1 {
    font-size: 23px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
