:root {
  --bg-night: #17141d;
  --bg-header: #211c27;
  --bg-toolbar: #2b2433;
  --paper-light: #fbf7ef;
  --paper-warm: #f3ead8;
  --paper-card: #fffdf8;
  --paper-border: #d8c8ac;
  --ink-dark: #221c18;
  --ink-muted: #5c5046;
  --burgundy: #8b2635;
  --burgundy-dark: #631823;
  --gold: #c99227;
  --gold-soft: #f5e4bc;
  --teal: #1b5e68;
  --teal-light: #e2f1f3;
  --green-ok: #236c45;
  --green-bg: #e3f5eb;
  --scale-1: #efe4cc;
  --scale-2: #dcbf8b;
  --scale-3: #c29556;
  --scale-4: #9d5c34;
  --scale-5: #6d2428;
  --shadow-lg: 0 14px 36px rgba(15, 11, 20, 0.32);
  --font-serif: Georgia, "Palatino Linotype", "Book Antiqua", serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  color: var(--ink-dark);
  background: var(--bg-night);
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
}

.hidden {
  display: none !important;
}

/* Top Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 14px;
  background: var(--bg-header);
  color: var(--paper-light);
  border-bottom: 1px solid rgba(201, 146, 39, 0.3);
  min-height: 48px;
  z-index: 1000;
}

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

.brand-emblem {
  font-size: 1.3rem;
  background: rgba(201, 146, 39, 0.18);
  border: 1px solid var(--gold);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fdf6e7;
  letter-spacing: 0.02em;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: #d6c8b4;
  display: flex;
  align-items: center;
  gap: 6px;
}

.role-note {
  background: var(--gold);
  color: #1c140a;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 0.7rem;
}

.profile-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-pills {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.profile-btn {
  border: none;
  background: transparent;
  color: #e2d9cc;
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.profile-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.profile-btn.active {
  background: var(--burgundy);
  color: #fff;
  box-shadow: 0 2px 8px rgba(139, 38, 53, 0.5);
}

.profile-btn.role-parent {
  border: 1px dashed rgba(201, 146, 39, 0.6);
}

.profile-btn.role-parent.active {
  background: #4a3b5c;
  border-style: solid;
  border-color: var(--gold);
}

.profile-btn.role-dev {
  border: 1px dotted #68d391;
}

.profile-btn.role-dev.active {
  background: #1f4e3d;
  border-color: #68d391;
}

.profile-mini-count {
  font-size: 0.7rem;
  background: rgba(0, 0, 0, 0.28);
  padding: 1px 6px;
  border-radius: 99px;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #f3ead8;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.18);
}

.btn-dev-fast.fast-on {
  background: #22543d;
  border-color: #68d391;
  color: #c6f6d5;
}

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

.search-wrap {
  position: relative;
}

.region-search-input {
  width: 230px;
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 0.82rem;
}

.region-search-input::placeholder {
  color: #bfb3a3;
}

.region-search-input:focus {
  outline: 2px solid var(--gold);
  background: rgba(255, 255, 255, 0.16);
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 300px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--paper-card);
  color: var(--ink-dark);
  border: 1px solid var(--paper-border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 2500;
}

.search-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-bottom: 1px solid #eee4d3;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.84rem;
}

.search-item:hover {
  background: var(--paper-warm);
}

.search-item-tag {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 99px;
  background: #e8decb;
  color: #4a3f35;
  font-weight: 600;
}

.btn-surprise {
  background: linear-gradient(135deg, #c99227, #a86f12);
  color: #1c1306;
  border: none;
  padding: 7px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(201, 146, 39, 0.35);
}

.btn-surprise:hover {
  filter: brightness(1.08);
}

.btn-passport {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--burgundy);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
}

.btn-passport:hover {
  background: var(--burgundy-dark);
}

.stamp-count-badge {
  background: var(--gold);
  color: #1e1405;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 800;
}

/* Secondary Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 14px;
  background: var(--bg-toolbar);
  color: #e6dac6;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.75rem;
  min-height: 34px;
}

.lens-group, .view-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.toolbar-label {
  font-weight: 700;
  color: var(--gold);
  margin-right: 2px;
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

.lens-btn, .zoom-pill {
  background: rgba(255, 255, 255, 0.07);
  color: #dfd3c0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 3px 9px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 600;
  transition: all 0.15s;
}

.lens-btn:hover, .zoom-pill:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.lens-btn.active {
  background: var(--teal);
  color: #fff;
  border-color: #4fd1c5;
}

.lens-btn-ancestry {
  border-color: rgba(201, 146, 39, 0.55);
  color: #fde68a;
}

.lens-btn-ancestry.active {
  background: linear-gradient(135deg, #c99227, #8b2635);
  color: #fff;
  border-color: #ffd166;
}

.ancestry-dock-pills {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.ancestry-pill-btn {
  background: rgba(139, 38, 53, 0.75);
  color: #fff;
  border: 1px solid rgba(255, 209, 102, 0.7);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: filter 0.14s;
}

.ancestry-pill-btn:hover {
  filter: brightness(1.18);
}

/* Family Heritage Story Section Inside Card */
.heritage-story-section {
  background: linear-gradient(135deg, #fff9eb, #f7e6c0);
  border: 2px solid var(--gold);
  box-shadow: 0 4px 14px rgba(201, 146, 39, 0.18);
}

.heritage-heading {
  color: #6b4205 !important;
  font-size: 1.02rem;
}

.btn-edit-heritage {
  background: #8b2635;
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.heritage-story-text {
  font-size: 0.88rem;
  line-height: 1.52;
  color: #2d1e0b;
  white-space: pre-line;
  margin-top: 4px;
}

.heritage-editor {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #c99227;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.heritage-editor-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: #5c4012;
}

.heritage-editor textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #c99227;
  font-family: inherit;
  font-size: 0.84rem;
  background: #fff;
}

.heritage-editor-actions {
  display: flex;
  gap: 8px;
}

.btn-cancel-heritage {
  background: transparent;
  border: 1px solid #8c7658;
  color: var(--ink-dark);
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.zoom-pill.active {
  background: rgba(201, 146, 39, 0.26);
  color: #fff;
  border-color: var(--gold);
}

#clearFeaturePinsBtn {
  background: #8b2635;
  color: #fff;
  border-color: #f56565;
}

/* Main Workspace */
.workspace {
  position: relative;
  height: calc(100vh - 82px);
  width: 100%;
  display: flex;
  overflow: hidden;
}

.map-stage {
  flex: 1;
  position: relative;
  height: 100%;
  background: radial-gradient(circle at center, #0d2b45 0%, #050e1a 100%);
}

#map {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #0d2b45 0%, #050e1a 100%);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.55);
}

.leaflet-container img {
  max-width: none !important;
  max-height: none !important;
}

.leaflet-labels-pane {
  pointer-events: none !important;
}

/* Map Legend */
.map-legend {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 600;
  background: rgba(251, 247, 239, 0.95);
  border: 1px solid var(--paper-border);
  border-radius: 10px;
  padding: 10px 13px;
  max-width: 390px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  font-size: 0.75rem;
}

.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.legend-region-count {
  font-size: 0.68rem;
  color: var(--ink-muted);
  font-weight: 600;
}

.legend-swatches {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
}

.swatch {
  height: 12px;
  flex: 1;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.swatch.s1 { background: var(--scale-1); }
.swatch.s2 { background: var(--scale-2); }
.swatch.s3 { background: var(--scale-3); }
.swatch.s4 { background: var(--scale-4); }
.swatch.s5 { background: var(--scale-5); }

.swatch-ancestry {
  width: 18px;
  height: 12px;
  border-radius: 3px;
  border: 2px dashed #c99227;
  background: rgba(201, 146, 39, 0.25);
}

.swatch-stamped {
  width: 18px;
  height: 12px;
  border-radius: 3px;
  border: 2px solid #1b5e68;
  background: #236c45;
}

.legend-disclaimer {
  color: var(--ink-muted);
  line-height: 1.35;
}

/* Custom Map Markers (Home Base & Notable Feature Pop-Up Pins) */
.home-base-marker {
  background: #8b2635;
  color: #fff;
  border: 2px solid #ffd166;
  border-radius: 999px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  box-shadow: 0 0 0 5px rgba(139, 38, 53, 0.28), 0 3px 10px rgba(0, 0, 0, 0.4);
}

.feature-popup-pin {
  background: linear-gradient(135deg, #1b5e68, #0f3c42);
  color: #fff;
  border: 2.5px solid #ffd166;
  border-radius: 50% 50% 50% 4px;
  width: 34px;
  height: 34px;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  animation: pinPopIn 0.38s cubic-bezier(0.18, 1.4, 0.4, 1);
}

.feature-popup-pin span {
  transform: rotate(45deg);
  font-size: 1rem;
  font-weight: 800;
}

@keyframes pinPopIn {
  0% {
    transform: translateY(-28px) rotate(-45deg) scale(0.2);
    opacity: 0;
  }
  75% {
    transform: translateY(3px) rotate(-45deg) scale(1.12);
    opacity: 1;
  }
  100% {
    transform: translateY(0) rotate(-45deg) scale(1);
    opacity: 1;
  }
}

.leaflet-popup-content-wrapper {
  background: var(--paper-card);
  color: var(--ink-dark);
  border: 2px solid var(--gold);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}

.feature-map-popup strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--burgundy);
  margin-bottom: 2px;
}

.feature-map-popup .popup-place {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--teal);
  margin-bottom: 6px;
}

