:root {
  color-scheme: light dark;
  --bg: #eef1f6;
  --surface: rgba(255, 255, 255, .72);
  --field: rgba(255, 255, 255, .78);
  --text: #111722;
  --muted: #566070;
  --line: rgba(17, 23, 34, .13);
  --danger: #b3261e;
  --accent: #059669;
  --accent-soft: rgba(5, 150, 105, .22);
  --on-accent: #ffffff;
  --blob-opacity: .42;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

body[data-fuel="dizel"] { --accent: #c2570c; --accent-soft: rgba(194, 87, 12, .22); }
body[data-fuel="lpg"] { --accent: #0369a1; --accent-soft: rgba(3, 105, 161, .22); }
body[data-fuel="ev"] { --accent: #6d3fe0; --accent-soft: rgba(109, 63, 224, .22); }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e13;
    --surface: rgba(24, 29, 38, .68);
    --field: rgba(255, 255, 255, .05);
    --text: #f1f4f8;
    --muted: #a3adbb;
    --line: rgba(255, 255, 255, .12);
    --danger: #ff9a90;
    --accent: #34d399;
    --accent-soft: rgba(52, 211, 153, .24);
    --on-accent: #06130e;
    --blob-opacity: .3;
  }
  body[data-fuel="dizel"] { --accent: #fb923c; --accent-soft: rgba(251, 146, 60, .24); }
  body[data-fuel="lpg"] { --accent: #38bdf8; --accent-soft: rgba(56, 189, 248, .24); }
  body[data-fuel="ev"] { --accent: #b197fc; --accent-soft: rgba(177, 151, 252, .26); }
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  line-height: 1.45;
}

.backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.backdrop i {
  position: absolute;
  width: 56vmax;
  height: 56vmax;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, transparent 64%);
  opacity: var(--blob-opacity);
  transition: background .6s;
  will-change: transform;
}
.backdrop i:nth-child(1) { top: -30vmax; left: -18vmax; animation: float-a 19s ease-in-out infinite alternate; }
.backdrop i:nth-child(2) { right: -26vmax; top: 8vmax; opacity: calc(var(--blob-opacity) * .7); animation: float-b 24s ease-in-out infinite alternate; }
.backdrop i:nth-child(3) { bottom: -38vmax; left: 22vmax; opacity: calc(var(--blob-opacity) * .55); animation: float-a 28s ease-in-out infinite alternate-reverse; }

@keyframes float-a { to { transform: translate(9vmax, 7vmax) scale(1.12); } }
@keyframes float-b { to { transform: translate(-10vmax, 6vmax) scale(.9); } }

.page {
  position: relative;
  z-index: 1;
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 44px 24px 32px;
}

.reveal { animation: rise .8s var(--ease) both; }
.layout .reveal:nth-child(1) { animation-delay: .08s; }
.layout .reveal:nth-child(2) { animation-delay: .16s; }
footer.reveal { animation-delay: .26s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }

.intro { margin-bottom: 26px; }
.intro > p:last-child { margin: 0; color: var(--muted); font-size: 1.05rem; }
h1 {
  margin: 12px 0 6px;
  font-size: clamp(2.2rem, 6.4vw, 3.8rem);
  font-weight: 750;
  line-height: 1.04;
  letter-spacing: -.035em;
}
h1 em { color: var(--accent); font-style: normal; transition: color .45s; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  margin: 0;
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
  backdrop-filter: blur(12px);
}
.dot { position: relative; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); transition: background .45s; }
.dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit; animation: ping 1.9s ease-out infinite; }
.live-pill[data-state="error"] .dot { background: var(--danger); }
.live-pill[data-state="error"] .dot::after { animation: none; }
@keyframes ping { to { transform: scale(3.2); opacity: 0; } }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.card, .display {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 24px 60px -32px rgba(0, 0, 0, .5);
  backdrop-filter: blur(22px) saturate(1.3);
}

.card { display: grid; gap: 20px; padding: 26px; }

.field { min-width: 0; margin: 0; padding: 0; border: 0; }
.field > label, .field > legend, .label {
  display: block;
  margin-bottom: 7px;
  padding: 0;
  font-size: .88rem;
  font-weight: 600;
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.segments {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 15px;
}
.thumb {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 11px;
  background: var(--accent);
  box-shadow: 0 8px 20px -8px var(--accent);
  transition: transform .45s var(--ease), width .45s var(--ease), height .45s var(--ease), background .45s;
}
.segments label { position: relative; z-index: 1; cursor: pointer; }
.segments input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.segments label > span {
  display: grid;
  gap: 1px;
  padding: 8px 2px;
  border-radius: 11px;
  color: var(--muted);
  text-align: center;
  transition: color .25s, transform .2s var(--ease);
}
.segments label:active > span { transform: scale(.96); }
.segments b { font-size: .86rem; font-weight: 650; }
.segments small { font-size: .74rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.segments input:checked + span { color: var(--on-accent); }
.segments input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 1px; }

.input {
  display: flex;
  align-items: center;
  height: 50px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 13px;
  transition: border-color .2s, box-shadow .25s;
}
.input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input:has([aria-invalid="true"]) { border-color: var(--danger); animation: shake .32s; }
.input.flash { animation: flash .9s var(--ease); }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes flash { 0% { box-shadow: 0 0 0 0 var(--accent); } 100% { box-shadow: 0 0 0 10px transparent; } }
.input input {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 4px 0 14px;
  background: transparent;
  border: 0;
  outline: 0;
  color: inherit;
  font: inherit;
  font-size: 1.12rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.input span { flex: none; padding-right: 13px; color: var(--muted); font-size: .83rem; }

.field > label.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; margin: 12px 0 0; cursor: pointer; font-size: .93rem; font-weight: 400; }
.switch input { position: absolute; opacity: 0; }
.switch i {
  position: relative;
  flex: none;
  width: 40px;
  height: 23px;
  border-radius: 99px;
  background: var(--line);
  transition: background .3s;
}
.switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
  transition: transform .35s var(--ease);
}
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(17px); }
.switch input:focus-visible + i { outline: 2px solid var(--text); outline-offset: 2px; }

.price-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  min-height: 26px;
  margin-top: -8px;
  color: var(--muted);
  font-size: .83rem;
}
#priceStatus[data-state="loading"] {
  background: linear-gradient(90deg, var(--muted) 30%, var(--accent) 50%, var(--muted) 70%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
#priceStatus[data-state="error"] { color: var(--danger); }
#resetPrice {
  padding: 3px 10px;
  background: var(--accent-soft);
  border: 0;
  border-radius: 99px;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .2s var(--ease);
}
#resetPrice:hover { transform: translateY(-1px); }

