:root {
  --ink: #2d2115;
  --muted: #725f43;
  --paper: #ead9b8;
  --paper-dark: #c7a66c;
  --bronze: #8a5b25;
  --gold: #c59a3a;
  --shadow: rgba(49, 31, 14, 0.25);
  --line: rgba(99, 64, 25, 0.55);
}

body.dark-theme {
  --ink: #f3e6c7;
  --muted: #dfcca4;
  --paper: #3a2c1d;
  --paper-dark: #6d5431;
  --bronze: #efc76e;
  --gold: #d6a84a;
  --shadow: rgba(0, 0, 0, 0.38);
  --line: rgba(226, 178, 83, 0.62);
  background:
    radial-gradient(circle at 15% 10%, rgba(156, 112, 43, 0.35), transparent 24rem),
    radial-gradient(circle at 72% 18%, rgba(224, 173, 80, 0.18), transparent 18rem),
    linear-gradient(135deg, #18120d, #2b2118 48%, #0f0b08);
}

body.dark-theme::before {
  opacity: 0.18;
  background-image:
    linear-gradient(90deg, rgba(239, 199, 110, 0.1) 1px, transparent 1px),
    linear-gradient(rgba(239, 199, 110, 0.1) 1px, transparent 1px);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Almendra, Georgia, serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 239, 190, 0.55), transparent 24rem),
    radial-gradient(circle at 70% 20%, rgba(179, 121, 45, 0.22), transparent 18rem),
    linear-gradient(135deg, #d8bd83, #f1dfba 42%, #b98947);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.32;
  background-image:
    linear-gradient(90deg, rgba(77, 48, 18, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(77, 48, 18, 0.08) 1px, transparent 1px);
  background-size: 42px 42px;
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid rgba(78, 50, 20, 0.28);
  background: rgba(239, 218, 178, 0.86);
  backdrop-filter: blur(8px);
}

.eyebrow {
  margin: 0 0 0.15rem;
  color: var(--bronze);
  font-family: Cinzel, serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: Cinzel, serif;
}

h1 {
  font-size: clamp(1.35rem, 2.2vw, 1.8rem);
}

.beta-version {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-family: Cinzel, serif;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h2 {
  font-size: 1rem;
}

.topbar-actions {
  display: flex;
  gap: 0.75rem;
  align-items: end;
  flex-wrap: wrap;
  justify-content: end;
}

.mobile-menu-details {
  display: none;
  position: relative;
}

.mobile-menu-button {
  display: none;
  position: relative;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid rgba(94, 61, 25, 0.32);
  border-radius: 999px;
  padding: 0.5rem 0.75rem 0.5rem 2rem;
  color: var(--ink);
  background: rgba(255, 247, 226, 0.82);
  cursor: pointer;
  text-decoration: none;
  list-style: none;
}

.mobile-menu-button::-webkit-details-marker {
  display: none;
}

.mobile-menu-mount {
  display: none;
}

.mobile-menu-toggle {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.mobile-menu-button span {
  display: block;
  position: absolute;
  left: 0.75rem;
  width: 0.85rem;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.mobile-menu-button span:nth-of-type(1) {
  top: calc(50% - 0.35rem);
}

.mobile-menu-button span:nth-of-type(2) {
  top: 50%;
}

.mobile-menu-button span:nth-of-type(3) {
  top: calc(50% + 0.35rem);
}

.mobile-sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(34, 23, 12, 0.42);
  display: none;
}

.mobile-bottom-nav {
  display: none;
}

.mobile-view-title {
  display: none;
}

.mobile-close-menu-button {
  display: none;
}

.tree-name-heading {
  margin: 0.15rem 0 0;
  color: var(--muted);
}

.search {
  position: relative;
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.search input {
  width: min(54vw, 22rem);
  border: 1px solid rgba(94, 61, 25, 0.32);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  color: var(--ink);
  background: rgba(255, 247, 226, 0.9);
}

.search-results {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  z-index: 30;
  width: min(32rem, calc(100vw - 2.5rem));
  max-height: min(34rem, calc(100vh - 7rem));
  overflow: auto;
  border: 1px solid rgba(82, 51, 18, 0.24);
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.96);
  box-shadow: 0 18px 42px rgba(44, 29, 13, 0.32);
  backdrop-filter: blur(8px);
}

.search-results-empty {
  margin: 0;
  color: var(--muted);
}

.search-section + .search-section {
  margin-top: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(82, 51, 18, 0.16);
}

.search-section h3 {
  margin-bottom: 0.45rem;
  color: var(--bronze);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.search-result-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  align-items: center;
  width: 100%;
  border: 1px solid rgba(82, 51, 18, 0.16);
  border-radius: 7px;
  padding: 0.55rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.58);
}

.search-result-row + .search-result-row {
  margin-top: 0.4rem;
}

.search-result-main {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.search-result-main strong,
.search-result-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-main small {
  color: var(--muted);
}

.search-result-actions {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: end;
}

.search-result-actions button {
  border: 1px solid rgba(82, 51, 18, 0.22);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.8);
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(82, 51, 18, 0.34);
  border-radius: 6px;
  padding: 0.62rem 0.8rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.75);
  cursor: pointer;
  box-shadow: 0 2px 7px var(--shadow);
  text-align: center;
  text-decoration: none;
}

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

.button.gold {
  color: #24180d;
  background: linear-gradient(#d8af4b, #ad7828);
}

.button.ghost {
  background: rgba(255, 248, 229, 0.48);
}

.button.danger-soft {
  color: #5b2418;
  border-color: rgba(91, 36, 24, 0.28);
}

.button.full {
  width: 100%;
  margin-top: 0.55rem;
}

.inline-link-button {
  width: fit-content;
  margin: -0.25rem 0 0.25rem;
  padding: 0;
  border: 0;
  color: #725022;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.inline-link-button:hover {
  color: #4c2a13;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.admin-stat-card {
  padding: 0.85rem;
  border: 1px solid rgba(122, 83, 40, 0.22);
  border-radius: 8px;
  background: rgba(255, 248, 229, 0.62);
}

.admin-stat-card small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.admin-stat-card strong {
  display: block;
  margin-top: 0.2rem;
  font-family: Cinzel, serif;
  font-size: 1.35rem;
}

.temporary-password-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.85rem;
  border: 1px solid rgba(122, 83, 40, 0.3);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(255, 248, 229, 0.72);
}

.temporary-password-box small {
  grid-column: 1 / -1;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.temporary-password-box code {
  display: block;
  overflow-wrap: anywhere;
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  color: #24180d;
  background: rgba(255, 255, 255, 0.68);
  font-family: "Courier New", monospace;
  font-size: 1rem;
}

.temporary-password-box input[readonly] {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(122, 83, 40, 0.22);
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  color: #24180d;
  background: rgba(255, 255, 255, 0.68);
  font-family: "Courier New", monospace;
  font-size: 0.9rem;
}

.guest-access-options {
  display: grid;
  gap: 0.65rem;
}

.guest-access-options label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem;
  align-items: start;
  border: 1px solid rgba(122, 83, 40, 0.22);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(255, 248, 229, 0.52);
  cursor: pointer;
}

.guest-access-options input {
  margin-top: 0.25rem;
}

.guest-access-options span {
  display: grid;
  gap: 0.15rem;
}

.guest-access-options strong {
  font-family: Cinzel, serif;
  font-size: 0.9rem;
}

.guest-access-options small {
  color: var(--muted);
  line-height: 1.35;
}

.guest-export-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.75rem;
  color: var(--muted);
}

.admin-activity-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 1rem;
}

.admin-activity-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid rgba(122, 83, 40, 0.16);
}

.admin-users-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 1rem;
}

.admin-user-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid rgba(122, 83, 40, 0.18);
  border-radius: 8px;
  background: rgba(255, 248, 229, 0.5);
}

.admin-user-row small {
  display: block;
  color: var(--muted);
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 18rem 1fr;
  min-height: calc(100vh - 4rem);
}

.sidebar {
  padding: 1rem;
  border-right: 1px solid rgba(78, 50, 20, 0.25);
  background: rgba(235, 210, 163, 0.9);
}

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  padding: 0.25rem;
  border: 1px solid rgba(78, 50, 20, 0.24);
  border-radius: 8px;
  background: rgba(255, 247, 226, 0.42);
}

#saveStatus {
  color: var(--bronze);
  font-weight: 700;
}

#saveStatus.dirty {
  color: #8b3d25;
}

