:root {
  --ink: #122236;
  --muted: #566579;
  --surface: #ffffff;
  --bg-start: #f2f7ff;
  --bg-end: #ecfff6;
  --line: #d7dfeb;
  --line-strong: #bcc8da;
  --brand: #00677b;
  --brand-2: #1ea79d;
  --panel-glow: 0 18px 45px rgb(18 33 55 / 8%);
  --danger: #b00020;
  --ok: #1b7f3b;
  --focus-ring: 0 0 0 3px rgb(32 166 157 / 24%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(145deg, var(--bg-start), var(--bg-end));
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(40rem 22rem at 10% 6%, rgb(71 118 255 / 11%), transparent 60%),
    radial-gradient(34rem 20rem at 92% 90%, rgb(23 166 143 / 14%), transparent 62%);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 430px) 1fr;
  gap: 1rem;
  padding: 1rem;
  min-height: calc(100vh - 2.1rem);
}

.controls-panel {
  background: rgb(255 255 255 / 88%);
  backdrop-filter: blur(8px);
  border: 1px solid rgb(255 255 255 / 70%);
  border-radius: 18px;
  padding: 1rem;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--panel-glow);
  animation: rise-fade 420ms ease both;
}

h1 {
  margin: 0;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: 1.8rem;
  letter-spacing: -0.02em;
}

.app-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.08rem;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.app-reset-btn:hover,
.app-reset-btn:focus-visible {
  color: var(--brand);
  box-shadow: none;
}

.subtitle {
  margin: 0.08rem 0 0.7rem;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 32ch;
}

.planner-form {
  display: grid;
  gap: 0.9rem;
}

.planner-form label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.hint {
  margin: -0.08rem 0 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.quick-card {
  position: relative;
  z-index: 6;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 0.9rem;
  display: grid;
  gap: 0.55rem;
  box-shadow: 0 10px 24px rgb(16 34 70 / 5%);
  animation: rise-fade 520ms ease both;
}

.action-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.25rem;
}

.action-row .hint {
  margin: 0;
}

.advanced-panel {
  position: relative;
  z-index: 2;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 0.2rem 0.9rem 0.9rem;
  box-shadow: 0 8px 20px rgb(16 34 70 / 4%);
  animation: rise-fade 620ms ease both;
}

.advanced-panel summary {
  cursor: pointer;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ink);
  padding: 0.45rem 0;
}

.advanced-grid {
  margin-top: 0.45rem;
}

.location-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.location-autocomplete {
  position: relative;
  z-index: 18;
  min-width: 0;
}

.location-autocomplete #location {
  width: 100%;
}

.location-suggestions {
  position: absolute;
  z-index: 40;
  top: calc(100% + 0.2rem);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.24rem;
  list-style: none;
  max-height: 15rem;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 12px 28px rgb(16 34 70 / 18%);
}

.location-suggestion-btn {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 0.4rem 0.45rem;
  border-radius: 8px;
  display: grid;
  gap: 0.12rem;
  cursor: pointer;
}

.location-suggestion-btn:hover,
.location-suggestion-btn.is-active,
.location-suggestion-btn:focus-visible {
  background: rgb(0 103 123 / 10%);
  outline: none;
}

.location-suggestion-main {
  display: block;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
}

.location-suggestion-meta {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
}

input,
select,
button {
  font: inherit;
  border-radius: 11px;
  border: 1px solid var(--line);
  padding: 0.62rem 0.68rem;
  background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

input:focus,
select:focus,
button:focus-visible {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: var(--focus-ring);
}

#compare-cars {
  min-height: 118px;
  width: 100%;
}

.compare-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 0.2rem 0.85rem 0.85rem;
  box-shadow: 0 8px 20px rgb(16 34 70 / 4%);
  display: grid;
  gap: 0.5rem;
  min-width: 0;
}

.compare-panel summary {
  cursor: pointer;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ink);
  padding: 0.45rem 0;
}

.summary-title-with-beta {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
}

