:root {
  --bg: #05070a;
  --panel: rgba(11, 16, 24, 0.94);
  --panel-2: rgba(18, 25, 36, 0.9);
  --text: #f4f7fb;
  --muted: #aeb8c7;
  --border: rgba(255, 255, 255, 0.12);
  --yellow: #ffd400;
  --orange: #ff8c00;
  --red: #ff3b30;
  --green: #39d98a;
  --amber: #ffc857;
  --road: rgba(230, 236, 245, 0.75);
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.4);
  --radius: 18px;
  --sidebar-width: 390px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

a {
  color: #8cc7ff;
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #0a0f18;
  color: white;
  text-align: center;
}

#app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  position: relative;
  z-index: 5;
  height: 100dvh;
  overflow-y: auto;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(8, 12, 18, 0.98), rgba(8, 12, 18, 0.92)),
    radial-gradient(circle at top left, rgba(255, 212, 0, 0.12), transparent 35%);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.brand {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--yellow);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  line-height: 1.05;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.language-panel {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 18px 0;
}

.lang-btn,
.retry,
.icon-btn,
.segment {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 10px;
  cursor: pointer;
}

.lang-btn:hover,
.retry:hover,
.icon-btn:hover,
.segment:hover {
  background: rgba(255, 255, 255, 0.12);
}

.lang-btn.active,
.segment.active {
  background: var(--yellow);
  color: #141414;
  border-color: transparent;
  font-weight: 800;
}

.panel,
.notice,
.source {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.notice {
  background: rgba(255, 255, 255, 0.055);
}

.danger-soft {
  background:
    linear-gradient(180deg, rgba(255, 212, 0, 0.12), rgba(255, 59, 48, 0.07)),
    rgba(255, 255, 255, 0.04);
}

.notice strong,
.source strong {
  display: block;
  margin-bottom: 8px;
}

.notice p,
.source p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #d8dee9;
}

.aoi-card {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  text-align: left;
}

button.aoi-card {
  cursor: pointer;
}

button.aoi-card:hover {
  background: rgba(255, 255, 255, 0.1);
}

.active-aoi {
  border-color: rgba(57, 217, 138, 0.45);
  box-shadow: 0 0 0 1px rgba(57, 217, 138, 0.18) inset;
}

.aoi-card.disabled {
  opacity: 0.55;
}

.aoi-card strong {
  display: block;
}

.aoi-card small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.status-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 999px;
  box-shadow: 0 0 18px currentColor;
}

.status-dot.green {
  background: var(--green);
  color: var(--green);
}

.status-dot.amber {
  background: var(--amber);
  color: var(--amber);
}

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

.segment {
  border-radius: 14px;
  font-size: 0.9rem;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 13px;
  color: #d8dee9;
  line-height: 1.35;
  cursor: pointer;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--yellow);
}

.helper {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.86rem;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 11px;
  color: #d8dee9;
}

.swatch {
  width: 22px;
  height: 16px;
  flex: 0 0 22px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.swatch.possible {
  background: var(--yellow);
}

.swatch.damaged {
  background: var(--orange);
}

.swatch.destroyed {
  background: var(--red);
}

.swatch.road {
  height: 3px;
  border: 0;
  border-radius: 999px;
  background: var(--road);
}

.swatch.hatch {
  background:
    repeating-linear-gradient(
      45deg,
      rgba(180, 188, 200, 0.95) 0,
      rgba(180, 188, 200, 0.95) 2px,
      rgba(40, 45, 55, 0.95) 2px,
      rgba(40, 45, 55, 0.95) 6px
    );
}

.source {
  margin-bottom: 20px;
}

.small {
  margin-top: 8px !important;
  font-size: 0.84rem;
}

.map-area {
  position: relative;
  min-width: 0;
  height: 100dvh;
}

#map {
  position: absolute;
  inset: 0;
  background: #05070a;
}

.mobile-topbar {
  display: none;
}

