:root {
  --bg-panel: rgba(10, 23, 31, 0.9);
  --bg-panel-soft: rgba(10, 23, 31, 0.76);
  --text: #eaf3f7;
  --muted: #b9c9d1;
  --accent: #f6bd60;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body,
#map {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  overflow: hidden;
  background: radial-gradient(circle at 20% 10%, #24566a, #0b1b24 55%);
  color: var(--text);
  padding: 12px;
}

.app-shell {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 12px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.panel {
  background: linear-gradient(140deg, var(--bg-panel), var(--bg-panel-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  padding: 14px;
}

.map-frame {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: #0b1b24;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.map-search-bar {
  flex-shrink: 0;
  padding: 8px 10px;
  background: rgba(10, 23, 31, 0.88);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}

.map-search-bar input {
  flex: 1;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  outline: none;
  font-size: 0.92rem;
}

.map-layer-control {
  margin: 12px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  width: 252px;
  overflow: hidden;
}

.map-layer-toggle {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  color: #1f2937;
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
  font-size: 0.92rem;
}

.map-layer-toggle:hover {
  transform: none;
  background: #f3f4f6;
}

.map-layer-panel {
  display: none;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
}

.map-layer-panel.is-open {
  display: block;
}

.map-layer-style-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.map-layer-option {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  color: #334155;
  padding: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.map-layer-option:hover {
  transform: none;
  background: #f8fafc;
}

.map-layer-option.is-active {
  border-color: #1a73e8;
  box-shadow: inset 0 0 0 1px #1a73e8;
  color: #0f4fb8;
}

.map-layer-thumb {
  width: 58px;
  height: 58px;
  border-radius: 9px;
  border: 1px solid #d1d5db;
  background-size: cover;
  background-position: center;
}

.map-layer-thumb-silver {
  background-image:
    linear-gradient(120deg, rgba(255, 255, 255, 0.25) 0 15%, transparent 15% 100%),
    linear-gradient(35deg, #d5d9d6 0 38%, #b9c0b7 38% 58%, #e5e7eb 58% 100%);
}

.map-layer-thumb-roadmap {
  background-image:
    linear-gradient(90deg, transparent 0 25%, rgba(255, 255, 255, 0.9) 25% 35%, transparent 35% 100%),
    linear-gradient(0deg, transparent 0 52%, rgba(233, 30, 99, 0.8) 52% 58%, transparent 58% 100%),
    linear-gradient(35deg, #cae6d2 0 44%, #b6d4ea 44% 60%, #f1f5f9 60% 100%);
}

.map-layer-thumb-satellite {
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0 12%, transparent 12% 100%),
    linear-gradient(135deg, #1f3b2d 0 35%, #4a6a3f 35% 52%, #2f4f39 52% 74%, #6a7f46 74% 100%);
}

.map-layer-label {
  font-size: 0.78rem;
  line-height: 1.1;
}

.map-overlay-panel {
  border-top: 1px solid #e5e7eb;
  padding-top: 8px;
  display: grid;
  gap: 6px;
}

.map-overlay-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #334155;
  font-size: 0.82rem;
  font-weight: 600;
}

.map-overlay-toggle input {
  margin: 0;
  accent-color: #0284c7;
}

.map-search-bar input::placeholder {
  color: var(--muted);
}

#map {
  width: 100%;
  flex: 1;
  min-height: 0;
}

h1,
h2 {
  margin: 0 0 8px;
  letter-spacing: 0.02em;
}

h1 {
  font-size: 1.2rem;
}

h2 {
  font-size: 1rem;
}

.muted {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.field {
  margin-bottom: 10px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.88rem;
  color: var(--muted);
}

input[type="text"],
input[type="time"] {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 10px;
  outline: none;
}

input[type="range"] {
  width: 100%;
}

.time-row {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.swap-row {
  display: flex;
  justify-content: center;
  margin: -2px 0 8px;
}

.swap-icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.swap-icon-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.swap-icon-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.22);
}

button {
  width: 100%;
  border: 0;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 700;
  color: #132734;
  background: linear-gradient(120deg, var(--accent), #ffd79a);
  cursor: pointer;
  transition: transform 0.2s ease;
}

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

.legend {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.legend-color {
  width: 20px;
  height: 8px;
  border-radius: 999px;
}

.active-info {
  max-height: 200px;
  overflow: auto;
  padding-right: 4px;
  font-size: 0.86rem;
  color: var(--muted);
}

.radio-row {
  display: flex;
  gap: 16px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
}

.radio-label input[type="radio"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.route-result {
  margin-top: 10px;
  min-height: 24px;
  font-size: 0.9rem;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

.status-ok {
  color: #9ff59d;
}

.status-warn {
  color: #ffd48f;
}

.status-loading {
  color: #cbd5e1;
}

@keyframes routeProgress {
  0%   { width: 0%; }
  50%  { width: 80%; }
  100% { width: 100%; }
}

@media (max-width: 900px) {
  body {
    padding: 10px;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    max-height: 46vh;
    overflow-y: auto;
  }

  @supports (height: 1svh) {
    .sidebar {
      max-height: 46svh;
    }
  }

  #legend,
  #activeInfo {
    display: none;
  }
}
