:root {
  --bg: #eef3f7;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: #ffffff;
  --text: #162033;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.1);
  --accent: #13a9c8;
  --accent-strong: #078db0;
  --accent-soft: rgba(19, 169, 200, 0.12);
  --success: #26a26f;
  --warning: #d08a1e;
  --danger: #d6576f;
  --shadow: 0 18px 38px rgba(15, 23, 42, 0.12);
  --map-frame: rgba(255, 255, 255, 0.7);
}

body[data-theme="dark"] {
  --bg: #0d1625;
  --panel: rgba(15, 24, 41, 0.94);
  --panel-strong: #121c2f;
  --text: #edf2ff;
  --muted: #97a8c5;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #4cc6e2;
  --accent-strong: #7fe5f5;
  --accent-soft: rgba(76, 198, 226, 0.14);
  --success: #32c78d;
  --warning: #f0b14b;
  --danger: #ff8197;
  --shadow: 0 20px 46px rgba(0, 0, 0, 0.38);
  --map-frame: rgba(10, 16, 28, 0.78);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(19, 169, 200, 0.12), transparent 24%),
    radial-gradient(circle at bottom right, rgba(19, 169, 200, 0.08), transparent 24%),
    var(--bg);
}
button, input, select { font: inherit; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }
.mobile-only { display: none !important; }

.app-shell {
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 470px minmax(0, 1fr);
}

.sidebar {
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.03));
  border-right: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.hero-card,
.panel,
.map-topbar,
.map-hint,
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hero-card,
.panel,
.modal-card {
  border-radius: 24px;
}

.hero-card {
  padding: 22px;
  margin-bottom: 16px;
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

h1 {
  font-size: 28px;
  line-height: 1.08;
  margin-bottom: 12px;
}

h2 { font-size: 18px; }
h3 { font-size: 15px; }

.lead {
  color: var(--muted);
  line-height: 1.58;
}

.hero-chips,
.tag-row,
.active-filters,
.hero-meta,
.object-meta,
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-chips { margin-top: 16px; }

.hero-chip,
.filter-pill,
.tag,
.object-meta span,
.detail-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
}