.beta-tag {
  display: inline-block;
  margin: 0;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  border: 1px solid rgb(0 103 123 / 30%);
  background: rgb(0 103 123 / 8%);
  color: #0d5667;
  font-family: "Manrope", "Segoe UI", sans-serif;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: middle;
}

.compare-actions {
  display: flex;
  justify-content: flex-start;
}

.compare-results {
  border-top: 1px dashed var(--line-strong);
  margin-top: 0.35rem;
  padding-top: 0.5rem;
  overflow-x: hidden;
  min-width: 0;
}

#compare-btn {
  border-color: var(--line-strong);
  background: #f8fbff;
  color: var(--ink);
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-weight: 700;
  min-height: 40px;
  padding-inline: 0.9rem;
}

#compare-btn:hover {
  transform: translateY(-1px);
}

button {
  cursor: pointer;
  font-weight: 600;
}

#plan-btn {
  border-color: transparent;
  background: linear-gradient(130deg, var(--brand), var(--brand-2) 70%);
  color: #fff;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-weight: 700;
  white-space: nowrap;
  min-height: 42px;
  padding-inline: 1rem;
  box-shadow: 0 10px 24px rgb(0 103 123 / 28%);
}

#plan-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

#plan-btn.is-loading {
  cursor: progress;
  animation: compute-glow 1s ease-in-out infinite;
}

.summary {
  margin-top: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem;
  background: #fff;
  box-shadow: 0 10px 22px rgb(16 34 70 / 5%);
  animation: rise-fade 700ms ease both;
}

.compact-summary {
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  font-size: 0.8rem;
}

.compact-summary h2 {
  margin: 0 0 0.22rem;
  font-size: 0.88rem;
}

.compact-summary p {
  margin: 0.16rem 0;
  font-size: 0.79rem;
}

.summary h2 {
  margin: 0 0 0.45rem;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: 1.02rem;
}

.summary p {
  margin: 0.22rem 0;
  font-size: 0.89rem;
}

.compare-title {
  margin-top: 0.65rem;
  margin-bottom: 0.35rem;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: 0.94rem;
}

.compare-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.compare-table th,
.compare-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.42rem 0.35rem;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.compare-table th {
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-size: 0.74rem;
}

.compare-table tr:last-child td {
  border-bottom: none;
}

.compare-table tr.compare-best td {
  background: rgb(30 167 157 / 9%);
}

.note {
  margin-top: 0.9rem;
  padding: 0.7rem 0.78rem;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: rgb(255 255 255 / 62%);
  font-size: 0.8rem;
  color: var(--muted);
}

.ad-slot {
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  padding: 0.5rem 0.65rem 0.62rem;
  background: rgb(255 255 255 / 78%);
}

.ad-slot-map {
  margin: 0.6rem;
  margin-top: 0;
}

.ad-label {
  margin: 0 0 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.ad-placeholder {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #fff, #f8fbff);
  padding: 0.65rem;
  overflow: hidden;
}

.ad-runtime {
  position: relative;
  height: 78px;
}

.ad-fallback-image {
  display: block;
  width: 100%;
  height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  object-position: center;
  opacity: 0.35;
}

.ad-runtime .adsbygoogle {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  transition: opacity 180ms ease;
}

.ad-runtime.is-filled .adsbygoogle {
  opacity: 1;
}

.ad-runtime.is-filled .ad-fallback-image {
  display: none;
}

.map-panel {
  display: grid;
  grid-template-rows: minmax(320px, 1fr) auto;
  border: 1px solid rgb(255 255 255 / 80%);
  border-radius: 18px;
  overflow: hidden;
  background: rgb(255 255 255 / 90%);
  backdrop-filter: blur(8px);
  box-shadow: var(--panel-glow);
  animation: rise-fade 520ms ease both;
}

#map {
  height: 100%;
  min-height: 460px;
}

#map:focus-visible {
  outline: 3px solid rgb(30 167 157 / 42%);
  outline-offset: -3px;
}

