:root {
  --vtd-red: #a30f2d;
  --vtd-red-dark: #7f0b22;
  --vtd-bg: #f5f6f8;
  --vtd-text: #111827;
  --vtd-muted: #4b5563;
  --vtd-border: #e5e7eb;
  --vtd-panel: #ffffff;
  --vtd-soft: #f9fafb;
  --vtd-shadow: 0 18px 48px rgba(17, 24, 39, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
}

body {
  background: var(--vtd-bg);
  color: var(--vtd-text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

.vtd-app {
  width: 100%;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(163, 15, 45, 0.08), rgba(245, 246, 248, 0) 360px),
    var(--vtd-bg);
}

.site-header {
  width: 100%;
  background: #ffffff;
  border-bottom: 1px solid var(--vtd-border);
}

.header-inner {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 38px 0 34px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--vtd-red);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 1080px;
  margin-bottom: 14px;
  color: var(--vtd-text);
  font-size: clamp(2rem, 4vw, 3.55rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.subtitle {
  max-width: 1120px;
  margin-bottom: 0;
  color: var(--vtd-muted);
  font-size: 1.03rem;
}

.viewer-shell {
  width: min(1440px, calc(100% - 48px));
  margin: 28px auto;
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 16px;
  min-width: 0;
}

.panel,
.map-card,
.notice {
  background: var(--vtd-panel);
  border: 1px solid var(--vtd-border);
  box-shadow: var(--vtd-shadow);
}

.panel {
  border-radius: 8px;
  padding: 18px;
}

.panel-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.panel h2,
.notice h2 {
  margin-bottom: 8px;
  font-size: 1.15rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.panel-copy {
  margin-bottom: 18px;
  color: var(--vtd-muted);
  font-size: 0.92rem;
}

.status-badge {
  flex: 0 0 auto;
  border: 1px solid rgba(163, 15, 45, 0.18);
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--vtd-red-dark);
  background: rgba(163, 15, 45, 0.07);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge.is-ready {
  border-color: rgba(22, 101, 52, 0.18);
  color: #166534;
  background: rgba(22, 163, 74, 0.08);
}

.search-label {
  display: block;
  margin-bottom: 6px;
  color: var(--vtd-text);
  font-size: 0.82rem;
  font-weight: 800;
}

.search-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--vtd-border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--vtd-text);
  background: #ffffff;
  outline: none;
}

.search-input:focus {
  border-color: rgba(163, 15, 45, 0.62);
  box-shadow: 0 0 0 3px rgba(163, 15, 45, 0.12);
}

.search-hint {
  margin: 7px 0 0;
  color: var(--vtd-muted);
  font-size: 0.76rem;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 10px;
}

.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

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

.button-primary {
  color: #ffffff;
  background: var(--vtd-red);
  border-color: var(--vtd-red);
}

.button-primary:hover {
  background: var(--vtd-red-dark);
  border-color: var(--vtd-red-dark);
}

.button-light {
  color: var(--vtd-red-dark);
  background: #ffffff;
  border-color: rgba(163, 15, 45, 0.25);
}

.button-light:hover {
  background: rgba(163, 15, 45, 0.06);
}

.search-status {
  min-height: 22px;
  margin: 6px 0 12px;
  color: var(--vtd-muted);
  font-size: 0.84rem;
}

.search-status.is-error {
  color: var(--vtd-red-dark);
  font-weight: 700;
}

.layer-list {
  display: grid;
  gap: 16px;
}

.layer-category {
  border-top: 1px solid var(--vtd-border);
  padding-top: 14px;
}

.layer-category:first-child {
  border-top: 0;
  padding-top: 0;
}

.category-title {
  margin: 0 0 9px;
  color: var(--vtd-text);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.layer-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
}

.layer-item + .layer-item {
  border-top: 1px solid #f0f1f3;
}

.layer-item input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--vtd-red);
}

.layer-main {
  min-width: 0;
}

.layer-title-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.layer-swatch {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 999px;
  border: 2px solid currentColor;
  background: currentColor;
}