.map-status {
  position: absolute;
  left: 24px;
  bottom: 30px;
  z-index: 4;
  max-width: min(460px, calc(100% - 48px));
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(9, 13, 20, 0.9);
  color: var(--text);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.map-status.hidden {
  display: none;
}

.map-status.error {
  border-color: rgba(255, 59, 48, 0.5);
}

.map-status.success {
  border-color: rgba(57, 217, 138, 0.45);
}

.map-status strong {
  display: block;
  margin-bottom: 4px;
}

.map-status p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--yellow);
  border-radius: 999px;
  animation: spin 0.9s linear infinite;
}

.map-status.success .spinner {
  animation: none;
  border-color: rgba(57, 217, 138, 0.35);
  border-top-color: var(--green);
}

.map-status.error .spinner {
  animation: none;
  border-color: rgba(255, 59, 48, 0.35);
  border-top-color: var(--red);
}

.retry {
  margin-top: 10px;
  padding-inline: 16px;
}

.hidden {
  display: none !important;
}

.maplibregl-ctrl-attrib {
  background: rgba(8, 12, 18, 0.72) !important;
  color: #d8dee9 !important;
}

.maplibregl-ctrl-attrib a {
  color: #a9d3ff !important;
}

.maplibregl-ctrl-logo {
  filter: grayscale(1);
}

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

@media (max-width: 820px) {
  #app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(88vw, var(--sidebar-width));
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .map-area {
    height: 100dvh;
  }

  .mobile-topbar {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
    right: 12px;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(9, 13, 20, 0.82);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
    font-weight: 800;
  }

  .icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
  }

  .map-status {
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    max-width: none;
  }
}


.legend-toggle {
  cursor: pointer;
  user-select: none;
}

.legend-toggle.off {
  opacity: 0.45;
}

.layer-checkbox {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin: 0;
  accent-color: var(--yellow);
}


.data-status-panel {
  background:
    linear-gradient(180deg, rgba(55, 93, 140, 0.14), rgba(255, 255, 255, 0.045)),
    var(--panel-2);
}

.data-source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.data-source-links a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: #a9d3ff;
  font-size: 0.84rem;
  text-decoration: none;
}

.data-source-links a:hover {
  background: rgba(255, 255, 255, 0.11);
}

.data-status-grid {
  display: grid;
  gap: 8px;
}

.data-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.data-row:last-child {
  border-bottom: 0;
}

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

.data-value {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.freshness-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 12px;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
}

.freshness-badge.fresh {
  background: rgba(57, 217, 138, 0.16);
  color: #7ff0b3;
  border: 1px solid rgba(57, 217, 138, 0.35);
}

.freshness-badge.recent {
  background: rgba(255, 212, 0, 0.15);
  color: #ffe680;
  border: 1px solid rgba(255, 212, 0, 0.32);
}

.freshness-badge.old,
.freshness-badge.stale {
  background: rgba(255, 140, 0, 0.15);
  color: #ffc27a;
  border: 1px solid rgba(255, 140, 0, 0.35);
}

.freshness-badge.neutral {
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  border: 1px solid var(--border);
}

.secondary-btn {
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.065);
  color: var(--text);
  cursor: pointer;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}


.legend-toggle.disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.legend-toggle.disabled .layer-checkbox,
.legend-toggle.disabled .swatch,
.legend-toggle.disabled span {
  cursor: not-allowed;
}

