:root {
  --bg: #fff1a8;
  --panel: #ffffff;
  --panel-2: #fff7cf;
  --ink: #3b2413;
  --muted: #7b6546;
  --line: #d7aa51;
  --green: #8c3f1f;
  --green-dark: #5e2714;
  --coral: #d95f4c;
  --amber: #d89a26;
  --cyan: #2f8ea8;
  --shadow: 0 14px 32px rgba(86, 50, 15, 0.16);
  --family-bg: url("images/nen-gia-pha-nguyen-huu.png");
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(rgba(255, 244, 181, 0.82), rgba(255, 244, 181, 0.82)),
    var(--family-bg) center top / cover fixed,
    var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 22px;
  background: rgba(255, 246, 201, 0.9);
  border-bottom: 1px solid #b47a29;
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #9f3f1e, #d79b27);
  color: #fff;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn,
.ghost-btn,
.danger-btn,
.text-btn {
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 8px;
  font-weight: 700;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn {
  background: var(--green);
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 123, 99, 0.22);
}

.btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.text-btn:hover {
  transform: translateY(-1px);
}

.ghost-btn {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.danger-btn {
  background: #fff2f0;
  color: #9b2f22;
  border: 1px solid #f0bbb3;
}

.text-btn {
  background: transparent;
  color: var(--green-dark);
}

.workspace {
  position: relative;
  padding: 18px 22px 24px;
  background:
    linear-gradient(rgba(255, 244, 181, 0.42), rgba(255, 244, 181, 0.42)),
    var(--family-bg) center top / min(100%, 1120px) auto no-repeat;
}

.floating-tools {
  position: fixed;
  right: 18px;
  top: 86px;
  z-index: 30;
}

.menu-toggle {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 233, 0.96);
  color: var(--green-dark);
  box-shadow: var(--shadow);
}

.menu-panel {
  position: absolute;
  right: 0;
  top: 54px;
  width: min(340px, calc(100vw - 28px));
  display: none;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 235, 0.98);
  box-shadow: 0 18px 42px rgba(86, 50, 15, 0.22);
}

.floating-tools.open .menu-panel {
  display: block;
}

.menu-section {
  padding: 10px 0;
  border-bottom: 1px solid rgba(215, 170, 81, 0.55);
}

.menu-section:first-child {
  padding-top: 0;
}

.menu-section:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.menu-section h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.compact-search {
  min-width: 0;
  width: 100%;
  box-shadow: none;
}

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

.stats-menu h3,
.menu-help {
  grid-column: 1 / -1;
}

.stats-menu div:not(:first-child) {
  padding: 8px;
  border: 1px solid rgba(215, 170, 81, 0.55);
  border-radius: 8px;
  background: #fff7cf;
}

.stats-menu strong {
  display: block;
  font-size: 18px;
}