.layer-name {
  color: var(--vtd-text);
  font-size: 0.91rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.layer-meta {
  margin-top: 4px;
  color: var(--vtd-muted);
  font-size: 0.78rem;
}

.layer-error {
  margin-top: 4px;
  color: var(--vtd-red-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.map-column {
  min-width: 0;
}

.map-card {
  width: 100%;
  height: 760px;
  min-height: 720px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 720px;
  position: relative;
  overflow: hidden;
  background: #e8eef3;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #e8eef3;
  font-family: inherit;
}

.leaflet-container img,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  max-width: none !important;
  max-height: none !important;
  width: auto;
  height: auto;
  padding: 0;
  margin: 0;
  border: none;
  box-shadow: none;
}

.leaflet-tile-container {
  pointer-events: none;
}

.leaflet-pane,
.leaflet-map-pane,
.leaflet-tile-pane,
.leaflet-overlay-pane,
.leaflet-shadow-pane,
.leaflet-marker-pane,
.leaflet-tooltip-pane,
.leaflet-popup-pane {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-control-layers,
.leaflet-control-scale,
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  font-family: inherit;
}

.leaflet-popup-content {
  width: min(340px, 72vw) !important;
  margin: 16px;
}

.popup-title {
  margin: 0 0 8px;
  color: var(--vtd-text);
  font-size: 1rem;
  line-height: 1.2;
}

.popup-meta {
  display: grid;
  gap: 4px;
  margin: 0 0 10px;
  color: var(--vtd-muted);
  font-size: 0.78rem;
}

.popup-description {
  max-height: 150px;
  overflow: auto;
  border-top: 1px solid var(--vtd-border);
  padding-top: 10px;
  color: var(--vtd-text);
  font-size: 0.84rem;
  white-space: pre-wrap;
}

.popup-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.78rem;
}

.popup-table th,
.popup-table td {
  border-top: 1px solid var(--vtd-border);
  padding: 6px 0;
  text-align: left;
  vertical-align: top;
}

.popup-table th {
  width: 38%;
  padding-right: 10px;
  color: var(--vtd-muted);
  font-weight: 800;
}

.popup-note {
  margin: 12px 0 0;
  border-left: 3px solid var(--vtd-red);
  padding-left: 9px;
  color: var(--vtd-muted);
  font-size: 0.78rem;
}

.coordinate-marker {
  background: transparent;
  border: 0;
}

.coordinate-pin {
  width: 28px;
  height: 28px;
  display: block;
  position: relative;
  border: 3px solid #ffffff;
  border-radius: 999px;
  background: var(--vtd-red);
  box-shadow:
    0 0 0 3px rgba(17, 24, 39, 0.82),
    0 12px 24px rgba(17, 24, 39, 0.32);
}

.coordinate-pin::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  left: 10px;
  top: 10px;
  border-radius: 999px;
  background: #ffffff;
}

.coordinate-results {
  margin-top: 12px;
  border-top: 1px solid var(--vtd-border);
  padding-top: 10px;
}

.coordinate-results h4 {
  margin: 0 0 7px;
  color: var(--vtd-text);
  font-size: 0.86rem;
}

.coordinate-results p {
  margin: 0;
  color: var(--vtd-muted);
  font-size: 0.8rem;
}

.coordinate-results ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.coordinate-results li {
  border-left: 3px solid var(--vtd-red);
  padding-left: 8px;
}

.coordinate-results li strong,
.coordinate-results li span {
  display: block;
}

.coordinate-results li strong {
  color: var(--vtd-text);
  font-size: 0.82rem;
}

.coordinate-results li span {
  color: var(--vtd-muted);
  font-size: 0.76rem;
}

.coordinate-hit-description {
  margin-top: 3px;
}

.home-control {
  display: block;
  min-width: 36px;
  height: 36px;
  border: 0;
  border-bottom: 1px solid #ccc;
  background: #ffffff;
  color: var(--vtd-red-dark);
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  line-height: 36px;
  text-align: center;
}

.home-control:hover {
  background: #f4f4f4;
}

.notice {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto 34px;
  border-radius: 8px;
  padding: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
}

.notice p {
  margin-bottom: 0;
  color: var(--vtd-muted);
}

.notice-button {
  min-width: 170px;
}

@media (max-width: 980px) {
  .viewer-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .map-card,
  #map {
    height: 660px;
    min-height: 600px;
  }
}

@media (max-width: 640px) {
  .header-inner,
  .viewer-shell,
  .notice {
    width: min(100% - 28px, 1440px);
  }

  .header-inner {
    padding: 28px 0 26px;
  }

  h1 {
    font-size: 2rem;
  }

  .actions,
  .notice {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 15px;
  }

  .map-card,
  #map {
    height: 620px;
    min-height: 600px;
  }

  .leaflet-popup-content {
    width: min(290px, 74vw) !important;
  }
}