.hero-chip {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.section-note,
.muted,
.coord-note {
  color: var(--muted);
}

.section-note,
.muted { font-size: 13px; }
.coord-note {
  font-size: 12px;
  line-height: 1.5;
  margin-top: 8px;
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}
.panel-compact { padding: 18px; }
.panel-list { padding-bottom: 12px; }

.panel-title-row,
.panel-title-row--stacked,
.detail-head,
.coords-row,
.detail-actions,
.edit-actions,
.modal-actions,
.topbar-actions,
.theme-switcher,
.segmented {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title-row,
.detail-head,
.detail-actions,
.edit-actions { justify-content: space-between; }
.panel-title-row { margin-bottom: 14px; }
.panel-title-row--stacked {
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field--wide { grid-column: 1 / -1; }
.field span {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
.field input,
.field select {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-strong);
  color: var(--text);
  outline: none;
}
.field input:focus,
.field select:focus {
  border-color: rgba(19, 169, 200, 0.45);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.segmented {
  padding: 4px;
  border-radius: 16px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
}
.segmented--full {
  width: 100%;
  justify-content: stretch;
}
.segment,
.theme-btn,
.primary-btn,
.secondary-btn,
.link-btn,
.primary-link,
.icon-btn,
.icon-close,
.layer-toggle,
.lock-pill,
.object-card {
  border-radius: 14px;
}
.segment,
.theme-btn,
.primary-btn,
.secondary-btn,
.link-btn,
.icon-btn,
.icon-close,
.layer-toggle,
.object-card {
  border: 0;
  cursor: pointer;
  transition: 0.18s ease;
}
.segment,
.theme-btn {
  flex: 1 1 0;
  min-height: 42px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}
.segment.is-active,
.theme-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.active-filters {
  margin-top: 14px;
}
.filter-pill {
  background: rgba(127, 140, 160, 0.14);
  color: var(--muted);
  font-weight: 600;
}

.layer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.layer-toggle {
  width: 100%;
  text-align: left;
  padding: 14px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
}
.layer-toggle:hover { transform: translateY(-1px); }
.layer-toggle.is-active {
  background: var(--accent-soft);
  border-color: rgba(19, 169, 200, 0.36);
}
.layer-toggle-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.layer-toggle-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex: 0 0 auto;
}
.layer-toggle strong {
  font-size: 15px;
  line-height: 1.25;
}
.layer-toggle small {
  display: block;
  color: var(--muted);
  line-height: 1.4;
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.stat-card {
  padding: 14px;
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
}
.stat-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}
.stat-value {
  font-size: 24px;
  line-height: 1;
}

.object-list {
  display: grid;
  gap: 10px;
  max-height: none;
  overflow: visible;
}
.object-card {
  width: 100%;
  text-align: left;
  padding: 14px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
}
.object-card:hover,
.object-card.is-active {
  transform: translateY(-1px);
  border-color: rgba(19, 169, 200, 0.36);
  box-shadow: 0 10px 24px rgba(19, 169, 200, 0.08);
}
.object-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.object-type {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.object-type-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}
.object-title {
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.35;
}
.object-excerpt {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 10px;
}
.object-meta span,
.detail-meta span {
  background: rgba(127, 140, 160, 0.12);
  color: var(--muted);
}

.detail-panel ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.58;
}
.detail-panel li + li { margin-top: 6px; }
.detail-kicker {
  margin-bottom: 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.detail-head { align-items: flex-start; }
.detail-head h2 {
  font-size: 22px;
  line-height: 1.18;
}
.detail-description {
  margin-top: 14px;
  line-height: 1.62;
}
.tag-row { margin-top: 14px; }
.tag {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}
.detail-block { margin-top: 18px; }
.coords-row {
  margin-top: 8px;
  justify-content: space-between;
}
code {
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
}
.empty-detail {
  color: var(--muted);
  line-height: 1.6;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.status-badge.status-active {
  color: var(--success);
  background: rgba(38, 162, 111, 0.12);
}
.status-badge.status-development {
  color: var(--warning);
  background: rgba(208, 138, 30, 0.12);
}

.primary-btn,
.secondary-btn,
.link-btn,
.primary-link,
.lock-pill {
  min-height: 42px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.primary-btn,
.primary-link {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  text-decoration: none;
}
.secondary-btn,
.link-btn {
  background: var(--panel-strong);
  color: var(--text);
  border: 1px solid var(--border);
}
.secondary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.link-btn {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
}
.lock-pill {
  min-height: auto;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  font-size: 12px;
}
.lock-pill.is-auth { color: var(--success); }
.edit-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.map-stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(19, 169, 200, 0.05), rgba(19, 169, 200, 0));
}
#map {
  position: absolute;
  inset: 16px;
  border-radius: 30px;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.map-topbar,
.map-hint,
.toast {
  position: absolute;
  z-index: 500;
  backdrop-filter: blur(10px);
}
.map-topbar {
  top: 28px;
  left: 28px;
  right: auto;
  width: min(980px, calc(100% - 56px));
  max-width: calc(100% - 56px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 20px;
}
.map-topbar strong {
  display: block;
  font-size: 17px;
  line-height: 1.15;
}
.map-topbar .muted {
  display: block;
  margin-top: 4px;
  line-height: 1.4;
}
.map-hint {
  left: 28px;
  bottom: 28px;
  max-width: 480px;
  padding: 12px 14px;
  border-radius: 16px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
}
.toast {
  right: 28px;
  bottom: 28px;
  padding: 12px 14px;
  border-radius: 16px;
  color: white;
  background: rgba(12, 20, 34, 0.92);
}

.icon-btn {
  width: 42px;
  height: 42px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  padding: 0;
  position: relative;
}
.icon-btn span {
  position: absolute;
  left: 11px;
  right: 11px;
  height: 2px;
  background: var(--text);
  border-radius: 999px;
}
.icon-btn span:nth-child(1) { top: 13px; }
.icon-btn span:nth-child(2) { top: 20px; }
.icon-btn span:nth-child(3) { top: 27px; }
.icon-close {
  width: 38px;
  height: 38px;
  background: var(--panel-strong);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 20, 0.55);
}
.modal-card {
  position: relative;
  z-index: 1;
  width: min(420px, calc(100vw - 24px));
  padding: 20px;
}
.login-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.error-text {
  color: var(--danger);
  font-size: 13px;
}

.leaflet-control-zoom {
  margin: 0 28px 28px 0 !important;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.leaflet-control-zoom a {
  width: 46px;
  height: 46px;
  line-height: 44px;
  color: var(--text);
  background: var(--panel-strong);
  border-bottom-color: var(--border);
}
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--panel-strong);
  color: var(--text);
}
.leaflet-popup-content-wrapper {
  max-width: min(340px, calc(100vw - 88px));
  border-radius: 22px;
  overflow: hidden;
}
.leaflet-popup-content {
  margin: 0;
}
.leaflet-container {
  background: #dbe4ea;
}

.popup-card {
  min-width: 0;
  width: min(320px, calc(100vw - 112px));
  max-width: 100%;
  padding: 14px 16px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.popup-card--rich {
  min-width: 0;
  max-width: none;
}
.popup-kicker {
  margin-bottom: 6px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.popup-title {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.popup-description {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.popup-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.popup-meta span,
.popup-metal {
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(127, 140, 160, 0.12);
  color: var(--muted);
  font-size: 11px;
}
.popup-metals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.popup-metal {
  color: var(--text);
  background: color-mix(in srgb, var(--popup-metal) 12%, white 88%);
  border: 1px solid color-mix(in srgb, var(--popup-metal) 26%, transparent);
}
.leaflet-tooltip.tmk-tooltip {
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel-strong) 94%, white 6%);
  color: var(--text);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.18);
  border-radius: 16px;
  padding: 0;
}
.leaflet-tooltip.tmk-tooltip:before {
  border-top-color: color-mix(in srgb, var(--panel-strong) 94%, white 6%);
}
.tooltip-card {
  min-width: 0;
  width: min(300px, calc(100vw - 120px));
  max-width: 100%;
  padding: 12px 14px;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.tooltip-card__title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 4px;
}
.tooltip-card__meta {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 6px;
}
.tooltip-card__text {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.leaflet-marker-icon:focus,
.leaflet-interactive:focus {
  outline: none;
}

.tmk-marker {
  position: relative;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
}
.tmk-marker__pulse,
.tmk-marker__ring {
  position: absolute;
  inset: 0;
  border-radius: 999px;
}
.tmk-marker__pulse {
  background: color-mix(in srgb, var(--marker-accent) 18%, transparent);
  animation: pulseMarker 1.9s infinite ease-out;
}
.tmk-marker__ring {
  inset: 6px;
  border: 2px solid color-mix(in srgb, var(--marker-accent) 56%, white 0%);
  background: color-mix(in srgb, white 86%, var(--marker-accent) 14%);
  box-shadow: 0 12px 20px rgba(12, 20, 34, 0.18);
}
.tmk-marker__icon {
  position: relative;
  z-index: 2;
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.18));
}
.tmk-marker.is-active .tmk-marker__ring {
  transform: scale(1.08);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--marker-accent) 16%, transparent), 0 16px 28px rgba(12, 20, 34, 0.22);
}
.tmk-marker.is-scheme .tmk-marker__icon {
  width: 22px;
  height: 22px;
}

