:root {
  --midnight: #01313f;
  --pebble: #fbf1e6;
  --gold: #d8b283;
  --sand: #ebd8c1;
  --teal: #026d77;
  --ink: #143845;
  --muted: #6a7478;
  --line: rgba(1, 49, 63, 0.16);
  --white: #fffaf4;
  --shadow: 0 24px 70px rgba(1, 49, 63, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(2, 109, 119, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(2, 109, 119, 0.08) 1px, transparent 1px),
    var(--pebble);
  background-size: 52px 52px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 300;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.intro {
  min-height: 34vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 430px);
  gap: 32px;
  padding: 28px clamp(20px, 4vw, 54px);
  color: var(--pebble);
  background:
    linear-gradient(rgba(1, 49, 63, 0.84), rgba(1, 49, 63, 0.82)),
    url("../assets/chauffair-pattern-blue.jpg") center / cover;
  border-radius: 8px 8px 0 0;
  position: relative;
  overflow: hidden;
}

.intro::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(1, 49, 63, 0.22), rgba(1, 49, 63, 0)),
    radial-gradient(circle at 82% 18%, rgba(216, 178, 131, 0.18), transparent 36%);
  pointer-events: none;
}

.brandbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: relative;
  z-index: 1;
}

.logo-link img {
  width: clamp(150px, 18vw, 232px);
}

.brandmark {
  width: clamp(42px, 7vw, 74px);
  height: clamp(42px, 7vw, 74px);
  object-fit: contain;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.16));
}

.intro-copy {
  position: relative;
  z-index: 1;
  align-self: end;
  max-width: 700px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.intro .eyebrow {
  color: var(--gold);
}

h1,
h2 {
  font-family: "DM Serif Display", Georgia, serif;
  font-weight: 400;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2.9rem, 7vw, 6.4rem);
  line-height: 0.91;
}

.intro-copy p:last-child {
  max-width: 620px;
  margin: 22px 0 0;
  color: rgba(251, 241, 230, 0.82);
  font-size: clamp(1rem, 1.8vw, 1.22rem);
  line-height: 1.55;
}

.assumptions {
  position: relative;
  z-index: 1;
  align-self: end;
  display: grid;
  gap: 12px;
}

.assumptions div {
  padding: 16px 18px;
  border-left: 3px solid var(--gold);
  background: rgba(251, 241, 230, 0.08);
  color: rgba(251, 241, 230, 0.78);
  line-height: 1.45;
}

.assumptions span {
  display: block;
  margin-bottom: 4px;
  color: var(--sand);
  font-weight: 700;
}

.calculator {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  background: var(--white);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel {
  padding: clamp(22px, 4vw, 38px);
  background: var(--sand);
  border-right: 1px solid var(--line);
}

.form-grid {
  display: grid;
  gap: 16px;
}

label span,
legend {
  display: block;
  margin-bottom: 7px;
  color: var(--midnight);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(1, 49, 63, 0.24);
  border-radius: 6px;
  padding: 0 13px;
  background: rgba(255, 250, 244, 0.92);
  color: var(--midnight);
  outline: none;
}

input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(2, 109, 119, 0.16);
}

.segmented {
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented legend {
  grid-column: 1 / -1;
}

.segmented label {
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid rgba(1, 49, 63, 0.2);
  border-radius: 6px;
  background: rgba(255, 250, 244, 0.58);
  color: var(--midnight);
  font-size: 0.92rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

.segmented input:checked + span {
  background: var(--midnight);
  color: var(--gold);
  border-color: var(--midnight);
}

.primary {
  width: 100%;
  min-height: 54px;
  margin-top: 22px;
  border: 0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--teal);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.primary:disabled {
  opacity: 0.62;
  cursor: wait;
}

.primary svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fineprint {
  margin: 18px 0 0;
  color: rgba(1, 49, 63, 0.66);
  font-size: 0.82rem;
  line-height: 1.45;
}

.fineprint a {
  display: inline-block;
  margin-top: 8px;
  color: var(--midnight);
  font-weight: 700;
}

.results {
  min-height: 460px;
  padding: clamp(22px, 4vw, 42px);
  display: grid;
}

.empty-state,
.loading-state,
.error-state {
  align-self: center;
  justify-self: center;
  max-width: 360px;
  text-align: center;
  color: var(--muted);
}

.icon-ring {
  width: 74px;
  height: 74px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border: 2px solid var(--sand);
  border-radius: 999px;
  color: var(--gold);
  font-size: 2rem;
}

.spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 18px;
  border: 3px solid rgba(1, 49, 63, 0.13);
  border-top-color: var(--teal);
  border-radius: 999px;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.result-state {
  display: grid;
  gap: 22px;
}

.winner {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.winner h2 {
  margin: 0;
  color: var(--midnight);
  font-size: clamp(2.6rem, 5vw, 4.8rem);
  line-height: 0.96;
}

.winner p:last-child {
  max-width: 620px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.5;
}

.mode-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.mode-card {
  min-height: 164px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  align-content: space-between;
  gap: 18px;
}

.mode-card.fastest {
  background: var(--midnight);
  color: var(--pebble);
  border-color: var(--midnight);
}

.mode-card h3 {
  margin: 0;
  color: inherit;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.time {
  margin: 0;
  font-family: "DM Serif Display", Georgia, serif;
  font-size: clamp(2rem, 4vw, 3.35rem);
  line-height: 0.95;
  color: var(--teal);
}

.fastest .time {
  color: var(--gold);
}

.meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.fastest .meta {
  color: rgba(251, 241, 230, 0.74);
}

.details {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

summary {
  cursor: pointer;
  color: var(--midnight);
  font-weight: 700;
}

#routeNotes {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.error-state {
  padding: 20px;
  border: 1px solid rgba(137, 29, 29, 0.25);
  border-radius: 8px;
  background: rgba(137, 29, 29, 0.06);
  color: #7a2525;
}

.hidden {
  display: none;
}

@media (max-width: 880px) {
  .intro,
  .calculator {
    grid-template-columns: 1fr;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .mode-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .shell {
    width: 100%;
    padding: 0;
  }

  .intro,
  .calculator {
    border-radius: 0;
  }

  .brandbar {
    align-items: flex-start;
  }

  .logo-link img {
    width: 172px;
  }

  .brandmark {
    width: 44px;
    height: 44px;
  }

  h1 {
    font-size: 3.1rem;
  }
}