.stats-menu span,
.menu-help {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.searchbar {
  flex: 1 1 260px;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: rgba(255, 252, 233, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(24, 35, 31, 0.06);
}

.search-icon {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.searchbar input {
  width: 100%;
  min-width: 120px;
  border: 0;
  outline: 0;
  background: transparent;
}

.toolbar-actions {
  display: flex;
  flex: 0 0 auto;
  align-self: center;
  gap: 8px;
  align-items: center;
}

.segmented,
.zoom-controls {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: rgba(255, 252, 233, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button,
.zoom-controls button {
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.active,
.zoom-controls button.active {
  background: var(--green);
  color: #fff;
}

.icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat {
  padding: 14px;
  background: rgba(255, 252, 233, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat strong {
  display: block;
  font-size: 22px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.tree-viewport {
  position: relative;
  height: calc(100vh - 124px);
  min-height: 620px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 246, 188, 0.72), rgba(255, 246, 188, 0.72)),
    var(--family-bg) center center / cover no-repeat,
    #fff2a6;
  border: 3px double #9b6425;
  border-radius: 8px;
  cursor: grab;
  touch-action: none;
  box-shadow: var(--shadow), inset 0 0 0 10px rgba(255, 232, 130, 0.28);
}

.tree-viewport.dragging {
  cursor: grabbing;
}

.tree-canvas {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

.tree-lines {
  position: absolute;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.pan-pad {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 8;
  display: none;
  grid-template-columns: repeat(3, 40px);
  grid-template-rows: repeat(3, 40px);
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(155, 100, 37, 0.55);
  border-radius: 8px;
  background: rgba(255, 252, 235, 0.86);
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 24px rgba(86, 50, 15, 0.18);
}

.pan-pad button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #fff8dc;
  color: var(--green-dark);
  border: 1px solid var(--line);
}

.pan-pad [data-pan="up"] {
  grid-column: 2;
}

.pan-pad [data-pan="left"] {
  grid-column: 1;
  grid-row: 2;
}

.pan-pad [data-pan="right"] {
  grid-column: 3;
  grid-row: 2;
}

.pan-pad [data-pan="down"] {
  grid-column: 2;
  grid-row: 3;
}

.mobile-help {
  display: none;
  margin: -4px 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 235, 0.9);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.edge {
  fill: none;
  stroke: #6d8179;
  stroke-width: 2;
}

.spouse-line {
  stroke: var(--coral);
  stroke-width: 3;
  stroke-linecap: round;
}

.person-card {
  position: absolute;
  width: 218px;
  height: 128px;
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 11px;
  align-items: center;
  padding: 10px;
  background: rgba(255, 252, 235, 0.96);
  border: 1px solid #c59542;
  border-left: 5px solid var(--green);
  border-radius: 8px;
  box-shadow: 0 9px 18px rgba(86, 50, 15, 0.14);
  text-align: left;
}

.person-card.female {
  border-left-color: var(--coral);
}

.person-card.other {
  border-left-color: var(--cyan);
}

.person-card.highlight {
  outline: 3px solid rgba(230, 169, 59, 0.55);
}

.person-photo,
.avatar-fallback {
  width: 58px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel-2);
}

.photo-button {
  width: fit-content;
  height: fit-content;
  display: block;
  padding: 0;
  border-radius: 8px;
  background: transparent;
}

.photo-button:hover {
  outline: 3px solid rgba(216, 154, 38, 0.5);
}

.photo-button img {
  display: block;
}

.avatar-fallback {
  display: grid;
  place-items: center;
  color: var(--green-dark);
  font-size: 22px;
  font-weight: 900;
}

.person-main {
  min-width: 0;
}

.person-name {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
  overflow: hidden;
  color: var(--ink);
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gender-symbol {
  display: inline-grid;
  place-items: center;
}

.gender-symbol .icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.gender-symbol.female {
  color: var(--coral);
}

.gender-symbol.male {
  color: var(--green);
}

.gender-symbol.other {
  color: var(--cyan);
}

.person-meta {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  color: #17724f;
  font-size: 12px;
  font-weight: 800;
}

.status-line.deceased,
.mini-badge.deceased,
.chip.deceased {
  color: #8b3529;
}

.status-line.alive,
.mini-badge.alive,
.chip.alive {
  color: #17724f;
}

.status-line .icon {
  width: 14px;
  height: 14px;
}

.achievement-pill {
  display: inline-block;
  max-width: 100%;
  margin-top: 5px;
  padding: 3px 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #fff5d8;
  color: #7b5510;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-panel,
.admin-panel,
.login-panel {
  background: rgba(255, 252, 235, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.viewer-login-screen {
  min-height: calc(100vh - 78px);
}

.viewer-login-panel {
  width: min(440px, calc(100vw - 28px));
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 224px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1320px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff4bf;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr:hover td {
  background: #fff8d8;
}

.table-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mini-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 245, 216, 0.9);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.mini-badge .icon {
  width: 14px;
  height: 14px;
}

.detail-drawer {
  position: fixed;
  right: 18px;
  top: 82px;
  bottom: 18px;
  z-index: 50;
  width: min(420px, calc(100vw - 36px));
  display: flex;
  flex-direction: column;
  background: rgba(255, 252, 235, 0.98);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(24, 35, 31, 0.22);
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  margin: 0;
  font-size: 22px;
}

.drawer-body {
  overflow: auto;
  padding: 16px;
}

.profile-hero {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}

.profile-hero img,
.profile-hero .avatar-fallback {
  width: 92px;
  height: 112px;
}

.profile-hero .photo-button .person-photo {
  width: 92px;
  height: 112px;
}

.info-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 9px 12px;
}

.info-grid dt {
  color: var(--muted);
  font-weight: 700;
}

.info-grid dd {
  margin: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 8px 0 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.icon-chip .icon {
  width: 14px;
  height: 14px;
}

.gallery-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.gallery-section h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
}

.gallery-photo {
  aspect-ratio: 1;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8dc;
}

.gallery-photo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.gallery-photo:hover {
  outline: 3px solid rgba(216, 154, 38, 0.5);
}

.empty-state {
  padding: 36px;
  text-align: center;
  color: var(--muted);
}

.admin-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 14px;
}

.admin-panel {
  min-height: calc(100vh - 128px);
  overflow: hidden;
}

.admin-sidebar {
  display: flex;
  flex-direction: column;
}

.panel-head {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.person-list {
  overflow: auto;
  padding: 8px;
}

.admin-person-row {
  width: 100%;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
  padding: 8px;
  background: transparent;
  border-radius: 8px;
  text-align: left;
}

.admin-person-row.active,
.admin-person-row:hover {
  background: var(--panel-2);
}

.mini-avatar {
  width: 40px;
  height: 46px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--panel-2);
}

.form-wrap {
  overflow: auto;
  max-height: calc(100vh - 128px);
  padding: 16px;
}

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

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

.role-hidden {
  display: none !important;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: #fffdf2;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.readonly-box {
  min-height: 48px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8dc;
  color: var(--ink);
  line-height: 1.55;
}

.field select[multiple] {
  min-height: 132px;
}

.form-actions,
.import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.login-screen {
  min-height: calc(100vh - 72px);
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 22px;
}

.login-panel h2 {
  margin: 0 0 8px;
}

.notice {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 80;
  max-width: min(480px, calc(100vw - 30px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
}

.photo-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(33, 22, 11, 0.72);
}

.photo-viewer-panel {
  position: relative;
  z-index: 1;
  width: min(920px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff8dc;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.photo-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.photo-viewer-panel img {
  max-width: 100%;
  max-height: calc(92vh - 62px);
  object-fit: contain;
  background: #1f160c;
}

@media (max-width: 920px) {
  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .floating-tools {
    top: 76px;
    right: 10px;
  }

  .toolbar-actions {
    align-self: flex-start;
    flex-wrap: wrap;
  }

  .nav-actions {
    justify-content: flex-start;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-help {
    display: block;
  }

  .pan-pad {
    display: grid;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-panel {
    min-height: auto;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 10px;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stat {
    padding: 10px;
  }

  .stat strong {
    font-size: 18px;
  }

  .stat span {
    font-size: 11px;
  }

  .tree-viewport {
    height: calc(100dvh - 118px);
    min-height: 500px;
  }

  .floating-tools {
    top: 66px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .topbar {
    padding: 10px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }
}

/* Visual refresh */
:root {
  --bg: #f8e6a3;
  --panel: #fffaf0;
  --panel-2: #fff1bf;
  --ink: #2b1a10;
  --muted: #765d3e;
  --line: #c69239;
  --green: #0f6f55;
  --green-dark: #5a1f12;
  --coral: #c64035;
  --amber: #c88724;
  --cyan: #287f95;
  --shadow: 0 18px 38px rgba(80, 44, 13, 0.18);
}

body {
  background:
    linear-gradient(180deg, rgba(255, 248, 211, 0.76), rgba(249, 224, 139, 0.74)),
    var(--family-bg) center top / cover fixed,
    #f3d676;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(127, 55, 19, 0.08), transparent 16%, transparent 84%, rgba(127, 55, 19, 0.08)),
    repeating-linear-gradient(0deg, rgba(92, 52, 18, 0.035) 0 1px, transparent 1px 7px);
}

.topbar {
  padding: 12px 22px;
  background: rgba(255, 248, 221, 0.92);
  border-bottom: 2px solid rgba(135, 63, 27, 0.42);
  box-shadow: 0 10px 32px rgba(75, 38, 12, 0.12);
}

.brand-mark {
  border: 1px solid rgba(255, 229, 153, 0.82);
  background:
    linear-gradient(145deg, #7b2416, #b64a20 54%, #d79b27);
  box-shadow:
    inset 0 0 0 2px rgba(255, 238, 183, 0.25),
    0 8px 18px rgba(90, 31, 18, 0.18);
  letter-spacing: 0;
}

.brand h1 {
  color: #321509;
  font-size: 21px;
  font-weight: 900;
}

.brand p {
  color: #7a4820;
  font-weight: 700;
}

.workspace {
  min-height: calc(100vh - 72px);
  padding: 16px 18px 18px;
  background:
    linear-gradient(rgba(255, 239, 166, 0.48), rgba(255, 239, 166, 0.48)),
    var(--family-bg) center 12px / min(100%, 1180px) auto no-repeat;
}

.btn,
.ghost-btn,
.danger-btn,
.text-btn {
  border-radius: 7px;
}

.btn {
  background: linear-gradient(180deg, #9b351b, #762212);
  box-shadow: 0 10px 24px rgba(118, 34, 18, 0.24);
}

.ghost-btn {
  background: rgba(255, 250, 235, 0.92);
  color: #5a1f12;
}

.floating-tools {
  top: 88px;
  right: 18px;
}

.menu-toggle {
  border-color: rgba(122, 58, 22, 0.48);
  background: linear-gradient(180deg, #fff9de, #ffe9a4);
  color: #6b2415;
}

.menu-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(80, 44, 13, 0.24);
}

.menu-panel {
  width: min(360px, calc(100vw - 28px));
  max-height: calc(100vh - 152px);
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(143, 83, 29, 0.55);
  background:
    linear-gradient(180deg, rgba(255, 252, 238, 0.98), rgba(255, 244, 204, 0.98));
  box-shadow: 0 22px 58px rgba(72, 37, 13, 0.26);
}

.menu-section h3 {
  color: #7a3f1d;
  font-size: 11px;
  font-weight: 900;
}

.searchbar,
.field input,
.field select,
.field textarea,
.readonly-box {
  border-color: rgba(151, 91, 34, 0.48);
  background: rgba(255, 253, 243, 0.95);
}

.segmented,
.zoom-controls {
  background: rgba(255, 247, 220, 0.95);
  border-color: rgba(151, 91, 34, 0.45);
}

.segmented button.active,
.zoom-controls button.active {
  background: linear-gradient(180deg, #8a321b, #642012);
}

.stats-menu div:not(:first-child) {
  border-color: rgba(151, 91, 34, 0.4);
  background: linear-gradient(180deg, #fff8d8, #ffefb9);
}

.stats-menu strong {
  color: #6d2413;
  font-weight: 900;
}

.tree-viewport {
  height: calc(100vh - 116px);
  min-height: 640px;
  border: 2px solid rgba(117, 63, 22, 0.72);
  background:
    linear-gradient(rgba(255, 246, 195, 0.68), rgba(255, 241, 169, 0.7)),
    var(--family-bg) center center / cover no-repeat,
    #ffefa0;
  box-shadow:
    0 20px 44px rgba(80, 44, 13, 0.18),
    inset 0 0 0 8px rgba(255, 232, 130, 0.26),
    inset 0 0 0 1px rgba(255, 255, 255, 0.44);
}

.edge {
  stroke: #4f746c;
  stroke-width: 2.2;
}

.spouse-line {
  stroke: #bf4a34;
  stroke-width: 3.2;
}

.person-card {
  background:
    linear-gradient(180deg, rgba(255, 253, 239, 0.98), rgba(255, 244, 205, 0.98));
  border-color: rgba(143, 83, 29, 0.56);
  border-left-width: 6px;
  box-shadow:
    0 12px 22px rgba(74, 42, 13, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.person-card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 18px 30px rgba(74, 42, 13, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.person-card.male {
  border-left-color: #12684f;
}

.person-card.female {
  border-left-color: #c64035;
}

.person-card.other {
  border-left-color: #287f95;
}

.person-photo,
.avatar-fallback {
  border: 1px solid rgba(156, 96, 34, 0.26);
  background: linear-gradient(145deg, #fff6d5, #ffe7a4);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.avatar-fallback {
  color: #6d2413;
}

.person-name {
  color: #2b1208;
  font-size: 13px;
  font-weight: 900;
}

.person-meta {
  color: #795637;
}

.status-line {
  color: #0f6f55;
}

.status-line.deceased,
.mini-badge.deceased,
.chip.deceased {
  color: #9a2f22;
}

.achievement-pill,
.chip,
.mini-badge {
  background: linear-gradient(180deg, #fff7d9, #ffedb1);
}

.detail-drawer,
.list-panel,
.admin-panel,
.login-panel {
  background:
    linear-gradient(180deg, rgba(255, 253, 243, 0.98), rgba(255, 246, 215, 0.98));
  border-color: rgba(143, 83, 29, 0.5);
  box-shadow: 0 24px 58px rgba(70, 38, 13, 0.24);
}

.detail-drawer {
  width: min(460px, calc(100vw - 32px));
}

.drawer-head {
  background: linear-gradient(180deg, rgba(255, 244, 204, 0.86), rgba(255, 250, 232, 0.72));
}

.drawer-head h2 {
  color: #321509;
  font-size: 24px;
  font-weight: 900;
}

.info-grid {
  grid-template-columns: 132px 1fr;
  gap: 11px 14px;
}

.info-grid dt {
  color: #80603e;
}

.info-grid dd {
  color: #3a1b0d;
  font-weight: 600;
}

.gallery-photo {
  border-color: rgba(151, 91, 34, 0.45);
  box-shadow: 0 8px 16px rgba(80, 44, 13, 0.14);
}

.admin-person-row.active,
.admin-person-row:hover,
tr:hover td {
  background: rgba(255, 238, 177, 0.72);
}

.login-screen {
  background:
    linear-gradient(rgba(255, 239, 172, 0.38), rgba(255, 239, 172, 0.38)),
    var(--family-bg) center center / min(100%, 1180px) auto no-repeat;
}

.login-panel {
  border-width: 2px;
}

.login-panel h2 {
  color: #4d1a0d;
  font-size: 26px;
  font-weight: 900;
}

.toast {
  background: #35180c;
}

@media (max-width: 920px) {
  .floating-tools {
    top: 74px;
  }

  .detail-drawer {
    top: 74px;
    right: 10px;
    bottom: 10px;
    width: min(460px, calc(100vw - 20px));
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 8px;
  }

  .tree-viewport {
    height: calc(100dvh - 96px);
    min-height: 520px;
  }

  .menu-panel {
    max-height: calc(100dvh - 118px);
  }

  .brand p {
    display: none;
  }
}