.feature-map-popup p {
  font-size: 0.83rem;
  line-height: 1.4;
  color: var(--ink-dark);
}

/* Country / State / Province Card Drawer */
.card-drawer {
  width: 500px;
  max-width: 94vw;
  height: 100%;
  background: var(--paper-light);
  border-left: 2px solid var(--paper-border);
  box-shadow: -8px 0 28px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  z-index: 800;
}

.card-sticky-top {
  padding: 14px 18px 12px;
  background: var(--paper-warm);
  border-bottom: 1px solid var(--paper-border);
}

.card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-type {
  background: #e2d5be;
  color: #413529;
}

.badge-ancestry {
  background: var(--gold-soft);
  color: #6b4704;
  border: 1px solid var(--gold);
}

.badge-stamped {
  background: var(--green-bg);
  color: var(--green-ok);
  border: 1px solid #86efac;
}

.btn-close-card {
  background: var(--burgundy);
  color: #fff;
  border: none;
  padding: 5px 12px;
  border-radius: 7px;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
}

.btn-close-card:hover {
  background: var(--burgundy-dark);
}

.card-country-name {
  font-family: var(--font-serif);
  font-size: 1.55rem;
  color: var(--ink-dark);
  line-height: 1.15;
}

.card-pin-meta {
  font-size: 0.82rem;
  color: var(--ink-muted);
  font-weight: 600;
  margin-top: 2px;
}

