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

:root {
  --bg: #0d0d0f;
  --surface: #141418;
  --surface-2: #1a1a20;
  --border: #2a2a32;
  --text: #e8e8ec;
  --muted: #8a8a96;
  --accent: #c9a227;
  --link: #8eb4e8;
  --on-accent: #0d0d0f;
  --surface-overlay: rgba(20, 20, 24, 0.92);
  --surface-drawer: rgba(20, 20, 24, 0.96);
  --surface-hover: rgba(26, 26, 32, 0.98);
  --navbar-bg: rgba(20, 20, 20, 0.8);
  --navbar-border: rgba(255, 255, 255, 0.08);
  --navbar-text: #b8b8c0;
  --navbar-text-hover: #eeeeee;
  --navbar-hover-bg: rgba(255, 255, 255, 0.06);
  --navbar-hover-border: rgba(255, 255, 255, 0.1);
  --dropdown-bg: rgba(20, 20, 20, 0.95);
  --dropdown-border: rgba(255, 255, 255, 0.1);
  --dropdown-item-text: #cccccc;
  --attribution-bg: rgba(13, 13, 15, 0.85);
  --popup-bg: rgba(18, 18, 22, 0.97);
  --divider: rgba(255, 255, 255, 0.06);
  --modal-bg: #1a1a1e;
  --modal-backdrop: rgba(0, 0, 0, 0.72);
  --article-text: #cccccc;
  --article-heading: #eeeeee;
  --header-h: 44px;
  --timeline-h: 108px;
  --panel-w: 280px;
  --settings-w: 260px;
}

body.light-theme {
  --bg: #e8e8ec;
  --surface: #ffffff;
  --surface-2: #f4f4f7;
  --border: #b8b8c4;
  --text: #1a1a22;
  --muted: #5c5c68;
  --accent: #9a7b1a;
  --link: #2a5a9a;
  --on-accent: #ffffff;
  --surface-overlay: rgba(255, 255, 255, 0.94);
  --surface-drawer: rgba(255, 255, 255, 0.98);
  --surface-hover: rgba(244, 244, 247, 0.98);
  --navbar-bg: rgba(255, 255, 255, 0.92);
  --navbar-border: rgba(0, 0, 0, 0.1);
  --navbar-text: #4a4a54;
  --navbar-text-hover: #1a1a22;
  --navbar-hover-bg: rgba(0, 0, 0, 0.05);
  --navbar-hover-border: rgba(0, 0, 0, 0.12);
  --dropdown-bg: rgba(255, 255, 255, 0.98);
  --dropdown-border: rgba(0, 0, 0, 0.1);
  --dropdown-item-text: #3a3a44;
  --attribution-bg: rgba(255, 255, 255, 0.9);
  --popup-bg: rgba(255, 255, 255, 0.98);
  --divider: rgba(0, 0, 0, 0.08);
  --modal-bg: #ffffff;
  --modal-backdrop: rgba(0, 0, 0, 0.45);
  --article-text: #3a3a44;
  --article-heading: #1a1a22;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
}

#map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: var(--timeline-h);
}

#map-app {
  position: absolute;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: 0;
}

#map-app.hidden {
  display: none;
}

#map.panel-open {
  right: var(--panel-w);
}

#map.settings-open {
  right: var(--settings-w);
}

#map.panel-open.settings-open {
  right: calc(var(--panel-w) + var(--settings-w));
}

#map.settings-open ~ #panel:not(.hidden),
#map.panel-open.settings-open ~ #panel:not(.hidden) {
  right: var(--settings-w);
}

.leaflet-container {
  background: var(--bg);
  font-family: inherit;
  font-size: 11px;
}

.leaflet-control-attribution {
  background: var(--attribution-bg) !important;
  color: var(--muted) !important;
  font-size: 9px;
  padding: 0 4px !important;
  margin: 0 !important;
}

.leaflet-control-attribution a {
  color: var(--muted);
}

/* ── Timeline ── */
#timeline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--timeline-h);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 1001;
}