.legend {
  background: #fff;
  padding: 0.58rem 0.68rem;
  border-radius: 11px;
  border: 1px solid var(--line);
  font-size: 0.79rem;
  line-height: 1.25;
  box-shadow: 0 6px 20px rgb(30 45 80 / 13%);
}

.legend strong {
  display: block;
  margin-bottom: 0.2rem;
  font-family: "Space Grotesk", "Manrope", sans-serif;
  font-size: 0.82rem;
}

.legend .dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: baseline;
}

.dot.reachable {
  background: #2f9e44;
}

.dot.caution {
  background: #f08c00;
}

.route-note {
  font-size: 0.8rem;
  color: var(--muted);
}

.warning {
  color: var(--danger);
  font-weight: 600;
}

@keyframes rise-fade {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes compute-glow {
  0%,
  100% {
    box-shadow: 0 10px 24px rgb(0 103 123 / 28%);
  }
  50% {
    box-shadow: 0 0 0 3px rgb(30 167 157 / 22%), 0 12px 30px rgb(0 103 123 / 36%);
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .map-panel {
    min-height: 64vh;
  }

  .ad-slot-map {
    margin: 0.5rem;
    margin-top: 0;
  }

  .action-row {
    grid-template-columns: 1fr;
  }
}

/* ── Brand bolt icon ── */
.brand-bolt {
  display: inline-block;
  width: 1.45rem;
  height: 1.45rem;
  vertical-align: -0.22em;
  color: var(--brand);
  margin-right: 0.12em;
  flex-shrink: 0;
}

h1::after {
  content: '';
  display: block;
  width: 2rem;
  height: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: 2px;
  margin-top: 0.22rem;
}

/* ── Custom scrollbar ── */
.controls-panel {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.controls-panel::-webkit-scrollbar { width: 4px; }
.controls-panel::-webkit-scrollbar-track { background: transparent; }
.controls-panel::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 99px;
}

/* ── Custom details/summary chevron ── */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }

.advanced-panel > summary,
.compare-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.advanced-panel > summary::after,
.compare-panel > summary::after {
  content: '';
  flex-shrink: 0;
  width: 0.48rem;
  height: 0.48rem;
  border-right: 1.5px solid var(--brand);
  border-bottom: 1.5px solid var(--brand);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 220ms ease;
}
details[open] > summary::after {
  transform: rotate(-135deg) translateY(2px);
}

/* ── GPS button – secondary/outline style ── */
#use-location {
  background: transparent;
  color: var(--brand);
  border-color: var(--brand-2);
  font-weight: 600;
  white-space: nowrap;
}
#use-location:hover {
  background: rgb(0 103 123 / 6%);
  transform: translateY(-1px);
}

/* ── Prevent form elements from overflowing grid containers on narrow viewports ── */
.planner-form select,
.planner-form input {
  min-width: 0;
  max-width: 100%;
}

/* ── Share button ── */
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  margin-top: 0.6rem;
  padding: 0.34rem 0.72rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: transparent;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 150ms ease, transform 100ms ease, border-color 150ms ease;
}
.share-btn:hover {
  background: rgb(0 103 123 / 7%);
  border-color: var(--brand);
  transform: translateY(-1px);
}
.share-btn:active {
  transform: none;
}

/* ── Button loading / disabled state ── */
#plan-btn:disabled,
#compare-btn:disabled {
  opacity: 0.72;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
  box-shadow: none;
}

#plan-btn.is-loading:disabled {
  opacity: 1;
  cursor: progress;
  filter: brightness(1.03) !important;
  box-shadow: 0 10px 24px rgb(0 103 123 / 28%) !important;
}

.site-footnote {
  text-align: center;
  padding: 0.15rem 0 0.5rem;
  font-size: 0.72rem;
  color: rgb(18 34 54 / 48%);
  letter-spacing: 0.01em;
}

.site-footnote a {
  color: inherit;
  text-decoration: none;
}

.site-footnote a:hover,
.site-footnote a:focus-visible {
  color: rgb(18 34 54 / 78%);
  text-decoration: underline;
}