.issue-report {
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.issue-report a {
  margin-left: 4px;
  font-weight: 800;
}


.built-by-author {
  color: var(--muted);
}


.footer-source-line {
  margin-bottom: 8px !important;
}

.footer-credit {
  line-height: 1.5;
}

.footer-credit a {
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* AOI dynamic list styles: start */
.aoi-list {
  display: grid;
  gap: 10px;
}

.aoi-card.placeholder-aoi {
  opacity: 0.68;
}

.aoi-card.available-aoi {
  opacity: 1;
}

.status-dot.red {
  background: var(--red);
  color: var(--red);
}
/* AOI dynamic list styles: end */

/* Map legend overlay styles: start */
.map-legend {
  position: absolute;
  right: 16px;
  bottom: 18px;
  z-index: 5;
  width: min(380px, calc(100% - 32px));
  max-height: min(72dvh, 680px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(9, 13, 20, 0.9);
  color: var(--text);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.map-legend-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(9, 13, 20, 0.94);
}

.map-legend-header strong {
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.legend-collapse-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  line-height: 1;
}

.legend-collapse-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.map-legend.collapsed {
  overflow: hidden;
}

.map-legend.collapsed .map-legend-body {
  display: none;
}

.map-legend-body {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.legend-section {
  display: grid;
  gap: 8px;
}

.legend-section-title {
  margin-top: 2px;
  color: #f4f7fb;
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.legend-section-title.with-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.map-legend-row {
  display: grid;
  grid-template-columns: 18px 34px 1fr;
  align-items: center;
  gap: 9px;
  min-height: 24px;
  color: #d8dee9;
  font-size: 0.86rem;
  line-height: 1.25;
}

.map-legend-row:not(.legend-toggle) {
  grid-template-columns: 34px 1fr;
  padding-left: 27px;
}

.map-legend-row.legend-toggle {
  cursor: pointer;
  user-select: none;
}

.map-legend .layer-checkbox {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--yellow);
}

.map-legend .swatch {
  width: 28px;
  height: 17px;
}

.line-swatch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 14px;
}

.line-swatch::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 999px;
}

.line-swatch.highway::before {
  height: 5px;
  background: rgba(255, 180, 188, 0.96);
  border: 1px solid rgba(95, 95, 95, 0.95);
}

.line-swatch.main-road::before {
  height: 4px;
  background: rgba(246, 248, 250, 0.96);
  border: 1px solid rgba(105, 105, 105, 0.9);
}

.line-swatch.local-road::before {
  height: 3px;
  background: rgba(170, 174, 180, 0.95);
  border: 1px solid rgba(70, 70, 70, 0.75);
}

.line-swatch.track::before {
  border-top: 3px dashed rgba(190, 194, 200, 0.96);
}

.line-swatch.railway::before {
  height: 3px;
  background: rgba(18, 18, 18, 0.95);
}

.line-swatch.railway::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 1px;
  width: 2px;
  height: 12px;
  background: rgba(18, 18, 18, 0.95);
  box-shadow:
    10px 0 0 rgba(18, 18, 18, 0.95),
    20px 0 0 rgba(18, 18, 18, 0.95);
}

.aoi-swatch {
  width: 28px;
  height: 17px;
  border: 3px solid #61f06d;
  border-radius: 3px;
  background: rgba(97, 240, 109, 0.08);
}

@media (max-width: 820px) {
  .map-legend {
    left: 12px;
    right: 12px;
    bottom: 118px;
    width: auto;
    max-height: 42dvh;
  }

  .map-legend-body {
    gap: 12px;
    padding: 12px;
  }

  .map-legend-row {
    font-size: 0.82rem;
  }
}
/* Map legend overlay styles: end */

/* Selectable transport legend styles: start */
.map-legend-row.transport-toggle {
  grid-template-columns: 18px 34px 1fr;
}

.map-legend-row.transport-toggle .line-swatch,
.map-legend-row.transport-toggle .swatch,
.map-legend-row.transport-toggle .aoi-swatch {
  pointer-events: none;
}

.map-legend-row.transport-toggle.off {
  opacity: 0.45;
}

.line-swatch.railway::before {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.45);
}
/* Selectable transport legend styles: end */


/* Ground movement legend styles: start */
.legend-section.hidden,
.map-legend-row.hidden {
  display: none !important;
}

.legend-subtitle {
  padding-left: 27px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.ground-swatch {
  width: 28px;
  height: 17px;
  flex: 0 0 28px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18) inset;
}

.ground-swatch.gm-neg-high {
  background: #4965ad;
}

.ground-swatch.gm-neg-medium {
  background: #76a3c7;
}

.ground-swatch.gm-neg-low {
  background: #b4d8e7;
}

.ground-swatch.gm-near-zero-neg {
  background: #e4f3f8;
}

.ground-swatch.gm-near-zero-pos {
  background: #fee6a6;
}

.ground-swatch.gm-pos-low {
  background: #f6ad68;
}

.ground-swatch.gm-pos-medium {
  background: #e56845;
}

.ground-swatch.gm-pos-high {
  background: #be2f2f;
}

.ground-swatch.gm-above-high {
  background: #9e182c;
}
/* Ground movement legend styles: end */