.tab-button {
  border: 0;
  border-radius: 6px;
  padding: 0.62rem 0.7rem;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.tab-button.active {
  color: var(--ink);
  background: linear-gradient(#e8ca7b, #c18b34);
  box-shadow: 0 5px 14px rgba(76, 47, 17, 0.22);
}

.tab-panel {
  margin-top: 1rem;
  border: 1px solid rgba(78, 50, 20, 0.22);
  border-radius: 8px;
  padding: 1rem;
  background: rgba(255, 247, 226, 0.45);
  box-shadow: 0 10px 24px rgba(69, 42, 16, 0.12);
}

.panel-kicker {
  margin: 0 0 0.2rem;
  color: var(--bronze);
  font-family: Cinzel, serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-stack {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.panel-note {
  display: grid;
  gap: 0.25rem;
  margin-top: 1rem;
  border-top: 1px solid rgba(78, 50, 20, 0.18);
  padding-top: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.panel-note strong {
  color: var(--bronze);
  font-family: Cinzel, serif;
  font-size: 0.78rem;
}

.panel-intro {
  margin: 0.65rem 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.timeline {
  display: grid;
  gap: 0.65rem;
  margin: 0.8rem 0 0;
  padding-left: 1.1rem;
}

.timeline li {
  position: relative;
  padding: 0 0 0.75rem 0.7rem;
  border-left: 1px solid rgba(99, 64, 25, 0.32);
}

.timeline li::before {
  content: "";
  position: absolute;
  left: -0.35rem;
  top: 0.15rem;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(197, 154, 58, 0.22);
}

.timeline strong {
  display: block;
  font-family: Cinzel, serif;
  font-size: 0.78rem;
}

.relations-panel-list {
  display: grid;
  gap: 0.85rem;
  margin-top: 0.85rem;
}

.relations-section {
  display: grid;
  gap: 0.55rem;
}

.relations-section h3 {
  color: var(--bronze);
  font-size: 0.82rem;
}

.relationship-warnings {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.relationship-warnings li {
  border: 1px solid rgba(139, 61, 37, 0.28);
  border-radius: 8px;
  padding: 0.55rem;
  color: #6b2d1c;
  background: rgba(255, 226, 197, 0.46);
}

.panel-relation-row {
  display: grid;
  gap: 0.5rem;
  border: 1px solid rgba(78, 50, 20, 0.18);
  border-radius: 8px;
  padding: 0.65rem;
  background: rgba(255, 248, 229, 0.42);
}

.panel-relation-row span {
  display: grid;
  gap: 0.15rem;
}

.panel-relation-row strong {
  line-height: 1.2;
}

.panel-relation-row small {
  color: var(--muted);
}

.panel-relation-row select {
  width: 100%;
  border: 1px solid rgba(94, 61, 25, 0.32);
  border-radius: 6px;
  padding: 0.48rem 0.55rem;
  color: var(--ink);
  background: rgba(255, 247, 226, 0.9);
}

.canvas-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: calc(100vh - 5.3rem);
  overflow: visible;
}

.canvas-toolbar {
  position: relative;
  z-index: 6;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 1rem;
  color: var(--muted);
  border-bottom: 1px solid rgba(78, 50, 20, 0.18);
  background: rgba(255, 246, 222, 0.42);
}

.empty-tree-state {
  position: absolute;
  left: 50%;
  top: 45%;
  width: min(28rem, calc(100vw - 2rem));
  border: 1px solid rgba(93, 61, 26, 0.22);
  border-radius: 8px;
  padding: 1.15rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.88);
  box-shadow: 0 18px 44px rgba(51, 32, 13, 0.18);
  transform: translate(-50%, -50%);
}

.empty-tree-state h2 {
  margin-bottom: 0.45rem;
  font-size: 1.15rem;
}

.empty-tree-state p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.empty-tree-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}

.view-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: end;
}

.language-controls,
.view-mode-controls,
.focus-controls,
.theme-controls {
  display: flex;
  gap: 0.25rem;
  border: 1px solid rgba(82, 51, 18, 0.28);
  border-radius: 999px;
  padding: 0.2rem;
  background: rgba(255, 248, 229, 0.5);
}

.language-controls button,
.view-mode-controls button,
.focus-controls button,
.theme-controls button {
  border: 0;
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.focus-controls {
  align-items: center;
}

.focus-controls span {
  max-width: 11rem;
  padding: 0.28rem 0.65rem;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.language-controls button.active,
.view-mode-controls button.active,
.theme-controls button.active {
  color: #24180d;
  background: linear-gradient(#d8af4b, #ad7828);
}

.tree-name-field {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.85rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.tree-name-field input {
  width: 100%;
  border: 1px solid rgba(94, 61, 25, 0.32);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  color: var(--ink);
  background: rgba(255, 247, 226, 0.9);
}

.backup-card,
.cloud-card {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.85rem;
  border: 1px solid rgba(78, 50, 20, 0.18);
  border-radius: 8px;
  padding: 0.7rem;
  background: rgba(255, 248, 229, 0.42);
}

.backup-card strong,
.cloud-card strong {
  color: var(--bronze);
  font-family: Cinzel, serif;
  font-size: 0.78rem;
}

.backup-card span,
.backup-card small,
.cloud-card span,
.cloud-card small {
  color: var(--muted);
}

.cloud-card.connected {
  border-color: rgba(72, 112, 48, 0.34);
  background: rgba(225, 244, 204, 0.34);
}

.cloud-card.offline {
  border-color: rgba(135, 77, 42, 0.28);
}

.cloud-card.error {
  border-color: rgba(140, 44, 32, 0.42);
  background: rgba(140, 44, 32, 0.08);
}

body.dark-theme .cloud-card {
  border-color: rgba(224, 190, 123, 0.22);
  background: rgba(38, 26, 15, 0.72);
}

body.dark-theme .cloud-card.connected {
  border-color: rgba(155, 185, 94, 0.28);
  background: rgba(54, 82, 38, 0.32);
}

body.dark-theme .cloud-card.error {
  border-color: rgba(220, 92, 78, 0.36);
  background: rgba(120, 38, 32, 0.24);
}

.quality-summary {
  border-radius: 999px;
  padding: 0.18rem 0.45rem;
  background: rgba(88, 121, 55, 0.13);
  color: #45602b;
  font-size: 0.78rem;
}

.quality-summary.has-warnings {
  background: rgba(156, 105, 32, 0.14);
  color: #76501f;
}

.quality-summary.has-errors {
  background: rgba(128, 42, 28, 0.14);
  color: #7c2d22;
}

body.dark-theme .quality-summary {
  background: rgba(155, 185, 94, 0.16);
  color: #d5e9a6;
}

body.dark-theme .quality-summary.has-warnings {
  background: rgba(210, 151, 70, 0.18);
  color: #f2c782;
}

body.dark-theme .quality-summary.has-errors {
  background: rgba(220, 92, 78, 0.18);
  color: #ffb5aa;
}

.zoom-controls {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.zoom-controls button,
.zoom-controls span {
  min-width: 2.2rem;
  border: 1px solid rgba(82, 51, 18, 0.28);
  border-radius: 999px;
  padding: 0.28rem 0.58rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.72);
  text-align: center;
}

.zoom-controls button {
  cursor: pointer;
}

.geo-places-popup-wrap {
  position: relative;
}

.geo-places-popup {
  position: absolute;
  right: 0;
  top: calc(100% + 0.55rem);
  z-index: 8;
  display: grid;
  gap: 0.55rem;
  width: 20rem;
  max-height: min(36rem, calc(100vh - 11rem));
  overflow: auto;
  border: 1px solid rgba(82, 51, 18, 0.26);
  border-radius: 8px;
  padding: 0.85rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.94);
  box-shadow: 0 18px 42px rgba(44, 29, 13, 0.34);
  backdrop-filter: blur(6px);
}

.geo-popup-place-list {
  display: grid;
  gap: 0.45rem;
}

.tree-canvas {
  position: relative;
  flex: 1;
  height: auto;
  min-height: 34rem;
  overflow: auto;
  background:
    linear-gradient(rgba(102, 72, 34, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(102, 72, 34, 0.12) 1px, transparent 1px);
  background-size: 80px 80px;
}

.tree-canvas.geo-canvas {
  overflow: hidden;
}

.tree-canvas.geo-canvas .zoom-layer {
  width: 100% !important;
  height: 100% !important;
  min-width: 0;
}

.tree-canvas.geo-canvas .relation-lines,
.tree-canvas.geo-canvas .node-layer {
  width: 100% !important;
  height: 100% !important;
  min-width: 0 !important;
  min-height: 0 !important;
}

.zoom-layer {
  position: relative;
  width: 1250px;
  height: 820px;
  transform-origin: 0 0;
}

.relation-lines,
.node-layer {
  position: absolute;
  inset: 0;
  min-width: 1250px;
  min-height: 820px;
}

.relation-lines {
  pointer-events: none;
}

.person-node {
  position: absolute;
  width: 12.25rem;
  min-height: 7rem;
  border: 1px solid rgba(75, 45, 15, 0.42);
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 246, 222, 0.95), rgba(214, 177, 105, 0.86)),
    var(--paper);
  box-shadow: 0 12px 24px var(--shadow);
  cursor: pointer;
  user-select: none;
}

.person-node.highlight {
  outline: 3px solid rgba(197, 154, 58, 0.75);
}

.person-node.focus-person {
  border-color: rgba(141, 90, 28, 0.86);
  box-shadow:
    0 0 0 4px rgba(197, 154, 58, 0.26),
    0 14px 30px var(--shadow);
}

.person-node.pedigree-node {
  width: 8.25rem;
  min-height: 3.65rem;
  padding: 0.45rem;
}

.person-node.pedigree-node h3 {
  font-size: 0.78rem;
}

.person-node.pedigree-node p {
  margin-top: 0.16rem;
  font-size: 0.72rem;
}

.person-node.pedigree-node p:nth-of-type(3) {
  display: none;
}

.person-node.pedigree-node .pedigree-actions {
  margin-top: 0.25rem;
}

.person-node.pedigree-node .pedigree-actions button {
  min-height: 1.25rem;
  padding: 0.02rem 0.4rem;
  font-size: 0.68rem;
}

.family-card-slot {
  position: absolute;
  width: 12.25rem;
  min-height: 7rem;
  border: 1px dashed rgba(138, 91, 37, 0.58);
  border-radius: 8px;
  color: var(--bronze);
  background: rgba(255, 248, 229, 0.36);
  cursor: pointer;
  font-family: Cinzel, serif;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255, 248, 229, 0.34);
}

.family-card-slot:hover {
  background: rgba(255, 248, 229, 0.62);
  transform: translateY(-1px);
}

.geo-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background:
    radial-gradient(ellipse at 50% 48%, rgba(197, 154, 58, 0.2), transparent 23rem),
    linear-gradient(135deg, rgba(255, 248, 229, 0.7), rgba(214, 177, 105, 0.32));
  overflow: hidden;
}

.geo-map::before {
  content: "";
  position: absolute;
  inset: 2.5rem;
  border: 1px solid rgba(138, 91, 37, 0.18);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 48%, rgba(138, 91, 37, 0.12) 49%, transparent 50%),
    repeating-linear-gradient(90deg, transparent 0 6rem, rgba(138, 91, 37, 0.08) 6.05rem 6.12rem);
  opacity: 0.28;
  pointer-events: none;
}

.geo-map-title {
  position: absolute;
  left: 1.25rem;
  top: 1.15rem;
  z-index: 7;
  width: 22rem;
  border: 1px solid rgba(82, 51, 18, 0.2);
  border-radius: 8px;
  padding: 0.85rem;
  background: rgba(255, 248, 229, 0.86);
  box-shadow: 0 16px 34px rgba(44, 29, 13, 0.26);
  backdrop-filter: blur(7px);
}

.geo-map-title p:not(.eyebrow) {
  margin-top: 0.45rem;
  color: var(--muted);
  line-height: 1.45;
}

.geo-filter {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}

.geo-filter button {
  border: 1px solid rgba(82, 51, 18, 0.24);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.72);
  cursor: pointer;
}

.geo-filter button.active {
  color: #2c1c0d;
  background: linear-gradient(#e7c76a, #ad7931);
  box-shadow: 0 0 0 3px rgba(197, 154, 58, 0.18);
}

.geo-globe-wrap {
  position: absolute;
  inset: 0.65rem;
  z-index: 2;
  width: auto;
  height: auto;
  min-height: 0;
  border-radius: 8px;
  filter: drop-shadow(0 2rem 3rem rgba(60, 37, 14, 0.28));
}

.geo-globe {
  position: relative;
  width: 100%;
  height: 100%;
  border: 2px solid rgba(100, 65, 25, 0.38);
  border-radius: 8px;
  overflow: visible;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 251, 229, 0.34), transparent 18%),
    linear-gradient(145deg, rgba(214, 177, 105, 0.32), rgba(83, 55, 24, 0.4));
  box-shadow:
    inset -2rem -1.5rem 3rem rgba(36, 24, 13, 0.18),
    inset 1.6rem 1.2rem 2rem rgba(255, 248, 229, 0.18);
  cursor: grab;
  touch-action: none;
}

