:root {
  --panel: rgba(248, 251, 254, 0.9);
  --panel-soft: rgba(232, 239, 246, 0.86);
  --text: #102030;
  --muted: #5f7284;
  --line: rgba(16, 32, 48, 0.1);
  --accent: #28c46d;
  --accent-strong: #0f8c47;
  --accent-soft: rgba(40, 196, 109, 0.12);
  --shadow: 0 24px 60px rgba(15, 31, 46, 0.16);
  --surface: rgba(255, 255, 255, 0.7);
  --map-note: rgba(255, 255, 255, 0.9);
  --map-note-text: #0d1f31;
  color-scheme: light;
}

html[data-theme="dark"] {
  --panel: rgba(7, 18, 31, 0.84);
  --panel-soft: rgba(18, 34, 54, 0.82);
  --text: #f4f8fb;
  --muted: #a9bdcd;
  --line: rgba(255, 255, 255, 0.09);
  --accent: #39d878;
  --accent-strong: #1eb864;
  --accent-soft: rgba(57, 216, 120, 0.12);
  --shadow: 0 24px 60px rgba(7, 18, 31, 0.28);
  --surface: rgba(255, 255, 255, 0.05);
  --map-note: rgba(7, 18, 31, 0.84);
  --map-note-text: #edf5fb;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
}

body {
  min-height: 100vh;
  min-height: 100svh;
  background:
    radial-gradient(circle at top left, rgba(55, 214, 122, 0.14), transparent 24%),
    linear-gradient(135deg, #dce6ee 0%, #eef3f7 48%, #d6e3ee 100%);
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(55, 214, 122, 0.14), transparent 24%),
    linear-gradient(135deg, #07111b 0%, #0b1b2c 48%, #11263d 100%);
}

.app-shell {
  display: block;
  min-height: 100vh;
  min-height: 100svh;
}

.map-wrap {
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100vh;
  height: 100svh;
  filter: saturate(1.04) contrast(1.02);
}

.map-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(6, 17, 28, 0.18) 0%, transparent 24%, transparent 76%, rgba(6, 17, 28, 0.22) 100%);
  pointer-events: none;
  z-index: 350;
}

.map-hud {
  position: absolute;
  left: 20px;
  right: 20px;
  display: grid;
  gap: 12px;
  z-index: 500;
  pointer-events: none;
}

.map-hud--top {
  top: calc(18px + env(safe-area-inset-top));
  grid-template-columns: 120px 1fr;
  align-items: stretch;
}

.map-hud--bottom {
  bottom: calc(110px + env(safe-area-inset-bottom));
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hud-speed,
.hud-next,
.map-chip,
.floating-note,
.brand,
.install-card,
.search-card,
.nav-card,
.settings-card,
.stat,
.upcoming-card {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hud-speed,
.hud-next,
.map-chip {
  border-radius: 22px;
  padding: 16px;
}

.hud-speed {
  text-align: center;
}

.hud-speed strong {
  display: block;
  font-size: 2.4rem;
  line-height: 1;
}

.hud-label,
.map-chip span,
.eyebrow,
.stat__label {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}

.hud-unit {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.hud-next strong,
.map-chip strong {
  display: block;
  margin-top: 8px;
  line-height: 1.35;
  color: var(--text);
}

.hud-next__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 94vw);
  padding: calc(18px + env(safe-area-inset-top)) 24px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-soft) 100%);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  z-index: 1300;
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.18);
}

.panel[hidden] {
  display: none;
}

.brand,
.install-card,
.search-card,
.nav-card,
.settings-card,
.settings-sheet {
  border-radius: 24px;
  padding: 20px;
  margin-bottom: 18px;
}

