:root {
  --bg: #0b0f14;
  --bg-elev: #121820;
  --bg-panel: #0f141c;
  --border: #243041;
  --text: #e8eef6;
  --muted: #8b9bb0;
  --accent: #3b9eff;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --toolbar-h: 64px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Splash Screen — same as TEMPLATE map.html */
#splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  animation: fadeOut 0.6s ease-in-out 2s forwards;
}

#splash-logo-daeges,
#splash-logo-3dgr {
  width: 280px;
}

#splash-logo-daeges {
  animation: slideFromTop 0.6s ease-out forwards;
}

#splash-logo-3dgr {
  animation: slideFromBottom 0.6s ease-out forwards;
}

@keyframes slideFromTop {
  from {
    transform: translateY(-100vh);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes slideFromBottom {
  from {
    transform: translateY(100vh);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/* Toolbar */
.toolbar {
  height: var(--toolbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  background: linear-gradient(180deg, #141b25 0%, #10161e 100%);
  border-bottom: 1px solid var(--border);
  z-index: 20;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: radial-gradient(circle at 30% 30%, #5eb3ff, #1d6fd4);
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(59, 158, 255, 0.35), 0 8px 20px rgba(29, 111, 212, 0.35);
}

.brand h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.subtitle {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: #1a2330;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  user-select: none;
  white-space: nowrap;
}

.btn:hover {
  background: #223044;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(180deg, #4aa8ff, #2b7fd4);
  border-color: #6bb8ff55;
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(180deg, #5eb3ff, #3489e0);
}

.btn-secondary {
  background: #182232;
  border-color: var(--border);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn-ghost:hover,
.btn-ghost.active {
  color: var(--text);
  border-color: #3a4d66;
  background: #182232;
}

/* Workspace layout */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr minmax(280px, 380px);
  gap: 0;
}

.workspace.map-collapsed {
  grid-template-columns: 1fr 0px;
}

.workspace.list-only .map-wrap {
  display: none;
}

.workspace.map-only .list-wrap {
  display: none;
}

/* Viewer */
.viewer-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: #05070a;
}

#viewer {
  width: 100%;
  height: 100%;
}

#viewer .psv-container {
  --psv-loader-background: transparent;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(59, 158, 255, 0.12), transparent 55%),
    #070a0f;
  z-index: 5;
}

.empty-state.hidden {
  display: none;
}

.empty-card {
  width: min(560px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.empty-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.empty-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
}

.empty-card p {
  margin: 0 0 1.25rem;
  color: var(--muted);
  line-height: 1.5;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

/* HUD overlay */
.viewer-hud {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 4;
  max-width: min(420px, calc(100% - 2rem));
  padding: 0.7rem 0.95rem;
  background: rgba(10, 14, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.viewer-hud[hidden] {
  display: none;
}

.hud-title {
  font-weight: 650;
  font-size: 0.95rem;
}

.hud-meta {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Nearby navigation arrows (Street View style) */
.nav-arrows {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.nav-arrows[hidden] {
  display: none;
}

.nav-arrow {
  --nav-rot: 0deg;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border: none;
  border-radius: 50%;
  background: rgba(12, 18, 28, 0.78);
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  transition: background 0.15s, box-shadow 0.15s;
  display: grid;
  place-items: center;
  padding: 0;
  /* Same base arrow for all; rotate toward target */
  transform: rotate(var(--nav-rot));
}

.nav-arrow:hover {
  background: rgba(59, 158, 255, 0.95);
  box-shadow: 0 0 0 3px rgba(59, 158, 255, 0.35), 0 4px 18px rgba(0, 0, 0, 0.4);
}

.nav-arrow-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.nav-arrow .tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  /* Counter-rotate label so text stays upright */
  transform: translateX(-50%) rotate(calc(-1 * var(--nav-rot)));
  white-space: nowrap;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.nav-arrow:hover .tip {
  opacity: 1;
}

/* Side panel */
.side-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow: hidden;
  transition: width 0.2s;
}

.workspace.map-collapsed .side-panel {
  border-left: none;
  overflow: hidden;
}

.map-wrap {
  position: relative;
  flex: 1 1 55%;
  min-height: 180px;
  border-bottom: 1px solid var(--border);
}

#map {
  width: 100%;
  height: 100%;
  background: #e8eef4;
}

.map-legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.6rem;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #d0d7e2;
  border-radius: 8px;
  font-size: 0.72rem;
  color: #4a5568;
  backdrop-filter: blur(6px);
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #64748b;
  box-shadow: 0 0 0 2px rgba(100, 116, 139, 0.25);
  margin-right: 2px;
}

.dot.active {
  background: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}

/* Leaflet light map */
.leaflet-container {
  background: #e8eef4;
  font-family: var(--font);
}

.leaflet-control-zoom a {
  background: #fff !important;
  color: #1a2330 !important;
  border-color: #c5ced9 !important;
}

.leaflet-control-zoom a:hover {
  background: #f3f6fa !important;
}

/* Attribution removed via map options (attributionControl: false) */
.leaflet-control-attribution {
  display: none !important;
}

/* Custom map markers */
.pano-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #64748b;
  border: 2px solid #e8eef6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s, background 0.15s;
}

.pano-marker.active {
  background: var(--accent);
  transform: scale(1.25);
  box-shadow: 0 0 0 4px rgba(59, 158, 255, 0.35), 0 2px 10px rgba(0, 0, 0, 0.5);
}

.pano-marker:hover {
  transform: scale(1.2);
}

/* List */
.list-wrap {
  flex: 1 1 45%;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.list-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.list-header h2 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 650;
  white-space: nowrap;
}

#pano-count {
  display: inline-grid;
  place-items: center;
  min-width: 1.4rem;
  height: 1.2rem;
  padding: 0 0.35rem;
  margin-left: 0.25rem;
  border-radius: 999px;
  background: #1a2636;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

#search {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0a0e14;
  color: var(--text);
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 0.8rem;
}

#search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 158, 255, 0.2);
}

.pano-list {
  list-style: none;
  margin: 0;
  padding: 0.4rem;
  overflow: auto;
  flex: 1;
}

.pano-list li {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.5rem;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}

.pano-list li:hover {
  background: #151d28;
}

.pano-list li.active {
  background: rgba(59, 158, 255, 0.12);
  border-color: rgba(59, 158, 255, 0.35);
}

.pano-thumb {
  width: 56px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  background: #1a2330;
  border: 1px solid var(--border);
}

.pano-thumb.placeholder {
  display: grid;
  place-items: center;
  font-size: 0.9rem;
  color: var(--muted);
}

.pano-info {
  min-width: 0;
}

.pano-info .title {
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pano-info .coords {
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pano-index {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
  padding-right: 0.2rem;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%) translateY(120%);
  z-index: 1000;
  padding: 0.7rem 1.1rem;
  border-radius: 10px;
  background: #152033;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  max-width: min(480px, calc(100% - 2rem));
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.5);
  background: #2a1518;
}

/* Responsive */
@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr minmax(220px, 38vh);
  }

  .workspace.map-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 0;
  }

  .side-panel {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .brand .subtitle {
    display: none;
  }

  .toolbar-actions .btn {
    padding: 0.4rem 0.65rem;
    font-size: 0.78rem;
  }
}

@media (max-width: 560px) {
  .toolbar {
    height: auto;
    min-height: var(--toolbar-h);
    flex-wrap: wrap;
    padding: 0.55rem 0.75rem;
  }

  .toolbar-actions {
    width: 100%;
  }
}