.geo-globe.dragging {
  cursor: grabbing;
}

.geo-engine-globe {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 8px;
  overflow: visible;
}

.geo-engine-globe canvas {
  display: block;
  border-radius: 8px;
  touch-action: none;
}

.geo-html-marker {
  position: relative;
  display: block;
  width: 0.82rem;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 248, 229, 0.88);
  border-radius: 999px 999px 999px 0;
  color: #fff8e7;
  background: #b7352e;
  box-shadow:
    0 0 0 3px rgba(127, 47, 42, 0.16),
    0 8px 16px rgba(32, 20, 8, 0.34);
  cursor: pointer;
  font-family: Cinzel, serif;
  font-size: 0;
  font-weight: 700;
  pointer-events: auto;
  transform: translate(-50%, -100%) rotate(-45deg);
  z-index: 6;
}

.geo-html-marker::after {
  position: absolute;
  inset: -0.45rem;
  content: "";
}

.geo-pin-count {
  display: none;
  transform: rotate(45deg);
}

.geo-pin-label {
  position: absolute;
  left: 0.78rem;
  top: -0.34rem;
  display: block;
  max-width: 5.8rem;
  border: 1px solid rgba(47, 27, 10, 0.22);
  border-radius: 999px;
  padding: 0.1rem 0.34rem;
  color: #1b0f06;
  background: rgba(255, 246, 222, 0.9);
  box-shadow: 0 4px 12px rgba(32, 20, 8, 0.24);
  font-family: Cinzel, Almendra, Georgia, serif;
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.1;
  text-shadow: 0 1px 0 rgba(255, 248, 229, 0.65);
  white-space: nowrap;
  transform: rotate(45deg);
  opacity: 1;
  pointer-events: none;
  transition: opacity 70ms ease;
}

.geo-pin-label.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.geo-html-marker[data-geo-type="death"] {
  background: #9f2f2a;
}

.geo-html-marker[data-geo-type="relationship"] {
  background: #c43d32;
}

.geo-html-marker.active {
  width: 1rem;
  background: #e03d35;
  box-shadow:
    0 0 0 5px rgba(196, 61, 50, 0.22),
    0 0 20px rgba(127, 47, 42, 0.46);
}

.geo-html-marker.active .geo-pin-label {
  color: #120904;
  background: rgba(255, 241, 194, 0.96);
  font-size: 0.6rem;
}

.geo-hover-tooltip {
  position: fixed;
  z-index: 50;
  display: grid;
  gap: 0.12rem;
  border: 1px solid rgba(47, 27, 10, 0.28);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  color: #1b0f06;
  background: rgba(255, 246, 222, 0.96);
  box-shadow: 0 10px 24px rgba(32, 20, 8, 0.32);
  font-family: Almendra, Georgia, serif;
  pointer-events: none;
}

.geo-hover-tooltip[hidden] {
  display: none;
}

.geo-hover-tooltip strong {
  font-family: Cinzel, Almendra, Georgia, serif;
  font-size: 0.9rem;
}

.geo-hover-tooltip span {
  color: var(--muted);
  font-size: 0.82rem;
}

.geo-globe-fallback {
  position: absolute;
  inset: 18%;
  z-index: 2;
  display: grid;
  place-content: center;
  gap: 0.35rem;
  border: 1px solid rgba(82, 51, 18, 0.24);
  border-radius: 8px;
  padding: 1rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.78);
  text-align: center;
}

.geo-globe-fallback span {
  color: var(--muted);
}

.geo-globe-surface {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 100%;
  height: 100%;
  transform-origin: center;
  transition: transform 120ms ease-out;
}

.geo-route-lines {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.geo-route-lines path {
  fill: none;
  stroke: rgba(73, 45, 16, 0.34);
  stroke-width: 0.45;
  stroke-linecap: round;
  stroke-dasharray: 2 2.8;
}

.geo-globe-grid {
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  background:
    repeating-linear-gradient(0deg, transparent 0 3.35rem, rgba(61, 38, 14, 0.18) 3.42rem 3.5rem),
    repeating-linear-gradient(90deg, transparent 0 3.35rem, rgba(61, 38, 14, 0.15) 3.42rem 3.5rem);
  mask-image: radial-gradient(circle, #000 0 69%, transparent 70%);
  opacity: 0.74;
}

.geo-world-map {
  position: absolute;
  inset: 8%;
  z-index: 1;
  width: 84%;
  height: 84%;
  opacity: 0.95;
}

.geo-world-map .geo-country {
  fill: rgba(116, 92, 43, 0.58);
  stroke: rgba(59, 36, 13, 0.34);
  stroke-width: 0.75;
  vector-effect: non-scaling-stroke;
}

.geo-world-map .sweden {
  fill: rgba(209, 169, 74, 0.76);
  stroke: rgba(67, 39, 12, 0.58);
  stroke-width: 0.95;
}

.geo-world-map .scandinavia {
  fill: rgba(137, 111, 53, 0.52);
}

.geo-world-map text {
  fill: rgba(57, 36, 14, 0.72);
  font-family: Cinzel, Almendra, Georgia, serif;
  font-size: 2.35px;
  font-weight: 700;
  letter-spacing: 0.05em;
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(255, 248, 229, 0.45);
}

.geo-globe-shine {
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 236, 0.54), transparent 19%),
    radial-gradient(circle at 72% 74%, rgba(30, 18, 8, 0.42), transparent 34%);
  pointer-events: none;
}

.geo-compass {
  position: absolute;
  right: 1rem;
  top: 1rem;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 2.7rem;
  aspect-ratio: 1;
  border: 1px solid rgba(82, 51, 18, 0.32);
  border-radius: 50%;
  color: var(--bronze);
  background: rgba(255, 248, 229, 0.72);
  font-family: Cinzel, serif;
  font-weight: 700;
}

.geo-globe-help {
  position: absolute;
  left: 50%;
  bottom: 0.85rem;
  z-index: 4;
  transform: translateX(-50%);
  width: max-content;
  border: 1px solid rgba(82, 51, 18, 0.22);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  color: var(--muted);
  background: rgba(255, 248, 229, 0.72);
  font-size: 0.82rem;
  box-shadow: 0 8px 18px var(--shadow);
}