@keyframes pulseMarker {
  0% { transform: scale(0.7); opacity: 0.55; }
  70% { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(1.15); opacity: 0; }
}

@media (max-width: 1280px) {
  .app-shell { grid-template-columns: 430px minmax(0, 1fr); }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 900;
    inset: 0 auto 0 0;
    width: min(460px, 100vw);
    height: 100vh;
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    background: var(--bg);
    box-shadow: 18px 0 40px rgba(15, 23, 42, 0.18);
  }
  .sidebar.is-open { transform: translateX(0); }
  .mobile-only { display: inline-flex !important; }
  .map-topbar { left: 16px; top: 16px; width: calc(100% - 32px); max-width: calc(100% - 32px); }
  .map-hint {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }
  #map { inset: 10px; border-radius: 22px; }
  .leaflet-control-zoom { margin: 0 16px 16px 0 !important; }
}

@media (max-width: 640px) {
  .sidebar { padding: 14px; }
  .filters-grid,
  .layer-grid,
  .stats-panel {
    grid-template-columns: 1fr;
  }
  .panel-title-row,
  .panel-title-row--stacked,
  .detail-actions,
  .edit-actions,
  .coords-row {
    flex-direction: column;
    align-items: stretch;
  }
  .detail-head {
    flex-direction: column;
    align-items: flex-start;
  }
  h1 { font-size: 24px; }
  .map-topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

.metal-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.metal-chips-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px;
}

