:root {
  --bg: #242424;
  --bg-soft: rgba(44, 44, 44, 0.88);
  --panel: rgba(54, 54, 54, 0.92);
  --panel-2: rgba(70, 70, 70, 0.78);
  --stroke: rgba(255, 255, 255, 0.1);
  --ink: #f2f0ea;
  --muted: #b6b2a7;
  --accent: #eba546;
  --accent-2: #8db14e;
  --plot: #d7cfb4;
}

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

body {
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  overflow: hidden;
}

.viewer-shell {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(129, 158, 69, 0.12), transparent 20%),
    radial-gradient(circle at bottom left, rgba(235, 165, 70, 0.06), transparent 18%),
    var(--bg);
}

.canvas-wrap,
.map-panel {
  position: absolute;
  inset: 0;
}

#threeCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.map-panel {
  background:
    linear-gradient(180deg, rgba(42, 42, 42, 0.9), rgba(38, 38, 38, 0.96)),
    repeating-linear-gradient(to right, rgba(255,255,255,0.04) 0 1px, transparent 1px 60px),
    repeating-linear-gradient(to bottom, rgba(255,255,255,0.04) 0 1px, transparent 1px 60px),
    #2a2a2a;
}

.map-grid {
  position: absolute;
  inset: 11% 14% 18% 14%;
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 2px;
}

.map-grid::before,
.map-grid::after {
  content: "";
  position: absolute;
  background: rgba(132, 156, 74, 0.8);
}

.map-grid::before {
  inset: 10% 10% 10% auto;
  width: 18%;
  clip-path: polygon(0 0, 100% 12%, 84% 100%, 0 80%);
}

.map-grid::after {
  left: 0;
  right: 0;
  bottom: 0;
  height: 12%;
  clip-path: polygon(0 34%, 60% 24%, 82% 70%, 100% 0, 100% 100%, 0 100%);
}

.map-overlay-copy {
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  max-width: 260px;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  background: rgba(34, 34, 34, 0.84);
  border: 1px solid var(--stroke);
  color: var(--muted);
}

.brand-hud {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.95rem;
  padding: 0.8rem 1rem;
}

.brand-mark {
  position: relative;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}

.brand-mark-main {
  position: absolute;
  inset: 0;
  background: var(--accent);
  clip-path: polygon(0 42%, 34% 6%, 68% 6%, 100% 36%, 100% 100%, 74% 100%, 74% 42%, 26% 42%, 26% 100%, 0 100%);
  border-radius: 6px;
}

.brand-mark-cut {
  position: absolute;
  left: 14px;
  top: 16px;
  width: 10px;
  height: 20px;
  background: var(--bg);
  border-radius: 2px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
}

.brand-sub {
  margin-top: 0.15rem;
  font-size: 0.76rem;
  color: rgba(255,255,255,0.56);
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.left-rail,
.top-right-tools {
  position: absolute;
  z-index: 20;
}

.left-rail {
  top: 72px;
  left: 10px;
}

.top-right-tools {
  top: 10px;
  right: 10px;
}

.rail-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(43,43,43,0.88);
  color: white;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.north-btn {
  border-radius: 999px;
  font-size: 0.88rem;
}

.gem-btn {
  border-radius: 2px;
}

.gem-shape {
  width: 16px;
  height: 16px;
  background: linear-gradient(135deg, #9ed251, #6ca735);
  transform: rotate(45deg);
  border-radius: 2px;
  position: relative;
}

.gem-shape::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: rgba(43,43,43,0.78);
}

.plot-card {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 20;
  width: min(290px, calc(100vw - 36px));
  padding: 0.9rem 1rem;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: rgba(33, 33, 33, 0.92);
  box-shadow: 0 18px 40px rgba(0,0,0,0.22);
}

.plot-card-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.45);
}

.plot-card-title {
  margin: 0.35rem 0 0.6rem;
  font-size: 1.05rem;
  color: var(--ink);
}

.plot-card-line {
  font-size: 0.84rem;
  color: var(--muted);
}

.plot-card-line + .plot-card-line {
  margin-top: 0.2rem;
}

.control-dock {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  width: min(330px, calc(100vw - 28px));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.status-toggle-row {
  display: flex;
  justify-content: flex-start;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 112px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(62,62,62,0.95);
  color: var(--ink);
  font-size: 0.95rem;
}

.switch-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.switch-wrap input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-ui {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  position: relative;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  transition: transform 0.18s ease;
}

#statusToggle:checked + .switch-ui::after {
  transform: translateX(16px);
}

#statusToggle:checked + .switch-ui {
  background: rgba(141, 177, 78, 0.55);
}

.legend-dock {
  display: none;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--stroke);
  background: rgba(39,39,39,0.92);
}

.legend-dock.is-open {
  display: block;
}

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

.legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(77,77,77,0.45);
  color: var(--ink);
  cursor: pointer;
}

.legend-item:hover,
.legend-item.is-active {
  background: rgba(235,165,70,0.12);
  border-color: rgba(235,165,70,0.28);
}

.legend-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
}

.legend-count {
  color: rgba(255,255,255,0.55);
  font-size: 0.8rem;
}

.search-shell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(58,58,58,0.95);
}

.search-shell input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.96rem;
}

.search-shell input::placeholder {
  color: rgba(255,255,255,0.36);
}

.search-shell button,
.search-icon {
  flex: 0 0 auto;
  color: rgba(255,255,255,0.55);
}

.search-shell button {
  border: 0;
  background: transparent;
  font-size: 1.1rem;
  line-height: 1;
}

.quick-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.circle-action {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(56,56,56,0.95);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.96rem;
}

.footer-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.footer-pill {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(58,58,58,0.95);
  color: var(--muted);
  font-size: 0.95rem;
}

.meta-chip {
  position: absolute;
  top: 16px;
  right: 64px;
  z-index: 20;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(52,52,52,0.82);
  color: rgba(255,255,255,0.5);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
}

.hover-card {
  position: absolute;
  z-index: 30;
  min-width: 150px;
  max-width: 220px;
  padding: 0.7rem 0.8rem;
  border-radius: 16px;
  border: 1px solid var(--stroke);
  background: rgba(38,38,38,0.96);
  color: var(--ink);
  pointer-events: none;
  transform: translate(14px, 14px);
}

.hover-title {
  font-weight: 700;
}

.hover-meta {
  margin-top: 0.2rem;
  color: rgba(255,255,255,0.58);
  font-size: 0.82rem;
}

.is-invalid {
  color: #ffb2b2 !important;
}

@media (max-width: 900px) {
  .brand-sub,
  .meta-chip {
    display: none;
  }
}

@media (max-width: 768px) {
  .brand-hud {
    top: max(6px, env(safe-area-inset-top));
    gap: 0.7rem;
    padding: 0.7rem 0.8rem;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand-title {
    font-size: 1rem;
  }

  .left-rail {
    top: 64px;
    left: 8px;
  }

  .rail-btn {
    width: 38px;
    height: 38px;
  }

  .control-dock {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .plot-card {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: 206px;
  }

  .footer-pill {
    min-height: 42px;
    font-size: 0.88rem;
  }

  .circle-action {
    width: 44px;
    height: 44px;
  }

  .hover-card {
    display: none !important;
  }
}