.card-ancestry-note {
  font-size: 0.8rem;
  color: #7c4d05;
  background: var(--gold-soft);
  padding: 4px 9px;
  border-radius: 6px;
  margin-top: 6px;
  font-weight: 600;
  display: inline-block;
}

.card-flight-pill {
  margin-top: 6px;
  font-size: 0.78rem;
  background: var(--teal-light);
  color: var(--teal);
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 600;
  border: 1px solid rgba(27, 94, 104, 0.2);
}

/* Gate Tracker */
.gate-tracker {
  margin-top: 10px;
  background: var(--paper-card);
  border: 1px solid var(--paper-border);
  border-radius: 9px;
  padding: 8px 10px;
}

.gate-progress-bar {
  height: 6px;
  background: #e6dcc8;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 7px;
}

.gate-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--green-ok));
  transition: width 0.25s linear;
}

.gate-steps {
  display: flex;
  gap: 6px;
  margin-bottom: 5px;
}

.gate-chip {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 6px;
  border-radius: 6px;
  background: #f1e9d8;
  color: var(--ink-muted);
  border: 1px solid #dfd2ba;
}

.gate-chip.done {
  background: var(--green-bg);
  color: var(--green-ok);
  border-color: #68d391;
}

.gate-rule-note {
  font-size: 0.71rem;
  color: var(--ink-muted);
  line-height: 1.3;
}

/* Scrollable Card Body */
.card-scroll-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-lang-banner {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 10px;
}

.lang-greeting-box, .lang-secret-box {
  background: var(--paper-card);
  border: 1px solid var(--paper-border);
  border-radius: 10px;
  padding: 10px 12px;
}

.lang-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.lang-kicker {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  font-weight: 700;
}

.btn-audio-speak {
  background: var(--teal);
  color: #fff;
  border: none;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-audio-speak:hover {
  filter: brightness(1.1);
}

.lang-main-word {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--burgundy);
  margin-top: 3px;
}

.lang-phonetic, .lang-phonetic-inline {
  font-size: 0.76rem;
  color: var(--teal);
  font-weight: 600;
}

.lang-meaning {
  font-size: 0.76rem;
  color: var(--ink-dark);
  margin-top: 3px;
  line-height: 1.35;
}

/* Card Sections */
.card-section {
  background: var(--paper-card);
  border: 1px solid var(--paper-border);
  border-radius: 11px;
  padding: 12px 14px;
}

