:root {
  color-scheme: dark;
  --bg: #101318;
  --bg-elev: #181d25;
  --bg-input: #0d1014;
  --line: #2a3340;
  --text: #e8edf4;
  --muted: #9aa5b4;
  --copper: #e0a15a;
  --copper-dim: #b47a35;
  --ok: #8fce8f;
  --warn: #e6c07b;
  --err: #f0a0a0;
  --focus: #7eb6ff;
  --radius: 14px;
  /* Floor for the “One-way length” column so the label stays on one line.
     Tweak this if the row is too wide or the label wraps. */
  --length-label-width: 7.1rem;
  --field-min-width: 5.6rem;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 600px at 10% -10%, #2a2218 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.45;
}

.page {
  width: 100%;
  max-width: 56rem;
  min-width: 0;
  margin: 0 auto;
  padding: 1.5rem 1.1rem 3rem;
  padding-top: calc(1.5rem + env(safe-area-inset-top, 0px));
  padding-bottom: calc(3rem + env(safe-area-inset-bottom, 0px));
  padding-left: calc(1.1rem + env(safe-area-inset-left, 0px));
  padding-right: calc(1.1rem + env(safe-area-inset-right, 0px));
}

.hero h1 {
  margin: 0.15rem 0 0.5rem;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  letter-spacing: -0.03em;
}

.eyebrow {
  margin: 0;
  color: var(--copper);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.lede {
  margin: 0;
  color: var(--muted);
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.15rem 0 1.25rem;
}

.preset {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.preset:hover,
.preset:focus-visible {
  border-color: var(--copper);
  outline: none;
}

.layout {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem 1.15rem;
  min-width: 0;
  max-width: 100%;
}

fieldset {
  border: 0;
  margin: 0 0 0.95rem;
  padding: 0;
}

legend {
  padding: 0;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.input-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  min-width: 0;
}

.grid {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.55rem;
  width: 100%;
  min-width: 0;
  margin-bottom: 0.95rem;
}

.grid > label {
  flex: 1 1 0;
  min-width: 0;
}

.grid > label .field-caption {
  white-space: nowrap;
}

.grid > .length-field {
  flex: 1.15 1 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.92rem;
}

.field {
  display: flex;
  align-items: center;
  min-width: 0;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.field:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 30%, transparent);
}

input[type="number"] {
  flex: 1;
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  padding: 0.65rem 0.7rem;
  outline: none;
}

.unit {
  color: var(--muted);
  padding-right: 0.75rem;
  font-size: 0.85rem;
}

.seg {
  display: flex;
  gap: 0.35rem;
}

.seg.stacked {
  flex-direction: column;
}

.seg-item {
  flex: 1;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-input);
  cursor: pointer;
  font-size: 0.92rem;
  text-align: center;
}

.seg-item:has(input:checked) {
  border-color: var(--copper);
  background: color-mix(in srgb, var(--copper) 16%, var(--bg-input));
}

.seg-item input {
  accent-color: var(--copper);
}

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

.advanced {
  margin: 0.15rem 0 0;
  border-top: 1px solid var(--line);
  padding-top: 0.7rem;
}

.fold > summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
  min-width: 0;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 650;
  list-style: none;
  text-align: left;
}

.fold > summary::marker,
.fold > summary::-webkit-details-marker {
  display: none;
  content: none;
}

.fold > summary::before {
  content: "";
  flex: 0 0 auto;
  width: 0.62rem;
  height: 0.62rem;
  border-right: 2.5px solid var(--copper);
  border-bottom: 2.5px solid var(--copper);
  transform: rotate(-45deg);
  transform-origin: 50% 50%;
}

.fold[open] > summary::before {
  transform: rotate(45deg) translate(0, -1px);
}

.fold-label,
.advanced-label {
  margin-right: auto;
}

.advanced-hint {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.advanced-body {
  margin-top: 0.85rem;
}

.calc-details {
  margin: 0.1rem 0 0;
  border-top: 1px solid var(--line);
  padding-top: 0.7rem;
}

.calc-details[hidden] {
  display: none;
}

.result-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
  line-height: inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.size {
  margin: 0.15rem 0 0.1rem;
  font-size: clamp(2.2rem, 6vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--copper);
  font-variant-numeric: tabular-nums;
}

.awg {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.governing {
  margin: 0 0 0.55rem;
  color: var(--ok);
  font-size: 0.95rem;
}

.governing.is-amp {
  color: var(--warn);
}

.governing.is-both {
  color: var(--muted);
}

.details {
  margin: 0.85rem 0 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.35rem 0.8rem;
  font-size: 0.92rem;
}

.details dt {
  color: var(--muted);
  min-width: 0;
}

.details dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 0.86rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.error {
  margin: 0.4rem 0 0;
  color: var(--err);
}

.disclaimer {
  margin: 1.15rem 0 0;
  padding: 0.9rem 1rem;
  border-left: 3px solid var(--copper-dim);
  background: color-mix(in srgb, var(--copper) 8%, transparent);
  border-radius: 0 10px 10px 0;
  color: var(--text);
  font-size: 0.92rem;
}

.method,
.faq {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.method h2,
.faq h2 {
  margin: 0 0 0.5rem;
  color: var(--text);
  font-size: 1rem;
}

.faq h3 {
  margin: 1rem 0 0.3rem;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 650;
}

.faq p {
  margin: 0;
}

.method ul {
  margin: 0;
  padding-left: 1.15rem;
}

.method li {
  margin-bottom: 0.4rem;
}

.ad-slot {
  margin: 1.15rem 0 0;
}

.ad-slot[hidden] {
  display: none;
}

footer {
  margin-top: 1.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}

footer a {
  color: inherit;
  text-underline-offset: 0.15em;
}

footer a:hover {
  color: var(--copper);
}

.noscript {
  padding: 1rem;
  color: var(--err);
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
