:root {
  --ink: #17212b;
  --muted: #5c6875;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: #ffffff;
  --line: rgba(27, 39, 52, 0.16);
  --accent: #009ff5;
  --accent-dark: #0078bd;
  --danger: #c53929;
  --ready: #23864d;
  --shadow: 0 10px 28px rgba(16, 33, 50, 0.2);
  font-family: "Encode Sans", "Inter", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: #eef2f5;
}

button,
input {
  font: inherit;
}

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

.map-section {
  position: relative;
  height: min(760px, 82vh);
  min-height: 580px;
  overflow: hidden;
  background: #d9e2ea;
}

.map {
  position: absolute;
  inset: 0;
  z-index: 0;
  overscroll-behavior: contain;
}

.external-stage {
  position: absolute;
  inset: 0;
  z-index: 520;
  background: #f6f9fb;
  overscroll-behavior: contain;
}

.external-stage[hidden] {
  display: none;
}

.external-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.brand-panel,
.status-panel,
.layer-panel,
.altitude-panel,
.time-panel,
.icon-button {
  position: absolute;
  z-index: 700;
}

.brand-panel {
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(420px, calc(100vw - 32px));
  min-height: 70px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand-logo {
  width: 154px;
  height: auto;
  flex: 0 0 auto;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-text strong {
  font-size: 1rem;
  line-height: 1.1;
}

.brand-text span {
  color: var(--muted);
  font-size: 0.82rem;
}

.status-panel {
  left: 16px;
  bottom: 108px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(460px, calc(100vw - 32px));
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 6px 16px rgba(16, 33, 50, 0.16);
  color: var(--muted);
  font-size: 0.84rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #8b98a6;
}

.status-dot[data-status="pending"] {
  background: #d69a1b;
}

.status-dot[data-status="ready"] {
  background: var(--ready);
}

.status-dot[data-status="demo"] {
  background: var(--accent);
}

.status-dot[data-status="error"] {
  background: var(--danger);
}

.layer-panel {
  top: 16px;
  right: 16px;
  width: 286px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-heading {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.layer-panel-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  list-style: none;
  cursor: pointer;
  user-select: none;
  transition: margin-bottom 220ms ease;
}

.layer-panel:not([open]) .layer-panel-summary {
  margin-bottom: 0;
}

.layer-panel-summary::-webkit-details-marker {
  display: none;
}

.layer-panel-summary::marker {
  content: '';
}

.layer-panel-summary-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.layer-panel-summary .panel-heading {
  margin-bottom: 0;
}

.layer-panel-active {
  color: var(--accent-dark);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.2;
}

.layer-panel-caret {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
  box-shadow: 0 6px 16px rgba(16, 33, 50, 0.12);
  color: var(--ink);
}

.layer-panel-caret::before {
  display: block;
  content: '⌃';
  font-size: 0.9rem;
  line-height: 1;
  transform: translateY(-1px) rotate(0deg);
  transition: transform 180ms ease;
}

.layer-panel:not([open]) .layer-panel-caret::before {
  transform: translateY(-1px) rotate(180deg);
}

.layer-panel-body {
  position: relative;
  max-height: 300px;
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  overflow: hidden;
  transition:
    max-height 220ms ease,
    opacity 160ms ease,
    transform 220ms ease,
    visibility 0s;
}

.layer-panel:not([open]) .layer-panel-body {
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  pointer-events: none;
  transition:
    max-height 220ms ease,
    opacity 160ms ease,
    transform 220ms ease,
    visibility 0s linear 220ms;
}

.layer-panel-body-inner {
  min-height: 0;
}

.layer-scroll-hint,
.content-scroll-hint {
  position: absolute;
  right: 16px;
  bottom: 10px;
  z-index: 2;
  display: grid;
  gap: 1px;
  align-items: center;
  justify-items: center;
  color: var(--accent-dark);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.content-scroll-hint {
  right: 0;
  top: 16px;
  bottom: auto;
}

.layer-scroll-hint.is-visible,
.content-scroll-hint.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.layer-scroll-hint-icon,
.content-scroll-hint-icon {
  display: block;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.layer-scroll-hint-mouse,
.content-scroll-hint-mouse {
  display: block;
  width: 18px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.layer-scroll-hint-mouse path,
.content-scroll-hint-mouse path {
  animation: scroll-hint-wheel 1.6s ease-in-out infinite;
}

.layer-scroll-hint-icon-up,
.content-scroll-hint-icon-up {
  animation: scroll-hint-up 1.4s ease-in-out infinite;
}

.layer-scroll-hint-icon-down,
.content-scroll-hint-icon-down {
  animation: scroll-hint-down 1.4s ease-in-out infinite;
}

.layer-panel-scroll {
  max-height: 300px;
  overflow-y: scroll;
  padding-right: 4px;
  padding-bottom: 28px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
  scrollbar-color: rgba(27, 39, 52, 0.34) rgba(27, 39, 52, 0.08);
}

@keyframes scroll-hint-up {
  0%,
  100% {
    transform: translateY(1px);
    opacity: 0.55;
  }
  50% {
    transform: translateY(-2px);
    opacity: 1;
  }
}

@keyframes scroll-hint-down {
  0%,
  100% {
    transform: translateY(-1px);
    opacity: 0.55;
  }
  50% {
    transform: translateY(2px);
    opacity: 1;
  }
}

@keyframes scroll-hint-wheel {
  0%,
  100% {
    opacity: 0.45;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(2px);
  }
}

.layer-panel-scroll::-webkit-scrollbar {
  width: 12px;
}

.layer-panel-scroll::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(27, 39, 52, 0.08);
}

.layer-panel-scroll::-webkit-scrollbar-thumb {
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: rgba(27, 39, 52, 0.28);
}

.layer-panel-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(27, 39, 52, 0.4);
}

.layer-groups {
  display: grid;
  gap: 10px;
}

.layer-group + .layer-group {
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.layer-group-toggle {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.layer-group-heading {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.layer-group-title {
  margin-bottom: 0;
}

.layer-group-caption {
  color: var(--muted);
  font-size: 0.76rem;
}

.layer-group-body {
  opacity: 1;
  overflow: visible;
  transform: none;
  transition: none;
}

.layer-group.is-collapsible .layer-group-body {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-6px);
  transition:
    max-height 220ms ease,
    opacity 160ms ease,
    transform 220ms ease;
}

.layer-group.is-collapsible.is-open .layer-group-body {
  max-height: 3200px;
  opacity: 1;
  transform: translateY(0);
}

.layer-group-body-inner {
  padding-top: 10px;
}

.layer-node-stack {
  display: grid;
  gap: 8px;
}

.layer-subgroup + .layer-subgroup {
  padding-top: 12px;
  border-top: 1px solid rgba(27, 39, 52, 0.1);
}

.layer-subgroup-title {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.layer-subgroup-depth-2 {
  padding-left: 8px;
}

.layer-subgroup-depth-3 {
  padding-left: 16px;
}

.layer-button {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.layer-button strong {
  font-size: 0.92rem;
}

.layer-button span {
  color: var(--muted);
  font-size: 0.78rem;
}

.layer-button:hover,
.layer-button.is-selected {
  border-color: rgba(0, 159, 245, 0.75);
}

.layer-button.is-selected {
  background: #edf8ff;
  box-shadow: inset 4px 0 0 var(--accent);
}

.map-section.is-external-mode .status-panel,
.map-section.is-external-mode .map-reset,
.map-section.is-external-mode .info-button,
.map-section.is-external-mode .altitude-panel,
.map-section.is-external-mode .time-panel {
  display: none;
}

.map-section.is-external-mode .map {
  visibility: hidden;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
  box-shadow: 0 6px 16px rgba(16, 33, 50, 0.16);
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.map-reset-icon {
  display: block;
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-reset {
  top: 102px;
  left: 16px;
}

.info-button {
  top: 148px;
  left: 16px;
  font-weight: 800;
  font-style: italic;
}

.altitude-panel {
  right: 16px;
  bottom: 108px;
  display: grid;
  justify-items: center;
  gap: 5px;
  width: 86px;
  padding: 8px 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.altitude-heading {
  width: 100%;
  text-align: center;
  margin-bottom: 0;
}

.altitude-value-label {
  width: 100%;
  text-align: center;
  font-size: 0.84rem;
  line-height: 1.1;
}

.altitude-slider-shell {
  position: relative;
  width: 56px;
  height: 176px;
  margin-inline: auto;
  margin-top: 10px;
}

.altitude-slider {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  width: 24px;
  height: 136px;
  margin: 0;
  writing-mode: vertical-lr;
  direction: rtl;
  accent-color: var(--accent);
  cursor: pointer;
}

.altitude-scale {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1;
}

.altitude-scale span {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  text-align: center;
  white-space: nowrap;
}

.altitude-scale-top {
  top: 0;
}

.altitude-scale-mid {
  display: none;
}

.altitude-scale-bottom {
  bottom: 12px;
}

.time-panel {
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: grid;
  grid-template-columns: minmax(140px, 180px) 52px 1fr minmax(180px, 260px);
  align-items: center;
  gap: 18px;
  min-height: 76px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.time-meta {
  display: grid;
  gap: 3px;
}

.time-meta span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.time-meta strong {
  font-size: 1.35rem;
}

.time-play-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: 0 6px 16px rgba(16, 33, 50, 0.12);
  cursor: pointer;
}

.time-play-button:hover,
.time-play-button[aria-pressed="true"] {
  border-color: var(--accent);
}

.time-play-button[aria-pressed="true"] {
  background: #edf8ff;
  color: var(--accent-dark);
}

.time-play-icon {
  display: block;
  font-size: 0.95rem;
  transform: translateY(-2px);
}

.slider-wrap {
  min-width: 0;
  position: relative;
  --time-tick-inset: 10px;
}

.time-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.time-ticks {
  position: relative;
  height: 16px;
  margin-top: 4px;
  margin-inline: var(--time-tick-inset);
  color: var(--muted);
  font-size: 0.72rem;
}

.time-ticks span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
}

.time-ticks span:first-child {
  left: 0;
  transform: none;
}

.time-ticks span:nth-child(2) {
  left: 20%;
}

.time-ticks span:nth-child(3) {
  left: 40%;
}

.time-ticks span:nth-child(4) {
  left: 60%;
}

.time-ticks span:nth-child(5) {
  left: 80%;
}

.time-ticks span:last-child {
  right: 0;
  left: auto;
  transform: none;
}

.time-value {
  justify-self: end;
  color: var(--muted);
  font-size: 0.92rem;
  white-space: nowrap;
}

.content-section {
  background: #f7f9fb;
  border-top: 1px solid var(--line);
}

.content-inner {
  width: min(980px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 46px 0 64px;
  position: relative;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.content-inner h1 {
  margin: 0 0 18px;
  font-size: 1.8rem;
}

.text-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  color: #354252;
  line-height: 1.6;
}

.text-grid p {
  margin: 0;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(13, 28, 42, 0.58);
  backdrop-filter: blur(6px);
}

.login-gate.is-hidden {
  display: none;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(390px, 100%);
  padding: 26px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.login-logo {
  width: 164px;
}

.login-card h2 {
  margin: 2px 0 0;
  font-size: 1.45rem;
}

.login-card p {
  margin: 0;
  color: var(--muted);
}

.login-card label {
  display: grid;
  gap: 6px;
  font-size: 0.86rem;
  font-weight: 700;
}

.login-card input {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.login-card button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.login-card button:hover {
  background: var(--accent-dark);
}

.login-error {
  min-height: 18px;
  color: var(--danger) !important;
  font-size: 0.84rem;
}

.info-dialog {
  width: min(520px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.info-dialog::backdrop {
  background: rgba(13, 28, 42, 0.45);
  backdrop-filter: blur(4px);
}

.info-card {
  padding: 24px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.dialog-header h2 {
  margin: 0;
}

.dialog-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 1.25rem;
  cursor: pointer;
}

.info-card p {
  color: #354252;
  line-height: 1.55;
}

.map-popup h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.map-popup dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 12px;
  margin: 0;
}

.map-popup dt {
  color: var(--muted);
  font-weight: 700;
}

.map-popup dd {
  margin: 0;
}

@media (max-width: 760px) {
  .map-section {
    height: 84vh;
    min-height: 640px;
  }

  .brand-panel {
    align-items: flex-start;
    width: calc(100vw - 24px);
    top: 12px;
    left: 12px;
    padding: 10px 12px;
  }

  .brand-logo {
    width: 128px;
  }

  .brand-text span {
    display: none;
  }

  .layer-panel {
    top: 94px;
    right: 12px;
    width: 232px;
  }

  .layer-panel-summary {
    margin-bottom: 8px;
  }

  .layer-panel-body {
    max-height: 196px;
  }

  .layer-panel-scroll {
    max-height: 196px;
  }

  .layer-button {
    min-height: 44px;
  }

  .layer-button span {
    display: none;
  }

  .map-reset {
    top: 94px;
    left: 12px;
  }

  .info-button {
    top: 146px;
    bottom: auto;
    left: 12px;
    right: auto;
  }

  .altitude-panel {
    right: 12px;
    bottom: 208px;
    width: 90px;
    padding: 7px 5px 9px;
  }

  .altitude-slider-shell {
    width: 52px;
    height: 168px;
  }

  .altitude-slider {
    top: 16px;
    height: 136px;
  }

  .status-panel {
    left: 12px;
    right: 12px;
    bottom: 126px;
    max-width: none;
  }

  .time-panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .time-value {
    justify-self: start;
    white-space: normal;
  }

  .text-grid {
    grid-template-columns: 1fr;
  }
}
