:root {
  --md-bg: #e7eef8;
  --md-surface: rgba(255, 255, 255, 0.54);
  --md-surface-strong: rgba(255, 255, 255, 0.78);
  --md-outline: rgba(63, 97, 150, 0.2);
  --md-ink: #102346;
  --md-muted: #4f6187;
  --md-primary: #1e75e7;
  --md-primary-strong: #0f5cc5;
  --md-shadow: 0 18px 50px rgba(26, 54, 110, 0.16);
  --md-danger: #b3261e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Roboto Flex", "Segoe UI", sans-serif;
  color: var(--md-ink);
  background:
    radial-gradient(70vw 56vh at 12% -10%, #d2e7ff 0%, transparent 70%),
    radial-gradient(66vw 54vh at 100% 0%, #d8f0ff 0%, transparent 69%),
    linear-gradient(145deg, #edf4ff 0%, #e6eef8 56%, #ecf2fe 100%);
}

.bg-orb {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(16px);
}

.orb-a {
  width: 350px;
  height: 350px;
  left: -90px;
  top: 110px;
  background: rgba(86, 168, 255, 0.34);
}

.orb-b {
  width: 300px;
  height: 300px;
  right: -70px;
  top: 270px;
  background: rgba(117, 211, 255, 0.26);
}

.orb-c {
  width: 300px;
  height: 300px;
  right: 30%;
  bottom: -110px;
  background: rgba(123, 162, 255, 0.2);
}

.wrapper {
  max-width: 1340px;
  margin: 0 auto;
  padding: 24px 18px 34px;
}

.glass {
  background: var(--md-surface);
  border: 1px solid var(--md-outline);
  box-shadow: var(--md-shadow);
  backdrop-filter: blur(16px) saturate(135%);
  -webkit-backdrop-filter: blur(16px) saturate(135%);
  border-radius: 26px;
}

.hero {
  padding: 24px 26px;
  margin-bottom: 16px;
  animation: fadeUp 0.55s ease;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(30, 117, 231, 0.14);
  color: var(--md-primary-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.material-symbols-rounded {
  font-size: 18px;
  vertical-align: middle;
}

h1 {
  margin: 12px 0 10px;
  font-size: clamp(28px, 4.1vw, 46px);
  line-height: 1.08;
}

.hero p {
  margin: 0;
  max-width: 980px;
  color: var(--md-muted);
  font-size: 15px;
}

.muted {
  color: var(--md-muted);
  font-size: 14px;
  margin-top: 8px;
}

.error {
  color: var(--md-danger);
  margin-top: 8px;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: minmax(520px, 1.4fr) minmax(340px, 1fr);
  gap: 16px;
}

.map-card,
.panel {
  padding: 16px;
  animation: fadeUp 0.7s ease;
}

.map-head,
.panel h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.map-head {
  margin-bottom: 10px;
}

.map-head h2,
.panel h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 21px;
}

.map-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(78, 113, 173, 0.26);
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--md-primary-strong);
  background: var(--md-surface-strong);
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(30, 117, 231, 0.5);
  background: rgba(255, 255, 255, 0.92);
}

.map-viewport {
  position: relative;
  aspect-ratio: 1.5;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(90, 124, 188, 0.28);
  background:
    radial-gradient(circle at 10% 10%, rgba(203, 232, 255, 0.7) 0%, transparent 55%),
    linear-gradient(160deg, rgba(241, 247, 255, 0.9), rgba(225, 237, 255, 0.74));
  cursor: grab;
}

.map-viewport.is-panning {
  cursor: grabbing;
}

.map-scene {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.map-svg {
  width: 100%;
  height: 100%;
}

.map-image {
  display: block;
  object-fit: contain;
  object-position: center;
  user-select: none;
  pointer-events: none;
  filter: drop-shadow(0 14px 22px rgba(37, 80, 146, 0.22));
}

.map-hint {
  margin: 8px 2px 0;
}

.pin-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pin {
  position: absolute;
  transform: translate(-50%, -50%) scale(var(--pin-inv-scale, 1));
  transform-origin: 50% 50%;
  pointer-events: auto;
  border: 0;
  cursor: pointer;
}

.cluster-pin {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  padding: 0;
  display: grid;
  place-items: center;
  color: transparent;
  background: transparent;
  border: 0;
  box-shadow: none;
  animation: pinIn 0.3s ease;
}

.cluster-pin::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  background: linear-gradient(160deg, #146de3, #4d92ff);
  box-shadow: 0 0 0 2px rgba(16, 72, 153, 0.22), 0 10px 18px rgba(28, 96, 194, 0.34);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.cluster-pin:hover::before,
.cluster-pin.active::before {
  transform: scale(1.35);
  box-shadow: 0 0 0 2px rgba(16, 72, 153, 0.32), 0 12px 22px rgba(28, 96, 194, 0.46);
}

.cluster-pin::after {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  top: -8px;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(73, 104, 160, 0.28);
  border-radius: 10px;
  color: #153768;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  box-shadow: 0 12px 20px rgba(26, 64, 126, 0.18);
  transition: opacity 0.12s ease;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cluster-pin:hover::after,
.cluster-pin.active::after {
  opacity: 1;
}

.micro-pin {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.88);
  background: linear-gradient(160deg, #1b7af6, #43a4ff);
  box-shadow: 0 0 0 2px rgba(16, 72, 153, 0.2), 0 7px 14px rgba(20, 79, 165, 0.38);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.micro-pin:hover,
.micro-pin.active {
  transform: translate(-50%, -50%) scale(var(--pin-inv-scale, 1)) scale(1.35);
  box-shadow: 0 0 0 2px rgba(16, 72, 153, 0.3), 0 10px 18px rgba(20, 79, 165, 0.46);
}

.micro-pin::after {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  top: -8px;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(73, 104, 160, 0.28);
  border-radius: 10px;
  color: #153768;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  box-shadow: 0 12px 20px rgba(26, 64, 126, 0.18);
  transition: opacity 0.12s ease;
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.micro-pin:hover::after,
.micro-pin.active::after {
  opacity: 1;
}

.panel {
  min-height: 600px;
}

.media-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  max-height: 300px;
  overflow: auto;
  padding-right: 3px;
}

.media-item {
  text-align: left;
  border: 1px solid rgba(81, 111, 167, 0.22);
  border-radius: 14px;
  padding: 11px;
  background: var(--md-surface-strong);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.media-item:hover,
.media-item.active {
  border-color: rgba(30, 117, 231, 0.46);
  transform: translateY(-1px);
}

.media-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.media-item span {
  font-size: 12px;
  color: var(--md-muted);
}

.media-stats {
  margin-top: 12px;
}

.stats-box {
  border: 1px solid rgba(81, 111, 168, 0.24);
  border-radius: 16px;
  background: var(--md-surface-strong);
  padding: 13px;
}

.stats-box h3 {
  margin: 0 0 8px;
}

.stats-grid {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.stats-grid-single {
  grid-template-columns: 1fr;
}

.stat {
  border-radius: 12px;
  border: 1px solid rgba(81, 111, 168, 0.18);
  background: rgba(255, 255, 255, 0.6);
  padding: 10px;
}

.stat .label {
  font-size: 11px;
  color: var(--md-muted);
  margin-bottom: 4px;
}

.stat .value {
  font-size: 18px;
  font-weight: 700;
}

.meta-row {
  margin-top: 9px;
  font-size: 13px;
  color: var(--md-muted);
}

.media-link {
  color: var(--md-primary-strong);
  text-decoration: none;
  border-bottom: 1px solid rgba(30, 117, 231, 0.28);
  word-break: break-all;
}

.media-link:hover {
  border-bottom-color: rgba(30, 117, 231, 0.6);
}

.settings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.text-input {
  border: 1px solid rgba(79, 109, 167, 0.26);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.84);
  color: #1b325c;
  min-height: 38px;
  padding: 8px 11px;
  outline: none;
  width: 100%;
}

.text-input:focus {
  border-color: rgba(30, 117, 231, 0.5);
}

.btn {
  min-height: 38px;
  border: 1px solid rgba(79, 109, 167, 0.26);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  padding: 0 14px;
  cursor: pointer;
  color: #1b325c;
  font-weight: 600;
}

.btn.primary {
  color: #fff;
  border-color: rgba(20, 92, 190, 0.24);
  background: linear-gradient(160deg, #1c72e5, #3f9ef6);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.settings-card {
  padding: 16px;
}

.settings-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px;
  margin-bottom: 12px;
}

.table-wrap {
  border: 1px solid rgba(80, 110, 166, 0.25);
  border-radius: 15px;
  overflow: auto;
  max-height: 70vh;
  background: rgba(255, 255, 255, 0.68);
}

.settings-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1100px;
}

.settings-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-size: 12px;
  color: #27467f;
  padding: 11px 10px;
  border-bottom: 1px solid rgba(80, 110, 166, 0.25);
  background: rgba(243, 249, 255, 0.9);
}

.settings-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(80, 110, 166, 0.18);
  vertical-align: middle;
}

.settings-table tr.is-selected td {
  background: rgba(206, 231, 255, 0.55);
}

.settings-table tr.is-selected td:first-child {
  box-shadow: inset 4px 0 0 rgba(30, 117, 231, 0.55);
}

.settings-table tr:last-child td {
  border-bottom: 0;
}

.settings-table .id-col {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: #344f7f;
}

.settings-table .title-col {
  font-weight: 600;
  min-width: 210px;
}

.settings-table input[type="text"],
.settings-table input[type="number"] {
  width: 100%;
  min-width: 94px;
  border: 1px solid rgba(79, 109, 167, 0.26);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  color: #1d3664;
  min-height: 32px;
  padding: 5px 8px;
}

.settings-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.settings-meta {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--md-muted);
}

.settings-status {
  font-weight: 700;
  color: #114484;
}

.page-settings .micro-pin {
  width: 14px;
  height: 14px;
}

.page-settings .micro-pin.is-disabled {
  opacity: 0.45;
  filter: grayscale(0.35);
}

.page-settings .micro-pin.active {
  transform: translate(-50%, -50%) scale(var(--pin-inv-scale, 1)) scale(1.45);
}

.page-settings .micro-pin::after {
  max-width: 280px;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pinIn {
  from {
    opacity: 0;
    transform: translate(-50%, -46%) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
  }

  .settings-toolbar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .wrapper {
    padding: 16px 12px 24px;
  }

  .hero {
    padding: 18px 16px;
  }

  .map-card,
  .panel {
    padding: 12px;
  }

  .map-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .map-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .micro-pin::after {
    display: none;
  }
}