.timeline-milestones {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 6px;
  border-bottom: 1px solid var(--divider);
  min-height: 0;
}

.timeline-milestones__label {
  flex-shrink: 0;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  writing-mode: horizontal-tb;
  max-width: 72px;
  line-height: 1.25;
}

.milestones-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  padding: 2px 4px 4px;
  mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 16px,
    #000 calc(100% - 16px),
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    #000 16px,
    #000 calc(100% - 16px),
    transparent 100%
  );
}

.milestones-bar::-webkit-scrollbar {
  height: 4px;
}

.milestones-bar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.milestone-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  max-width: 280px;
  padding: 5px 11px;
  font: inherit;
  font-size: 11px;
  line-height: 1.3;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.milestone-badge__year {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent);
}

.milestone-badge__sep {
  flex-shrink: 0;
  color: var(--muted);
  opacity: 0.7;
}

.milestone-badge__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.milestone-badge:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}

.milestone-badge:hover .milestone-badge__year {
  color: var(--accent);
}

.milestone-badge--near {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}

.milestone-badge--active {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: none;
}

.milestone-badge--active .milestone-badge__year,
.milestone-badge--active .milestone-badge__sep,
.milestone-badge--active .milestone-badge__title {
  color: var(--on-accent);
}

.timeline-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px 8px;
}

.year-stepper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.year-stepper__btn {
  width: 22px;
  height: 16px;
  padding: 0;
  font-size: 9px;
  line-height: 1;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}

.year-stepper__btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(201, 162, 39, 0.08);
}

#year-label {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 600;
  min-width: 64px;
  text-align: center;
  color: var(--accent);
  line-height: 1.2;
}

#year-slider {
  flex: 1;
  height: 2px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

#year-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 0;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

#year-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 0;
  background: var(--accent);
  border: none;
  cursor: pointer;
}

#year-range {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Settings drawer ── */
.settings-tab {
  position: absolute;
  top: 12px;
  right: 0;
  z-index: 1002;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 8px 12px;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: color 0.15s, background 0.15s, border-color 0.15s, right 0.2s;
}

.settings-tab--open {
  right: var(--settings-w);
}

.settings-tab:hover,
.settings-tab--open {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface-hover);
}

.settings-tab__icon {
  font-size: 13px;
  line-height: 1;
}

.settings-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: var(--timeline-h);
  width: var(--settings-w);
  z-index: 1001;
  background: var(--surface-drawer);
  border-left: 1px solid var(--border);
  padding: 14px 14px 20px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  backdrop-filter: blur(8px);
}

.settings-drawer--open {
  transform: translateX(0);
}

.settings-drawer--open ~ #map,
#map-app:has(.settings-drawer--open) #map {
  right: var(--settings-w);
}

#map-app:has(.settings-drawer--open) #map.panel-open {
  right: calc(var(--panel-w) + var(--settings-w));
}

#map-app:has(.settings-drawer--open) #panel:not(.hidden) {
  right: var(--settings-w);
}