.brand__title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand__icon {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

h1,
h2,
.stat__value {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.2rem;
}

.lede,
.helper-text,
.settings-status,
.route-summary,
.route-steps,
.setting-row small,
.install-card p {
  color: var(--muted);
}

.lede {
  margin: 14px 0 0;
  line-height: 1.65;
}

.install-card p {
  margin: 0;
  line-height: 1.5;
}

.action-strip,
.nav-buttons {
  display: flex;
  gap: 12px;
}

.action-strip {
  margin-bottom: 18px;
}

.action-strip > *,
.nav-buttons > * {
  flex: 1;
}

.label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.92rem;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input,
button,
select {
  border: 0;
  border-radius: 16px;
  font: inherit;
}

input,
select {
  padding: 14px 16px;
  min-height: 52px;
  background: rgba(255, 255, 255, 0.95);
  color: #102030;
}

button {
  padding: 14px 18px;
  min-height: 52px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent) 0%, #63f59d 100%);
  color: #062313;
  transition: transform 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.icon-button {
  flex: 0 0 auto;
  width: 48px;
  min-width: 48px;
  min-height: 48px;
  height: 48px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  border-radius: 16px;
}

.icon-button--light {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 1px solid var(--line);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ghost-button {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.helper-text {
  margin: 10px 0 0;
  line-height: 1.5;
  font-size: 0.9rem;
}

.results {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.result {
  width: 100%;
  text-align: left;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  border: 1px solid var(--line);
}

.result small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  border-radius: 22px;
  padding: 16px;
}

.stat--hero {
  background: linear-gradient(135deg, rgba(55, 214, 122, 0.22), rgba(255, 255, 255, 0.08));
}

.stat__label {
  margin-bottom: 10px;
}

.stat__value {
  display: block;
  font-size: clamp(1.4rem, 2vw, 2rem);
  line-height: 1;
}

.stat__value--small {
  font-size: 1rem;
  line-height: 1.4;
}

.stat__unit {
  display: inline-block;
  margin-top: 6px;
  color: var(--accent);
  font-size: 0.86rem;
}

.nav-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.route-summary {
  line-height: 1.5;
  margin-bottom: 14px;
}

.upcoming-card {
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, var(--accent-soft), transparent);
}

.upcoming-text {
  display: block;
  line-height: 1.4;
}

.route-steps {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 12px;
}

.route-steps li.is-current {
  color: var(--accent-strong);
  font-weight: 700;
}

.settings-card {
  margin-bottom: 0;
}

.settings-modal[hidden] {
  display: none;
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
}

.settings-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 17, 28, 0.48);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.settings-sheet {
  position: absolute;
  top: max(16px, calc(16px + env(safe-area-inset-top)));
  right: 16px;
  width: min(92vw, 420px);
  margin-bottom: 0;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-soft) 100%);
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

.panel-modal[hidden] {
  display: none;
}

.panel-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
}

.panel-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 17, 28, 0.44);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.settings-sheet__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.setting-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.setting-row strong,
.setting-row small {
  display: block;
}

.setting-row input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: var(--accent-strong);
}

.settings-status {
  margin-top: 10px;
  line-height: 1.5;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #0d2238;
  color: #edf5fb;
}

@media (max-width: 1100px) {
  .panel {
    width: min(440px, 96vw);
  }

  .map-hud--bottom {
    bottom: calc(110px + env(safe-area-inset-bottom));
  }

  .floating-note {
    max-width: 420px;
  }
}

@media (max-width: 720px) {
  .map-hud {
    left: 12px;
    right: 12px;
  }

  .map-hud--top {
    grid-template-columns: 96px 1fr;
  }

  .map-hud--bottom {
    grid-template-columns: 1fr;
    bottom: calc(110px + env(safe-area-inset-bottom));
  }

  .panel {
    padding: calc(14px + env(safe-area-inset-top)) 16px calc(14px + env(safe-area-inset-bottom));
    width: min(100vw, 420px);
  }

  .action-strip,
  .search-row,
  .stats-grid,
  .nav-buttons {
    display: grid;
    grid-template-columns: 1fr;
  }

  .nav-card__head,
  .setting-row,
  .brand__title {
    flex-direction: column;
    align-items: stretch;
  }

  .hud-next__top,
  .settings-sheet__head {
    align-items: stretch;
  }

  .brand__icon {
    width: 56px;
    height: 56px;
  }

  .settings-sheet {
    left: 12px;
    right: 12px;
    width: auto;
  }
}