.stepper {
  display: inline-flex;
  align-items: center;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 13px;
}
.stepper button {
  width: 48px;
  height: 46px;
  background: transparent;
  border: 0;
  border-radius: 12px;
  color: inherit;
  font-size: 1.4rem;
  cursor: pointer;
  transition: background .2s, transform .15s var(--ease);
}
.stepper button:hover:not(:disabled) { background: var(--accent-soft); }
.stepper button:active:not(:disabled) { transform: scale(.88); }
.stepper button:disabled { opacity: .32; cursor: default; }
.stepper output { width: 40px; text-align: center; font-size: 1.12rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper output.bump { animation: bump .32s var(--ease); }
@keyframes bump { 40% { transform: scale(1.35); } }

.display { position: sticky; top: 18px; padding: 26px; overflow: hidden; }
.display::before {
  content: "";
  position: absolute;
  top: -90px;
  right: -70px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: var(--accent);
  filter: blur(70px);
  opacity: .26;
  transition: background .5s;
  pointer-events: none;
}
.display > * { position: relative; }
.display h2 { margin: 0; color: var(--muted); font-size: .9rem; font-weight: 600; }
.total {
  margin: 4px 0 14px;
  font-size: clamp(2.8rem, 7.4vw, 4rem);
  font-weight: 760;
  line-height: 1.06;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.total small { color: var(--accent); font-size: .42em; font-weight: 700; letter-spacing: 0; transition: color .45s; }
.error { margin: -4px 0 14px; color: var(--danger); font-size: .88rem; }

.route { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.stop { flex: none; width: 10px; height: 10px; border: 2px solid var(--accent); border-radius: 50%; transition: border-color .45s; }
.track {
  position: relative;
  flex: 1;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--line) 0 8px, transparent 8px 14px);
}
.car {
  position: absolute;
  top: -4px;
  left: 0;
  width: 26px;
  height: 10px;
  border-radius: 99px;
  background: var(--accent);
  box-shadow: 0 0 16px 2px var(--accent-soft);
  offset-path: none;
  animation: drive 3.4s var(--ease) infinite;
  transition: background .45s;
}
.route[data-round="true"] .car { animation: drive-round 5s ease-in-out infinite; }
.route[data-idle="true"] .car { animation-play-state: paused; opacity: .35; }
@keyframes drive {
  0% { left: 0; opacity: 0; }
  12% { opacity: 1; }
  82% { opacity: 1; }
  100% { left: calc(100% - 26px); opacity: 0; }
}
@keyframes drive-round {
  0%, 100% { left: 0; }
  50% { left: calc(100% - 26px); }
}

dl { margin: 0 0 18px; }
dl div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
dt { color: var(--muted); font-size: .92rem; }
dd { margin: 0; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
dd.tick { animation: tick .38s var(--ease); }
@keyframes tick { from { opacity: .25; transform: translateY(5px); } }

.copy {
  position: relative;
  width: 100%;
  height: 50px;
  overflow: hidden;
  background: var(--accent);
  border: 0;
  border-radius: 14px;
  color: var(--on-accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform .2s var(--ease), box-shadow .25s, background .45s, opacity .2s;
}
.copy::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -40%;
  width: 30%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .42), transparent);
  transform: skewX(-18deg);
}
.copy:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 26px -12px var(--accent); }
.copy:hover:not(:disabled)::after { left: 120%; transition: left .7s var(--ease); }
.copy:active:not(:disabled) { transform: scale(.98); }
.copy:disabled { opacity: .4; cursor: default; }
.copy:focus-visible, .stepper button:focus-visible, #resetPrice:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

footer { margin-top: 26px; color: var(--muted); font-size: .8rem; }
footer p { margin: 0 0 6px; }
footer a { color: inherit; text-underline-offset: 2px; }

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 800px) {
  .page { padding: 26px 16px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .card, .display { padding: 18px; }
  .display { position: relative; top: 0; }
}

@media (max-width: 460px) {
  .segments { grid-template-columns: 1fr 1fr; }
  .row { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  #priceStatus[data-state="loading"] { background: none; color: var(--muted); }
}