.settings-drawer__header {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.settings-section {
  margin-bottom: 16px;
}

.settings-section__title {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.settings-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 11px;
  color: var(--text);
  margin-bottom: 8px;
  cursor: pointer;
  line-height: 1.35;
}

.settings-check input {
  margin-top: 2px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.settings-check--switch {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.settings-accordion {
  margin-bottom: 8px;
}

.settings-accordion__summary {
  font-size: 11px;
  color: var(--link);
  cursor: pointer;
  user-select: none;
  margin-bottom: 8px;
  list-style: none;
}

.settings-accordion__summary::-webkit-details-marker {
  display: none;
}

.settings-accordion__summary::before {
  content: "▸ ";
  color: var(--muted);
}

.settings-accordion[open] .settings-accordion__summary::before {
  content: "▾ ";
}

.settings-accordion__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 180px;
  overflow-y: auto;
  padding-left: 2px;
}

/* ── Sidebar ── */
#panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: var(--timeline-h);
  width: var(--panel-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 12px 14px;
  overflow-y: auto;
  z-index: 1000;
  transform: translateX(0);
  transition: transform 0.12s ease;
}

#panel.hidden {
  transform: translateX(100%);
  pointer-events: none;
}

.panel-section {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.panel-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.panel-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
  line-height: 1.3;
}

.panel-meta {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 8px;
}

.panel-photo {
  display: block;
  width: 100%;
  max-height: 250px;
  object-fit: cover;
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

.panel-gallery {
  margin-bottom: 10px;
}

.panel-gallery-more {
  margin-top: 6px;
}

.panel-gallery-more summary {
  font-size: 10px;
  color: var(--link);
  cursor: pointer;
  user-select: none;
  margin-bottom: 8px;
}

.panel-gallery-more summary:hover {
  color: var(--accent);
}

.panel-gallery-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.panel-gallery-thumb {
  width: 52px;
  height: 52px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.12s, opacity 0.12s;
}

.panel-gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0.75;
  transition: opacity 0.12s;
}

.panel-gallery-thumb:hover img,
.panel-gallery-thumb--active img {
  opacity: 1;
}

.panel-gallery-thumb:hover,
.panel-gallery-thumb--active {
  border-color: var(--accent);
}

.panel-mode {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 8px;
}

.panel-status-line {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 10px;
}

.panel-status-value--active {
  color: #9fd49f;
}

.panel-status-value--abandoned {
  color: #b0b0b8;
}

.panel-desc {
  font-size: 11px;
  color: var(--text);
  line-height: 1.45;
}

.panel-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
}

.panel-dl dt {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panel-dl dd {
  font-size: 12px;
  margin: 0;
}

.panel-heading {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

.panel-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-btn {
  display: block;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-decoration: none;
  text-align: center;
  transition: border-color 0.12s, color 0.12s;
}

.panel-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.panel-btn--external::after {
  content: " ↗";
  font-size: 9px;
  opacity: 0.7;
}

.panel-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--link);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  display: block;
  margin-bottom: 4px;
}

.panel-link:hover {
  text-decoration: underline;
}

.panel-prince-link {
  font-weight: 600;
}

.prince-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.prince-portrait {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #555;
  flex-shrink: 0;
}

.dynasty-badge {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
  margin-left: auto;
}

.prince-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.prince-name {
  font-weight: 600;
  font-size: 1.05em;
  color: #eeeeee;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.prince-name:hover {
  color: var(--accent);
}

.prince-role {
  font-size: 0.85em;
  color: #aaaaaa;
  margin: 2px 0 0 0;
}

.dynasty-line {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 8px;
}

.dynasty-coat-inline {
  width: 36px;
  height: 36px;
  object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px;
}

.dynasty-coat-large {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  margin-bottom: 10px;
}

.dynasty-name-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 11px;
  color: var(--link);
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.dynasty-name-link:hover {
  color: var(--accent);
}

.panel-related--inline {
  margin: 0;
}

.dynasty-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dynasty-tree-children {
  list-style: none;
  margin: 4px 0 4px 12px;
  padding: 0 0 0 10px;
  border-left: 1px solid var(--border);
}

.dynasty-tree-node {
  margin-bottom: 6px;
}

.dynasty-tree-name {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--link);
  cursor: pointer;
  text-align: left;
}

.dynasty-tree-name:hover {
  color: var(--accent);
  text-decoration: underline;
}

.dynasty-tree-fork {
  margin: 6px 0;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.4;
}

.dynasty-expand-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  margin-right: 4px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  vertical-align: middle;
  transition: border-color 0.12s, background 0.12s;
}

.dynasty-expand-btn:hover {
  border-color: var(--accent);
  background: rgba(201, 162, 39, 0.12);
}

.dynasty-tree-fork-name {
  color: var(--text);
}

.dynasty-tree-fork-branch {
  color: var(--muted);
  font-size: 10px;
}

.panel-back {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  padding: 5px 8px;
  font: inherit;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s, color 0.12s;
}

.panel-back:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.panel-photo--sign {
  object-fit: contain;
  background: var(--surface-2);
  max-height: 180px;
}