.geo-place-list {
  position: absolute;
  right: 2rem;
  top: 5.3rem;
  z-index: 4;
  display: grid;
  gap: 0.55rem;
  width: 18.5rem;
  max-height: 36rem;
  overflow: auto;
  border: 1px solid rgba(82, 51, 18, 0.24);
  border-radius: 8px;
  padding: 0.85rem;
  background: rgba(255, 248, 229, 0.88);
  box-shadow: 0 16px 34px rgba(44, 29, 13, 0.32);
  backdrop-filter: blur(5px);
}

.geo-place-list.collapsed {
  max-height: none;
}

.geo-place-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}

.geo-place-list h3 {
  margin: 0;
  font-size: 0.95rem;
}

.geo-place-list-header button,
.geo-all-places-button,
.geo-place-layer-actions button {
  border: 1px solid rgba(82, 51, 18, 0.22);
  border-radius: 999px;
  padding: 0.32rem 0.62rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.66);
  cursor: pointer;
}

.geo-all-places-button {
  width: 100%;
  margin: 0.15rem 0 0.25rem;
  text-align: left;
  font-family: Cinzel, serif;
  font-weight: 700;
}

.geo-all-places-button.active {
  color: #2c1c0d;
  background: linear-gradient(#e7c76a, #ad7931);
}

.geo-layer-status {
  margin: -0.05rem 0 0.25rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.geo-place-layer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 0.3rem;
}

.geo-place-layer-actions button {
  font-size: 0.84rem;
}

.geo-place-row {
  display: grid;
  gap: 0.1rem;
  border: 1px solid rgba(82, 51, 18, 0.2);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.64);
  cursor: pointer;
  text-align: left;
}

.geo-place-row.active {
  border-color: rgba(141, 90, 28, 0.58);
  background: rgba(231, 199, 106, 0.36);
  box-shadow: inset 0 0 0 1px rgba(255, 248, 229, 0.45);
}

.geo-place-row.inactive-layer {
  opacity: 0.58;
}

.geo-place-toggle {
  justify-self: start;
  border: 1px solid rgba(82, 51, 18, 0.2);
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  color: var(--bronze);
  background: rgba(255, 248, 229, 0.58);
  font-family: Cinzel, serif;
  font-size: 0.68rem;
  font-weight: 700;
}

.geo-place-row.inactive-layer .geo-place-toggle {
  color: var(--muted);
}

.geo-place-row.missing-coordinates {
  border-style: dashed;
  opacity: 0.72;
}

.geo-place-row span {
  color: var(--muted);
  font-size: 0.85rem;
}

.geo-coordinate-note {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.geo-detail-panel {
  position: absolute;
  left: 1.25rem;
  top: 13.9rem;
  z-index: 7;
  width: 22rem;
  max-height: calc(100% - 15.2rem);
  overflow: auto;
  border: 1px solid rgba(82, 51, 18, 0.24);
  border-radius: 8px;
  padding: 0.95rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.9);
  box-shadow: 0 18px 38px rgba(44, 29, 13, 0.34);
  backdrop-filter: blur(7px);
}

.geo-detail-panel h3 {
  margin: 0.1rem 0 0.25rem;
  font-size: 1.15rem;
}

.geo-person-list {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.geo-person-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.45rem;
  align-items: center;
  border: 1px solid rgba(82, 51, 18, 0.18);
  border-radius: 6px;
  padding: 0.55rem;
  background: rgba(255, 248, 229, 0.58);
}

.geo-person-row strong,
.geo-person-row small,
.geo-person-row span {
  display: block;
}

.geo-person-row small {
  color: var(--bronze);
  font-family: Cinzel, serif;
  font-size: 0.72rem;
}

.geo-person-row span {
  color: var(--muted);
  font-size: 0.85rem;
}

.geo-person-row button {
  border: 1px solid rgba(82, 51, 18, 0.24);
  border-radius: 999px;
  padding: 0.32rem 0.55rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.74);
  cursor: pointer;
}

.geo-marker {
  position: absolute;
  z-index: 1;
  display: grid;
  gap: 0.18rem;
  width: 13rem;
  border: 1px solid rgba(82, 51, 18, 0.34);
  border-radius: 8px;
  padding: 0.65rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.9);
  box-shadow: 0 10px 22px var(--shadow);
  cursor: pointer;
  text-align: left;
}

.geo-globe-marker {
  z-index: 5;
  width: var(--marker-size);
  min-width: var(--marker-size);
  min-height: var(--marker-size);
  border-radius: 999px;
  padding: 0;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #fff4c9, #c89a3e 54%, #6d4418 100%);
}

.geo-globe-marker[data-geo-type="death"] {
  background: radial-gradient(circle at 35% 30%, #efe7d2, #8f8170 54%, #3e3124 100%);
}

.geo-globe-marker[data-geo-type="relationship"] {
  background: radial-gradient(circle at 35% 30%, #fff1bd, #b35f49 54%, #5f2418 100%);
}

.geo-globe-marker.active {
  outline: 3px solid rgba(255, 248, 229, 0.8);
  box-shadow:
    0 0 0 6px rgba(197, 154, 58, 0.34),
    0 0 28px rgba(255, 230, 160, 0.45);
}

.geo-globe-marker strong,
.geo-globe-marker span,
.geo-globe-marker small {
  position: absolute;
  left: calc(100% + 0.45rem);
  display: none;
  width: 12rem;
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.94);
  box-shadow: 0 8px 20px var(--shadow);
}

.geo-globe-marker:hover strong,
.geo-globe-marker:hover span,
.geo-globe-marker:hover small,
.geo-globe-marker:focus-visible strong,
.geo-globe-marker:focus-visible span,
.geo-globe-marker:focus-visible small {
  display: block;
}

.geo-globe-marker strong {
  top: -0.7rem;
  padding: 0.55rem 0.65rem 0.15rem;
}

.geo-globe-marker span {
  top: 1.15rem;
  padding: 0.1rem 0.65rem;
  box-shadow: none;
}

.geo-globe-marker small {
  top: 2.55rem;
  padding: 0.05rem 0.65rem 0.55rem;
  box-shadow: none;
}

.geo-marker::before {
  content: "";
  position: absolute;
  left: -0.45rem;
  top: -0.45rem;
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(197, 154, 58, 0.25);
}

.geo-marker strong {
  font-family: Cinzel, serif;
}

.geo-marker span,
.geo-marker small {
  color: var(--muted);
}

.geo-empty {
  position: absolute;
  left: 2rem;
  top: 7rem;
  color: var(--muted);
}

.person-node h3 {
  font-size: 1rem;
  line-height: 1.2;
}

.person-node p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.node-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.65rem;
  flex-wrap: wrap;
}

.node-actions button {
  min-width: 1.85rem;
  min-height: 1.85rem;
  border: 1px solid rgba(79, 48, 16, 0.32);
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  background: rgba(255, 247, 226, 0.8);
  cursor: pointer;
  font-size: 0.82rem;
}

.read-only .node-actions,
.read-only #newTreeButton,
.read-only #resetDataButton,
.read-only #cloudSaveButton,
.read-only #guestLinkButton,
.read-only #importJsonButton,
.read-only #gedcomButton {
  display: none;
}

.person-dialog {
  width: min(44rem, calc(100vw - 2rem));
  border: 1px solid rgba(84, 52, 20, 0.45);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: linear-gradient(135deg, #f3e2bf, #d8b778);
  box-shadow: 0 28px 70px rgba(39, 25, 12, 0.45);
}

.person-dialog::backdrop {
  background: rgba(29, 19, 10, 0.54);
}

.import-review-dialog,
.about-archive-dialog,
.pdf-export-dialog {
  width: min(34rem, calc(100vw - 2rem));
  border: 1px solid rgba(84, 52, 20, 0.45);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background: linear-gradient(135deg, #f3e2bf, #d8b778);
  box-shadow: 0 28px 70px rgba(39, 25, 12, 0.45);
}

.import-review-dialog::backdrop,
.about-archive-dialog::backdrop,
.pdf-export-dialog::backdrop {
  background: rgba(29, 19, 10, 0.54);
}

.import-review-content,
.about-archive-content,
.pdf-export-content {
  display: grid;
  gap: 0.9rem;
  padding: 1.3rem;
}

.about-archive-content p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.pdf-report-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 7rem;
  gap: 0.55rem;
}

.visual-pedigree-controls {
  grid-template-columns: minmax(9rem, 12rem) minmax(10rem, 1fr);
}

.pdf-report-controls label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.pdf-report-controls select,
.pdf-report-controls input {
  min-width: 0;
  border: 1px solid rgba(82, 51, 18, 0.24);
  border-radius: 6px;
  padding: 0.48rem 0.55rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.82);
}

.pdf-option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.pdf-option-grid label {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  border: 1px solid rgba(82, 51, 18, 0.18);
  border-radius: 7px;
  padding: 0.55rem;
  background: rgba(255, 248, 229, 0.45);
}

.import-stats {
  display: grid;
  gap: 0.45rem;
  margin: 0;
}

.import-stats div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid rgba(78, 50, 20, 0.16);
  padding-bottom: 0.35rem;
}

.import-stats dt {
  color: var(--muted);
}

.import-stats dd {
  margin: 0;
  font-weight: 700;
}

.import-warning-box {
  border: 1px solid rgba(139, 61, 37, 0.26);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(255, 226, 197, 0.36);
}

.import-warning-box ul {
  display: grid;
  gap: 0.35rem;
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
}

.danger-note {
  margin: 0;
  color: #6b2d1c;
}