.notable-features-section {
  background: linear-gradient(180deg, #fffdf8 0%, #f4efe2 100%);
  border: 2px solid var(--gold);
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.section-heading {
  font-family: var(--font-serif);
  font-size: 0.98rem;
  color: var(--burgundy);
  margin-bottom: 5px;
}

.section-subnote {
  font-size: 0.76rem;
  color: var(--ink-muted);
  margin-bottom: 9px;
}

.btn-pop-all-pins {
  background: var(--teal);
  color: #fff;
  border: none;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.notable-features-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feature-pin-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  background: #fff;
  border: 1px solid #decbb0;
  border-radius: 9px;
  padding: 9px 11px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.15s ease;
}

.feature-pin-card:hover {
  border-color: var(--teal);
  background: var(--teal-light);
  transform: translateY(-1px);
}

.feature-pin-card.pin-active {
  border: 2px solid var(--teal);
  background: var(--teal-light);
}

.feature-pin-info strong {
  display: block;
  font-size: 0.88rem;
  color: var(--ink-dark);
}

.feature-pin-place {
  font-size: 0.73rem;
  color: var(--teal);
  font-weight: 700;
  margin-bottom: 3px;
}

.feature-pin-blurb {
  font-size: 0.78rem;
  color: var(--ink-muted);
  line-height: 1.35;
}

.feature-pin-action {
  background: var(--burgundy);
  color: #fff;
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 0.73rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: center;
}

.feature-pin-card.pin-active .feature-pin-action {
  background: var(--teal);
}

.card-body-text {
  font-size: 0.88rem;
  line-height: 1.52;
  color: var(--ink-dark);
}

.protein-pill {
  margin-top: 8px;
  font-size: 0.8rem;
  background: var(--paper-warm);
  padding: 5px 10px;
  border-radius: 6px;
  border-left: 3px solid var(--burgundy);
}

/* Wonder Section */
.wonder-header, .poll-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.gate-badge {
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--gold-soft);
  color: #6b4704;
  padding: 2px 7px;
  border-radius: 99px;
}

.btn-wonder {
  width: 100%;
  padding: 11px 14px;
  border-radius: 9px;
  border: 2px solid var(--gold);
  background: linear-gradient(135deg, #fff8e6, #f7e2b2);
  color: #4a3004;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.12s;
}

.btn-wonder:hover {
  transform: scale(1.01);
}

.wonder-reveal {
  margin-top: 10px;
  padding: 11px 13px;
  background: #fdf6e4;
  border-left: 4px solid var(--gold);
  border-radius: 7px;
}

.wonder-question-text {
  font-family: var(--font-serif);
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--ink-dark);
  line-height: 1.48;
}

.wonder-discuss-hint {
  margin-top: 6px;
  font-size: 0.74rem;
  color: var(--ink-muted);
  font-style: italic;
}

/* Poll Section */
.poll-sub {
  font-size: 0.7rem;
  color: var(--ink-muted);
}

.poll-question-text {
  font-size: 0.87rem;
  font-weight: 600;
  margin-bottom: 9px;
  line-height: 1.42;
}

.poll-options-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.poll-option-btn {
  text-align: left;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid #d4c3a3;
  background: #fff;
  color: var(--ink-dark);
  font-size: 0.82rem;
  line-height: 1.35;
  cursor: pointer;
  transition: all 0.14s;
}

.poll-option-btn:hover {
  background: var(--paper-warm);
  border-color: var(--burgundy);
}

.poll-option-btn.selected {
  background: var(--burgundy);
  color: #fff;
  border-color: var(--burgundy-dark);
  font-weight: 700;
}

.poll-chart-box {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px dashed var(--paper-border);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.poll-bar-row {
  font-size: 0.76rem;
}

.poll-bar-labels {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
  font-weight: 600;
}

.poll-bar-track {
  height: 8px;
  background: #eadfce;
  border-radius: 99px;
  overflow: hidden;
}

.poll-bar-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 99px;
}

.poll-bar-row.is-user-choice .poll-bar-fill {
  background: var(--burgundy);
}

/* Factoids Details */
.factoids-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--burgundy);
  list-style: none;
}

.factoids-summary::-webkit-details-marker {
  display: none;
}

.factoids-content {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--paper-border);
}

.factoids-disclaimer {
  font-size: 0.74rem;
  color: var(--ink-muted);
  margin-bottom: 8px;
}

.factoids-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.factoid-item {
  background: var(--paper-warm);
  padding: 7px 9px;
  border-radius: 7px;
}

.factoid-item dt {
  font-size: 0.68rem;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 700;
}

.factoid-item dd {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-dark);
  margin-top: 2px;
}

.btn-leave-bottom {
  width: 100%;
  padding: 11px;
  background: var(--burgundy);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-weight: 700;
  cursor: pointer;
}