.panel-btn--map::after {
  content: " ⊕";
  font-size: 9px;
  opacity: 0.7;
}

.panel-related {
  list-style: none;
}

.panel-related li {
  margin-bottom: 4px;
}

.panel-empty {
  color: var(--muted);
  font-size: 11px;
}


/* ── Tribe polygons ── */
.leaflet-tooltip.tribe-tooltip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 9px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
  border-radius: 6px;
  line-height: 1.35;
  max-width: 260px;
}

.leaflet-tooltip.tribe-tooltip::before {
  border-top-color: var(--border);
}

.tribe-tooltip__name {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.tribe-tooltip__culture {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
}

.panel-facts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-fact {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text);
}

.panel-fact b {
  font-weight: 600;
  color: var(--muted);
}

.leaflet-popup.polygon-pick-popup .leaflet-popup-content-wrapper {
  background: var(--popup-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.leaflet-popup.polygon-pick-popup .leaflet-popup-tip {
  background: var(--popup-bg);
  border: 1px solid var(--border);
}

.leaflet-popup.polygon-pick-popup .leaflet-popup-content {
  margin: 10px 12px;
}

.leaflet-popup.polygon-pick-popup .leaflet-popup-close-button {
  color: var(--muted);
}

.leaflet-popup.polygon-pick-popup .leaflet-popup-close-button:hover {
  color: var(--accent);
}

.polygon-pick__title {
  margin: 0 0 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.polygon-pick__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.polygon-pick__btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  font: inherit;
  text-align: left;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.polygon-pick__btn:hover {
  border-color: var(--accent);
  background: rgba(201, 162, 39, 0.1);
  color: var(--accent);
}

.polygon-pick__swatch {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.5);
}

.polygon-pick__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.polygon-pick__name {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
}

.polygon-pick__meta {
  font-size: 9px;
  color: var(--muted);
  line-height: 1.2;
}

.tribe-icon-wrap {
  background: transparent !important;
  border: none !important;
}

.tribe-icon-badge {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #0a0a0c;
  border: 2px solid #000000;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  box-sizing: border-box;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}

.tribe-icon-badge:hover {
  border-color: var(--accent);
  transform: scale(1.06);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.75);
}

.tribe-icon-marker {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: contain;
  background: transparent;
  border: none;
  display: block;
  pointer-events: none;
}

/* ── Place markers (divIcon) ── */
.place-icon-wrap {
  background: transparent !important;
  border: none !important;
}

.place-dot {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  box-sizing: border-box;
}

.place-dot--cooled {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.place-dot--capsule {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.place-dot--active.active {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.place-dot__img {
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  margin: 4px;
  border-radius: 50%;
  object-fit: contain;
  display: block;
}

.place-dot__fallback {
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  margin: 4px;
  border-radius: 50%;
  background: #ffffff;
  display: block;
}

/* ── Navbar ── */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  z-index: 1100;
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: var(--navbar-bg);
  border-bottom: 1px solid var(--navbar-border);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

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

.navbar__btn {
  padding: 8px 14px;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--navbar-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}

.navbar__btn:hover {
  color: var(--navbar-text-hover);
  background: var(--navbar-hover-bg);
  border-color: var(--navbar-hover-border);
}

.navbar__btn--active {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.navbar__btn--active:hover {
  color: var(--on-accent);
  background: #d4ad2e;
  border-color: #d4ad2e;
}

.navbar__dropdown {
  position: relative;
}

.navbar__dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.navbar__caret {
  font-size: 9px;
  opacity: 0.75;
  transition: transform 0.2s ease;
}

.navbar__dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  padding-top: 6px;
  background: transparent;
  border: none;
  box-shadow: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
  pointer-events: none;
}

.navbar__dropdown-panel {
  padding: 6px;
  background: var(--dropdown-bg);
  border: 1px solid var(--dropdown-border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Десктоп: открытие по наведению, без клика */
@media (hover: hover) and (pointer: fine) {
  .navbar__dropdown:hover .navbar__caret {
    transform: rotate(180deg);
  }

  .navbar__dropdown:hover .navbar__dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
  }
}

/* Мобильные: открытие по клику */
@media (hover: none) {
  .navbar__dropdown--open .navbar__caret {
    transform: rotate(180deg);
  }

  .navbar__dropdown--open .navbar__dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
  }
}

.navbar__dropdown-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  font: inherit;
  font-size: 11px;
  color: var(--dropdown-item-text);
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.navbar__dropdown-item:hover {
  color: var(--navbar-text-hover);
  background: var(--navbar-hover-bg);
}

/* ── Article modal ── */
.article-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(var(--header-h) + 20px) 16px 24px;
  overflow-y: auto;
}

.article-modal.hidden {
  display: none;
}

.article-modal__backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  backdrop-filter: blur(3px);
}

.article-modal__box {
  position: relative;
  width: 100%;
  max-width: 800px;
  max-height: calc(100vh - var(--header-h) - 44px);
  overflow-y: auto;
  padding: 28px 32px 32px;
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  z-index: 1;
  animation: article-modal-in 0.25s ease;
}

@keyframes article-modal-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.article-modal__close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  color: #888890;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.article-modal__close:hover {
  color: #eeeeee;
  background: rgba(255, 255, 255, 0.08);
}

.article-content {
  color: var(--article-text);
  font-size: 13px;
  line-height: 1.6;
}

.article-content h1,
.article-content h2,
.article-content h3 {
  color: var(--article-heading);
  font-weight: 600;
  line-height: 1.35;
  margin: 1.4em 0 0.6em;
}

.article-content h1 {
  font-size: 1.45em;
  margin-top: 0;
}

.article-content h2 {
  font-size: 1.15em;
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--border);
}

.article-content p {
  margin: 0 0 1em;
}

.article-content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 16px 0;
  display: block;
}