.close-button {
  position: absolute;
  top: 0.7rem;
  right: 0.8rem;
  border: 0;
  background: transparent;
  font-size: 1.8rem;
  cursor: pointer;
}

.person-dialog-content {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 1.1rem;
  padding: 1.3rem;
}

.relative-dialog {
  width: min(38rem, calc(100vw - 2rem));
}

.relative-dialog-content {
  padding: 1.3rem;
}

.relative-fields {
  margin-top: 0.75rem;
}

.portrait {
  width: 9rem;
  aspect-ratio: 1;
  border: 2px solid rgba(93, 58, 18, 0.38);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 246, 219, 0.9) 0 18%, transparent 19%),
    radial-gradient(circle at 50% 72%, rgba(93, 58, 18, 0.8) 0 32%, transparent 33%),
    linear-gradient(135deg, #b98c41, #f2d795);
  background-position: center;
  background-size: cover;
}

.portrait.has-image {
  background-color: #d9bd80;
  background-repeat: no-repeat;
}

.life {
  color: var(--muted);
}

dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

dt {
  color: var(--bronze);
  font-family: Cinzel, serif;
  font-size: 0.72rem;
  font-weight: 700;
}

dd {
  margin: 0.15rem 0 0;
}

.notes {
  line-height: 1.5;
}

.edit-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 1rem;
}

.edit-fields label {
  display: grid;
  gap: 0.25rem;
  color: var(--bronze);
  font-family: Cinzel, serif;
  font-size: 0.72rem;
  font-weight: 700;
}

.edit-fields input,
.edit-fields select,
.edit-fields textarea {
  width: 100%;
  border: 1px solid rgba(94, 61, 25, 0.32);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  color: var(--ink);
  background: rgba(255, 247, 226, 0.88);
  font-family: Almendra, Georgia, serif;
  font-size: 1rem;
}

.edit-fields input[type="file"] {
  padding: 0.42rem;
}

.file-note {
  grid-column: 1 / -1;
  margin: -0.35rem 0 0;
  color: var(--muted);
}

.coordinate-editor {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.65rem;
  border: 1px solid rgba(82, 51, 18, 0.18);
  border-radius: 8px;
  padding: 0.8rem;
  background: rgba(255, 248, 229, 0.48);
}

.coordinate-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.coordinate-advanced {
  display: grid;
  gap: 0.65rem;
}

.coordinate-advanced summary {
  width: fit-content;
  color: var(--bronze);
  cursor: pointer;
  font-family: Cinzel, serif;
  font-size: 0.78rem;
  font-weight: 700;
}

.coordinate-advanced[open] {
  border-top: 1px solid rgba(82, 51, 18, 0.14);
  padding-top: 0.65rem;
}

.coordinate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.place-autocomplete {
  position: relative;
}

.place-suggestions {
  display: grid;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.25rem;
}

.place-suggestions[hidden] {
  display: none;
}

.place-suggestions button {
  display: grid;
  gap: 0.12rem;
  width: 100%;
  border: 1px solid rgba(82, 51, 18, 0.2);
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  color: var(--ink);
  background: rgba(255, 248, 229, 0.68);
  cursor: pointer;
  text-align: left;
}

.place-suggestions button:hover,
.place-suggestions button:focus-visible {
  border-color: rgba(173, 121, 49, 0.45);
  background: rgba(231, 199, 106, 0.18);
}

.place-suggestions span {
  color: var(--muted);
  font-size: 0.86rem;
}

.place-suggestion-message {
  border: 1px dashed rgba(82, 51, 18, 0.22);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  color: var(--muted);
  background: rgba(255, 248, 229, 0.48);
  font-family: Almendra, Georgia, serif;
  font-size: 0.95rem;
}

.validation-list {
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.validation-item,
.validation-ok {
  display: grid;
  gap: 0.12rem;
  border: 1px solid rgba(82, 51, 18, 0.16);
  border-radius: 6px;
  padding: 0.55rem 0.65rem;
  background: rgba(255, 248, 229, 0.52);
}

.validation-item strong,
.validation-ok {
  color: var(--ink);
}

.validation-item span {
  color: var(--muted);
}

.validation-item.error {
  border-color: rgba(127, 47, 42, 0.35);
  background: rgba(127, 47, 42, 0.09);
}

.validation-item.warning {
  border-color: rgba(173, 121, 49, 0.36);
  background: rgba(231, 199, 106, 0.16);
}

.edit-fields label:last-child {
  grid-column: 1 / -1;
}

.source-panel,
.source-edit,
.validation-panel {
  margin-top: 1rem;
  border-top: 1px solid rgba(78, 50, 20, 0.2);
  padding-top: 0.9rem;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.panel-heading h3 {
  margin: 0.1rem 0 0;
  font-size: 0.95rem;
}

.source-count {
  min-width: 1.7rem;
  border: 1px solid rgba(94, 61, 25, 0.25);
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  text-align: center;
  color: var(--bronze);
  background: rgba(255, 247, 226, 0.64);
  font-family: Cinzel, serif;
  font-size: 0.78rem;
  font-weight: 700;
}

.source-list {
  display: grid;
  gap: 0.55rem;
}

.source-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  border: 1px solid rgba(94, 61, 25, 0.22);
  border-radius: 6px;
  padding: 0.65rem;
  background: rgba(255, 247, 226, 0.45);
}

.source-item strong,
.source-item p,
.source-document,
.source-meta {
  display: block;
}

.source-item p {
  margin: 0.25rem 0;
  color: var(--muted);
}

.source-meta {
  margin-top: 0.2rem;
  color: var(--muted);
}

.source-event {
  display: inline-block;
  margin-bottom: 0.25rem;
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  color: #3f2a11;
  background: rgba(207, 166, 76, 0.32);
  font-size: 0.74rem;
  font-weight: 700;
}

.source-document {
  color: var(--bronze);
  font-size: 0.88rem;
}

.source-document.muted {
  color: var(--muted);
}

.source-remove {
  align-self: start;
  border: 1px solid rgba(94, 61, 25, 0.25);
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  color: var(--ink);
  background: rgba(255, 247, 226, 0.72);
  cursor: pointer;
}

.source-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.75rem;
}

.source-form label {
  display: grid;
  gap: 0.25rem;
  color: var(--bronze);
  font-family: Cinzel, serif;
  font-size: 0.72rem;
  font-weight: 700;
}

.source-form label:nth-child(3),
.source-form label:nth-child(4) {
  grid-column: 1 / -1;
}

.source-form input,
.source-form select,
.source-form textarea {
  width: 100%;
  border: 1px solid rgba(94, 61, 25, 0.32);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  color: var(--ink);
  background: rgba(255, 247, 226, 0.88);
  font-family: Almendra, Georgia, serif;
  font-size: 1rem;
}

.source-form .button {
  justify-self: start;
}

.relationship-edit {
  margin-top: 1rem;
  border-top: 1px solid rgba(78, 50, 20, 0.2);
  padding-top: 0.9rem;
}

.relationship-edit h3 {
  margin-bottom: 0.65rem;
  font-size: 0.9rem;
}

.relationship-list {
  display: grid;
  gap: 0.55rem;
}

.relationship-row {
  display: grid;
  grid-template-columns: 1fr 9rem;
  gap: 0.65rem;
  align-items: center;
  border: 1px solid rgba(94, 61, 25, 0.22);
  border-radius: 6px;
  padding: 0.55rem;
  background: rgba(255, 247, 226, 0.45);
}

.relationship-row span {
  color: var(--muted);
}

.relationship-row strong {
  display: block;
  color: var(--ink);
}

.relationship-row select,
.edit-fields select {
  width: 100%;
  border: 1px solid rgba(94, 61, 25, 0.32);
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  color: var(--ink);
  background: rgba(255, 247, 226, 0.88);
}

.dialog-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 420;
  max-width: min(24rem, calc(100vw - 2rem));
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  color: #24180d;
  background: #e1bd60;
  box-shadow: 0 10px 30px var(--shadow);
  opacity: 0;
  transform: translateY(0.5rem);
  transition: 180ms ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast button {
  border: 1px solid rgba(36, 24, 13, 0.25);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  color: #24180d;
  background: rgba(255, 248, 229, 0.62);
  cursor: pointer;
}

body.dark-theme .topbar {
  border-bottom-color: rgba(239, 199, 110, 0.22);
  background: rgba(24, 18, 13, 0.9);
}

body.dark-theme .sidebar {
  border-right-color: rgba(239, 199, 110, 0.18);
  background: rgba(31, 23, 16, 0.96);
}

body.dark-theme .canvas-toolbar,
body.dark-theme .tree-canvas {
  border-color: rgba(239, 199, 110, 0.18);
  background-color: rgba(20, 15, 11, 0.66);
}