.metal-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  min-width: 0;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.metal-chip:hover,
.metal-chip.is-active {
  transform: translateY(-1px);
  border-color: rgba(19, 169, 200, 0.32);
  box-shadow: 0 10px 24px rgba(19, 169, 200, 0.1);
}

.metal-chip.is-active {
  background: var(--accent-soft);
}

.metal-chip__dot,
.metal-color-chip {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.metal-color-chip {
  width: 18px;
  height: 18px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.7);
}

.metal-chip__label {
  font-size: 13px;
  font-weight: 700;
}

.metal-chip__count {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(127, 140, 160, 0.12);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.metal-insight {
  margin-top: 14px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel-strong) 86%, var(--accent-soft) 14%);
}

.metal-insight-head,
.metal-insight-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.metal-insight-head {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.metal-insight .tag-row {
  margin-top: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-row {
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
}

.detail-row__label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-row__value {
  font-size: 14px;
  line-height: 1.5;
}

.detail-metal-profiles {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-metal-profile {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
}

.detail-metal-profile__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.detail-metal-profile__title {
  font-size: 14px;
  font-weight: 800;
}

.detail-metal-profile__text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.tag {
  border: 1px solid transparent;
  background: rgba(127, 140, 160, 0.12);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.tag:hover {
  transform: translateY(-1px);
  border-color: rgba(19, 169, 200, 0.28);
  box-shadow: 0 8px 18px rgba(19, 169, 200, 0.08);
}

.tag.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: rgba(19, 169, 200, 0.32);
}

@media (max-width: 640px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .metal-insight-head {
    flex-direction: column;
    align-items: stretch;
  }
}


body { overflow: hidden; }

.metal-insight .tag-row {
  align-items: flex-start;
}

.metal-insight .tag,
.detail-panel .tag {
  max-width: 100%;
  white-space: normal;
  text-align: left;
}

.theme-switcher {
  flex-wrap: wrap;
}
/* === FIX: карта и popup не должны вылезать за границы === */

.map-shell,
.map-stage,
.map-panel,
.map-wrap,
.map-container,
#map {
  min-width: 0;
  min-height: 0;
}

.map-stage,
.map-panel,
.map-wrap,
.map-container {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
}

#map,
.leaflet-container {
  width: 100%;
  height: 100%;
  overflow: hidden !important;
  border-radius: 24px;
  background: #eef3f7;
}

/* popup */
.leaflet-popup {
  max-width: min(360px, calc(100vw - 32px)) !important;
}

.leaflet-popup-content-wrapper {
  max-width: min(360px, calc(100vw - 32px)) !important;
  width: auto !important;
  border-radius: 18px !important;
  overflow: hidden !important;
  box-sizing: border-box;
}

.leaflet-popup-content {
  margin: 14px 16px !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: calc(min(360px, calc(100vw - 32px)) - 32px) !important;
  box-sizing: border-box;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.leaflet-popup-tip-container {
  overflow: hidden;
}

.leaflet-popup-close-button {
  top: 8px !important;
  right: 8px !important;
}

/* заголовки и текст внутри карточки объекта */
.leaflet-popup-content h3,
.leaflet-popup-content h4,
.leaflet-popup-content .popup-title {
  margin: 0 0 8px 0;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.leaflet-popup-content p,
.leaflet-popup-content .popup-subtitle,
.leaflet-popup-content .popup-text,
.leaflet-popup-content .popup-description,
.leaflet-popup-content .popup-meta,
.leaflet-popup-content .popup-tags {
  margin: 0 0 8px 0;
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

/* если внутри popup есть строки/чипсы/теги */
.leaflet-popup-content .chips,
.leaflet-popup-content .tags,
.leaflet-popup-content .badges,
.leaflet-popup-content .meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.leaflet-popup-content .chip,
.leaflet-popup-content .tag,
.leaflet-popup-content .badge {
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

/* hover-tooltip */
.map-tooltip,
.leaflet-tooltip {
  max-width: min(280px, calc(100vw - 32px)) !important;
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-sizing: border-box;
}