.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 11px;
  line-height: 1.45;
}

.article-content th,
.article-content td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.article-content td[rowspan] {
  font-weight: 500;
  color: #dddddd;
  background: rgba(255, 255, 255, 0.04);
}

.article-content th {
  color: #eeeeee;
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
}

.article-content tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.article-content a {
  color: var(--link);
}

.article-content a:hover {
  color: var(--accent);
}

.article-content ul,
.article-content ol {
  margin: 0 0 1em 1.2em;
}

.article-loading,
.article-error {
  color: #888890;
  text-align: center;
  padding: 24px 0;
}

.article-error {
  color: #c98a8a;
}

body.mode-mythology {
  background: #ffffff;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

/* ── Mythology viewer ── */
.mythology-viewer {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  color-scheme: only light;
  forced-color-adjust: none;
}

.mythology-viewer.hidden {
  display: none;
}

.mythology-toolbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 10px 16px;
  border-bottom: 1px solid #e0e0e4;
  background: #ffffff;
}

.mythology-hint {
  margin: 0;
  font-size: 11px;
  color: #666670;
  line-height: 1.4;
}

.mythology-svg-host {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  cursor: grab;
  background: #ffffff;
  color-scheme: only light;
  forced-color-adjust: none;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

.mythology-svg-host:active {
  cursor: grabbing;
}

.mythology-svg-host svg {
  display: block;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  color: #000000;
  color-scheme: only light;
  forced-color-adjust: none;
  touch-action: none;
}

/* Не даём глобальным стилям страницы ломать подписи draw.io */
.mythology-svg-host svg foreignObject,
.mythology-svg-host svg foreignObject * {
  color: #000000 !important;
  -webkit-text-fill-color: #000000 !important;
}

.mythology-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  color: #888890;
  letter-spacing: 0.04em;
}

.mythology-loading.hidden {
  display: none;
}

.mythology-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 320px;
  text-align: center;
  font-size: 12px;
  color: #c98a8a;
  line-height: 1.5;
}

/* svg-pan-zoom control icons */
.mythology-svg-host .svg-pan-zoom-control {
  opacity: 0.85;
}

.mythology-svg-host .svg-pan-zoom-control:hover {
  opacity: 1;
}