body.dark-theme .tree-canvas {
  background-image:
    linear-gradient(rgba(239, 199, 110, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(239, 199, 110, 0.08) 1px, transparent 1px);
}

body.dark-theme .panel-tabs,
body.dark-theme .tab-panel,
body.dark-theme .panel-note,
body.dark-theme .relationship-row,
body.dark-theme .source-item,
body.dark-theme .source-count,
body.dark-theme .validation-item,
body.dark-theme .validation-ok,
body.dark-theme .coordinate-editor,
body.dark-theme .place-suggestions button,
body.dark-theme .geo-place-list,
body.dark-theme .geo-places-popup,
body.dark-theme .geo-place-row,
body.dark-theme .geo-detail-panel,
body.dark-theme .geo-person-row,
body.dark-theme .geo-globe-help,
body.dark-theme .geo-compass {
  border-color: rgba(239, 199, 110, 0.2);
  background: rgba(50, 38, 26, 0.72);
}

body.dark-theme .geo-map {
  background:
    radial-gradient(ellipse at 50% 48%, rgba(239, 199, 110, 0.12), transparent 23rem),
    linear-gradient(135deg, rgba(39, 29, 20, 0.84), rgba(20, 15, 11, 0.92));
}

body.dark-theme .geo-map-title {
  color: var(--ink);
  border-color: rgba(239, 199, 110, 0.24);
  background: rgba(34, 25, 17, 0.84);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.34);
}

body.dark-theme .geo-map-title .eyebrow {
  color: #efc76e;
}

body.dark-theme .geo-map-title p:not(.eyebrow) {
  color: var(--muted);
}

body.dark-theme .geo-globe {
  border-color: rgba(239, 199, 110, 0.34);
  background:
    radial-gradient(circle at 34% 28%, rgba(244, 218, 158, 0.42), transparent 18%),
    radial-gradient(circle at 58% 54%, rgba(239, 199, 110, 0.16), transparent 45%),
    linear-gradient(145deg, #87622f 0%, #51351c 58%, #1f150e 100%);
}

body.dark-theme .geo-globe-fallback {
  color: var(--ink);
  border-color: rgba(239, 199, 110, 0.22);
  background: rgba(50, 38, 26, 0.82);
}

body.dark-theme .geo-continent {
  border-color: rgba(239, 199, 110, 0.18);
  background: linear-gradient(135deg, rgba(124, 96, 42, 0.7), rgba(67, 49, 24, 0.7));
}

body.dark-theme .geo-world-map .geo-country {
  fill: rgba(113, 86, 38, 0.64);
  stroke: rgba(239, 199, 110, 0.18);
}

body.dark-theme .geo-world-map .sweden {
  fill: rgba(205, 158, 57, 0.78);
  stroke: rgba(255, 229, 154, 0.4);
}

body.dark-theme .geo-world-map text {
  fill: rgba(239, 199, 110, 0.72);
  text-shadow: none;
}

body.dark-theme .geo-filter button,
body.dark-theme .geo-person-row button,
body.dark-theme .geo-place-list-header button,
body.dark-theme .geo-all-places-button,
body.dark-theme .geo-place-layer-actions button,
body.dark-theme .geo-place-toggle {
  color: var(--ink);
  border-color: rgba(239, 199, 110, 0.22);
  background: rgba(68, 51, 33, 0.82);
}

body.dark-theme .geo-filter button.active,
body.dark-theme .geo-all-places-button.active {
  color: #21170d;
  background: linear-gradient(#f0c967, #b77d2e);
}

body.dark-theme .geo-place-row.active {
  border-color: rgba(239, 199, 110, 0.42);
  background: rgba(104, 78, 38, 0.74);
}

body.dark-theme .geo-route-lines path {
  stroke: rgba(239, 199, 110, 0.34);
}

body.dark-theme .button,
body.dark-theme .search input,
body.dark-theme .search-results,
body.dark-theme .search-result-row,
body.dark-theme .search-result-actions button,
body.dark-theme .zoom-controls button,
body.dark-theme .zoom-controls span,
body.dark-theme .theme-controls,
body.dark-theme .node-actions button,
body.dark-theme .edit-fields input,
body.dark-theme .edit-fields select,
body.dark-theme .edit-fields textarea,
body.dark-theme .source-form input,
body.dark-theme .source-form select,
body.dark-theme .source-form textarea,
body.dark-theme .source-remove,
body.dark-theme .relationship-row select {
  color: var(--ink);
  border-color: rgba(239, 199, 110, 0.24);
  background: rgba(68, 51, 33, 0.9);
}

body.dark-theme .search-results {
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
}

body.dark-theme .search-section + .search-section {
  border-top-color: rgba(239, 199, 110, 0.16);
}

body.dark-theme .button.gold,
body.dark-theme .tab-button.active,
body.dark-theme .theme-controls button.active {
  color: #21170d;
  background: linear-gradient(#f0c967, #b77d2e);
}

body.dark-theme .button.ghost {
  background: rgba(68, 51, 33, 0.62);
}

body.dark-theme .mobile-menu-button {
  border-color: rgba(239, 199, 110, 0.25);
  background: rgba(68, 51, 33, 0.72);
}

body.dark-theme .button.danger-soft {
  color: #ffd0bd;
  border-color: rgba(255, 167, 133, 0.32);
}

body.dark-theme .inline-link-button {
  color: #f3dfb3;
}

body.dark-theme .inline-link-button:hover {
  color: #fff4d0;
}

body.dark-theme .admin-stat-card {
  border-color: rgba(239, 199, 110, 0.22);
  background: rgba(68, 51, 33, 0.62);
}

body.dark-theme .temporary-password-box {
  border-color: rgba(239, 199, 110, 0.22);
  background: rgba(68, 51, 33, 0.62);
}

body.dark-theme .temporary-password-box code {
  color: #fff8e6;
  background: rgba(20, 15, 10, 0.56);
}

body.dark-theme .temporary-password-box input[readonly] {
  color: #fff8e6;
  background: rgba(20, 15, 10, 0.56);
}

body.dark-theme .guest-access-options label {
  border-color: rgba(239, 199, 110, 0.18);
  background: rgba(68, 51, 33, 0.5);
}

body.dark-theme .admin-activity-row {
  border-bottom-color: rgba(239, 199, 110, 0.14);
}

body.dark-theme .admin-user-row {
  border-color: rgba(239, 199, 110, 0.18);
  background: rgba(68, 51, 33, 0.5);
}

body.dark-theme .person-node {
  color: var(--ink);
  border-color: rgba(239, 199, 110, 0.28);
  background:
    linear-gradient(135deg, rgba(67, 50, 31, 0.96), rgba(39, 29, 20, 0.94)),
    var(--paper);
}

body.dark-theme .empty-tree-state {
  border-color: rgba(239, 199, 110, 0.22);
  background: rgba(44, 32, 21, 0.94);
}

body.dark-theme .person-node p,
body.dark-theme .life,
body.dark-theme .relationship-row span,
body.dark-theme .source-item p,
body.dark-theme .source-meta,
body.dark-theme .source-document.muted,
body.dark-theme .file-note,
body.dark-theme .notes {
  color: var(--muted);
}

body.dark-theme .source-event {
  color: #21170d;
  background: rgba(239, 199, 110, 0.72);
}

body.dark-theme .source-document {
  color: #efc76e;
}

body.dark-theme .person-dialog,
body.dark-theme .about-archive-dialog,
body.dark-theme .pdf-export-dialog {
  color: var(--ink);
  border-color: rgba(239, 199, 110, 0.28);
  background: linear-gradient(135deg, #3c2d1e, #21170f);
}

body.dark-theme .pdf-option-grid label {
  border-color: rgba(239, 199, 110, 0.2);
  background: rgba(50, 38, 26, 0.72);
}

body.dark-theme .pdf-report-controls select,
body.dark-theme .pdf-report-controls input {
  color: var(--ink);
  border-color: rgba(239, 199, 110, 0.24);
  background: rgba(68, 51, 33, 0.9);
}

body.dark-theme .portrait {
  border-color: rgba(239, 199, 110, 0.35);
  background:
    radial-gradient(circle at 50% 35%, rgba(244, 218, 158, 0.85) 0 18%, transparent 19%),
    radial-gradient(circle at 50% 72%, rgba(35, 24, 15, 0.9) 0 32%, transparent 33%),
    linear-gradient(135deg, #6a4b24, #c69a47);
}

body.dark-theme .toast {
  color: #21170d;
  background: #e5bd5d;
}

body.dark-theme .toast button {
  color: #21170d;
  background: rgba(255, 248, 229, 0.72);
}

@media (max-width: 850px) {
  body {
    display: block;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
    padding: 0.7rem 0.85rem;
  }

  .app-shell {
    display: block;
    height: calc(100vh - 7rem);
    min-height: 0;
    overflow: hidden;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 0.45rem;
    justify-content: start;
    margin-top: 0;
  }

  .mobile-menu-details {
    display: block;
    position: static;
    z-index: 200;
  }

  .mobile-menu-button {
    display: inline-flex;
    position: relative;
    z-index: 201;
    pointer-events: auto;
    touch-action: manipulation;
    user-select: none;
  }

  .mobile-menu-details[open] {
    grid-column: 1 / -1;
  }

  .mobile-menu-details[open] .mobile-menu-button {
    margin-bottom: 0.55rem;
  }

  .mobile-menu-mount {
    display: block;
    position: relative;
    z-index: 200;
    width: min(100%, 26rem);
    max-height: min(70svh, 40rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid rgba(94, 61, 25, 0.2);
    border-radius: 12px;
    padding: 0.7rem;
    background:
      linear-gradient(135deg, rgba(255, 248, 229, 0.99), rgba(224, 190, 122, 0.99)),
      var(--paper);
    box-shadow: 0 18px 42px rgba(45, 30, 14, 0.22);
  }

  body.dark-theme .mobile-menu-mount {
    border-color: rgba(239, 199, 110, 0.22);
    background:
      linear-gradient(135deg, rgba(54, 40, 27, 0.99), rgba(31, 23, 16, 0.99)),
      var(--paper);
  }

  .search {
    min-width: 0;
  }

  .search input {
    width: 100%;
    min-width: 0;
  }

  .search-results {
    left: 0;
    right: auto;
    width: calc(100vw - 1.7rem);
    max-height: calc(100vh - 8rem);
  }

  .pdf-option-grid {
    grid-template-columns: 1fr;
  }

  .pdf-report-controls {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 40;
    width: min(21rem, 86vw);
    height: 100vh;
    overflow: auto;
    color: var(--ink);
    border-right: 0;
    border-bottom: 0;
    background:
      linear-gradient(135deg, rgba(246, 229, 190, 0.98), rgba(218, 184, 118, 0.98)),
      var(--paper);
    box-shadow: 18px 0 40px rgba(45, 30, 14, 0.28);
    transform: translate3d(-105%, 0, 0);
    transition: transform 180ms ease;
  }

  .mobile-menu-mount > .sidebar {
    position: static !important;
    inset: auto !important;
    z-index: auto !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    border: 0 !important;
    color: var(--ink);
    background: transparent !important;
    box-shadow: none !important;
    transform: none !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transition: none !important;
  }

  .mobile-close-menu-button {
    display: block;
    width: 100%;
    margin: 0 0 0.75rem;
    border: 1px solid rgba(94, 61, 25, 0.28);
    border-radius: 8px;
    padding: 0.7rem 0.85rem;
    color: var(--ink);
    background: rgba(255, 248, 229, 0.82);
    font-family: Cinzel, serif;
    cursor: pointer;
  }

  body.dark-theme .sidebar {
    background:
      linear-gradient(135deg, rgba(54, 40, 27, 0.99), rgba(31, 23, 16, 0.99)),
      var(--paper);
  }

  body.dark-theme .mobile-close-menu-button {
    border-color: rgba(239, 199, 110, 0.22);
    background: rgba(68, 51, 33, 0.82);
  }

  body.mobile-sidebar-open .sidebar,
  .sidebar:target {
    transform: translate3d(0, 0, 0);
    visibility: visible;
    pointer-events: auto;
  }

  .canvas-wrap {
    height: 100%;
    min-height: 0;
    border-left: 0;
  }

  .canvas-toolbar {
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.55rem;
    overflow-x: auto;
  }

  .canvas-toolbar > span {
    display: none;
  }

  .view-controls,
  .view-mode-controls,
  .focus-controls,
  .theme-controls,
  .zoom-controls {
    flex-wrap: nowrap;
  }

  .view-mode-controls {
    max-width: calc(100vw - 1.2rem);
    overflow-x: auto;
  }

  .tree-canvas {
    height: calc(100svh - 12.7rem);
    min-height: 18rem;
    overflow: hidden;
  }

  .tree-canvas.has-tree {
    overflow: auto;
  }

  .person-node {
    transform-origin: center;
  }

  .language-controls button,
  .theme-controls button,
  .view-mode-controls button,
  .focus-controls button,
  .zoom-controls button {
    min-height: 2.25rem;
  }

  .person-dialog-content {
    grid-template-columns: 1fr;
  }

  dl {
    grid-template-columns: 1fr;
  }

  .edit-fields {
    grid-template-columns: 1fr;
  }

  .relationship-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 1.25rem;
  }

  .beta-version {
    font-size: 0.62rem;
  }

  .topbar-actions {
    grid-template-columns: auto 1fr auto;
  }

  .language-controls {
    grid-column: 3;
  }

  #modeButton {
    grid-column: 1 / -1;
    width: 100%;
  }

  .canvas-toolbar {
    font-size: 0.88rem;
  }

  .pdf-export-dialog,
  .person-dialog {
    width: min(96vw, 44rem);
  }
}

/* Mobile app shell override: keep desktop intact, make mobile a stable native details menu. */
@media (max-width: 850px) {
  html,
  body {
    width: 100%;
    min-width: 0;
    overflow: hidden !important;
  }

  body > .topbar {
    position: relative;
    z-index: 100;
  }

  body > .app-shell {
    display: block !important;
    width: 100%;
    height: calc(100svh - 8.7rem);
    min-height: 0;
    overflow: hidden !important;
  }

  body > .app-shell > #sidePanel.sidebar {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    z-index: 80 !important;
    width: min(22rem, 88vw) !important;
    max-width: 88vw;
    height: 100svh !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    padding: 0.85rem !important;
    color: var(--ink);
    background:
      linear-gradient(135deg, rgba(247, 230, 190, 0.99), rgba(218, 184, 118, 0.99)),
      var(--paper) !important;
    box-shadow: 20px 0 48px rgba(28, 18, 8, 0.38);
    transform: translate3d(-110%, 0, 0) !important;
    visibility: hidden;
    pointer-events: none;
    transition: transform 180ms ease, visibility 0s linear 180ms;
  }

  body > .app-shell > #sidePanel.sidebar.mobile-mounted {
    position: static !important;
    inset: auto !important;
    z-index: auto !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    overflow: visible !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    transform: none !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transition: none !important;
  }

  body.mobile-sidebar-open > .app-shell > #sidePanel.sidebar,
  body[data-mobile-menu="open"] > .app-shell > #sidePanel.sidebar,
  body > .app-shell > #sidePanel.sidebar:target {
    transform: translate3d(0, 0, 0) !important;
    visibility: visible;
    pointer-events: auto;
    transition: transform 180ms ease;
  }

  body.dark-theme > .app-shell > #sidePanel.sidebar {
    background:
      linear-gradient(135deg, rgba(54, 40, 27, 0.99), rgba(31, 23, 16, 0.99)),
      var(--paper) !important;
  }

  body > .mobile-sidebar-backdrop {
    z-index: 70 !important;
    display: none;
  }

  body > .mobile-sidebar-backdrop {
    display: none !important;
  }

  .mobile-close-menu-button {
    display: block !important;
    position: sticky;
    top: 0;
    z-index: 2;
    text-align: center;
  }

  body > .app-shell > .canvas-wrap {
    width: 100% !important;
    height: 100% !important;
    min-width: 0;
  }

  .empty-tree-state {
    top: 42%;
    width: min(22rem, calc(100vw - 1.5rem));
    padding: 1rem;
  }

  .tree-canvas:not(.has-tree) {
    height: calc(100svh - 13rem);
    min-height: 18rem;
    overflow: hidden !important;
  }

  .empty-tree-actions .button {
    width: 100%;
  }
}