/* Modals (Passport & Family Manager) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 11, 20, 0.75);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-card {
  background: var(--paper-light);
  border: 2px solid var(--gold);
  border-radius: 14px;
  width: 100%;
  max-width: 820px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-header);
  color: var(--paper-light);
  border-bottom: 2px solid var(--gold);
}

.modal-kicker {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--gold);
  letter-spacing: 0.06em;
  font-weight: 700;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
}

.btn-close-modal {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.passport-stats-bar {
  display: flex;
  gap: 12px;
  padding: 10px 20px;
  background: var(--paper-warm);
  border-bottom: 1px solid var(--paper-border);
  font-size: 0.8rem;
  font-weight: 700;
  flex-wrap: wrap;
}

.passport-filter-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--paper-border);
  flex-wrap: wrap;
}

.pass-tab {
  background: #ebe1ce;
  border: 1px solid #d4c2a4;
  padding: 5px 12px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.pass-tab.active {
  background: var(--burgundy);
  color: #fff;
  border-color: var(--burgundy);
}

.passport-grid {
  padding: 18px 20px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 14px;
}

.stamp-card {
  background: var(--paper-card);
  border: 1.5px dashed var(--paper-border);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s;
}

.stamp-card:hover {
  transform: translateY(-2px) rotate(-1deg);
  border-color: var(--gold);
}

.stamp-svg-wrap {
  width: 82px;
  height: 82px;
  margin: 0 auto 6px;
}

.stamp-card-name {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.9rem;
}

.stamp-card-sub {
  font-size: 0.7rem;
  color: var(--ink-muted);
}

/* Family Manager Modal */
.family-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.family-section {
  background: var(--paper-card);
  border: 1px solid var(--paper-border);
  border-radius: 10px;
  padding: 13px 15px;
}

.family-section h3 {
  font-family: var(--font-serif);
  font-size: 0.96rem;
  color: var(--burgundy);
  margin-bottom: 10px;
}

.family-Selector-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.family-select-card {
  padding: 8px 13px;
  border-radius: 8px;
  border: 2px solid var(--paper-border);
  background: var(--paper-warm);
  cursor: pointer;
  text-align: left;
}

.family-select-card.active {
  border-color: var(--burgundy);
  background: #fcecef;
}

.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form input, .inline-form select, .stacked-form input {
  padding: 7px 10px;
  border: 1px solid #cbb99b;
  border-radius: 7px;
  background: #fff;
}

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.stacked-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-primary {
  background: var(--teal);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 7px;
  font-weight: 700;
  cursor: pointer;
  align-self: flex-start;
}

/* Early Leave Warning Modal */
.early-leave-card {
  max-width: 470px;
}

.early-leave-header {
  background: var(--burgundy);
}

.early-leave-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.early-leave-desc {
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--ink-dark);
}

.early-leave-checklist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--paper-warm);
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--paper-border);
}

.early-leave-checklist li {
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.early-leave-checklist li.gate-ok {
  color: var(--green-ok);
}

.early-leave-checklist li.gate-missing {
  color: var(--burgundy);
}

.early-leave-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.btn-stay-card {
  width: 100%;
  padding: 11px 16px;
  border-radius: 9px;
  border: 2px solid var(--gold);
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
}

.btn-stay-card:hover {
  filter: brightness(1.1);
}

.btn-confirm-leave {
  width: 100%;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid #cbb99b;
  background: transparent;
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}

.btn-confirm-leave:hover {
  background: #f2e6d4;
  color: var(--burgundy);
}

/* Stamp Celebration */
.stamp-celebration {
  position: fixed;
  inset: 0;
  background: rgba(15, 11, 20, 0.78);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.celebration-book {
  background: var(--paper-light);
  border: 3px solid var(--gold);
  border-radius: 16px;
  padding: 26px 34px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: stampThump 0.45s cubic-bezier(0.2, 1.3, 0.4, 1);
}

@keyframes stampThump {
  0% { transform: scale(1.6) rotate(-8deg); opacity: 0; }
  70% { transform: scale(0.95) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .celebration-book, .feature-popup-pin {
    animation: none !important;
  }
}

.celebration-kicker {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.08em;
}

.celebration-country {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  color: var(--burgundy);
  margin: 4px 0 12px;
}

.celebration-stamp-stage {
  width: 130px;
  height: 130px;
  margin: 0 auto 12px;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 3500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #211c27;
  color: #fff;
  border-left: 4px solid var(--gold);
  padding: 10px 15px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: 0.84rem;
  max-width: 340px;
}

@media (max-width: 900px) {
  .workspace {
    flex-direction: column;
  }
  .card-drawer {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
  }
  .map-legend {
    max-width: 260px;
    font-size: 0.68rem;
  }
}