/* Mobile bottom navigation: overrides the old drawer model without changing desktop. */
@media (max-width: 850px) {
  html,
  body {
    overflow: hidden !important;
  }

  body {
    padding-bottom: calc(4.4rem + env(safe-area-inset-bottom));
  }

  body > .topbar {
    z-index: 30;
  }

  .topbar {
    gap: 0.55rem;
  }

  .topbar-actions {
    grid-template-columns: 1fr auto auto;
  }

  .search {
    grid-column: 1 / 2;
  }

  .language-controls {
    grid-column: 2 / 3;
  }

  .mobile-menu-details {
    display: block !important;
    grid-column: 3 / 4;
    grid-row: 1;
    justify-self: end;
    position: relative;
    z-index: 330;
  }

  .mobile-menu-button {
    display: inline-flex !important;
    position: relative;
    z-index: 331;
    width: 2.85rem;
    height: 2.85rem;
    overflow: hidden;
    padding: 0;
    color: var(--ink);
    background: rgba(255, 247, 226, 0.92);
    text-indent: -999px;
    white-space: nowrap;
    pointer-events: auto;
    touch-action: manipulation;
  }

  #modeButton {
    grid-column: 1 / -1;
  }

  .legacy-mobile-menu-button,
  .mobile-sidebar-backdrop {
    display: none !important;
  }

  .mobile-menu-button span {
    left: 50%;
    width: 1.05rem;
    transform: translateX(-50%);
  }

  .mobile-menu-button span:nth-of-type(1) {
    top: calc(50% - 0.42rem);
  }

  .mobile-menu-button span:nth-of-type(2) {
    top: 50%;
  }

  .mobile-menu-button span:nth-of-type(3) {
    top: calc(50% + 0.42rem);
  }

  .mobile-menu-mount {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    top: 5.8rem;
    z-index: 329;
    display: block;
    max-height: min(68svh, 39rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid rgba(94, 61, 25, 0.2);
    border-radius: 12px;
    padding: 0.7rem;
    background:
      linear-gradient(135deg, rgba(255, 248, 229, 0.99), rgba(224, 190, 122, 0.99)),
      var(--paper);
    box-shadow: 0 18px 42px rgba(45, 30, 14, 0.22);
  }

  body.dark-theme .mobile-menu-mount {
    border-color: rgba(239, 199, 110, 0.22);
    background:
      linear-gradient(135deg, rgba(54, 40, 27, 0.99), rgba(31, 23, 16, 0.99)),
      var(--paper);
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 50%;
    bottom: calc(0.55rem + env(safe-area-inset-bottom));
    z-index: 300;
    display: grid;
    grid-template-columns: repeat(5, 2.85rem);
    gap: 0.38rem;
    transform: translateX(-50%);
    padding: 0.45rem;
    border: 1px solid rgba(94, 61, 25, 0.22);
    border-radius: 18px;
    background: rgba(255, 248, 229, 0.96);
    box-shadow: 0 14px 34px rgba(45, 30, 14, 0.28);
  }

  body.view-geo .mobile-bottom-nav {
    grid-template-columns: repeat(6, 2.65rem);
  }

  .mobile-view-title {
    position: fixed;
    left: 50%;
    bottom: calc(4.8rem + env(safe-area-inset-bottom));
    z-index: 299;
    display: block;
    min-width: 8rem;
    max-width: calc(100vw - 2rem);
    transform: translateX(-50%);
    padding: 0.38rem 0.8rem;
    border: 1px solid rgba(94, 61, 25, 0.18);
    border-radius: 999px;
    color: var(--ink);
    background: rgba(255, 248, 229, 0.94);
    box-shadow: 0 10px 28px rgba(45, 30, 14, 0.18);
    font-family: Cinzel, serif;
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
  }

  body.dark-theme .mobile-bottom-nav {
    border-color: rgba(239, 199, 110, 0.24);
    background: rgba(31, 23, 16, 0.96);
  }

  body.dark-theme .mobile-view-title {
    border-color: rgba(239, 199, 110, 0.2);
    background: rgba(31, 23, 16, 0.94);
  }

  .mobile-nav-button {
    display: grid;
    place-items: center;
    width: 2.85rem;
    height: 2.85rem;
    border: 1px solid rgba(94, 61, 25, 0.24);
    border-radius: 12px;
    color: var(--ink);
    background: rgba(255, 247, 226, 0.9);
    font-family: Cinzel, serif;
    font-size: 1.25rem;
    line-height: 1;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
    cursor: pointer;
    touch-action: manipulation;
  }

  body.view-geo .mobile-nav-button {
    width: 2.65rem;
    height: 2.65rem;
  }

  .mobile-geo-info-button {
    display: none;
  }

  body.view-geo .mobile-geo-info-button {
    display: grid;
  }

  .mobile-icon {
    position: relative;
    display: block;
    width: 1.35rem;
    height: 1.35rem;
    color: currentColor;
  }

  .mobile-icon::before,
  .mobile-icon::after {
    content: "";
    position: absolute;
    box-sizing: border-box;
  }

  .icon-card {
    border: 2px solid currentColor;
    border-radius: 4px;
  }

  .icon-card::before {
    left: 0.22rem;
    right: 0.22rem;
    top: 0.32rem;
    height: 2px;
    background: currentColor;
  }

  .icon-card::after {
    left: 0.22rem;
    right: 0.42rem;
    bottom: 0.32rem;
    height: 2px;
    background: currentColor;
    opacity: 0.75;
  }

  .icon-tree::before {
    left: 50%;
    top: 0.16rem;
    width: 2px;
    height: 1.05rem;
    transform: translateX(-50%);
    background: currentColor;
  }

  .icon-tree::after {
    left: 0.15rem;
    right: 0.15rem;
    top: 0.18rem;
    height: 0.75rem;
    border-top: 2px solid currentColor;
    border-left: 2px solid currentColor;
    border-right: 2px solid currentColor;
    border-radius: 10px 10px 0 0;
  }

  .icon-branch::before {
    left: 0.18rem;
    top: 0.58rem;
    width: 1rem;
    height: 2px;
    background: currentColor;
    transform: rotate(-28deg);
    transform-origin: left center;
  }

  .icon-branch::after {
    right: 0.1rem;
    top: 0.2rem;
    width: 0.62rem;
    height: 0.62rem;
    border: 2px solid currentColor;
    border-radius: 50%;
    box-shadow: -0.62rem 0.72rem 0 -0.12rem currentColor;
  }

  .icon-map {
    border: 2px solid currentColor;
    border-radius: 3px;
    transform: skewY(-6deg);
  }

  .icon-map::before {
    left: 33%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: currentColor;
    opacity: 0.65;
  }

  .icon-map::after {
    right: 33%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: currentColor;
    opacity: 0.65;
  }

  .icon-globe {
    border: 2px solid currentColor;
    border-radius: 50%;
  }

  .icon-globe::before {
    left: 50%;
    top: -2px;
    bottom: -2px;
    width: 0.45rem;
    transform: translateX(-50%);
    border-left: 2px solid currentColor;
    border-right: 2px solid currentColor;
    border-radius: 50%;
  }

  .icon-globe::after {
    left: 0.15rem;
    right: 0.15rem;
    top: 50%;
    height: 2px;
    transform: translateY(-50%);
    background: currentColor;
  }

  .icon-pin::before {
    left: 50%;
    top: 0.08rem;
    width: 0.82rem;
    height: 0.82rem;
    transform: translateX(-50%) rotate(45deg);
    border: 2px solid currentColor;
    border-radius: 50% 50% 50% 0;
  }

  .icon-pin::after {
    left: 50%;
    top: 0.36rem;
    width: 0.24rem;
    height: 0.24rem;
    transform: translateX(-50%);
    border-radius: 50%;
    background: currentColor;
  }

  .mobile-nav-button.active {
    color: #251708;
    border-color: rgba(132, 83, 24, 0.45);
    background: linear-gradient(135deg, #e1ae36, #b9871f);
  }

  body.dark-theme .mobile-nav-button {
    color: var(--ink);
    border-color: rgba(239, 199, 110, 0.18);
    background: rgba(68, 51, 33, 0.92);
  }

  body.dark-theme .mobile-nav-button.active {
    color: #21170d;
    background: linear-gradient(135deg, #e7bd55, #b9871f);
  }

  body > .app-shell {
    height: calc(100svh - clamp(7.2rem, 18svh, 9.2rem) - 4.4rem) !important;
    overflow: hidden !important;
  }

  .canvas-toolbar .view-mode-controls {
    display: none;
  }

  body > .app-shell > .canvas-wrap {
    width: 100% !important;
    height: 100% !important;
  }

  .tree-canvas {
    height: calc(100svh - clamp(12.6rem, 29svh, 17rem)) !important;
    min-height: min(18rem, 54svh);
  }

  .tree-canvas.has-tree {
    overscroll-behavior: contain;
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
  }

  .tree-canvas.geo-canvas {
    touch-action: none;
  }

  .tree-canvas:not(.has-tree) {
    display: grid !important;
    place-items: center !important;
    overflow: hidden !important;
    padding: 0.75rem !important;
  }

  .tree-canvas:not(.has-tree) .zoom-layer {
    display: grid !important;
    place-items: center !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    transform: none !important;
    margin: 0 !important;
    transform-origin: center !important;
  }

  .empty-tree-state {
    position: static !important;
    width: min(22rem, calc(100vw - 1.5rem)) !important;
    max-width: calc(100vw - 1.5rem);
    transform: none !important;
    margin: 0 !important;
    padding: 1rem;
    text-align: center;
  }

  .empty-tree-actions {
    justify-content: center;
  }

  body > .app-shell > #sidePanel.sidebar,
  body > .app-shell > #sidePanel.sidebar.mobile-mounted {
    display: none !important;
  }

  body.view-geo .geo-map-title,
  body.view-geo .geo-detail-panel {
    display: none !important;
  }

  body.view-geo.mobile-geo-info-open .geo-map-title {
    display: block !important;
    position: fixed !important;
    left: 0.7rem !important;
    right: 0.7rem !important;
    top: auto !important;
    bottom: calc(18.2rem + env(safe-area-inset-bottom)) !important;
    z-index: 285 !important;
    width: auto !important;
    max-height: 8.2rem !important;
    overflow: auto !important;
    border-radius: 12px !important;
    padding: 0.75rem !important;
    backdrop-filter: none !important;
  }

  body.view-geo.mobile-geo-info-open .geo-detail-panel {
    display: block !important;
    position: fixed !important;
    left: 0.7rem !important;
    right: 0.7rem !important;
    top: auto !important;
    bottom: calc(5.35rem + env(safe-area-inset-bottom)) !important;
    z-index: 286 !important;
    width: auto !important;
    max-height: 12.3rem !important;
    overflow: auto !important;
    border-radius: 12px !important;
    padding: 0.75rem !important;
    backdrop-filter: none !important;
  }

  body.view-geo.mobile-geo-info-open .mobile-geo-info-button {
    color: #251708;
    border-color: rgba(132, 83, 24, 0.45);
    background: linear-gradient(135deg, #e1ae36, #b9871f);
  }

  body.dark-theme.view-geo.mobile-geo-info-open .mobile-geo-info-button {
    color: #21170d;
    background: linear-gradient(135deg, #e7bd55, #b9871f);
  }

  body.view-geo .geo-globe-help {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.65rem;
    width: auto;
    max-width: none;
    transform: none;
    padding: 0.32rem 0.55rem;
    font-size: 0.76rem;
    white-space: normal;
    text-align: center;
  }

  body.view-geo .geo-empty {
    left: 50%;
    top: 1rem;
    z-index: 8;
    width: min(22rem, calc(100vw - 1.5rem));
    transform: translateX(-50%);
    border: 1px solid rgba(82, 51, 18, 0.2);
    border-radius: 999px;
    padding: 0.45rem 0.75rem;
    text-align: center;
    background: rgba(255, 248, 229, 0.88);
  }

  body.view-geo .geo-places-popup-wrap {
    display: none !important;
  }

  .toast {
    left: 0.75rem;
    right: 0.75rem;
    bottom: calc(5.35rem + env(safe-area-inset-bottom));
    max-width: none;
    justify-content: center;
    text-align: center;
  }
}
