/* Self-hosted fonts keep Vietnamese glyphs consistent under the site's strict CSP. */
@font-face {
  font-family: "Be Vietnam Pro";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Be Vietnam Pro";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-400-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

@font-face {
  font-family: "Be Vietnam Pro";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-500-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Be Vietnam Pro";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-500-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

@font-face {
  font-family: "Be Vietnam Pro";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-600-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Be Vietnam Pro";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-600-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

@font-face {
  font-family: "Be Vietnam Pro";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Be Vietnam Pro";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-700-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

@font-face {
  font-family: "Be Vietnam Pro";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-800-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Be Vietnam Pro";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("fonts/be-vietnam-pro-800-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

@font-face {
  font-family: "Noto Serif";
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("fonts/noto-serif-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Noto Serif";
  font-style: normal;
  font-weight: 600 700;
  font-display: swap;
  src: url("fonts/noto-serif-vietnamese.woff2") format("woff2");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

@font-face {
  font-family: "Playwrite VN";
  font-style: normal;
  font-weight: 100 400;
  font-display: swap;
  src: url("fonts/playwrite-vn.woff2") format("woff2");
}

@font-face {
  font-family: "Dancing Script";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/dancing-script-700.ttf") format("truetype");
}

@font-face {
  font-family: "Lora";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/lora-600-vietnamese.ttf") format("truetype");
}

@font-face {
  font-family: "Lora";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/lora-700-vietnamese.ttf") format("truetype");
}

: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");
  --family-tree-paper: url("images/nen-giay-sac-phong-v33.webp");
  --font-ceremony: "Dancing Script", "Playwrite VN", "Noto Serif", Georgia, serif;
}

.personal-call-chip {
  border: 1px solid rgba(147, 55, 28, 0.25);
  background: #ffe6aa;
  color: #7b2516;
}

.grave-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid #dfbd72;
}

.grave-section h3,
.form-subhead h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: #702617;
}

.grave-section h3 .icon { width: 20px; height: 20px; }

.grave-photo {
  width: 150px;
  height: 112px;
  margin-bottom: 14px;
}

.grave-photo img { width: 100%; height: 100%; object-fit: cover; }

.text-link { color: #8f2c19; font-weight: 700; }

.form-subhead {
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid #dfbd72;
}

.form-subhead p { margin: -6px 0 0; color: #756044; }

.permission-note {
  margin: 12px 0 0;
  padding: 12px;
  border-left: 3px solid #c17822;
  background: #fff3cf;
  color: #66492d;
  line-height: 1.45;
}

.change-requests-box { padding: 18px; border-top: 1px solid #dfbd72; }

.change-requests-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.change-requests-head h3 { margin: 0; }

.change-requests-head span {
  color: #7b5939;
  font-size: 14px;
  font-weight: 700;
}

.change-request-list { display: grid; gap: 9px; }

.change-request {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid #ddbf82;
  border-left: 4px solid #be7b21;
  border-radius: 6px;
  background: #fffaf0;
}

.change-request.approved { border-left-color: #168261; }
.change-request.rejected { border-left-color: #b63b2d; }
.change-request > div:first-child { display: grid; gap: 3px; }

.change-request span,
.change-request p {
  margin: 0;
  color: #725c41;
  font-size: 13px;
  line-height: 1.4;
}

.change-preview {
  display: grid;
  grid-template-columns: minmax(86px, auto) minmax(0, 1fr);
  gap: 4px 10px;
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
}

.change-preview dt { color: #806849; font-weight: 700; }
.change-preview dd { min-width: 0; margin: 0; overflow-wrap: anywhere; color: #412719; }

.request-actions { display: flex; gap: 8px; }
.request-actions button { min-height: 38px; padding: 8px 14px; }

.viewer-account-form,
.viewer-account-row { grid-template-columns: minmax(130px, 1fr); }

.viewer-account-form select[name="personId"],
.viewer-account-row select[name="personId"] { min-width: 0; }

@media (max-width: 720px) {
  .grave-photo { width: 120px; height: 90px; }
}

* {
  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;
}

.admin-suggestions {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.admin-suggestion {
  display: grid;
  gap: 2px;
  padding: 7px 9px;
  border: 1px solid rgba(198, 146, 57, 0.38);
  border-radius: 8px;
  background: rgba(255, 253, 242, 0.9);
  color: var(--ink);
  text-align: left;
}

.admin-suggestion:hover {
  border-color: var(--accent);
  background: var(--panel-2);
}

.admin-suggestion strong {
  font-size: 13px;
}

.admin-suggestion span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.admin-search-empty,
.empty-admin-search {
  margin: 8px 0 0;
  font-size: 12px;
}

.viewer-suggestions {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.viewer-suggestion {
  display: grid;
  gap: 2px;
  padding: 8px 9px;
  border: 1px solid rgba(198, 146, 57, 0.38);
  border-radius: 8px;
  background: rgba(255, 253, 242, 0.92);
  color: var(--ink);
  text-align: left;
}

.viewer-suggestion:hover {
  border-color: var(--accent);
  background: var(--panel-2);
}

.viewer-suggestion strong {
  font-size: 13px;
}

.viewer-suggestion span,
.search-empty {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
  gap: 8px;
}

.tool-action {
  width: 100%;
  min-height: 48px;
}

.tool-action span {
  display: none;
}

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

.mobile-account-section {
  display: none;
}

.kinship-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 35;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid rgba(255, 225, 153, 0.9);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 248, 205, 0.95), transparent 32%),
    linear-gradient(145deg, #bd4b1f, #7d2416);
  color: #fff8dd;
  box-shadow: 0 16px 34px rgba(75, 33, 14, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.kinship-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 42px rgba(75, 33, 14, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.kinship-fab .icon {
  width: 30px;
  height: 30px;
  stroke-width: 2.3;
}

.kinship-fab span {
  position: absolute;
  right: 74px;
  bottom: 13px;
  width: max-content;
  max-width: 210px;
  padding: 9px 11px;
  border: 1px solid rgba(198, 146, 57, 0.55);
  border-radius: 8px;
  background: rgba(255, 252, 235, 0.98);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(53, 30, 13, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateX(6px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.kinship-fab:hover span,
.kinship-fab:focus-visible span {
  opacity: 1;
  transform: translateX(0);
}

.kinship-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
}

.kinship-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(43, 25, 12, 0.34);
}

.kinship-panel {
  position: relative;
  width: min(680px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 235, 0.98);
  box-shadow: 0 28px 80px rgba(53, 30, 13, 0.34);
}

.kinship-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(215, 170, 81, 0.55);
}

.kinship-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
  color: var(--ink);
}

.kinship-head p,
.kinship-answer span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.kinship-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.kinship-result {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(198, 146, 57, 0.38);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff9df, #fff0bd);
}

.kinship-answer {
  display: grid;
  gap: 8px;
}

.kinship-answer p {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.kinship-answer b {
  color: #8a321b;
}

.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;
}

.branch-segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 233, 0.94);
}

.branch-segmented button {
  min-width: 0;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 9px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.branch-scope-note {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.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;
  will-change: transform;
  backface-visibility: hidden;
}

.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,
.edge-halo {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.edge-halo {
  stroke: rgba(255, 248, 211, 0.92);
  stroke-width: 7;
}

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

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

.person-card {
  position: absolute;
  width: var(--card-w, 218px);
  height: var(--card-h, 128px);
  display: grid;
  grid-template-columns: var(--photo-w, 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-card.is-viewer {
  outline: 3px solid rgba(186, 113, 19, 0.72);
  box-shadow: 0 14px 26px rgba(101, 54, 12, 0.25);
}

.viewer-card-label {
  position: absolute;
  top: -11px;
  right: 8px;
  z-index: 2;
  padding: 2px 7px;
  border: 1px solid #a66318;
  border-radius: 999px;
  background: #fff1ad;
  color: #66200f;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.4;
}

.person-photo,
.avatar-fallback {
  width: var(--photo-w, 58px);
  height: var(--photo-h, 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;
}

.deferred-photo-shell {
  position: relative;
  width: var(--photo-w, 58px);
  height: var(--photo-h, 72px);
  overflow: hidden;
}

.deferred-photo-shell .deferred-photo-fallback,
.deferred-photo-shell .deferred-tree-photo {
  position: absolute;
  inset: 0;
}

.deferred-tree-photo {
  opacity: 0;
  transition: opacity 120ms ease;
}

.deferred-tree-photo.is-loaded {
  opacity: 1;
}

.deferred-photo-fallback.is-hidden {
  visibility: hidden;
}

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

@media (prefers-reduced-motion: reduce) {
  .deferred-tree-photo {
    transition: none;
  }
}

.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);
}

.directory-head,
.directory-search,
.mobile-directory {
  display: none;
}

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

button:disabled {
  cursor: wait;
  opacity: 0.66;
  transform: none !important;
}

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);
}

.gallery-link-card {
  min-height: 86px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8dc;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

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

.gallery-link-card .icon {
  width: 24px;
  height: 24px;
}

.field > p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.avatar-upload-field input[type="file"] {
  min-height: 48px;
  padding: 8px;
}

.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 {
  flex: 0 0 auto;
  height: 330px;
  min-height: 280px;
  overflow: auto;
  padding: 8px;
  scrollbar-gutter: stable;
  border-bottom: 1px solid var(--line);
}

.searchable-person-select {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.select-search {
  position: relative;
  display: block;
  min-width: 0;
}

.select-search .icon {
  position: absolute;
  top: 50%;
  left: 10px;
  z-index: 1;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
  transform: translateY(-50%);
}

.select-search .person-select-filter {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px 7px 34px;
  border: 1px solid rgba(151, 91, 34, 0.42);
  border-radius: 8px;
  outline: 0;
  background: rgba(255, 253, 243, 0.95);
  color: var(--ink);
}

.select-search .person-select-filter:focus {
  border-color: #9c4a23;
  box-shadow: 0 0 0 3px rgba(156, 74, 35, 0.12);
}

.searchable-person-select > select {
  width: 100%;
  min-width: 0;
}

.viewer-account-box {
  flex: 0 0 auto;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: rgba(255, 248, 220, 0.74);
}

.viewer-account-box h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
  text-transform: uppercase;
}

.storage-box {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(198, 146, 57, 0.5);
  border-radius: 8px;
  background: rgba(255, 253, 242, 0.82);
}

.storage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
  font-size: 13px;
}

.storage-head span {
  color: var(--muted);
  font-weight: 800;
}

.storage-bar {
  height: 8px;
  margin: 8px 0;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(198, 146, 57, 0.22);
}

.storage-bar span {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: linear-gradient(90deg, #0f766e, #b7791f);
}

.storage-lines {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.storage-lines strong {
  color: var(--ink);
}

.storage-note {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.viewer-account-form {
  display: grid;
  gap: 8px;
}

.viewer-account-form input,
.viewer-account-form select {
  width: 100%;
  min-height: 36px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf2;
}

.viewer-account-form .btn {
  width: 100%;
}

.viewer-account-list {
  max-height: 170px;
  margin-top: 10px;
  overflow: auto;
}

.viewer-account-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 9px 0;
  border-top: 1px solid rgba(198, 146, 57, 0.38);
}

.viewer-account-row input,
.viewer-account-row select {
  width: 100%;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf2;
  font-size: 13px;
}

.account-main {
  display: grid;
  gap: 2px;
}

.account-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.account-lock {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.viewer-account-row small {
  color: var(--muted);
}

.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;
  }

  .person-list {
    height: 320px;
    min-height: 320px;
  }

  .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;
  }
}

/* Thư viện bài cúng cổ truyền */
.ritual-switch-fab {
  position: fixed;
  right: 22px;
  bottom: 168px;
  z-index: 35;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 225, 153, 0.9);
  border-radius: 50%;
  background: linear-gradient(145deg, #8d3422, #4e1b19);
  color: #fff8dd;
  box-shadow: 0 15px 32px rgba(62, 25, 21, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.ritual-switch-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 19px 38px rgba(62, 25, 21, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.ritual-switch-fab .icon {
  width: 27px;
  height: 27px;
  stroke-width: 2.1;
}

.ritual-switch-fab span {
  position: absolute;
  right: 68px;
  bottom: 10px;
  width: max-content;
  max-width: 220px;
  padding: 9px 11px;
  border: 1px solid rgba(198, 146, 57, 0.55);
  border-radius: 8px;
  background: rgba(255, 252, 235, 0.98);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(53, 30, 13, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateX(6px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.ritual-switch-fab:hover span,
.ritual-switch-fab:focus-visible span {
  opacity: 1;
  transform: translateX(0);
}

.ritual-library {
  min-height: calc(100vh - 112px);
  margin: -16px -18px -18px;
  padding: 38px clamp(18px, 5vw, 78px) 100px;
  background:
    linear-gradient(rgba(255, 249, 220, 0.9), rgba(244, 231, 177, 0.94)),
    var(--family-bg) center top / cover fixed,
    #f4e7b1;
  color: #2c2016;
}

.ritual-hero {
  position: relative;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  width: min(1120px, 100%);
  margin: 0 auto 28px;
  padding: 0 0 26px;
  border-bottom: 1px solid rgba(132, 53, 34, 0.45);
}

.ritual-hero::after {
  position: absolute;
  right: 0;
  bottom: -4px;
  left: 0;
  height: 1px;
  background: rgba(33, 91, 69, 0.35);
  content: "";
}

.ritual-seal {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border: 2px solid #a14a2c;
  outline: 1px solid rgba(182, 139, 56, 0.75);
  outline-offset: 5px;
  border-radius: 50%;
  background: #fff3c6;
  color: #772719;
  box-shadow:
    inset 0 0 0 5px rgba(166, 78, 38, 0.08),
    0 10px 28px rgba(104, 48, 24, 0.14);
}

.ritual-seal .icon {
  width: 37px;
  height: 37px;
}

.ritual-hero p,
.ritual-hero h2,
.ritual-hero span {
  margin: 0;
}

.ritual-hero p {
  color: #7c4f2b;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.ritual-hero h2 {
  margin: 0 0 5px;
  color: #4b1d14;
  font-family: var(--font-ceremony);
  font-size: 58px;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: 0;
  text-shadow:
    0 2px 0 rgba(255, 246, 211, 0.92),
    0 7px 18px rgba(91, 37, 19, 0.1);
}

.ritual-hero h2::after {
  display: block;
  width: 148px;
  margin-top: 8px;
  border-top: 2px solid rgba(147, 49, 31, 0.48);
  border-bottom: 1px solid rgba(31, 105, 79, 0.42);
  content: "";
}

.ritual-hero span {
  display: block;
  margin-top: 6px;
  color: #5c5143;
  font-size: 15px;
  line-height: 1.6;
}

.ritual-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 310px);
  gap: 14px;
  width: min(1120px, 100%);
  margin: 0 auto 18px;
}

.ritual-category-filter {
  display: grid;
  gap: 5px;
}

.ritual-category-filter span {
  color: #70422d;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.ritual-category-filter select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid rgba(151, 91, 34, 0.48);
  border-radius: 8px;
  background: rgba(255, 253, 241, 0.96);
  color: var(--ink);
  font-weight: 700;
}

.ritual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  width: min(1120px, 100%);
  margin: 0 auto;
}

.ritual-card {
  position: relative;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 28px;
  gap: 14px;
  align-items: start;
  min-height: 176px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid rgba(146, 82, 41, 0.52);
  border-left: 4px solid #8f3322;
  border-radius: 8px;
  background: rgba(255, 252, 234, 0.97);
  box-shadow: 0 14px 30px rgba(73, 47, 24, 0.14);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.ritual-card.has-cover {
  grid-template-columns: 82px minmax(0, 1fr) 28px;
}

.ritual-card-lead {
  position: relative;
  width: 42px;
}

.ritual-card-lead > img {
  display: block;
  width: 82px;
  height: 112px;
  border: 1px solid rgba(139, 73, 37, 0.38);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 7px 16px rgba(76, 42, 18, 0.16);
  object-fit: cover;
  object-position: top;
}

.ritual-card.has-cover .ritual-number {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 30px;
  height: 30px;
  border-color: #9f4727;
  background: #fff0ba;
  font-size: 11px;
  box-shadow: 0 4px 10px rgba(76, 42, 18, 0.18);
}

.ritual-card::after {
  position: absolute;
  right: -24px;
  bottom: -30px;
  width: 94px;
  height: 94px;
  border: 1px solid rgba(32, 102, 78, 0.14);
  transform: rotate(45deg);
  content: "";
}

.ritual-card:hover,
.ritual-card:focus-visible {
  border-color: #8f3322;
  box-shadow: 0 18px 38px rgba(73, 47, 24, 0.22);
  transform: translateY(-2px);
}

.ritual-number {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(166, 107, 31, 0.55);
  border-radius: 50%;
  background: #fff0ba;
  color: #7b2d1c;
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 900;
}

.ritual-card-body h3 {
  margin: 5px 0 7px;
  color: #36170f;
  font-family: var(--font-title);
  font-size: 21px;
  line-height: 1.25;
}

.ritual-card-body > p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #645340;
  font-size: 13px;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ritual-card-body .ritual-occasion {
  margin-bottom: 5px;
  color: #7e3c26;
  font-weight: 800;
}

.ritual-category {
  color: #1d6a53;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.ritual-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 14px;
  color: #7a664e;
  font-size: 11px;
  font-weight: 700;
}

.ritual-meta span {
  display: inline-flex;
  gap: 5px;
  align-items: center;
}

.ritual-meta .icon,
.ritual-open .icon {
  width: 15px;
  height: 15px;
}

.ritual-open {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #84331f;
}

.ritual-empty {
  grid-column: 1 / -1;
  padding: 64px 20px;
  border: 1px dashed rgba(146, 82, 41, 0.5);
  border-radius: 8px;
  background: rgba(255, 252, 234, 0.78);
  text-align: center;
}

.ritual-empty > .icon {
  width: 44px;
  height: 44px;
  color: #8f3322;
}

.ritual-empty h3 {
  margin: 12px 0 6px;
  font-family: var(--font-title);
  font-size: 22px;
}

.ritual-empty p {
  margin: 0;
  color: var(--muted);
}

.ritual-detail-page {
  position: relative;
  width: min(920px, calc(100% - 24px));
  min-height: calc(100vh - 124px);
  margin: 4px auto 60px;
  padding: 26px clamp(22px, 6vw, 74px) 42px;
  border: 1px solid rgba(151, 91, 34, 0.55);
  background:
    linear-gradient(rgba(255, 253, 239, 0.96), rgba(255, 249, 221, 0.96)),
    var(--family-bg) center top / cover;
  box-shadow: 0 20px 54px rgba(70, 38, 13, 0.22);
}

.ritual-detail-page::before,
.ritual-detail-page::after {
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(147, 49, 31, 0.24);
  pointer-events: none;
  content: "";
}

.ritual-detail-page::after {
  inset: 16px;
  border-color: rgba(31, 105, 79, 0.18);
}

.ritual-detail-actions {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 30px;
}

.ritual-detail-actions > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.ritual-detail-actions .btn,
.ritual-detail-actions .ghost-btn,
.ritual-word-note .btn,
.admin-section-tabs button,
.ritual-form-actions .ghost-btn {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
}

.ritual-detail-actions .icon,
.ritual-word-note .btn .icon,
.admin-section-tabs .icon,
.ritual-form-actions .icon {
  width: 17px;
  height: 17px;
}

.ritual-paper-head {
  position: relative;
  z-index: 1;
  padding: 10px 0 26px;
  border-bottom: 1px solid rgba(139, 73, 37, 0.38);
  text-align: center;
}

.ritual-paper-head > span {
  color: #1d6a53;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.ritual-paper-head h1 {
  margin: 9px auto;
  color: #431a12;
  font-family: var(--font-ceremony);
  font-size: 52px;
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: 0;
}

.ritual-paper-head h1::after {
  display: block;
  width: 84px;
  margin: 13px auto 0;
  border-top: 2px solid rgba(143, 51, 34, 0.5);
  border-bottom: 1px solid rgba(31, 105, 79, 0.38);
  content: "";
}

.ritual-paper-head p {
  margin: 0 0 8px;
  color: #7d3b27;
  font-weight: 800;
}

.ritual-paper-head small {
  display: block;
  max-width: 680px;
  margin: 0 auto;
  color: #675744;
  font-size: 13px;
  line-height: 1.6;
}

.ritual-prose {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 26px auto;
  color: #2b2119;
  font-family: var(--font-title);
  font-size: 17px;
  line-height: 1.85;
}

.ritual-prose p {
  margin: 0 0 1.3em;
}

.ritual-image-pages {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 22px;
  max-width: 760px;
  margin: 30px auto;
}

.ritual-image-pages-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(139, 73, 37, 0.35);
}

.ritual-image-pages-head strong {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #6f281b;
  font-family: var(--font-title);
  font-size: 17px;
}

.ritual-image-pages-head .icon {
  width: 19px;
  height: 19px;
}

.ritual-image-pages-head span {
  color: var(--muted);
  font-size: 12px;
}

.ritual-image-pages figure {
  margin: 0;
  break-inside: avoid;
}

.ritual-page-image {
  display: block;
  aspect-ratio: auto;
  width: 100%;
  max-height: none;
  border: 1px solid rgba(127, 67, 32, 0.42);
  border-radius: 5px;
  background: #fff;
  box-shadow: 0 14px 32px rgba(70, 38, 13, 0.16);
}

.ritual-page-image img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

.ritual-image-pages figcaption {
  margin-top: 7px;
  color: #80664c;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.ritual-document-viewer {
  position: relative;
  z-index: 1;
  margin: 30px 0 0;
  overflow: hidden;
  border: 1px solid rgba(139, 73, 37, 0.45);
  border-radius: 8px;
  background: #f7edd0;
}

.ritual-document-viewer > div {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
}

.ritual-document-viewer > div span {
  color: var(--muted);
  font-size: 12px;
}

.ritual-document-viewer iframe {
  display: block;
  width: 100%;
  height: min(74vh, 860px);
  min-height: 620px;
  border: 0;
  background: #555;
}

.ritual-word-note {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-top: 28px;
  padding: 16px;
  border: 1px solid rgba(31, 105, 79, 0.42);
  border-radius: 8px;
  background: rgba(233, 245, 235, 0.78);
}

.ritual-word-note > .icon {
  width: 38px;
  height: 38px;
  color: #1d6a53;
}

.ritual-word-note p {
  margin: 4px 0 0;
  color: #5f594c;
  font-size: 12px;
  line-height: 1.5;
}

.ritual-paper-foot {
  position: relative;
  z-index: 1;
  margin-top: 36px;
  padding-top: 14px;
  border-top: 1px solid rgba(139, 73, 37, 0.32);
  color: #80664c;
  font-family: var(--font-ceremony);
  font-size: 14px;
  line-height: 1.7;
  text-align: center;
}

.admin-section-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.admin-section-tabs button {
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid rgba(151, 91, 34, 0.48);
  border-radius: 8px;
  background: rgba(255, 252, 235, 0.9);
  color: var(--muted);
  font-weight: 900;
}

.admin-section-tabs button.active {
  border-color: #7d2e1c;
  background: #8f3322;
  color: #fff8df;
}

.ritual-admin-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
}

.ritual-admin-sidebar,
.ritual-editor-panel {
  min-height: calc(100vh - 178px);
}

.ritual-admin-sidebar .panel-head {
  display: grid;
  gap: 10px;
}

.ritual-admin-sidebar .panel-head h2 {
  margin: 0;
}

.ritual-admin-list {
  max-height: calc(100vh - 330px);
  overflow: auto;
  padding: 8px;
}

.ritual-admin-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  width: 100%;
  margin-bottom: 6px;
  padding: 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}

.ritual-admin-row:hover,
.ritual-admin-row.active {
  border-color: rgba(151, 91, 34, 0.35);
  background: rgba(255, 238, 177, 0.72);
}

.ritual-admin-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 40px;
  border: 1px solid rgba(151, 91, 34, 0.35);
  border-radius: 7px;
  color: #7d2e1c;
}

.ritual-admin-icon .icon {
  width: 20px;
  height: 20px;
}

.ritual-admin-row > span:last-child {
  min-width: 0;
}

.ritual-admin-row strong,
.ritual-admin-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ritual-admin-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.ritual-admin-form {
  height: calc(100vh - 178px);
  overflow: auto;
  padding: 20px;
}

.ritual-form-heading {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.ritual-form-heading span {
  color: #1d6a53;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.ritual-form-heading h2 {
  margin: 3px 0 0;
  font-family: var(--font-title);
  font-size: 24px;
}

.publish-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid rgba(31, 105, 79, 0.38);
  border-radius: 8px;
  background: rgba(233, 245, 235, 0.72);
  color: #175943;
  font-weight: 800;
}

.publish-toggle input {
  width: 18px;
  height: 18px;
}

.ritual-file-field small {
  color: var(--muted);
  font-size: 11px;
}

.ritual-image-field > small {
  color: var(--muted);
  font-size: 11px;
}

.ritual-image-field input[type="file"],
.ritual-file-field input[type="file"] {
  padding: 7px;
  border-style: dashed;
  background: rgba(255, 253, 241, 0.86);
}

.ritual-image-field input[type="file"]::file-selector-button,
.ritual-file-field input[type="file"]::file-selector-button {
  min-height: 34px;
  margin-right: 10px;
  padding: 7px 12px;
  border: 1px solid rgba(126, 57, 28, 0.48);
  border-radius: 6px;
  background: #fff0bb;
  color: #682517;
  font-family: var(--font-ui);
  font-weight: 700;
  cursor: pointer;
}

.ritual-selected-images,
.ritual-current-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 9px;
  margin-top: 10px;
}

.ritual-selected-image,
.ritual-current-image {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(151, 91, 34, 0.35);
  border-radius: 7px;
  background: rgba(255, 248, 218, 0.78);
}

.ritual-selected-image {
  grid-template-columns: 54px minmax(0, 1fr);
}

.ritual-selected-image img,
.ritual-current-image img {
  width: 54px;
  height: 68px;
  border-radius: 4px;
  background: #fff;
  object-fit: cover;
  object-position: top;
}

.ritual-selected-image span,
.ritual-current-image span {
  min-width: 0;
}

.ritual-selected-image strong,
.ritual-selected-image small,
.ritual-current-image strong,
.ritual-current-image small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ritual-selected-image small,
.ritual-current-image small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.ritual-current-image input {
  width: 18px;
  height: 18px;
}

.current-ritual-file {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  padding: 10px;
  border: 1px solid rgba(31, 105, 79, 0.34);
  border-radius: 8px;
  background: rgba(233, 245, 235, 0.72);
}

.current-ritual-file > .icon {
  width: 28px;
  height: 28px;
  color: #1d6a53;
}

.current-ritual-file strong,
.current-ritual-file small {
  display: block;
}

.current-ritual-file label {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

@media (max-width: 920px) {
  .ritual-admin-layout {
    grid-template-columns: 1fr;
  }

  .ritual-admin-sidebar,
  .ritual-editor-panel {
    min-height: auto;
  }

  .ritual-admin-list {
    max-height: 280px;
  }

  .ritual-admin-form {
    height: auto;
    overflow: visible;
  }
}

@media (max-width: 640px) {
  .ritual-switch-fab {
    right: 14px;
    bottom: 142px;
    width: 52px;
    height: 52px;
  }

  .ritual-switch-fab span {
    display: none;
  }

  .ritual-library {
    min-height: calc(100dvh - 62px);
    margin: -6px;
    padding: 22px 10px 214px;
    background-attachment: scroll;
  }

  .ritual-hero {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 12px;
    margin-bottom: 18px;
    padding: 0 46px 18px 0;
  }

  .ritual-seal {
    width: 50px;
    height: 50px;
    outline-offset: 3px;
  }

  .ritual-seal .icon {
    width: 26px;
    height: 26px;
  }

  .ritual-hero p {
    font-size: 9px;
  }

  .ritual-hero h2 {
    margin: 2px 0 3px;
    font-size: 27px;
    line-height: 1.4;
  }

  .ritual-hero span {
    grid-column: 1 / -1;
    font-size: 12px;
  }

  .ritual-toolbar,
  .ritual-grid {
    grid-template-columns: 1fr;
  }

  .ritual-card {
    grid-template-columns: 36px minmax(0, 1fr) 22px;
    gap: 9px;
    min-height: 0;
    padding: 14px 11px;
  }

  .ritual-card.has-cover {
    grid-template-columns: 64px minmax(0, 1fr) 22px;
  }

  .ritual-card-lead > img {
    width: 64px;
    height: 88px;
  }

  .ritual-number {
    width: 34px;
    height: 34px;
    font-size: 12px;
  }

  .ritual-card-body h3 {
    font-size: 17px;
  }

  .ritual-detail-page {
    width: calc(100% + 4px);
    min-height: calc(100dvh - 76px);
    margin: -2px -2px 80px;
    padding: 14px 18px 32px;
  }

  .ritual-detail-page::before {
    inset: 6px;
  }

  .ritual-detail-page::after {
    inset: 9px;
  }

  .ritual-detail-actions {
    align-items: stretch;
    flex-direction: column;
    margin: 3px 0 20px;
  }

  .ritual-detail-actions > div {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ritual-detail-actions .btn,
  .ritual-detail-actions .ghost-btn {
    min-height: 38px;
    padding: 8px;
    font-size: 12px;
  }

  .ritual-paper-head {
    padding: 7px 4px 19px;
  }

  .ritual-paper-head h1 {
    font-size: 27px;
  }

  .ritual-prose {
    margin: 20px 4px;
    font-size: 16px;
    line-height: 1.75;
  }

  .ritual-document-viewer iframe {
    height: 62vh;
    min-height: 480px;
  }

  .ritual-word-note {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .ritual-word-note .btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .admin-section-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-section-tabs button {
    min-width: 0;
    padding: 8px 7px;
    font-size: 12px;
  }

  .ritual-admin-form {
    padding: 13px;
  }

  .ritual-form-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .current-ritual-file {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .current-ritual-file label {
    grid-column: 1 / -1;
  }

  .ritual-current-images,
  .ritual-selected-images {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: #fff !important;
  }

  .topbar,
  .floating-tools,
  .ritual-switch-fab,
  .view-switch-fab,
  .kinship-fab,
  .screen-only {
    display: none !important;
  }

  .workspace {
    padding: 0 !important;
  }

  .ritual-detail-page {
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 12mm 15mm;
    border: 0;
    background: #fff;
    box-shadow: none;
  }

  .ritual-detail-page::before,
  .ritual-detail-page::after {
    display: none;
  }

  .ritual-prose {
    max-width: none;
    color: #000;
    font-size: 13pt;
    line-height: 1.65;
  }

  .ritual-image-pages {
    max-width: none;
    margin: 8mm 0;
  }

  .ritual-page-image {
    border: 0;
    box-shadow: none;
  }

  .ritual-paper-head h1 {
    color: #000;
  }
}

/* Mobile app shell: ưu tiên thao tác rõ ràng cho người lớn tuổi. */
@media (max-width: 640px) {
  .viewer-topbar .nav-actions {
    display: none;
  }

  .viewer-topbar .brand h1 {
    max-width: calc(100vw - 62px);
  }

  .viewer-topbar .brand p {
    max-width: calc(100vw - 62px);
  }

  .workspace {
    padding-right: 8px;
    padding-bottom: 94px;
    padding-left: 8px;
  }

  .floating-tools {
    position: fixed;
    inset: 0;
    z-index: 150;
    pointer-events: none;
  }

  .floating-tools.open {
    background: rgba(48, 27, 15, 0.32);
    backdrop-filter: blur(2px);
    pointer-events: auto;
  }

  .floating-tools .menu-toggle {
    display: none;
  }

  .floating-tools .menu-panel {
    top: auto;
    right: 0;
    bottom: calc(78px + env(safe-area-inset-bottom));
    left: 0;
    width: 100%;
    max-height: min(76dvh, 650px);
    padding: 16px 14px 20px;
    border: 1px solid rgba(126, 65, 25, 0.44);
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    background: rgba(255, 251, 232, 0.995);
    box-shadow: 0 -18px 50px rgba(59, 30, 13, 0.24);
  }

  .memory-switch-fab,
  .ritual-switch-fab,
  .view-switch-fab,
  .kinship-fab {
    display: none !important;
  }
}

/* Không gian ký ức dòng họ */
.memory-switch-fab {
  position: fixed;
  right: 22px;
  bottom: 240px;
  z-index: 35;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid #d8c58f;
  border-radius: 50%;
  background: #315f5b;
  color: #fff9df;
  box-shadow: 0 15px 32px rgba(28, 67, 63, 0.3);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.memory-switch-fab:hover,
.memory-switch-fab:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 19px 38px rgba(28, 67, 63, 0.38);
}

.memory-switch-fab .icon {
  width: 27px;
  height: 27px;
}

.memory-switch-fab span {
  position: absolute;
  right: 68px;
  bottom: 10px;
  width: max-content;
  max-width: 220px;
  padding: 9px 11px;
  border: 1px solid rgba(198, 146, 57, 0.55);
  border-radius: 8px;
  background: rgba(255, 252, 235, 0.98);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(53, 30, 13, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateX(6px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.memory-switch-fab:hover span,
.memory-switch-fab:focus-visible span {
  opacity: 1;
  transform: translateX(0);
}

.memory-archive {
  min-height: calc(100vh - 110px);
  margin: -16px -18px -18px;
  padding: 34px clamp(20px, 5vw, 76px) 100px;
  background-color: #f8f0d5;
  background-image: var(--family-bg);
  background-position: center top;
  background-size: cover;
  background-attachment: fixed;
}

.memory-hero {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  max-width: 1280px;
  margin: 0 auto 22px;
  padding: 22px 24px;
  border: 1px solid rgba(110, 75, 35, 0.34);
  border-radius: 8px;
  background: rgba(255, 251, 232, 0.94);
  box-shadow: 0 14px 34px rgba(72, 45, 20, 0.12);
}

.memory-hero-icon {
  display: grid;
  width: 70px;
  height: 70px;
  place-items: center;
  border: 1px solid #c9a956;
  border-radius: 50%;
  background: #315f5b;
  color: #fff8db;
  box-shadow: inset 0 0 0 5px #f4e6b8;
}

.memory-hero-icon .icon {
  width: 31px;
  height: 31px;
}

.memory-hero > div:nth-child(2) > span,
.memory-category {
  color: #27665c;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.memory-hero h2 {
  margin: 3px 0 4px;
  color: #51261c;
  font-family: "Noto Serif", Georgia, serif;
  font-size: clamp(28px, 4vw, 48px);
  letter-spacing: 0;
}

.memory-hero p {
  margin: 0;
  color: #765e45;
  line-height: 1.5;
}

.memory-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(76px, 1fr));
  margin: 0;
  border-left: 1px solid rgba(115, 79, 38, 0.2);
}

.memory-summary div {
  padding: 7px 14px;
  text-align: center;
}

.memory-summary dt {
  color: #8f2f20;
  font-family: Georgia, serif;
  font-size: 25px;
  font-weight: 800;
}

.memory-summary dd {
  margin: 2px 0 0;
  color: #7b654b;
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}

.memory-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 12px;
  max-width: 1280px;
  margin: 0 auto 16px;
}

.memory-filter {
  display: grid;
  gap: 5px;
  color: #704129;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.memory-filter select {
  height: 52px;
  padding: 0 14px;
  border: 1px solid rgba(151, 91, 34, 0.42);
  border-radius: 7px;
  background: #fffdf4;
  color: #3f2719;
  font: inherit;
  font-size: 13px;
  text-transform: none;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  max-width: 1280px;
  margin: auto;
}

.memory-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(125, 78, 35, 0.3);
  border-radius: 8px;
  background: rgba(255, 253, 241, 0.97);
  color: #44281d;
  box-shadow: 0 10px 24px rgba(60, 37, 18, 0.1);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.memory-card:hover,
.memory-card:focus-visible {
  border-color: #467b70;
  box-shadow: 0 15px 30px rgba(44, 80, 72, 0.18);
  transform: translateY(-2px);
}

.memory-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #e8ddbd;
}

.memory-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.memory-cover span {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 7px;
  border-radius: 6px;
  background: rgba(34, 48, 41, 0.82);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
}

.memory-cover span .icon {
  width: 14px;
  height: 14px;
}

.memory-quote {
  display: grid;
  height: 88px;
  place-items: center;
  border-bottom: 1px solid rgba(125, 78, 35, 0.16);
  background: #e4efe8;
  color: #367065;
}

.memory-quote .icon {
  width: 34px;
  height: 34px;
}

.memory-card-body {
  padding: 15px;
}

.memory-card h3 {
  margin: 5px 0 7px;
  overflow: hidden;
  color: #51261c;
  font-family: "Noto Serif", Georgia, serif;
  font-size: 19px;
  line-height: 1.35;
}

.memory-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  color: #7c674d;
  font-size: 10px;
}

.memory-meta .icon {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
}

.memory-story-preview {
  margin: 0;
  color: #654d38;
  font-size: 12px;
  line-height: 1.55;
}

.memory-people {
  display: flex;
  align-items: center;
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid rgba(125, 78, 35, 0.15);
}

.memory-people > span {
  display: grid;
  width: 25px;
  height: 25px;
  margin-right: -5px;
  place-items: center;
  border: 2px solid #fffdf1;
  border-radius: 50%;
  background: #e3c76d;
  color: #5a2a1b;
  font-size: 7px;
  font-weight: 900;
}

.memory-people small {
  min-width: 0;
  margin-left: 12px;
  overflow: hidden;
  color: #786247;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-empty {
  grid-column: 1 / -1;
  padding: 54px 18px;
  border: 1px dashed rgba(125, 78, 35, 0.4);
  border-radius: 8px;
  background: rgba(255, 253, 241, 0.85);
  color: #6c563c;
  text-align: center;
}

.memory-empty .icon {
  width: 38px;
  height: 38px;
  color: #367065;
}

.memory-empty h3 {
  margin: 10px 0 4px;
  color: #51261c;
}

.memory-empty p {
  margin: 0;
}

.memory-modal {
  position: fixed;
  inset: 0;
  z-index: 190;
  display: grid;
  place-items: center;
  padding: 18px;
}

.memory-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(35, 27, 17, 0.62);
}

.memory-detail {
  position: relative;
  width: min(920px, calc(100vw - 32px));
  max-height: min(820px, calc(100dvh - 32px));
  overflow: hidden;
  border: 1px solid #caa45b;
  border-radius: 8px;
  background: #fffaf0;
  box-shadow: 0 30px 90px rgba(35, 24, 12, 0.42);
}

.memory-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(142, 85, 34, 0.28);
  background: #fbf1d7;
}

.memory-detail-head span {
  color: #287064;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.memory-detail-head h2 {
  margin: 3px 0;
  color: #4f241a;
  font-family: "Noto Serif", Georgia, serif;
  font-size: 27px;
}

.memory-detail-head p {
  margin: 0;
  color: #7a6246;
  font-size: 11px;
}

.memory-detail-scroll {
  max-height: calc(100dvh - 154px);
  overflow: auto;
  padding: 18px 20px 24px;
}

.memory-gallery-main .gallery-photo {
  width: 100%;
  height: min(50vh, 460px);
  padding: 0;
}

.memory-gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ede4cc;
}

.memory-gallery-thumbs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  margin-top: 7px;
}

.memory-gallery-thumbs .gallery-photo {
  aspect-ratio: 4 / 3;
  padding: 0;
}

.memory-gallery-thumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.memory-detail-story,
.memory-detail-people,
.memory-links {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(142, 85, 34, 0.22);
}

.memory-detail-story h3,
.memory-detail-people h3,
.memory-links h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 10px;
  color: #54291c;
  font-family: "Noto Serif", Georgia, serif;
  font-size: 17px;
}

.memory-detail-story h3 .icon {
  color: #39756a;
}

.memory-detail-story p {
  margin: 0 0 10px;
  color: #4f3b2b;
  font-size: 14px;
  line-height: 1.75;
}

.memory-detail-people > div {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.memory-person {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 7px;
  border: 1px solid rgba(142, 85, 34, 0.25);
  border-radius: 7px;
  background: #fffdf5;
  color: #4c2d20;
  text-align: left;
}

.memory-person-photo,
.memory-person .avatar-fallback {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
}

.memory-person span,
.memory-person strong,
.memory-person small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-person small {
  margin-top: 2px;
  color: #806a50;
  font-size: 9px;
}

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

.memory-links h3 {
  grid-column: 1 / -1;
}

.memory-links a {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border: 1px solid #c8ddcf;
  border-radius: 7px;
  background: #edf5ef;
  color: #315f55;
  text-decoration: none;
}

.memory-links a > .icon:first-child {
  width: 27px;
  height: 27px;
}

.memory-links a > .icon:last-child {
  width: 16px;
  height: 16px;
}

.memory-links strong,
.memory-links small {
  display: block;
}

.memory-links small {
  margin-top: 2px;
  color: #66796e;
  font-size: 9px;
}

.memory-source {
  margin-top: 18px;
  padding: 10px 12px;
  border-left: 3px solid #b78a30;
  background: #f8edce;
  color: #71583c;
  font-size: 11px;
}

.memory-admin-row > img {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
}

.memory-admin-row {
  grid-template-columns: 38px minmax(0, 1fr);
}

.view-mode-grid .icon-btn:nth-child(8) {
  --mode-accent: #aa4b35;
  --mode-soft: #f6e4dc;
  --mode-border: #e8c8bd;
}

.view-mode-grid .icon-btn:nth-child(7) {
  --mode-accent: #315f5b;
  --mode-soft: #e3efeb;
  --mode-border: #c5dad4;
}

.mobile-hub-grid .tone-memory {
  --tile-accent: #315f5b;
  --tile-soft: #e3efeb;
  --tile-border: #c5dad4;
}

@media print {
  .memory-switch-fab,
  .memory-modal {
    display: none !important;
  }
}

@media (max-width: 980px) {
  .memory-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .memory-hero {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .memory-summary {
    grid-column: 1 / -1;
    border-top: 1px solid rgba(115, 79, 38, 0.2);
    border-left: 0;
  }
}

@media (max-width: 640px) {
  .memory-switch-fab {
    display: none !important;
  }

  .memory-archive {
    min-height: calc(100dvh - 62px);
    margin: -6px;
    padding: 10px 8px 82px;
    background-attachment: scroll;
  }

  .memory-hero {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 10px;
    margin-bottom: 10px;
    padding: 12px;
  }

  .memory-hero-icon {
    width: 46px;
    height: 46px;
    box-shadow: inset 0 0 0 3px #f4e6b8;
  }

  .memory-hero-icon .icon {
    width: 22px;
    height: 22px;
  }

  .memory-hero h2 {
    font-size: 22px;
  }

  .memory-hero p {
    font-size: 9px;
  }

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

  .memory-summary div {
    padding: 6px 4px;
  }

  .memory-summary dt {
    font-size: 18px;
  }

  .memory-summary dd {
    font-size: 7px;
  }

  .memory-toolbar,
  .memory-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .memory-filter {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .memory-filter select {
    height: 44px;
  }

  .memory-card {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    min-height: 112px;
  }

  .memory-card.story-only {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .memory-cover,
  .memory-quote {
    height: 100%;
    min-height: 112px;
    aspect-ratio: auto;
  }

  .memory-card-body {
    padding: 10px;
  }

  .memory-card h3 {
    margin: 3px 0 5px;
    font-size: 14px;
  }

  .memory-story-preview {
    display: -webkit-box;
    overflow: hidden;
    font-size: 9px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .memory-people {
    margin-top: 7px;
    padding-top: 7px;
  }

  .memory-people > span {
    width: 21px;
    height: 21px;
  }

  .memory-modal {
    padding: 0;
  }

  .memory-detail {
    width: 100vw;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .memory-detail-head {
    padding: 12px;
  }

  .memory-detail-head h2 {
    font-size: 20px;
  }

  .memory-detail-scroll {
    max-height: calc(100dvh - 88px);
    padding: 10px 10px 24px;
  }

  .memory-gallery-main .gallery-photo {
    height: 38vh;
  }

  .memory-gallery-thumbs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .memory-detail-people > div,
  .memory-links {
    grid-template-columns: 1fr;
  }

  .memory-links h3 {
    grid-column: auto;
  }

  .memory-admin-list {
    max-height: 260px;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 6px 6px calc(76px + env(safe-area-inset-bottom));
  }

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

@media (max-width: 640px) {
  main.workspace {
    padding: 6px 6px calc(76px + env(safe-area-inset-bottom)) !important;
  }

  .floating-tools.open .menu-panel {
    max-height: calc(100dvh - 190px) !important;
  }

  aside.detail-drawer {
    right: 0;
    left: 0;
    width: auto;
  }
}

@media print and (max-width: 640px) {
  main.workspace {
    padding: 0 !important;
  }
}

/* Modern family views and compact mobile navigation. */
.view-mode-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
}

.view-mode-grid .icon-btn {
  width: 100%;
  min-width: 0;
  height: 58px;
  padding: 6px 3px;
  flex-direction: column;
  gap: 4px;
}

.view-mode-grid .icon-btn .icon {
  width: 24px;
  height: 24px;
  padding: 4px;
  border: 1px solid var(--mode-border, #ead4bc);
  border-radius: 5px;
  background: var(--mode-soft, #f8e9d9);
  color: var(--mode-accent, #96341f);
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.view-mode-grid .icon-btn:nth-child(1) { --mode-accent: #96341f; --mode-soft: #f7e4dc; --mode-border: #e8c6b8; }
.view-mode-grid .icon-btn:nth-child(2) { --mode-accent: #26705d; --mode-soft: #e4f1ea; --mode-border: #c6ddcf; }
.view-mode-grid .icon-btn:nth-child(3) { --mode-accent: #2f7189; --mode-soft: #e1eef2; --mode-border: #c3dbe3; }
.view-mode-grid .icon-btn:nth-child(4) { --mode-accent: #4b5964; --mode-soft: #e8ecee; --mode-border: #d0d8dc; }
.view-mode-grid .icon-btn:nth-child(5) { --mode-accent: #2b7771; --mode-soft: #e0efec; --mode-border: #c1deda; }
.view-mode-grid .icon-btn:nth-child(6) { --mode-accent: #a06c16; --mode-soft: #f8edce; --mode-border: #e8d59c; }
.view-mode-grid .icon-btn:nth-child(7) { --mode-accent: #315f5b; --mode-soft: #e3efeb; --mode-border: #c5dad4; }
.view-mode-grid .icon-btn:nth-child(8) { --mode-accent: #aa4b35; --mode-soft: #f6e4dc; --mode-border: #e8c8bd; }

.view-mode-grid .icon-btn:hover .icon,
.view-mode-grid .icon-btn:focus-visible .icon {
  transform: translateY(-1px);
}

.view-mode-grid .icon-btn.active .icon {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.14);
  color: #fff9e8;
}

.view-mode-grid .icon-btn span {
  max-width: 100%;
  overflow: hidden;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.mobile-family-hub {
  display: none;
}

.view-page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(133, 74, 27, 0.3);
}

.view-page-head > div,
.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.view-page-head > div > span,
.section-heading > span {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid #d6a64d;
  border-radius: 50%;
  background: #fff1bd;
  color: #7c2818;
}

.view-page-head p,
.view-page-head h2,
.view-page-head small,
.section-heading h3,
.section-heading p {
  margin: 0;
}

.view-page-head p {
  color: #8a4b25;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.view-page-head h2 {
  color: #3c1b10;
  font: 800 28px/1.2 "Noto Serif", Georgia, serif;
}

.view-page-head > small {
  max-width: 430px;
  color: #756044;
  line-height: 1.55;
  text-align: right;
}

.my-family-dashboard,
.fan-page,
.timeline-page,
.places-page {
  width: min(1180px, calc(100vw - 44px));
  margin: 0 auto;
  padding: 26px;
  border: 1px solid rgba(143, 83, 29, 0.42);
  border-radius: 8px;
  background: rgba(255, 250, 229, 0.94);
  box-shadow: 0 18px 46px rgba(72, 37, 13, 0.16);
}

.my-family-hero {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 20px;
  border: 1px solid rgba(137, 73, 24, 0.35);
  border-radius: 8px;
  background: linear-gradient(110deg, #fff4c5, #fffaf0 60%, #e8f2df);
}

.my-family-photo,
.mini-person-initials {
  display: grid;
  object-fit: cover;
  place-items: center;
}

.my-family-photo {
  width: 104px;
  height: 118px;
  border: 2px solid #fff8dc;
  border-radius: 7px;
  box-shadow: 0 8px 20px rgba(66, 33, 12, 0.18);
}

.mini-person-initials {
  background: #ffe9a8;
  color: #7a2715;
  font-weight: 800;
}

.my-family-hero p,
.my-family-hero h2,
.my-family-hero span {
  margin: 0;
}

.my-family-hero p {
  color: #287260;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.my-family-hero h2 {
  margin: 4px 0 6px;
  color: #3e1b0f;
  font: 800 26px/1.25 "Noto Serif", Georgia, serif;
}

.my-family-summary {
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 8px;
  padding-left: 20px;
  border-left: 1px solid rgba(122, 78, 38, 0.24);
}

.my-family-summary strong {
  color: #8f2d1a;
  font-size: 25px;
  line-height: 1;
}

.my-family-summary span {
  color: #765f43;
  font-size: 11px;
}

.dashboard-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 20px;
}

.dashboard-actions button,
.my-family-person,
.upcoming-item,
.timeline-event,
.place-people button {
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.dashboard-actions button {
  --action-accent: #26705d;
  --action-soft: #e4f1ea;
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid rgba(143, 83, 29, 0.36);
  border-radius: 7px;
  background: #fffdf3;
  box-shadow: inset 3px 0 0 var(--action-accent), 0 5px 12px rgba(71, 39, 19, 0.06);
}

.dashboard-actions button:nth-child(2) {
  --action-accent: #2f7189;
  --action-soft: #e1eef2;
}

.dashboard-actions button:hover,
.my-family-person:hover,
.upcoming-item:hover,
.timeline-event:hover {
  border-color: #9c3a20;
  background: #fff5d5;
}

.dashboard-actions button > .icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  padding: 7px;
  border: 1px solid rgba(69, 108, 91, 0.24);
  border-radius: 6px;
  background: var(--action-soft);
  color: var(--action-accent);
}

.dashboard-actions span,
.my-family-person > span,
.upcoming-item > span,
.timeline-event > span:nth-child(2) {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.dashboard-actions small,
.my-family-person small,
.upcoming-item small,
.timeline-event small {
  color: #7b674b;
  font-size: 11px;
}

.my-family-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 18px;
}

.my-family-relations {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 14px;
}

.my-family-group,
.upcoming-panel {
  padding: 16px;
  border: 1px solid rgba(143, 83, 29, 0.3);
  border-radius: 7px;
  background: rgba(255, 254, 246, 0.85);
}

.my-family-group h3 {
  margin: 0 0 10px;
  color: #5d2818;
  font: 700 16px "Noto Serif", Georgia, serif;
}

.my-family-people {
  display: grid;
  gap: 5px;
}

.my-family-person {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
}

.mini-person-photo {
  width: 42px;
  height: 42px;
  border-radius: 5px;
  object-fit: cover;
}

.upcoming-panel .section-heading {
  margin-bottom: 12px;
}

.section-heading h3 {
  color: #4d2316;
  font-size: 15px;
}

.section-heading p {
  color: #806c50;
  font-size: 11px;
}

.upcoming-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 0;
  border: 0;
  border-top: 1px solid rgba(139, 90, 42, 0.17);
  background: transparent;
}

.upcoming-item time {
  display: grid;
  place-items: center;
  min-height: 46px;
  border-radius: 6px;
  background: #fce7a5;
  color: #7b2818;
  font-size: 18px;
  font-weight: 800;
}

.upcoming-item time small {
  font-size: 8px;
  text-transform: uppercase;
}

.upcoming-item.birth time {
  background: #dcebdd;
  color: #236c59;
}

.upcoming-item.memorial time {
  background: #f4ddd0;
  color: #982d1e;
}

.empty-dashboard {
  min-height: 360px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
}

.dashboard-empty-icon .icon {
  width: 44px;
  height: 44px;
}

.fan-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px;
  gap: 12px;
  margin-bottom: 14px;
}

.fan-toolbar label {
  display: grid;
  gap: 6px;
  color: #6f4a2e;
  font-size: 11px;
  font-weight: 800;
}

.fan-toolbar select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #d7a956;
  border-radius: 6px;
  background: #fffdf3;
  color: #3b2413;
}

.fan-viewport {
  overflow: auto;
  height: min(720px, calc(100vh - 250px));
  min-height: 470px;
  border: 1px solid rgba(136, 81, 31, 0.34);
  border-radius: 7px;
  background: radial-gradient(circle at 50% 90%, #fff8d8, #fff1a8 62%, #f4d77f);
  overscroll-behavior: contain;
}

.fan-canvas {
  position: relative;
}

.fan-canvas svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.fan-canvas path {
  fill: none;
  stroke: #758a78;
  stroke-width: 2;
}

.fan-person {
  position: absolute;
  display: grid;
  grid-template-columns: 45px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 178px;
  min-height: 62px;
  padding: 7px;
  transform: translate(-50%, -50%);
  border: 1px solid #d7aa51;
  border-left: 4px solid #23745f;
  border-radius: 6px;
  background: #fffbe8;
  color: #3b2413;
  text-align: left;
  box-shadow: 0 6px 14px rgba(73, 40, 18, 0.13);
  cursor: pointer;
}

.fan-person.level-0 {
  border-left-color: #9d301b;
  background: #fff0b7;
}

.fan-photo {
  display: grid;
  width: 45px;
  height: 48px;
  place-items: center;
  border-radius: 4px;
  object-fit: cover;
}

.fan-person span {
  display: grid;
  min-width: 0;
}

.fan-person strong,
.fan-person small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fan-person strong {
  font-size: 11px;
}

.fan-person small {
  color: #776148;
  font-size: 9px;
}

.timeline-search,
.places-search {
  max-width: 680px;
  margin-bottom: 20px;
}

.family-timeline {
  position: relative;
  display: grid;
  gap: 22px;
  padding-left: 72px;
}

.family-timeline::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 48px;
  width: 2px;
  background: linear-gradient(#a23920, #d8ac55, #2d7563);
}

.timeline-year {
  position: relative;
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 16px;
  content-visibility: auto;
  contain-intrinsic-size: 180px;
}

.timeline-year > time {
  position: relative;
  color: #8c301c;
  font: 800 22px "Noto Serif", Georgia, serif;
}

.timeline-year > time::before {
  content: "";
  position: absolute;
  top: 8px;
  left: -31px;
  width: 10px;
  height: 10px;
  border: 3px solid #fff4c5;
  border-radius: 50%;
  background: #9c301c;
}

.timeline-year > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.timeline-event {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 9px;
  min-height: 66px;
  padding: 9px;
  border: 1px solid rgba(143, 83, 29, 0.28);
  border-radius: 6px;
  background: #fffdf4;
}

.timeline-event-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: #fde7a8;
  color: #8d311d;
}

.timeline-event.achievement .timeline-event-icon {
  background: #f8d978;
}

.timeline-event.marriage .timeline-event-icon {
  background: #f7c9be;
}

.timeline-event.birth .timeline-event-icon {
  background: #dcebdc;
  color: #246c5b;
}

.timeline-photo {
  width: 42px;
  height: 46px;
  border-radius: 4px;
  object-fit: cover;
}

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

.place-card {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  padding: 17px;
  border: 1px solid rgba(143, 83, 29, 0.33);
  border-radius: 7px;
  background: linear-gradient(145deg, #fffdf2, #f5f0df);
  content-visibility: auto;
  contain-intrinsic-size: 260px;
}

.place-pin {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  background: #dce9db;
  color: #246c5b;
}

.place-card-head span {
  color: #29705d;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.place-card-head h3 {
  margin: 3px 0;
  color: #452015;
  font: 700 18px "Noto Serif", Georgia, serif;
}

.place-card-head p {
  margin: 0;
  color: #786247;
  font-size: 11px;
}

.place-people {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.place-people button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px 4px 4px;
  border: 1px solid rgba(82, 105, 81, 0.23);
  border-radius: 5px;
  background: #f2f7ec;
  font-size: 10px;
}

.place-person-photo {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 4px;
  object-fit: cover;
}

.place-card > a {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 6px;
  color: #7b2a18;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}

.view-empty {
  grid-column: 1 / -1;
  display: grid;
  min-height: 260px;
  place-items: center;
  align-content: center;
  color: #765f43;
  text-align: center;
}

.view-empty h3,
.view-empty p {
  margin: 5px;
}

.memory-section {
  margin-top: 18px;
  padding: 15px;
  border: 1px solid rgba(145, 86, 32, 0.3);
  border-left: 4px solid #28715e;
  border-radius: 7px;
  background: #fff9df;
}

.memory-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  color: #5a2818;
}

.life-story {
  color: #513b28;
  line-height: 1.7;
}

.memory-media {
  margin-top: 10px;
}

.memory-media audio {
  width: 100%;
}

.memory-media a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #7f2c19;
  font-weight: 800;
}

.information-source {
  margin-bottom: 0;
  color: #80684d;
  font-size: 11px;
}

@media (max-width: 900px) {
  .my-family-dashboard,
  .fan-page,
  .timeline-page,
  .places-page {
    width: min(100%, calc(100vw - 20px));
    padding: 18px;
  }

  .my-family-layout,
  .places-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .timeline-year > div {
    grid-template-columns: minmax(0, 1fr);
  }
}

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

  .mobile-bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 160;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: calc(78px + env(safe-area-inset-bottom));
    padding: 8px 6px max(6px, env(safe-area-inset-bottom));
    border: 0;
    border-top: 1px solid rgba(118, 62, 24, 0.34);
    border-radius: 0;
    background: rgba(255, 252, 238, 0.985);
    box-shadow: 0 -10px 30px rgba(67, 34, 13, 0.16);
    backdrop-filter: blur(12px);
  }

  .mobile-bottom-nav button {
    position: relative;
    display: grid;
    min-width: 0;
    place-items: center;
    align-content: center;
    gap: 3px;
    min-height: 58px;
    padding: 4px 2px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #6d5a42;
  }

  .mobile-bottom-nav button .icon {
    padding: 5px;
    border: 1px solid transparent;
    border-radius: 8px;
    transition: background 150ms ease, color 150ms ease, transform 150ms ease;
  }

  .mobile-bottom-nav button.active {
    background: transparent;
    color: #9a2c1d;
  }

  .mobile-bottom-nav button.active .icon {
    border-color: #e5b99b;
    background: #f6e2d8;
    color: #972e20;
    transform: translateY(-1px);
  }

  .mobile-bottom-nav button.active::before {
    content: "";
    position: absolute;
    top: -8px;
    left: 50%;
    width: 28px;
    height: 3px;
    transform: translateX(-50%);
    border-radius: 0 0 4px 4px;
    background: #a22d1f;
  }

  .mobile-bottom-nav .icon {
    width: 30px;
    height: 30px;
    stroke-width: 2.2;
  }

  .mobile-bottom-nav span {
    max-width: 100%;
    overflow: hidden;
    font-size: 10px;
    font-weight: 750;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .my-family-dashboard .my-family-hero,
  .my-family-dashboard .dashboard-actions {
    display: none;
  }

  .mobile-family-hub {
    display: block;
    margin: -2px -2px 10px;
    color: #432218;
  }

  .mobile-hub-family {
    position: relative;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    min-height: 76px;
    padding: 12px;
    overflow: hidden;
    border: 1px solid #6f2017;
    border-radius: 8px 8px 0 0;
    background: #8d271b;
    color: #fff8e8;
  }

  .mobile-hub-monogram {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid rgba(255, 234, 177, 0.65);
    border-radius: 7px;
    background: #fff1bf;
    color: #8d271b;
    font: 900 15px "Noto Serif", Georgia, serif;
    box-shadow: inset 0 0 0 2px rgba(141, 39, 27, 0.1);
  }

  .mobile-hub-family > div {
    min-width: 0;
  }

  .mobile-hub-family small,
  .mobile-hub-family h2,
  .mobile-hub-family p {
    margin: 0;
  }

  .mobile-hub-family small {
    color: #f2c991;
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .mobile-hub-family h2 {
    margin: 2px 0 3px;
    overflow: hidden;
    color: #fff9eb;
    font: 700 15px/1.25 "Noto Serif", Georgia, serif;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-hub-family p {
    color: #f5ddbd;
    font-size: 9px;
  }

  .mobile-hub-event > span {
    display: grid;
    min-width: 0;
    gap: 2px;
  }

  .mobile-hub-overview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border: 1px solid rgba(151, 91, 34, 0.34);
    border-top: 0;
    border-radius: 0 0 8px 8px;
    background: rgba(255, 250, 233, 0.96);
    box-shadow: 0 8px 18px rgba(108, 35, 23, 0.1);
  }

  .mobile-hub-overview span {
    padding: 10px 8px;
    color: #735a3c;
    font-size: 10px;
    text-align: center;
  }

  .mobile-hub-overview span + span {
    border-left: 1px solid rgba(151, 91, 34, 0.22);
  }

  .mobile-hub-overview strong {
    color: #84291b;
    font-size: 15px;
  }

  .mobile-hub-event {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-top: 9px;
    min-height: 66px;
    padding: 9px 11px;
    border: 1px solid rgba(151, 91, 34, 0.34);
    border-radius: 7px;
    background: #fffaf0;
    color: #4e2a1b;
    text-align: left;
  }

  .mobile-hub-event time {
    display: grid;
    height: 46px;
    place-items: center;
    border-radius: 6px;
    background: #f8e7b9;
    color: #9a2d1e;
    font-size: 17px;
    font-weight: 900;
  }

  .mobile-hub-event time small {
    color: #8d5d2e;
    font-size: 7px;
  }

  .mobile-hub-event.birth {
    border-left: 4px solid #287461;
  }

  .mobile-hub-event.birth time {
    background: #dcebdd;
    color: #236c59;
  }

  .mobile-hub-event.memorial {
    border-left: 4px solid #a13221;
  }

  .mobile-hub-event.memorial time {
    background: #f4ddd0;
    color: #982d1e;
  }

  .mobile-hub-event span > small {
    color: #9a2d1e;
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .mobile-hub-event strong {
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-hub-event em {
    color: #7c684d;
    font-size: 10px;
    font-style: normal;
  }

  .memory-switch-fab,
  .ritual-switch-fab,
  .view-switch-fab,
  .kinship-fab {
    display: none !important;
  }

  .floating-tools {
    position: fixed;
    inset: 0;
    z-index: 150;
    pointer-events: none;
  }

  .floating-tools.open {
    background: rgba(48, 27, 15, 0.32);
    backdrop-filter: blur(2px);
    pointer-events: auto;
  }

  .floating-tools .menu-toggle {
    display: none;
  }

  .menu-panel {
    position: absolute;
    right: 0;
    bottom: calc(78px + env(safe-area-inset-bottom));
    left: 0;
    top: auto;
    width: 100%;
    max-height: min(76dvh, 650px);
    padding: 16px 14px 20px;
    border: 1px solid rgba(126, 65, 25, 0.44);
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    background: rgba(255, 251, 232, 0.995);
    box-shadow: 0 -18px 50px rgba(59, 30, 13, 0.24);
    overscroll-behavior: contain;
  }

  .menu-panel::before {
    content: "";
    display: block;
    width: 42px;
    height: 4px;
    margin: -7px auto 10px;
    border-radius: 4px;
    background: #c7a980;
  }

  .desktop-menu-label {
    display: none;
  }

  .mobile-menu-label {
    display: inline;
  }

  .view-mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .view-mode-grid .icon-btn {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    min-height: 52px;
    justify-items: start;
    gap: 9px;
    padding: 7px 9px;
    border: 1px solid var(--mode-border, #ead4bc);
    border-radius: 8px;
    background: #fffdf5;
    color: #4c2b1c;
    text-align: left;
  }

  .view-mode-grid .icon-btn .icon {
    width: 34px;
    height: 34px;
    padding: 7px;
  }

  .view-mode-grid .icon-btn span {
    font-size: 11px;
    white-space: normal;
  }

  .view-mode-grid .icon-btn.active {
    background: #8a2f1b;
    color: #fff9e9;
  }

  .view-mode-grid .mobile-primary-duplicate {
    display: none;
  }

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

  .tool-action {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 9px;
    min-height: 50px;
    padding: 8px 10px;
    border: 1px solid #dfc39c;
    background: #fffdf5;
  }

  .tool-action .icon {
    width: 25px;
    height: 25px;
  }

  .tool-action span {
    display: inline;
    font-size: 11px;
    font-weight: 750;
  }

  .stats-menu,
  .menu-help {
    display: none;
  }

  .mobile-account-section {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .mobile-account-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 44px;
    padding: 8px;
    border: 1px solid #dec39d;
    border-radius: 8px;
    background: #fffdf5;
    color: #612719;
    font-size: 11px;
    font-weight: 750;
    text-decoration: none;
  }

  .mobile-account-link .icon {
    width: 19px;
    height: 19px;
  }

  .list-panel {
    width: 100%;
    min-height: calc(100dvh - 150px);
    padding: 12px;
  }

  .desktop-directory-table {
    display: none;
  }

  .directory-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 11px;
    border-bottom: 1px solid rgba(139, 79, 31, 0.24);
  }

  .directory-head > div {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 9px;
  }

  .directory-head > div > span {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    border: 1px solid #d5a954;
    border-radius: 8px;
    background: #fff0bd;
    color: #842a1b;
  }

  .directory-head p,
  .directory-head h2 {
    margin: 0;
  }

  .directory-head p {
    color: #8a4b25;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .directory-head h2 {
    color: #3e1b0f;
    font: 800 18px/1.2 "Noto Serif", Georgia, serif;
  }

  .directory-head > strong {
    flex: 0 0 auto;
    padding: 6px 8px;
    border-radius: 999px;
    background: #f5e7c2;
    color: #762719;
    font-size: 10px;
  }

  .directory-search {
    display: flex;
    width: 100%;
    min-height: 48px;
    margin: 11px 0;
  }

  .directory-search input {
    font-size: 14px;
  }

  .mobile-directory {
    display: grid;
    gap: 7px;
  }

  .mobile-directory-card {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) auto 18px;
    align-items: center;
    gap: 9px;
    min-height: 68px;
    padding: 8px;
    border: 1px solid rgba(139, 79, 31, 0.27);
    border-radius: 8px;
    background: rgba(255, 253, 243, 0.96);
    color: #442317;
    text-align: left;
  }

  .mobile-directory-card:active {
    background: #fff3cc;
  }

  .mobile-directory-photo {
    display: grid;
    width: 50px;
    height: 54px;
    place-items: center;
    border-radius: 7px;
    object-fit: cover;
  }

  .mobile-directory-main {
    display: grid;
    min-width: 0;
    gap: 2px;
  }

  .mobile-directory-main strong {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 5px;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-directory-main small,
  .mobile-directory-main em {
    overflow: hidden;
    color: #796247;
    font-size: 10px;
    font-style: normal;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-directory-status {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: #176d58;
    font-size: 9px;
    font-weight: 800;
    white-space: nowrap;
  }

  .mobile-directory-status.deceased {
    color: #a03425;
  }

  .mobile-directory-status .icon {
    width: 13px;
    height: 13px;
  }

  .my-family-dashboard,
  .fan-page,
  .timeline-page,
  .places-page {
    width: 100%;
    padding: 12px;
    border-radius: 7px;
  }

  .view-page-head {
    display: grid;
    gap: 7px;
    margin-bottom: 13px;
    padding-bottom: 11px;
  }

  .view-page-head > div {
    gap: 9px;
  }

  .view-page-head > div > span {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .view-page-head h2 {
    font-size: 20px;
  }

  .view-page-head > small {
    display: none;
  }

  .my-family-hero {
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 10px;
    padding: 11px;
  }

  .my-family-photo {
    width: 68px;
    height: 82px;
  }

  .my-family-hero p {
    font-size: 8px;
  }

  .my-family-hero h2 {
    margin: 2px 0 3px;
    font-size: 17px;
  }

  .my-family-hero > div:nth-child(2) > span {
    font-size: 10px;
  }

  .my-family-summary {
    grid-column: 1 / -1;
    grid-template-columns: auto 1fr auto 1fr;
    align-items: center;
    padding: 8px 0 0;
    border-top: 1px solid rgba(122, 78, 38, 0.2);
    border-left: 0;
  }

  .my-family-summary strong {
    font-size: 18px;
  }

  .dashboard-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    margin: 8px 0 11px;
  }

  .dashboard-actions button {
    display: grid;
    min-height: 58px;
    justify-items: center;
    gap: 3px;
    padding: 6px 3px;
    text-align: center;
  }

  .dashboard-actions button > .icon {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
    padding: 6px;
  }

  .dashboard-actions strong {
    font-size: 9px;
  }

  .dashboard-actions small {
    display: none;
  }

  .my-family-relations {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .my-family-layout {
    gap: 8px;
  }

  .my-family-group,
  .upcoming-panel {
    padding: 10px;
  }

  .fan-toolbar {
    grid-template-columns: minmax(0, 1fr) 108px;
    gap: 7px;
  }

  .fan-viewport {
    height: calc(100dvh - 340px);
    min-height: 390px;
  }

  .family-timeline {
    gap: 14px;
    padding-left: 42px;
  }

  .family-timeline::before {
    left: 24px;
  }

  .timeline-year {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .timeline-year > time {
    font-size: 18px;
  }

  .timeline-year > time::before {
    left: -24px;
  }

  .timeline-event {
    grid-template-columns: 30px minmax(0, 1fr) 38px;
    min-height: 58px;
    padding: 7px;
  }

  .timeline-photo {
    width: 38px;
    height: 41px;
  }

  .place-card {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 9px;
    padding: 12px;
  }

  .place-pin {
    width: 36px;
    height: 36px;
  }

  .memory-section {
    padding: 10px;
  }
}

@media print {
  .mobile-bottom-nav {
    display: none !important;
  }
}

/* Sách gia phả: bản dàn trang riêng để xem trước, in và lưu PDF. */
.family-book-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(43, 25, 12, 0.58);
  backdrop-filter: blur(7px);
}

.family-book-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  background: transparent;
}

.family-book-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1220px, 100%);
  height: min(94dvh, 940px);
  overflow: hidden;
  border: 1px solid #c4913c;
  border-radius: 8px;
  background: #e8d9aa;
  box-shadow: 0 28px 80px rgba(37, 20, 9, 0.38);
}

.family-book-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid #c99d54;
  background: #fff9df;
}

.family-book-toolbar > div,
.family-book-toolbar > div > span,
.family-book-toolbar > div:last-child {
  display: flex;
  align-items: center;
}

.family-book-toolbar > div {
  gap: 10px;
}

.family-book-toolbar > div > span {
  align-items: flex-start;
  flex-direction: column;
  gap: 1px;
}

.family-book-toolbar > div:last-child {
  gap: 8px;
}

.family-book-toolbar-title {
  min-width: 250px;
}

.family-book-toolbar-title .book-close-btn {
  display: inline-grid;
  width: 36px;
  min-width: 36px;
  height: 36px;
  margin-left: auto;
}

.book-print-scope {
  display: grid;
  gap: 2px;
  min-width: 148px;
}

.book-paper-scope {
  min-width: 205px;
}

.book-print-scope span {
  color: #785b3d;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.book-print-scope select {
  width: 100%;
  min-height: 38px;
  padding: 7px 28px 7px 10px;
  border: 1px solid #d4a85e;
  border-radius: 6px;
  background: #fffdf0;
  color: #4c2b19;
  font: 700 12px var(--font-body);
}

.family-book-toolbar > div:first-child > .icon {
  width: 28px;
  height: 28px;
  color: #842e1e;
}

.family-book-toolbar strong,
.family-book-toolbar small {
  display: block;
}

.family-book-toolbar strong {
  color: #4c2214;
  font-family: var(--font-title);
  font-size: 18px;
}

.family-book-toolbar small {
  color: #766043;
  font-size: 11px;
}

.family-book-toolbar .btn,
.family-book-toolbar .ghost-btn {
  min-height: 42px;
}

.family-book-toolbar .btn .icon {
  width: 17px;
  height: 17px;
}

.family-book-toolbar .btn:disabled .icon {
  animation: book-print-spin 0.9s linear infinite;
}

.family-pdf-capture {
  position: fixed;
  top: 0;
  left: -20000px;
  z-index: -1000;
  width: 1600px;
  overflow: visible;
  pointer-events: none;
}

.family-pdf-capture .family-book-overlay {
  position: static;
  display: block;
  padding: 0;
  background: transparent;
}

.family-pdf-capture .family-book-backdrop,
.family-pdf-capture .family-book-toolbar {
  display: none !important;
}

.family-pdf-capture .family-book-shell,
.family-pdf-capture .family-book-pages {
  width: 1600px;
  height: auto;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.family-pdf-capture .family-book-pages {
  padding: 0;
}

.family-pdf-capture .book-page {
  width: 1600px;
  margin: 0;
  box-shadow: none;
}

.family-pdf-capture .book-tree-canvas .person-card {
  overflow: hidden;
}

.family-pdf-capture .book-tree-canvas .person-photo,
.family-pdf-capture .book-tree-canvas .deferred-tree-photo {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
  object-fit: contain;
  background: #fff8dc;
}

.family-pdf-capture .book-tree-canvas .deferred-photo-fallback {
  display: none !important;
}

.family-pdf-capture .book-tree-canvas .person-main {
  min-width: 0;
  overflow: visible;
}

.family-pdf-capture .book-tree-canvas .person-name {
  display: block;
  margin-bottom: 4px;
  overflow: visible;
  font-size: 10.5px;
  line-height: 1.12;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.family-pdf-capture .book-tree-canvas .person-name.pdf-name-long {
  font-size: 9.5px;
}

.family-pdf-capture .book-tree-canvas .person-name.pdf-name-very-long {
  font-size: 8.5px;
}

.family-pdf-capture .book-tree-canvas .person-name .gender-symbol {
  display: inline-grid;
  margin-right: 3px;
  vertical-align: -2px;
}

.family-pdf-capture .book-tree-canvas .person-meta,
.family-pdf-capture .book-tree-canvas .status-line {
  overflow: visible;
  font-size: 8.5px;
  line-height: 1.2;
  text-overflow: clip;
  white-space: normal;
}

.family-pdf-capture .book-tree-canvas .achievement-pill,
.family-pdf-capture .book-tree-canvas .viewer-card-label {
  display: none !important;
}

@keyframes book-print-spin {
  to {
    transform: rotate(360deg);
  }
}

.family-book-pages {
  overflow: auto;
  padding: 22px;
  overscroll-behavior: contain;
}

.book-page {
  position: relative;
  box-sizing: border-box;
  width: min(1120px, 100%);
  min-height: 0;
  aspect-ratio: 297 / 210;
  margin: 0 auto 24px;
  padding: 38px 42px 28px;
  overflow: hidden;
  border: 1px solid rgba(149, 94, 32, 0.52);
  background:
    linear-gradient(rgba(255, 252, 230, 0.94), rgba(250, 241, 196, 0.94)),
    var(--family-bg) center / cover no-repeat,
    #fff8d7;
  color: #432817;
  box-shadow: 0 14px 34px rgba(72, 42, 16, 0.22);
}

.book-page::before,
.book-page::after {
  position: absolute;
  pointer-events: none;
  content: "";
}

.book-page::before {
  inset: 12px;
  border: 1px solid rgba(145, 79, 30, 0.38);
}

.book-page::after {
  inset: 17px;
  border: 1px solid rgba(192, 148, 68, 0.28);
}

.book-cover {
  display: grid;
  place-items: center;
  min-height: 0;
  background:
    linear-gradient(135deg, rgba(255, 249, 211, 0.95), rgba(240, 213, 132, 0.91)),
    var(--family-bg) center / cover no-repeat,
    #f7e6a9;
  text-align: center;
}

.book-cover-frame {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  width: min(760px, 86%);
  padding: 48px 42px;
  border-top: 2px solid #8d3823;
  border-bottom: 2px solid #8d3823;
}

.book-cover-kicker {
  color: #7e4c26;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.book-cover-mark {
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  margin: 24px 0 15px;
  border: 2px solid #a54b28;
  outline: 1px solid #c8953d;
  outline-offset: 6px;
  border-radius: 50%;
  background: rgba(255, 248, 213, 0.82);
  color: #842c1b;
  font-family: var(--font-title);
  font-size: 30px;
  font-weight: 900;
}

.book-cover h1 {
  margin: 5px 0 3px;
  color: #561f15;
  font-family: var(--font-ceremony);
  font-size: 58px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0;
}

.book-cover h2 {
  margin: 8px 0 3px;
  color: #4e2a18;
  font-family: var(--font-title);
  font-size: 23px;
}

.book-cover p {
  margin: 0;
  color: #7a4d29;
  font-weight: 800;
}

.book-flourish {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(360px, 72%);
  margin: 10px 0;
  color: #a04a27;
}

.book-flourish span {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, #a04a27);
}

.book-flourish span:last-child {
  background: linear-gradient(90deg, #a04a27, transparent);
}

.book-flourish b {
  font-size: 10px;
}

.book-cover dl {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(520px, 100%);
  margin: 32px 0 22px;
  border-top: 1px solid rgba(141, 77, 31, 0.38);
  border-bottom: 1px solid rgba(141, 77, 31, 0.38);
}

.book-cover dl div {
  padding: 14px 10px;
}

.book-cover dl div + div {
  border-left: 1px solid rgba(141, 77, 31, 0.28);
}

.book-cover dt {
  color: #76281b;
  font-family: var(--font-title);
  font-size: 25px;
  font-weight: 900;
}

.book-cover dd {
  margin: 2px 0 0;
  color: #745b3b;
  font-size: 12px;
  font-weight: 700;
}

.book-cover-frame > small {
  color: #816b4c;
  font-size: 11px;
}

.book-page-head {
  position: relative;
  z-index: 2;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(135, 71, 31, 0.42);
}

.book-page-head span {
  color: #8a3b24;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.book-page-head h2 {
  margin: 4px 0 0;
  color: #482215;
  font-family: var(--font-title);
  font-size: 27px;
}

.book-page > footer {
  position: absolute;
  right: 42px;
  bottom: 18px;
  left: 42px;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid rgba(139, 77, 35, 0.3);
  color: #7b6245;
  font-size: 10px;
}

.book-tree-overview {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.book-preview-poster .book-cover,
.book-preview-poster .book-generation-page,
.book-preview-generations .book-cover,
.book-preview-generations .book-tree-overview {
  display: none;
}

.book-preview-poster .book-tree-overview {
  aspect-ratio: var(--book-preview-ratio, 297 / 210);
}

.book-tree-stage {
  position: relative;
  z-index: 2;
  min-height: 570px;
  overflow: hidden;
  border: 1px solid rgba(148, 99, 38, 0.28);
  background: rgba(255, 250, 222, 0.56);
}

.book-tree-canvas {
  transform-origin: 0 0;
  pointer-events: none;
  will-change: auto;
}

.book-tree-canvas .person-card {
  box-shadow: 0 5px 10px rgba(72, 42, 16, 0.12);
}

.book-person-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(var(--book-columns, 4), minmax(0, 1fr));
  gap: 12px;
  width: min(100%, calc(var(--book-columns, 4) * 245px + (var(--book-columns, 4) - 1) * 12px));
  margin: 0 auto;
  padding-bottom: 32px;
}

.book-person-card {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 10px;
  min-height: 132px;
  padding: 10px;
  border: 1px solid rgba(176, 123, 49, 0.52);
  border-left: 4px solid var(--green);
  background: rgba(255, 253, 236, 0.88);
}

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

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

.book-person-photo {
  display: grid;
  place-items: center;
  width: 62px;
  height: 82px;
  border: 1px solid #d5b264;
  border-radius: 5px;
  object-fit: cover;
  background: #fff2bf;
}

.book-person-fallback {
  color: #7d291a;
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 900;
}

.book-person-card h4 {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 1px 0 5px;
  color: #482215;
  font-family: var(--font-title);
  font-size: 14px;
  line-height: 1.25;
}

.book-person-card h4 .icon {
  width: 13px;
  height: 13px;
}

.book-person-card p,
.book-person-card small {
  display: block;
  margin: 0 0 4px;
  color: #705b40;
  font-size: 9px;
  line-height: 1.35;
}

.book-life {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
  color: #17705a;
  font-size: 9px;
  font-weight: 800;
}

.book-life.deceased {
  color: #a63b2d;
}

.book-life .icon {
  width: 11px;
  height: 11px;
}

@media (max-width: 720px) {
  .ritual-hero h2 {
    font-size: 40px;
  }

  .ritual-paper-head h1 {
    font-size: 38px;
  }

  .family-book-overlay {
    padding: 0;
  }

  .family-book-shell {
    width: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .family-book-toolbar {
    align-items: stretch;
    flex-wrap: wrap;
    padding: 9px 10px;
  }

  .family-book-toolbar > div {
    width: 100%;
  }

  .family-book-toolbar-title {
    min-width: 0;
  }

  .family-book-toolbar-title .book-close-btn {
    display: inline-grid;
    width: 36px;
    min-width: 36px;
    height: 36px;
  }

  .family-book-toolbar > div:last-child {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    gap: 7px;
  }

  .family-book-toolbar > div:first-child small {
    display: none;
  }

  .book-print-scope {
    width: 100%;
    min-width: 0;
  }

  .book-paper-scope {
    min-width: 0;
  }

  .book-print-scope span {
    display: none;
  }

  .family-book-toolbar .btn,
  .family-book-toolbar .ghost-btn {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    font-size: 12px;
  }

  .family-book-toolbar .book-download-btn {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .family-book-pages {
    padding: 8px;
  }

  .book-page {
    min-height: 560px;
    margin-bottom: 10px;
    padding: 25px 22px 40px;
  }

  .book-page::before {
    inset: 7px;
  }

  .book-page::after {
    inset: 11px;
  }

  .book-cover {
    min-height: 620px;
  }

  .book-cover-frame {
    width: 92%;
    padding: 34px 12px;
  }

  .book-cover h1 {
    font-size: 40px;
  }

  .book-cover h2 {
    font-size: 18px;
  }

  .book-cover dl {
    margin-top: 24px;
  }

  .book-cover dl div {
    padding: 10px 4px;
  }

  .book-cover dd {
    font-size: 9px;
  }

  .book-page-head h2 {
    font-size: 21px;
  }

  .book-tree-stage {
    min-height: 430px;
  }

  .book-person-grid {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .book-person-card {
    min-height: 112px;
  }

  .book-page > footer {
    right: 22px;
    left: 22px;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 0;
  }

  @page family-book-a4 {
    size: 297mm 210mm;
    margin: 0;
  }

  @page family-book-a3 {
    size: 420mm 297mm;
    margin: 0;
  }

  @page family-poster-a3 {
    size: 420mm 297mm;
    margin: 0;
  }

  @page family-poster-a2 {
    size: 594mm 420mm;
    margin: 0;
  }

  @page family-poster-a1 {
    size: 841mm 594mm;
    margin: 0;
  }

  @page family-poster-a0 {
    size: 1189mm 841mm;
    margin: 0;
  }

  @page family-poster-90x60 {
    size: 900mm 600mm;
    margin: 0;
  }

  @page family-poster-120x80 {
    size: 1200mm 800mm;
    margin: 0;
  }

  body.book-printing,
  body.book-printing * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  body.book-printing {
    width: 100vw !important;
    min-width: 100vw !important;
    margin: 0 !important;
    background: #fff !important;
  }

  body.book-printing .app-shell,
  body.book-printing .family-book-overlay,
  body.book-printing .family-book-shell,
  body.book-printing .family-book-pages {
    width: 100vw !important;
    min-width: 100vw !important;
    max-width: none !important;
    margin: 0 !important;
  }

  body.book-printing.book-paper-a4 {
    --print-page-width: 297mm;
    --print-page-height: 210mm;
  }

  body.book-printing.book-paper-a3 {
    --print-page-width: 420mm;
    --print-page-height: 297mm;
  }

  body.book-printing.book-paper-a2 {
    --print-page-width: 594mm;
    --print-page-height: 420mm;
  }

  body.book-printing.book-paper-a1 {
    --print-page-width: 841mm;
    --print-page-height: 594mm;
  }

  body.book-printing.book-paper-a0 {
    --print-page-width: 1189mm;
    --print-page-height: 841mm;
  }

  body.book-printing.book-paper-90x60 {
    --print-page-width: 900mm;
    --print-page-height: 600mm;
  }

  body.book-printing.book-paper-120x80 {
    --print-page-width: 1200mm;
    --print-page-height: 800mm;
  }

  body.book-printing .app-shell > :not(.family-book-overlay) {
    display: none !important;
  }

  body.book-printing .family-book-overlay {
    position: static;
    display: block;
    padding: 0;
    background: #fff;
  }

  body.book-printing .family-book-shell,
  body.book-printing .family-book-pages {
    display: block;
    width: auto;
    height: auto;
    overflow: visible;
    border: 0;
    background: #fff;
    box-shadow: none;
  }

  body.book-printing .family-book-pages {
    padding: 0;
  }

  body.book-printing .book-page {
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    aspect-ratio: auto;
    margin: 0;
    padding: 11mm 12mm 10mm;
    border: 0;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }

  body.book-printing .book-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  body.book-printing .book-cover-frame {
    padding-top: 18mm;
    padding-bottom: 18mm;
  }

  body.book-printing .book-cover h1 {
    font-size: 42pt;
  }

  body.book-printing .book-tree-stage {
    min-height: 160mm;
  }

  body.book-printing.book-mode-full.book-paper-a4 .book-page,
  body.book-printing.book-mode-generations.book-paper-a4 .book-page {
    page: family-book-a4;
  }

  body.book-printing.book-mode-full.book-paper-a3 .book-page,
  body.book-printing.book-mode-generations.book-paper-a3 .book-page {
    page: family-book-a3;
  }

  body.book-printing.book-mode-poster.book-paper-a3 .book-tree-overview {
    page: family-poster-a3;
  }

  body.book-printing.book-mode-poster.book-paper-a2 .book-tree-overview {
    page: family-poster-a2;
  }

  body.book-printing.book-mode-poster.book-paper-a1 .book-tree-overview {
    page: family-poster-a1;
  }

  body.book-printing.book-mode-poster.book-paper-a0 .book-tree-overview {
    page: family-poster-a0;
  }

  body.book-printing.book-mode-poster.book-paper-90x60 .book-tree-overview {
    page: family-poster-90x60;
  }

  body.book-printing.book-mode-poster.book-paper-120x80 .book-tree-overview {
    page: family-poster-120x80;
  }

  body.book-printing.book-mode-poster .book-tree-overview {
    padding: 18mm 22mm 16mm;
    break-after: auto;
    page-break-after: auto;
  }

  body.book-printing.book-mode-poster .book-tree-overview .book-page-head {
    margin-bottom: 8mm;
    padding-bottom: 4mm;
  }

  body.book-printing.book-mode-poster .book-tree-overview .book-page-head span {
    font-size: 15pt;
  }

  body.book-printing.book-mode-poster .book-tree-overview .book-page-head h2 {
    font-size: 34pt;
  }

  body.book-printing.book-mode-poster .book-tree-overview .book-tree-stage {
    height: 100%;
    min-height: 0;
  }

  body.book-printing.book-mode-poster .book-tree-overview > footer {
    right: 22mm;
    bottom: 6mm;
    left: 22mm;
    font-size: 14pt;
  }

  body.book-printing.book-mode-poster .book-cover,
  body.book-printing.book-mode-poster .book-generation-page {
    display: none !important;
  }

  body.book-printing.book-mode-generations .book-cover,
  body.book-printing.book-mode-generations .book-tree-overview {
    display: none !important;
  }

  body.book-printing .book-person-grid {
    grid-template-columns: repeat(var(--book-columns, 4), minmax(0, 1fr));
    gap: 3mm;
    width: min(100%, calc(var(--book-columns, 4) * 62mm + (var(--book-columns, 4) - 1) * 3mm));
  }

  body.book-printing .book-person-card {
    min-height: 37mm;
    padding: 2.5mm;
  }

  body.book-printing .book-page > footer {
    right: 12mm;
    bottom: 5mm;
    left: 12mm;
  }
}

@media (max-width: 640px) {
  .topbar,
  .pan-pad {
    backdrop-filter: none;
  }
}

/* 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);
}

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

.branch-segmented 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.is-viewer {
  outline-color: rgba(197, 121, 24, 0.82);
  box-shadow:
    0 0 0 5px rgba(255, 222, 104, 0.26),
    0 16px 28px rgba(74, 42, 13, 0.24);
}

.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) {
  body {
    font-size: 14px;
  }

  .topbar {
    min-height: 52px;
    align-items: center;
    flex-direction: row;
    gap: 8px;
    padding: 6px 8px;
  }

  .brand {
    flex: 1 1 auto;
    gap: 7px;
    min-width: 0;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 6px;
    font-size: 14px;
  }

  .brand h1 {
    display: -webkit-box;
    overflow: hidden;
    max-width: 42vw;
    font-size: 15px;
    line-height: 1.12;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .nav-actions {
    flex: 0 0 auto;
    gap: 5px;
    justify-content: flex-end;
  }

  .nav-actions .btn,
  .nav-actions .ghost-btn {
    min-height: 30px;
    padding: 6px 8px;
    border-radius: 7px;
    font-size: 13px;
    line-height: 1;
  }

  .workspace {
    padding: 8px;
  }

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

  .pan-pad {
    display: none;
  }

  .floating-tools {
    top: 62px;
    right: 8px;
  }

  .detail-drawer {
    top: 62px;
  }

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

  .brand p {
    display: none;
  }
}

/* Typography polish */
:root {
  --font-ui: "Be Vietnam Pro", Arial, Helvetica, sans-serif;
  --font-title: "Noto Serif", "Be Vietnam Pro", Georgia, serif;
}

* {
  letter-spacing: 0;
}

body {
  font-family: var(--font-ui);
  font-weight: 400;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: var(--font-ui);
}

.brand h1,
.login-panel h2,
.drawer-head h2,
.form-wrap h2,
.panel-head h2 {
  font-family: var(--font-title);
  font-weight: 700;
  line-height: 1.22;
}

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

.brand p,
.notice,
.person-meta,
.info-grid dt,
.field label,
.menu-section h3,
th {
  font-weight: 600;
}

.brand-mark,
.person-name,
.admin-person-row strong,
.table-name,
.status-line,
.mini-badge,
.chip {
  font-family: var(--font-ui);
}

.person-name {
  font-size: 13px;
  font-weight: 700;
}

.person-meta {
  font-size: 11.5px;
  line-height: 1.45;
}

.btn,
.ghost-btn,
.danger-btn,
.text-btn {
  font-weight: 700;
}

.info-grid dd {
  font-weight: 500;
  line-height: 1.55;
}

.drawer-head h2 {
  font-size: 25px;
}

.login-panel h2 {
  font-size: 27px;
}

@media (max-width: 560px) {
  .brand h1 {
    font-size: 15px;
    line-height: 1.18;
  }

  .login-panel h2 {
    font-size: 22px;
  }
}

@media (max-width: 560px) {
  .kinship-fields {
    grid-template-columns: 1fr;
  }

  .kinship-head {
    align-items: stretch;
    flex-direction: column;
  }

  .kinship-fab {
    right: 14px;
    bottom: 14px;
    width: 54px;
    height: 54px;
  }

  .kinship-fab span {
    display: none;
  }
}

/* Bảng vàng vinh danh */
.view-switch-fab,
.kinship-fab {
  background: linear-gradient(145deg, #b7461f, #6f2015);
}

.view-switch-fab {
  position: fixed;
  right: 22px;
  bottom: 96px;
  z-index: 35;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 225, 153, 0.9);
  border-radius: 50%;
  background: linear-gradient(145deg, #17705a, #15493f);
  color: #fff8dd;
  box-shadow: 0 15px 32px rgba(36, 56, 36, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.view-switch-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 19px 38px rgba(36, 56, 36, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.view-switch-fab .icon {
  width: 27px;
  height: 27px;
  stroke-width: 2.2;
}

.view-switch-fab span {
  position: absolute;
  right: 68px;
  bottom: 10px;
  width: max-content;
  max-width: 220px;
  padding: 9px 11px;
  border: 1px solid rgba(198, 146, 57, 0.55);
  border-radius: 8px;
  background: rgba(255, 252, 235, 0.98);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(53, 30, 13, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateX(6px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.view-switch-fab:hover span,
.view-switch-fab:focus-visible span {
  opacity: 1;
  transform: translateX(0);
}

.honor-board {
  min-height: calc(100vh - 112px);
  margin: -16px -18px -18px;
  padding: 34px clamp(16px, 4vw, 64px) 72px;
  background:
    linear-gradient(90deg, rgba(54, 16, 12, 0.93), rgba(113, 35, 23, 0.84) 32%, rgba(116, 55, 22, 0.8) 68%, rgba(38, 65, 48, 0.9)),
    linear-gradient(rgba(75, 23, 16, 0.52), rgba(48, 42, 22, 0.72)),
    var(--family-bg) center top / cover fixed,
    #5c2117;
  color: #fff9e8;
}

.honor-banner {
  position: relative;
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px 0 28px;
  border-bottom: 1px solid rgba(255, 215, 125, 0.55);
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 18px 22px;
  align-items: center;
}

.honor-banner::before,
.honor-banner::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255, 229, 155, 0.3);
}

.honor-banner::before {
  top: 0;
}

.honor-banner::after {
  bottom: 4px;
}

.honor-emblem {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 224, 138, 0.75);
  border-radius: 50%;
  color: #ffe09a;
  background: rgba(86, 29, 17, 0.72);
  box-shadow: inset 0 0 0 5px rgba(255, 221, 126, 0.08), 0 14px 30px rgba(23, 9, 6, 0.24);
}

.honor-emblem .icon {
  width: 38px;
  height: 38px;
}

.honor-heading p {
  margin: 0 0 6px;
  color: #f2d49b;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.honor-heading h2 {
  margin: 0;
  color: #fff1bd;
  font-family: var(--font-title);
  font-size: clamp(27px, 4vw, 46px);
  line-height: 1.15;
  text-shadow: 0 3px 18px rgba(30, 9, 5, 0.42);
}

.honor-heading > span {
  display: block;
  max-width: 820px;
  margin-top: 8px;
  color: rgba(255, 249, 229, 0.85);
  font-size: 14px;
}

.honor-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid rgba(255, 218, 128, 0.26);
  border-bottom: 1px solid rgba(255, 218, 128, 0.26);
}

.honor-stats div {
  min-width: 0;
  padding: 13px 16px;
  border-right: 1px solid rgba(255, 218, 128, 0.24);
}

.honor-stats div:last-child {
  border-right: 0;
}

.honor-stats strong,
.honor-stats span {
  display: block;
}

.honor-stats strong {
  color: #ffe39d;
  font-family: var(--font-title);
  font-size: 25px;
}

.honor-stats span {
  color: rgba(255, 249, 229, 0.75);
  font-size: 11px;
  font-weight: 700;
}

.honor-toolbar {
  max-width: 1240px;
  margin: 22px auto 18px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(210px, 280px);
  gap: 12px;
  align-items: end;
}

.honor-search {
  width: 100%;
  min-width: 0;
  background: rgba(255, 251, 232, 0.96);
}

.honor-filter-label {
  display: grid;
  gap: 6px;
}

.honor-filter-label span {
  color: #f4dca8;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.honor-filter-label select {
  min-height: 46px;
  width: 100%;
  padding: 9px 34px 9px 11px;
  border: 1px solid rgba(229, 189, 100, 0.72);
  border-radius: 8px;
  background: rgba(255, 251, 232, 0.96);
  color: #432116;
  font-weight: 700;
}

.honor-grid {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.honor-card {
  position: relative;
  min-width: 0;
  padding: 16px;
  overflow: hidden;
  border: 1px solid rgba(219, 173, 74, 0.78);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 253, 239, 0.98), rgba(255, 241, 195, 0.97));
  color: #321b10;
  box-shadow: 0 18px 34px rgba(25, 9, 6, 0.28), inset 0 3px 0 rgba(146, 43, 24, 0.76);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.honor-card:hover,
.honor-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 24px 42px rgba(25, 9, 6, 0.36), inset 0 3px 0 #176b55;
  outline: none;
}

.honor-card-top {
  display: grid;
  grid-template-columns: 34px 76px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
}

.honor-rank {
  align-self: start;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid #c88a28;
  border-radius: 50%;
  background: #7d2919;
  color: #ffe9aa;
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 700;
}

.honor-card .photo-button {
  width: 76px;
  height: 92px;
  padding: 0;
}

.honor-photo,
.honor-card-top > .avatar-fallback {
  width: 76px;
  height: 92px;
  border-radius: 6px;
  object-fit: cover;
}

.honor-identity {
  min-width: 0;
}

.honor-level {
  display: inline-block;
  margin-bottom: 5px;
  color: #8b321e;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.honor-identity h3 {
  margin: 0;
  overflow-wrap: anywhere;
  color: #2f160c;
  font-family: var(--font-title);
  font-size: 18px;
  line-height: 1.25;
}

.honor-identity p {
  margin: 6px 0 0;
  color: #7a6044;
  font-size: 12px;
}

.honor-details {
  margin: 14px 0 0;
  padding-top: 11px;
  border-top: 1px solid rgba(174, 119, 42, 0.28);
  display: grid;
  gap: 6px;
}

.honor-details div {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 8px;
}

.honor-details dt {
  color: #806443;
  font-size: 11px;
  font-weight: 700;
}

.honor-details dd {
  margin: 0;
  color: #432116;
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.honor-achievements {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(174, 119, 42, 0.28);
  display: grid;
  gap: 5px;
}

.honor-achievements strong {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #7f2b1b;
  font-size: 11px;
  text-transform: uppercase;
}

.honor-achievements .icon {
  width: 14px;
  height: 14px;
}

.honor-achievements span,
.honor-achievements small {
  color: #59422c;
  font-size: 12px;
  line-height: 1.45;
}

.honor-achievements span::before {
  content: "•";
  margin-right: 7px;
  color: #b54a22;
}

.honor-note {
  margin: 11px 0 0;
  padding-top: 10px;
  border-top: 1px solid rgba(174, 119, 42, 0.28);
  color: #6c5438;
  font-size: 12px;
  line-height: 1.5;
}

.honor-empty {
  grid-column: 1 / -1;
  padding: 56px 20px;
  border-top: 1px solid rgba(255, 221, 139, 0.36);
  border-bottom: 1px solid rgba(255, 221, 139, 0.36);
  text-align: center;
  color: rgba(255, 249, 229, 0.82);
}

.honor-empty .icon {
  width: 42px;
  height: 42px;
  color: #ffe09a;
}

.honor-empty h3 {
  margin: 10px 0 4px;
  font-family: var(--font-title);
  color: #fff0bb;
}

.honor-empty p {
  margin: 0;
}

.login-warning {
  padding: 9px 10px;
  border-left: 3px solid #b54828;
  background: rgba(255, 235, 201, 0.8);
}

.login-security {
  margin: 8px 0 14px;
  padding: 9px 11px;
  border-left: 3px solid #9f3f1e;
  background: rgba(255, 239, 176, 0.58);
  color: #6d431f;
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .honor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .honor-board {
    min-height: calc(100dvh - 62px);
    margin: -8px;
    padding: 22px 12px 90px;
    background-attachment: scroll;
  }

  .honor-banner {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 12px;
    padding-bottom: 20px;
  }

  .honor-emblem {
    width: 54px;
    height: 54px;
  }

  .honor-emblem .icon {
    width: 29px;
    height: 29px;
  }

  .honor-heading h2 {
    font-size: 25px;
  }

  .honor-heading > span {
    grid-column: 1 / -1;
    font-size: 12px;
  }

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

  .honor-stats div:nth-child(2) {
    border-right: 0;
  }

  .honor-stats div:nth-child(-n + 2) {
    border-bottom: 1px solid rgba(255, 218, 128, 0.24);
  }

  .honor-toolbar,
  .honor-grid {
    grid-template-columns: 1fr;
  }

  .honor-card {
    padding: 13px;
  }

  .honor-card-top {
    grid-template-columns: 30px 66px minmax(0, 1fr);
    gap: 9px;
  }

  .honor-card .photo-button,
  .honor-photo,
  .honor-card-top > .avatar-fallback {
    width: 66px;
    height: 82px;
  }

  .honor-identity h3 {
    font-size: 16px;
  }

  .view-switch-fab {
    right: 14px;
    bottom: 78px;
    width: 52px;
    height: 52px;
  }

  .view-switch-fab span {
    display: none;
  }
}

/* Integrated person picker and compact mobile layout */
.searchable-person-select {
  position: relative;
  display: block;
  min-width: 0;
}

.searchable-person-select > select {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
  pointer-events: none;
}

.person-combobox {
  position: relative;
  min-width: 0;
}

.person-combobox > .icon {
  position: absolute;
  top: 12px;
  left: 11px;
  z-index: 2;
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

.person-combobox input.person-select-input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px 9px 42px;
  border: 1px solid rgba(151, 91, 34, 0.48);
  border-radius: 8px;
  outline: 0;
  background: rgba(255, 253, 243, 0.98);
  color: var(--ink);
}

.person-combobox input.person-select-input:focus {
  border-color: #9c4a23;
  box-shadow: 0 0 0 3px rgba(156, 74, 35, 0.12);
}

.person-combobox input.person-select-input:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.person-select-results {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  left: 0;
  z-index: 80;
  max-height: 230px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid rgba(151, 91, 34, 0.5);
  border-radius: 8px;
  background: #fffdf3;
  box-shadow: 0 14px 30px rgba(70, 38, 13, 0.22);
}

.person-select-results[hidden] {
  display: none;
}

.person-select-results button {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.person-select-results button:hover,
.person-select-results button.active,
.person-select-results button.keyboard-active {
  background: #ffedb4;
}

.person-select-results p {
  margin: 0;
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

.compact-personal-kinship {
  margin: 0 0 12px;
  padding: 8px 10px;
  border: 1px solid #d9a441;
  border-left: 3px solid #9f2f1b;
  border-radius: 6px;
  background: #fff4c9;
  color: #5e2818;
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 640px) {
  body {
    overflow-x: hidden;
    font-size: 13px;
  }

  .topbar {
    min-height: 54px;
    gap: 6px;
    padding: 6px 8px;
  }

  .brand {
    min-width: 0;
    gap: 7px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    font-size: 13px;
  }

  .brand h1 {
    max-width: 46vw;
    overflow: hidden;
    font-size: 16px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand p {
    max-width: 46vw;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-actions {
    flex: 0 0 auto;
    gap: 5px;
  }

  .nav-actions a[href="/"],
  .nav-actions a[href="./"] {
    display: none;
  }

  .nav-actions .btn,
  .nav-actions .ghost-btn {
    min-height: 34px;
    padding: 6px 9px;
    font-size: 12px;
    white-space: nowrap;
  }

  .workspace {
    padding: 6px;
  }

  .detail-drawer {
    top: 56px;
    right: 0;
    bottom: 0;
    width: 100vw;
    border-radius: 0;
  }

  .drawer-head {
    gap: 8px;
    padding: 10px 12px;
  }

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

  .drawer-head .notice {
    margin-top: 4px;
    font-size: 12px;
  }

  .drawer-head .ghost-btn {
    min-height: 38px;
    padding: 7px 10px;
  }

  .drawer-body {
    padding: 10px 12px 24px;
  }

  .compact-personal-kinship {
    margin-bottom: 10px;
    padding: 7px 9px;
    font-size: 12px;
  }

  .profile-hero {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
  }

  .profile-hero > button:first-child,
  .profile-hero > .profile-photo {
    width: 82px;
    height: 106px;
  }

  .chips {
    gap: 5px;
    margin-top: 3px;
  }

  .chip {
    padding: 5px 7px;
    font-size: 11px;
  }

  .info-grid {
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
    gap: 7px 10px;
    margin-top: 14px;
  }

  .info-grid dt,
  .info-grid dd {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .admin-layout {
    gap: 8px;
  }

  .panel-head,
  .form-wrap,
  .viewer-account-box,
  .change-requests-box {
    padding: 11px;
  }

  .person-list {
    height: 280px;
    min-height: 280px;
  }

  .form-wrap {
    max-height: none;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 11px;
  }

  .field.full {
    grid-column: auto;
  }

  .field input,
  .field select,
  .field textarea,
  .person-select-input {
    min-height: 40px;
  }

  .person-select-results {
    max-height: 220px;
  }

  .kinship-panel {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    padding: 12px;
  }

  .kinship-head {
    gap: 8px;
  }

  .kinship-head h2 {
    font-size: 20px;
  }

  .kinship-head p {
    font-size: 11px;
  }

  .kinship-fields {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
}

@media print {
  body {
    background: #fff !important;
  }

  .topbar,
  .floating-tools,
  .ritual-switch-fab,
  .view-switch-fab,
  .kinship-fab,
  .screen-only {
    display: none !important;
  }

  .workspace {
    padding: 0 !important;
  }

  .ritual-detail-page {
    width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 12mm 15mm !important;
    border: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  .ritual-detail-page::before,
  .ritual-detail-page::after {
    display: none !important;
  }

  .ritual-prose {
    max-width: none;
    color: #000;
    font-size: 13pt;
    line-height: 1.65;
  }
}

/* Final mobile overrides keep the app navigation stable across legacy layers. */
@media (max-width: 640px) {
  .viewer-topbar .nav-actions { display: none; }
  .viewer-topbar .brand h1,
  .viewer-topbar .brand p { max-width: calc(100vw - 62px); }
  .workspace { padding-right: 8px; padding-bottom: 94px; padding-left: 8px; }
  .floating-tools { position: fixed; inset: 0; z-index: 150; pointer-events: none; }
  .floating-tools.open { background: rgba(48, 27, 15, 0.32); backdrop-filter: blur(2px); pointer-events: auto; }
  .floating-tools .menu-toggle { display: none; }
  .floating-tools .menu-panel {
    top: auto;
    right: 0;
    bottom: calc(78px + env(safe-area-inset-bottom));
    left: 0;
    width: 100%;
    max-height: min(76dvh, 650px);
    padding: 16px 14px 20px;
    border: 1px solid rgba(126, 65, 25, 0.44);
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    background: rgba(255, 251, 232, 0.995);
    box-shadow: 0 -18px 50px rgba(59, 30, 13, 0.24);
  }
  .view-mode-grid .mobile-primary-duplicate { display: none; }
  .memory-switch-fab,
  .ritual-switch-fab,
  .view-switch-fab,
  .kinship-fab { display: none !important; }
}

/* Heritage Modern v24: one calm visual language for tree, stories and admin. */
:root {
  --bg: #e9efec;
  --panel: #ffffff;
  --panel-2: #f2f6f4;
  --ink: #1c2925;
  --muted: #65736e;
  --line: #cad6d1;
  --green: #1d6255;
  --green-dark: #174f45;
  --coral: #b34e43;
  --amber: #b88932;
  --cyan: #477b8a;
  --accent: #1d6255;
  --accent-soft: #e3efeb;
  --danger: #a54038;
  --shadow: 0 14px 34px rgba(25, 48, 41, 0.11);
  --shadow-raised: 0 20px 48px rgba(25, 48, 41, 0.16);
  --font-ui: "Be Vietnam Pro", Arial, Helvetica, sans-serif;
  --font-title: "Lora", "Noto Serif", Georgia, serif;
}

body {
  background: #e9efec;
  color: var(--ink);
}

body::before {
  display: none;
}

body,
button,
input,
select,
textarea {
  font-family: var(--font-ui);
}

body {
  font-size: 14px;
  line-height: 1.55;
}

h1,
h2,
h3,
.brand h1,
.view-page-head h2,
.my-family-hero h2,
.my-family-group h3,
.ritual-card-body h3,
.memory-card h3,
.honor-identity h3,
.drawer-head h2,
.login-panel h2,
.form-wrap h2,
.panel-head h2 {
  font-family: var(--font-title);
  letter-spacing: 0;
}

.topbar {
  min-height: 72px;
  padding: 10px 22px;
  border: 0;
  border-bottom: 1px solid rgba(29, 98, 85, 0.2);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 28px rgba(25, 48, 41, 0.08);
}

.brand {
  gap: 13px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border: 1px solid #c99b45;
  border-radius: 8px;
  background: #174f45;
  color: #fffaf0;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.09), 0 7px 18px rgba(23, 79, 69, 0.2);
  font-size: 16px;
  font-weight: 700;
}

.brand h1 {
  color: #1d2b27;
  font-size: 21px;
  font-weight: 700;
}

.brand p {
  color: #697671;
  font-size: 12px;
  font-weight: 500;
}

.workspace {
  min-height: calc(100vh - 72px);
  padding: 18px;
  background: #e9efec;
}

.btn,
.ghost-btn,
.danger-btn,
.text-btn {
  min-height: 42px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 650;
  box-shadow: none;
}

.btn {
  border: 1px solid #174f45;
  background: #174f45;
  color: #fff;
}

.btn:hover {
  background: #103f37;
  box-shadow: 0 8px 20px rgba(23, 79, 69, 0.18);
}

.ghost-btn {
  border: 1px solid #bac9c3;
  background: #fff;
  color: #23443b;
}

.ghost-btn:hover {
  border-color: #7ba095;
  background: #f2f7f5;
}

.danger-btn {
  border-color: #e0bbb7;
  background: #fff7f6;
  color: #923b34;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(47, 117, 101, 0.24);
  outline-offset: 2px;
}

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

.menu-toggle {
  width: 46px;
  height: 46px;
  border: 1px solid #bccbc5;
  background: #fff;
  color: #174f45;
  box-shadow: 0 10px 26px rgba(25, 48, 41, 0.12);
}

.menu-panel {
  width: min(372px, calc(100vw - 28px));
  border: 1px solid #c5d2cd;
  background: rgba(255, 255, 255, 0.985);
  box-shadow: var(--shadow-raised);
}

.menu-section {
  border-color: #e1e8e5;
}

.menu-section h3,
.view-page-head p,
.honor-heading p,
.ritual-category,
.ritual-category-filter span,
.honor-filter-label span {
  color: #526f66;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.searchbar,
.field input,
.field select,
.field textarea,
.readonly-box,
.person-combobox input.person-select-input,
.ritual-category-filter select,
.honor-filter-label select {
  border: 1px solid #c6d2cd;
  background: #fff;
  color: var(--ink);
  box-shadow: none;
}

.searchbar:focus-within,
.field input:focus,
.field select:focus,
.field textarea:focus,
.person-combobox input.person-select-input:focus {
  border-color: #4f8b7d;
  box-shadow: 0 0 0 3px rgba(47, 117, 101, 0.12);
}

.viewer-suggestion,
.admin-suggestion,
.person-select-results {
  border-color: #d1dcd7;
  background: #fff;
  box-shadow: 0 12px 28px rgba(25, 48, 41, 0.12);
}

.viewer-suggestion:hover,
.admin-suggestion:hover,
.person-select-results button:hover,
.person-select-results button.active,
.person-select-results button.keyboard-active {
  border-color: #7ca297;
  background: #edf5f2;
}

.segmented,
.zoom-controls,
.branch-segmented {
  border-color: #cad6d1;
  background: #f3f6f5;
}

.segmented button.active,
.zoom-controls button.active,
.branch-segmented button.active {
  background: #174f45;
  color: #fff;
}

.stats-menu div:not(:first-child) {
  border-color: #d5dfdb;
  background: #f5f8f7;
}

.stats-menu strong {
  color: #174f45;
  font-family: var(--font-title);
  font-weight: 700;
}

.tree-viewport {
  border: 1px solid #aabeb6;
  background:
    linear-gradient(rgba(248, 250, 244, 0.7), rgba(239, 245, 237, 0.78)),
    var(--family-bg) center center / cover no-repeat,
    #edf3ec;
  box-shadow: 0 18px 42px rgba(25, 48, 41, 0.12), inset 0 0 0 7px rgba(255, 255, 255, 0.42);
}

.edge-halo {
  stroke: rgba(247, 250, 247, 0.96);
}

.edge {
  stroke: #557b72;
}

.spouse-line {
  stroke: #b6584f;
}

.person-card {
  border: 1px solid #bfcfc9;
  border-left: 5px solid #276c5c;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 8px 20px rgba(25, 48, 41, 0.13);
}

.person-card:hover {
  box-shadow: 0 14px 28px rgba(25, 48, 41, 0.18);
}

.person-card.is-viewer {
  outline-color: #c09039;
  box-shadow: 0 0 0 5px rgba(192, 144, 57, 0.16), 0 13px 28px rgba(25, 48, 41, 0.16);
}

.person-card.male { border-left-color: #27705f; }
.person-card.female { border-left-color: #b65349; }
.person-card.other { border-left-color: #477b8a; }

.person-photo,
.avatar-fallback {
  border: 1px solid #d4ddd9;
  background: #edf3f0;
  box-shadow: none;
}

.avatar-fallback {
  color: #174f45;
}

.person-name {
  color: #192823;
  font-weight: 650;
}

.person-meta {
  color: #6c7874;
  font-weight: 500;
}

.achievement-pill,
.chip,
.mini-badge {
  border: 1px solid #dce5e1;
  background: #f3f7f5;
}

.list-panel,
.admin-panel,
.login-panel,
.detail-drawer,
.my-family-dashboard,
.fan-page,
.timeline-page,
.places-page {
  border: 1px solid #c8d5d0;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
}

.drawer-head {
  border-bottom-color: #d9e2de;
  background: #f4f7f6;
}

.drawer-head h2,
.login-panel h2,
.view-page-head h2 {
  color: #1c302a;
  font-weight: 700;
}

.my-family-hero {
  border-color: #c9d8d2;
  background: #f2f7f5;
}

.my-family-hero p {
  color: #326f60;
}

.my-family-hero h2,
.my-family-group h3,
.section-heading h3 {
  color: #213b34;
}

.my-family-summary {
  border-color: #c9d8d2;
}

.my-family-summary strong {
  color: #a4473e;
  font-family: var(--font-title);
}

.dashboard-actions button,
.my-family-group,
.upcoming-panel,
.timeline-event,
.place-card {
  border-color: #d2ddd8;
  background: #fff;
  box-shadow: none;
}

.dashboard-actions button:hover,
.my-family-person:hover,
.upcoming-item:hover,
.timeline-event:hover {
  border-color: #80a59a;
  background: #f1f7f4;
}

.upcoming-item time {
  background: #f3e7c9;
  color: #765b24;
}

.upcoming-item.birth time {
  background: #e1efe9;
  color: #1d6255;
}

.upcoming-item.memorial time {
  background: #f4e3e1;
  color: #994239;
}

.view-page-head > small,
.notice,
.menu-help,
.stats-menu span {
  color: #6c7974;
  font-weight: 500;
}

.directory-head,
.directory-search,
.mobile-directory-card {
  border-color: #d2ddd8;
  background: #fff;
}

.mobile-directory-card:active {
  background: #edf5f2;
}

.admin-person-row.active,
.admin-person-row:hover {
  border-color: #7ca297;
  background: #eaf3f0;
}

.form-wrap,
.viewer-account-box,
.storage-box,
.change-request,
.permission-note {
  border-color: #d0dcd7;
  background: #fff;
}

.permission-note {
  border-left-color: #b88932;
}

.login-screen {
  background: #e9efec;
}

.viewer-login-panel {
  border-top: 4px solid #174f45;
}

.login-security,
.login-warning {
  border-left-color: #b88932;
  background: #f8f3e7;
  color: #5c574b;
}

.ritual-library {
  background: #f2f1ec;
  color: #26322e;
}

.ritual-hero {
  border-color: #bfcfc9;
}

.ritual-hero::after {
  background: #b88932;
}

.ritual-seal {
  border-color: #a84a40;
  outline-color: #c29a4c;
  background: #fff;
  color: #8f3e36;
  box-shadow: 0 10px 26px rgba(25, 48, 41, 0.1);
}

.ritual-hero h2 {
  color: #24352f;
  font-family: var(--font-title);
  font-size: 48px;
  text-shadow: none;
}

.ritual-hero p,
.ritual-card-body .ritual-occasion {
  color: #9b443a;
}

.ritual-card {
  border-color: #ccd8d3;
  border-left-color: #a84a40;
  background: #fff;
  box-shadow: 0 10px 26px rgba(25, 48, 41, 0.09);
}

.ritual-card:hover,
.ritual-card:focus-visible {
  border-color: #76a093;
  box-shadow: 0 18px 36px rgba(25, 48, 41, 0.14);
}

.ritual-number {
  border-color: #d2b574;
  background: #f7f1e4;
  color: #8c3d35;
}

.ritual-card-body h3 {
  color: #21342e;
}

.memory-archive {
  background: #edf2ef;
  color: var(--ink);
}

.memory-hero,
.memory-card {
  border-color: #c8d6d0;
  background: #fff;
  box-shadow: 0 10px 28px rgba(25, 48, 41, 0.1);
}

.memory-hero h2,
.memory-card h3 {
  color: #20362f;
}

.honor-board {
  background: #183f38;
  color: #f6faf8;
}

.honor-banner,
.honor-stats,
.honor-stats div {
  border-color: rgba(220, 234, 228, 0.2);
}

.honor-emblem {
  border-color: #d3ad62;
  background: #11332d;
  color: #e5c77f;
}

.honor-heading h2,
.honor-stats strong {
  color: #f5e5bb;
  text-shadow: none;
}

.honor-card {
  border-color: #d4ddd9;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 15px 34px rgba(7, 27, 23, 0.24), inset 0 3px 0 #b88932;
}

.honor-card:hover,
.honor-card:focus-visible {
  box-shadow: 0 20px 40px rgba(7, 27, 23, 0.3), inset 0 3px 0 #2a7564;
}

.honor-rank {
  border-color: #d1ae69;
  background: #174f45;
  color: #f8e8be;
}

.honor-identity h3,
.honor-details dd {
  color: #1d2e29;
}

.honor-level,
.honor-achievements strong {
  color: #9f443a;
}

/* A modern summary that complements, rather than duplicates, the family tree. */
.family-overview-page {
  width: min(1180px, calc(100vw - 44px));
  margin: 0 auto;
  color: var(--ink);
}

.overview-hero {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 154px;
  padding: 26px;
  border: 1px solid #b9cdc5;
  border-radius: 8px;
  background: #174f45;
  color: #f8fbfa;
  box-shadow: var(--shadow);
}

.overview-emblem {
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  border: 1px solid rgba(232, 205, 145, 0.74);
  border-radius: 50%;
  background: #103e36;
  color: #e8cd91;
}

.overview-emblem .icon {
  width: 31px;
  height: 31px;
}

.overview-hero p,
.overview-hero h2,
.overview-hero span {
  margin: 0;
}

.overview-hero p {
  color: #c7ddd6;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.overview-hero h2 {
  margin: 4px 0 7px;
  color: #fffaf0;
  font-size: clamp(25px, 3vw, 38px);
  line-height: 1.18;
}

.overview-hero > div:nth-child(2) > span {
  color: #d7e5e0;
  font-size: 13px;
}

.overview-hero > button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  min-height: 58px;
  padding: 10px 14px;
  border: 1px solid rgba(231, 205, 149, 0.56);
  border-radius: 7px;
  background: #fff;
  color: #21443b;
  text-align: left;
}

.overview-hero > button .icon {
  width: 24px;
  height: 24px;
  color: #a47728;
}

.overview-hero > button span {
  display: grid;
}

.overview-hero > button small {
  color: #6b7873;
  font-size: 10px;
}

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

.overview-stat-grid article {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 16px;
  border: 1px solid #cbd8d3;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 7px 20px rgba(25, 48, 41, 0.07);
}

.overview-stat-grid article > span {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 7px;
  background: #e6f0ed;
  color: #1d6255;
}

.overview-stat-grid article:nth-child(3) > span {
  background: #f6efe1;
  color: #9b6d22;
}

.overview-stat-grid article:nth-child(4) > span {
  background: #e9eef4;
  color: #47718b;
}

.overview-stat-grid .icon {
  width: 21px;
  height: 21px;
}

.overview-stat-grid div {
  display: grid;
}

.overview-stat-grid strong {
  color: #20332d;
  font-family: var(--font-title);
  font-size: 24px;
  line-height: 1;
}

.overview-stat-grid small {
  color: #576861;
  font-size: 11px;
  font-weight: 650;
}

.overview-stat-grid em {
  grid-column: 1 / -1;
  padding-top: 9px;
  border-top: 1px solid #e5ebe8;
  color: #7b8782;
  font-size: 10px;
  font-style: normal;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 14px;
}

.overview-panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid #cad7d2;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(25, 48, 41, 0.07);
}

.overview-panel > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.overview-panel header p,
.overview-panel header h3 {
  margin: 0;
}

.overview-panel header p {
  color: #648078;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.overview-panel header h3 {
  margin-top: 3px;
  color: #20352f;
  font-size: 18px;
}

.overview-panel > header > strong {
  color: #a4473e;
  font-family: var(--font-title);
  font-size: 27px;
}

.generation-bars {
  display: grid;
  gap: 12px;
}

.generation-bars > div {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 30px;
  gap: 10px;
  align-items: center;
}

.generation-bars span,
.generation-bars strong {
  font-size: 11px;
}

.generation-bars span { color: #63736d; }
.generation-bars strong { color: #264b41; text-align: right; }

.generation-bars i {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9efec;
}

.generation-bars b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #367b6b;
}

.profile-health-panel {
  display: grid;
  align-content: start;
}

.completion-ring {
  display: grid;
  width: 126px;
  height: 126px;
  place-items: center;
  margin: 2px auto 16px;
  border-radius: 50%;
  background: conic-gradient(#2b7464 var(--completion), #e5ece9 0);
}

.completion-ring::before {
  grid-area: 1 / 1;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #fff;
  content: "";
}

.completion-ring span {
  z-index: 1;
  display: grid;
  grid-area: 1 / 1;
  text-align: center;
}

.completion-ring strong {
  color: #1d5c50;
  font-family: var(--font-title);
  font-size: 25px;
}

.completion-ring small {
  color: #718079;
  font-size: 9px;
}

.profile-health-panel > p {
  margin: 0;
  color: #697770;
  font-size: 11px;
  line-height: 1.65;
  text-align: center;
}

.profile-health-panel > p b { color: #254a40; }

.gender-meter {
  display: flex;
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1ef;
}

.gender-meter i { height: 100%; }
.gender-meter .male { background: #2b7464; }
.gender-meter .female { background: #bd6258; }
.gender-meter .other { background: #5f8895; }

.gender-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 17px;
}

.gender-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #697770;
  font-size: 11px;
}

.gender-legend i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.gender-legend .male { background: #2b7464; }
.gender-legend .female { background: #bd6258; }
.gender-legend .other { background: #5f8895; }
.gender-legend b { color: #263f38; }

.places-overview-panel header button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  background: #edf4f1;
  color: #285f52;
}

.overview-place-list {
  display: grid;
}

.overview-place-list button {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  min-height: 43px;
  border-top: 1px solid #e4ebe8;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.overview-place-list button:first-child { border-top: 0; }
.overview-place-list button:hover { background: #f3f7f5; }
.overview-place-list button > span { color: #a47a30; font: 600 11px var(--font-title); }
.overview-place-list button strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.overview-place-list button small { color: #75817c; font-size: 9px; }

@media (max-width: 900px) {
  .overview-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  body {
    background: #edf2ef;
    font-size: 13px;
  }

  .topbar {
    min-height: 58px;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.98);
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    font-size: 12px;
  }

  .brand h1 {
    color: #20342e;
    font-size: 15px;
  }

  .workspace {
    min-height: calc(100dvh - 58px);
    padding: 8px 8px 94px;
    background: #edf2ef;
  }

  .mobile-bottom-nav {
    height: calc(76px + env(safe-area-inset-bottom));
    padding: 7px 5px max(6px, env(safe-area-inset-bottom));
    border-top: 1px solid #c9d6d1;
    background: rgba(255, 255, 255, 0.985);
    box-shadow: 0 -10px 28px rgba(25, 48, 41, 0.12);
  }

  .mobile-bottom-nav button {
    min-height: 58px;
    color: #6b7873;
  }

  .mobile-bottom-nav button .icon {
    border-radius: 7px;
  }

  .mobile-bottom-nav button.active {
    color: #174f45;
  }

  .mobile-bottom-nav button.active .icon {
    border-color: #bed2ca;
    background: #e3efeb;
    color: #174f45;
  }

  .mobile-bottom-nav button.active::before {
    background: #b88932;
  }

  .mobile-bottom-nav span {
    font-size: 10px;
    font-weight: 650;
  }

  .floating-tools.open {
    background: rgba(18, 43, 36, 0.36);
  }

  .floating-tools .menu-panel {
    bottom: calc(76px + env(safe-area-inset-bottom));
    padding: 16px 14px 20px;
    border-color: #c5d2cd;
    border-radius: 14px 14px 0 0;
    background: #fff;
    box-shadow: 0 -18px 46px rgba(25, 48, 41, 0.18);
  }

  .mobile-hub-family,
  .mobile-hub-event,
  .mobile-hub-grid button,
  .my-family-group,
  .upcoming-panel,
  .directory-head,
  .directory-search,
  .mobile-directory-card {
    border-color: #d0dcd7;
    background: #fff;
    box-shadow: none;
  }

  .mobile-hub-family {
    border-top: 3px solid #174f45;
  }

  .mobile-hub-grid button .icon {
    color: #1d6255;
  }

  .my-family-dashboard,
  .fan-page,
  .timeline-page,
  .places-page {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
  }

  .detail-drawer {
    top: 58px;
    border: 0;
  }

  .family-overview-page {
    width: 100%;
  }

  .overview-hero {
    grid-template-columns: 46px minmax(0, 1fr);
    min-height: 0;
    padding: 18px 15px;
    gap: 11px;
  }

  .overview-emblem {
    width: 44px;
    height: 44px;
  }

  .overview-emblem .icon {
    width: 23px;
    height: 23px;
  }

  .overview-hero h2 {
    margin-top: 2px;
    font-size: 21px;
  }

  .overview-hero > div:nth-child(2) > span {
    display: none;
  }

  .overview-hero > button {
    grid-column: 1 / -1;
    min-width: 0;
    min-height: 48px;
  }

  .overview-stat-grid {
    gap: 8px;
    margin: 8px 0;
  }

  .overview-stat-grid article {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 8px;
    padding: 11px;
  }

  .overview-stat-grid article > span {
    width: 32px;
    height: 32px;
  }

  .overview-stat-grid .icon {
    width: 17px;
    height: 17px;
  }

  .overview-stat-grid strong {
    font-size: 20px;
  }

  .overview-stat-grid em {
    display: none;
  }

  .overview-grid {
    gap: 8px;
  }

  .overview-panel {
    padding: 15px;
  }

  .ritual-library,
  .memory-archive,
  .honor-board {
    margin: -8px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .ritual-hero h2 {
    font-size: 34px;
  }
}

/* Heritage cover v25: a distinctive home and a clearer member directory. */
.heritage-home {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  width: min(1120px, calc(100vw - 44px));
  margin: 0 auto;
}

.heritage-cover {
  position: relative;
  display: grid;
  min-height: calc(100vh - 110px);
  place-items: center;
  align-content: center;
  overflow: hidden;
  padding: clamp(34px, 6vw, 76px);
  border: 1px solid #b88451;
  border-radius: 8px;
  background:
    linear-gradient(rgba(253, 248, 235, 0.9), rgba(251, 246, 231, 0.94)),
    var(--family-bg) center top / cover no-repeat,
    #fbf6e7;
  box-shadow: 0 20px 50px rgba(56, 39, 25, 0.14), inset 0 0 0 7px rgba(255, 255, 255, 0.42);
  color: #4b211c;
  text-align: center;
}

.heritage-cover::before,
.heritage-cover::after {
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(135, 46, 38, 0.5);
  border-radius: 4px;
  pointer-events: none;
  content: "";
}

.heritage-cover::after {
  inset: 17px;
  border-color: rgba(185, 136, 50, 0.42);
}

.heritage-corner {
  position: absolute;
  z-index: 1;
  width: 48px;
  height: 48px;
  border-color: #963c32;
  pointer-events: none;
}

.corner-top-left { top: 10px; left: 10px; border-top: 3px double; border-left: 3px double; }
.corner-top-right { top: 10px; right: 10px; border-top: 3px double; border-right: 3px double; }
.corner-bottom-left { bottom: 10px; left: 10px; border-bottom: 3px double; border-left: 3px double; }
.corner-bottom-right { right: 10px; bottom: 10px; border-right: 3px double; border-bottom: 3px double; }

.heritage-title,
.heritage-crest,
.heritage-cover blockquote,
.heritage-divider,
.heritage-welcome,
.heritage-actions {
  position: relative;
  z-index: 2;
}

.heritage-title p,
.heritage-title h2,
.heritage-title span,
.heritage-cover blockquote,
.heritage-welcome {
  margin: 0;
}

.heritage-title p {
  color: #a2742c;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.heritage-title h2 {
  margin: 5px 0;
  color: #8c3028;
  font-size: clamp(32px, 5vw, 60px);
  line-height: 1.06;
  text-transform: uppercase;
}

.heritage-title span {
  color: #78614f;
  font-size: 12px;
  font-weight: 600;
}

.heritage-flourish {
  position: absolute;
  top: 38%;
  left: 50%;
  width: min(560px, 76%);
  height: 190px;
  transform: translate(-50%, -50%);
  opacity: 0.34;
  pointer-events: none;
}

.heritage-flourish i {
  position: absolute;
  top: 50%;
  width: 44%;
  height: 1px;
  background: #b49250;
  transform-origin: right center;
}

.heritage-flourish i:nth-child(1) { left: 1%; transform: rotate(12deg); }
.heritage-flourish i:nth-child(2) { left: 3%; transform: rotate(-16deg); }
.heritage-flourish i:nth-child(3) { left: 7%; transform: rotate(28deg); }
.heritage-flourish i:nth-child(4) { right: 1%; transform: rotate(-12deg); transform-origin: left center; }
.heritage-flourish i:nth-child(5) { right: 3%; transform: rotate(16deg); transform-origin: left center; }
.heritage-flourish i:nth-child(6) { right: 7%; transform: rotate(-28deg); transform-origin: left center; }

.heritage-flourish i::after {
  position: absolute;
  top: -11px;
  width: 22px;
  height: 12px;
  border: 1px solid #b49250;
  border-radius: 90% 0 90% 0;
  background: rgba(222, 196, 132, 0.22);
  content: "";
}

.heritage-crest {
  display: grid;
  width: clamp(150px, 22vw, 208px);
  height: clamp(150px, 22vw, 208px);
  place-items: center;
  margin: 32px auto 22px;
  border-radius: 50%;
  background: rgba(214, 177, 95, 0.18);
  box-shadow: 0 0 0 1px rgba(175, 122, 42, 0.22), 0 14px 36px rgba(88, 42, 28, 0.15);
}

.crest-outer {
  display: grid;
  width: 82%;
  height: 82%;
  place-items: center;
  border: 2px solid #c79a45;
  border-radius: 50%;
  background: #f4dfaa;
  box-shadow: inset 0 0 0 7px #fff7dc, inset 0 0 0 9px #a84a38;
}

.crest-inner {
  display: grid;
  width: 69%;
  height: 69%;
  place-items: center;
  align-content: center;
  border: 2px solid #e3b85c;
  border-radius: 50%;
  background: #7c221d;
  color: #f8d77b;
  box-shadow: inset 0 0 24px rgba(54, 8, 8, 0.38), 0 6px 16px rgba(85, 32, 22, 0.24);
}

.crest-inner strong {
  font-family: var(--font-title);
  font-size: clamp(31px, 5vw, 47px);
  line-height: 1;
}

.crest-inner small {
  margin-top: 5px;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
}

.heritage-cover blockquote {
  color: #4c3429;
  font-family: var(--font-title);
  font-size: clamp(17px, 2vw, 23px);
  line-height: 1.5;
}

.heritage-divider {
  display: flex;
  align-items: center;
  width: min(330px, 72%);
  gap: 9px;
  margin: 16px auto;
}

.heritage-divider span {
  flex: 1;
  border-top: 1px solid #c5a25e;
}

.heritage-divider b {
  width: 7px;
  height: 7px;
  border: 1px solid #a74939;
  transform: rotate(45deg);
}

.heritage-welcome {
  color: #776457;
  font-size: 12px;
}

.heritage-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(540px, 100%);
  margin-top: 26px;
}

.heritage-actions button {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 18px;
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid #c9b184;
  border-radius: 7px;
  background: rgba(255, 253, 246, 0.92);
  color: #542c25;
  text-align: left;
  box-shadow: 0 8px 18px rgba(75, 43, 29, 0.08);
}

.heritage-actions button:hover {
  border-color: #a94b3c;
  background: #fff;
  transform: translateY(-1px);
}

.heritage-actions button > .icon:first-child { width: 24px; height: 24px; color: #9b3e32; }
.heritage-actions button > .icon:last-child { width: 15px; height: 15px; color: #a77c32; }
.heritage-actions button span { display: grid; min-width: 0; }
.heritage-actions button strong { font-size: 12px; }
.heritage-actions button small { color: #837369; font-size: 9px; }

.heritage-glance {
  display: grid;
  align-content: start;
  gap: 10px;
}

.heritage-stat {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 2px 11px;
  align-items: center;
  min-height: 82px;
  padding: 14px;
  border: 1px solid #cbd8d3;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(25, 48, 41, 0.07);
}

.heritage-stat > span {
  grid-row: 1 / 3;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: #e6efec;
  color: #1d6255;
}

.heritage-stat strong {
  color: #243a34;
  font: 700 23px/1 var(--font-title);
}

.heritage-stat small {
  color: #728079;
  font-size: 10px;
}

.heritage-next-event {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 18px;
  gap: 10px;
  align-items: center;
  min-height: 84px;
  padding: 12px;
  border: 1px solid #d6c28f;
  border-radius: 8px;
  background: #f9f4e7;
  color: #3a302a;
  text-align: left;
}

.heritage-next-event time {
  display: grid;
  min-height: 52px;
  place-items: center;
  border-radius: 7px;
  background: #8b3028;
  color: #fff8df;
  font-size: 20px;
  font-weight: 700;
}

.heritage-next-event time small { font-size: 8px; }
.heritage-next-event > span { display: grid; gap: 2px; min-width: 0; }
.heritage-next-event > span small { color: #8c6c43; font-size: 9px; text-transform: uppercase; }
.heritage-next-event > span strong { overflow: hidden; font: 600 13px var(--font-title); text-overflow: ellipsis; white-space: nowrap; }
.heritage-next-event > span em { color: #6f746d; font-size: 9px; font-style: normal; }

/* Member directory: readable identity cards rather than an admin-like table. */
.directory-counts {
  display: flex;
  gap: 8px;
}

.directory-counts span {
  display: grid;
  min-width: 88px;
  padding: 8px 12px;
  border: 1px solid #d3ded9;
  border-radius: 7px;
  background: #f4f7f6;
  color: #6c7974;
  font-size: 9px;
  font-weight: 600;
  text-align: center;
}

.directory-counts strong {
  color: #1d6255;
  font: 700 18px var(--font-title);
}

.directory-head > div:first-child > div > small {
  display: block;
  margin-top: 3px;
  color: #718079;
  font-size: 10px;
}

.directory-search {
  position: relative;
}

.directory-search > button {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  border-radius: 50%;
  background: #edf3f0;
  color: #60736b;
}

.directory-search > button .icon { width: 15px; height: 15px; }
.directory-search > button[hidden],
.mobile-directory-card[hidden],
.directory-empty[hidden] { display: none !important; }

.directory-empty {
  grid-column: 1 / -1;
}

.mobile-directory-visual {
  position: relative;
  display: block;
  width: 58px;
  height: 66px;
}

.mobile-directory-visual b {
  position: absolute;
  right: -4px;
  bottom: -3px;
  padding: 2px 5px;
  border: 1px solid #d1b672;
  border-radius: 999px;
  background: #fff9e9;
  color: #8b6327;
  font-size: 7px;
  white-space: nowrap;
}

@media (min-width: 641px) {
  .list-panel {
    padding: 22px;
  }

  .list-panel .directory-head,
  .list-panel .directory-search,
  .list-panel .mobile-directory {
    display: flex;
  }

  .list-panel .directory-head {
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 14px;
  }

  .list-panel .directory-head > div:first-child {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .list-panel .directory-head > div:first-child > span {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 8px;
    background: #e4efeb;
    color: #1d6255;
  }

  .list-panel .directory-head p,
  .list-panel .directory-head h2 { margin: 0; }
  .list-panel .directory-head p { color: #6d847c; font-size: 9px; font-weight: 700; text-transform: uppercase; }
  .list-panel .directory-head h2 { color: #20372f; font-size: 22px; }

  .list-panel .directory-search {
    width: 100%;
    min-height: 48px;
    margin-bottom: 16px;
  }

  .list-panel .mobile-directory {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 10px;
  }

  .list-panel .mobile-directory-card {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) auto 17px;
    gap: 11px;
    align-items: center;
    min-height: 92px;
    padding: 12px;
    border: 1px solid #d0dcd7;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    text-align: left;
    box-shadow: 0 6px 18px rgba(25, 48, 41, 0.06);
  }

  .list-panel .mobile-directory-card:hover {
    border-color: #7ca297;
    background: #f6f9f8;
    transform: translateY(-1px);
  }

  .list-panel .mobile-directory-photo {
    width: 58px;
    height: 66px;
    border-radius: 7px;
    object-fit: cover;
  }

  .list-panel .mobile-directory-main {
    display: grid;
    min-width: 0;
    gap: 3px;
  }

  .list-panel .mobile-directory-main strong {
    display: flex;
    align-items: center;
    gap: 5px;
    overflow: hidden;
    font: 600 14px var(--font-title);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .list-panel .mobile-directory-main small,
  .list-panel .mobile-directory-main em {
    overflow: hidden;
    color: #697770;
    font-size: 9px;
    font-style: normal;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .list-panel .mobile-directory-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 999px;
    background: #e9f3ef;
    color: #1e6b59;
    font-size: 8px;
    white-space: nowrap;
  }

  .list-panel .mobile-directory-status.deceased {
    background: #f5e8e6;
    color: #a3443b;
  }

  .list-panel .mobile-directory-status .icon { width: 12px; height: 12px; }
  .list-panel .mobile-directory-card > .icon { width: 15px; height: 15px; color: #9aa59f; }
  .list-panel .desktop-directory-table { display: none; }
}

@media (max-width: 900px) {
  .heritage-home {
    grid-template-columns: minmax(0, 1fr);
  }

  .heritage-glance {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .heritage-next-event {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .heritage-home {
    display: block;
    width: 100%;
  }

  .heritage-cover {
    min-height: calc(100dvh - 164px);
    padding: 32px 25px 28px;
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(56, 39, 25, 0.13), inset 0 0 0 5px rgba(255, 255, 255, 0.38);
  }

  .heritage-title p { font-size: 9px; }
  .heritage-title h2 { max-width: 290px; font-size: clamp(27px, 9vw, 38px); }
  .heritage-title span { font-size: 9px; }

  .heritage-crest {
    width: 142px;
    height: 142px;
    margin: 24px auto 17px;
  }

  .crest-inner strong { font-size: 31px; }
  .heritage-cover blockquote { font-size: 16px; }
  .heritage-welcome { max-width: 270px; font-size: 10px; }

  .heritage-actions {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    margin-top: 18px;
  }

  .heritage-actions button {
    min-height: 54px;
  }

  .heritage-glance {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 8px;
  }

  .heritage-stat {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 3px;
    min-height: 76px;
    place-items: center;
    padding: 8px 4px;
    text-align: center;
  }

  .heritage-stat > span {
    grid-row: auto;
    width: 28px;
    height: 28px;
  }

  .heritage-stat > span .icon { width: 15px; height: 15px; }
  .heritage-stat strong { font-size: 18px; }
  .heritage-stat small { font-size: 8px; }
  .heritage-next-event { grid-column: 1 / -1; }

  .directory-head {
    padding: 14px;
    border-top: 3px solid #174f45;
  }

  .directory-head > div:first-child > span {
    background: #e4efeb;
    color: #1d6255;
  }

  .directory-head h2 {
    font-size: 19px;
  }

  .directory-head > div:first-child > div > small {
    display: none;
  }

  .directory-head > .directory-counts {
    display: none;
  }

  .directory-search {
    position: sticky;
    top: 58px;
    z-index: 5;
    min-height: 48px;
    margin: 8px 0;
    border-color: #bdcec7;
    background: rgba(255, 255, 255, 0.98);
  }

  .mobile-directory {
    gap: 8px;
  }

  .mobile-directory-card {
    position: relative;
    grid-template-columns: 58px minmax(0, 1fr) 24px;
    min-height: 86px;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 5px 14px rgba(25, 48, 41, 0.06);
  }

  .mobile-directory-photo {
    width: 58px;
    height: 66px;
    border-radius: 7px;
  }

  .mobile-directory-main strong {
    font-family: var(--font-title);
    font-size: 13px;
    font-weight: 600;
  }

  .mobile-directory-main small,
  .mobile-directory-main em {
    font-size: 9px;
    font-weight: 500;
  }

  .mobile-directory-status {
    position: absolute;
    top: 9px;
    right: 9px;
    width: 20px;
    height: 20px;
    padding: 0;
    place-content: center;
    border-radius: 50%;
    background: #e9f3ef;
  }

  .mobile-directory-status > span {
    display: none;
  }

  .mobile-directory-status .icon {
    width: 12px;
    height: 12px;
  }

  .mobile-directory-card > .icon {
    align-self: end;
    margin-bottom: 7px;
  }

  .view-landing .viewer-topbar {
    display: none;
  }

  .view-landing .workspace {
    min-height: calc(100dvh - 74px);
    padding-top: 8px;
  }

  .view-landing .heritage-cover {
    min-height: calc(100dvh - 98px);
  }
}

/* Heritage home v26: red lacquer, warm ivory, personal identity and family events. */
.view-landing {
  --heritage-ivory: #f7f1e3;
  --heritage-paper: #fffaf0;
  --heritage-red: #7d211f;
  --heritage-red-dark: #5c1518;
  --heritage-gold: #b9832e;
  --heritage-gold-light: #efd48b;
}

.view-landing,
.view-landing .workspace {
  background:
    radial-gradient(circle at 50% 4%, rgba(255, 255, 255, 0.78), transparent 32%),
    linear-gradient(rgba(247, 241, 227, 0.97), rgba(247, 241, 227, 0.97)),
    var(--family-bg) center top / cover fixed,
    var(--heritage-ivory);
}

.view-landing .viewer-topbar {
  border-bottom-color: #dcc29a;
  background: rgba(255, 251, 242, 0.96);
  box-shadow: 0 5px 20px rgba(84, 39, 20, 0.08);
}

.view-landing .viewer-topbar .brand-mark,
.view-landing .viewer-topbar .btn {
  border-color: #b87431;
  background: linear-gradient(145deg, #a12b1c, #711111);
  color: #ffe8a8;
}

.view-landing .viewer-topbar .brand h1 {
  color: #4f1c18;
}

.view-landing .viewer-topbar .brand p {
  color: #81644d;
}

.view-landing .viewer-topbar .ghost-btn {
  border-color: #d5b57b;
  background: #fffaf0;
  color: #68221d;
}

.view-landing .heritage-event-section {
  display: block;
}

.heritage-home {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  width: min(1180px, calc(100vw - 44px));
}

.heritage-home-cover {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  min-height: 286px;
  place-items: center;
  align-content: center;
  gap: 36px;
  padding: 42px clamp(40px, 7vw, 86px);
  border: 1px solid #b88a4a;
  border-radius: 8px;
  background:
    radial-gradient(circle at 79% 48%, rgba(209, 167, 78, 0.24), transparent 25%),
    linear-gradient(104deg, rgba(255, 250, 240, 0.985), rgba(247, 239, 218, 0.96)),
    var(--heritage-paper);
  box-shadow: 0 16px 40px rgba(69, 34, 25, 0.12), inset 0 0 0 6px rgba(255, 255, 255, 0.42);
  text-align: left;
}

.heritage-home-cover::before,
.heritage-home-cover::after {
  inset: 12px;
  border-color: rgba(128, 29, 28, 0.42);
}

.heritage-cover-copy,
.heritage-emblem,
.heritage-home-cover blockquote {
  position: relative;
  z-index: 2;
}

.heritage-cover-copy {
  justify-self: start;
}

.heritage-cover-copy p,
.heritage-cover-copy h2,
.heritage-cover-copy span,
.heritage-home-cover blockquote {
  margin: 0;
}

.heritage-cover-copy p {
  color: #9b6a27;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.3px;
  text-transform: uppercase;
}

.heritage-cover-copy h2 {
  max-width: 650px;
  margin: 7px 0 8px;
  color: var(--heritage-red);
  font: 700 clamp(38px, 5vw, 66px)/1.05 var(--font-title);
}

.heritage-cover-copy span {
  color: #755e4e;
  font-size: 12px;
  font-weight: 600;
}

.heritage-home-cover blockquote {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: -32px;
  color: #5f4032;
  font: 600 17px/1.45 var(--font-title);
}

.heritage-emblem {
  display: grid;
  width: 190px;
  height: 190px;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle, #f7d77f 0 55%, rgba(185, 131, 46, 0.24) 56% 70%, transparent 71%);
  filter: drop-shadow(0 13px 17px rgba(81, 33, 22, 0.2));
}

.heritage-emblem::before,
.heritage-emblem::after {
  position: absolute;
  width: 132px;
  height: 132px;
  border: 1px solid rgba(154, 103, 35, 0.46);
  border-radius: 50%;
  content: "";
}

.heritage-emblem::after {
  width: 154px;
  height: 154px;
  border-style: double;
  border-width: 3px;
}

.heritage-emblem > span {
  display: grid;
  z-index: 2;
  width: 112px;
  height: 112px;
  place-items: center;
  align-content: center;
  border: 2px solid #e0b85d;
  border-radius: 50%;
  background:
    radial-gradient(circle at 39% 28%, rgba(255, 255, 255, 0.13), transparent 18%),
    radial-gradient(circle at 40% 30%, #96312d, var(--heritage-red-dark) 72%);
  color: #f4d47b;
  box-shadow: inset 0 0 0 5px #f5d779, inset 0 0 22px rgba(38, 4, 8, 0.55);
}

.heritage-emblem strong {
  display: block;
  color: #f6d77c;
  font-family: "Noto Serif CJK SC", "Songti SC", "SimSun", "Noto Serif", serif;
  font-size: 55px;
  font-weight: 700;
  line-height: 0.88;
  text-shadow: 0 2px 0 rgba(82, 31, 15, 0.34), 0 0 12px rgba(255, 225, 133, 0.24);
}

.heritage-emblem small {
  margin-top: 7px;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.heritage-emblem i {
  position: absolute;
  width: 250px;
  height: 64px;
  border-top: 1px solid rgba(167, 122, 52, 0.42);
  border-radius: 50%;
}

.heritage-emblem i:nth-child(1) { transform: rotate(18deg); }
.heritage-emblem i:nth-child(2) { transform: rotate(-18deg); }
.heritage-emblem i:nth-child(3) { transform: rotate(41deg); }
.heritage-emblem i:nth-child(4) { transform: rotate(-41deg); }

.heritage-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.75fr);
  grid-template-areas:
    "profile glance"
    "quick events";
  gap: 14px;
}

.heritage-profile-card,
.heritage-quick-section,
.heritage-event-section,
.heritage-glance {
  border: 1px solid #ddcfb3;
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.97);
  box-shadow: 0 8px 24px rgba(70, 42, 28, 0.07);
}

.heritage-profile-card {
  grid-area: profile;
  position: relative;
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr) 40px;
  gap: 18px;
  align-items: center;
  min-height: 154px;
  overflow: hidden;
  padding: 18px;
  color: #3e2822;
}

.heritage-profile-card::after {
  position: absolute;
  right: -36px;
  bottom: -58px;
  width: 180px;
  height: 180px;
  border: 1px solid rgba(174, 126, 53, 0.18);
  border-radius: 50%;
  content: "";
}

.heritage-profile-visual {
  width: 116px;
  height: 116px;
  padding: 4px;
  border: 1px solid #caa85d;
  border-radius: 50%;
  background: #f7eac7;
}

.heritage-profile-photo {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border-radius: 50%;
  object-fit: cover;
  background: #791f1f;
  color: #f6d57e;
  font: 700 25px var(--font-title);
}

.heritage-profile-placeholder .icon {
  width: 34px;
  height: 34px;
}

.heritage-profile-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.heritage-profile-copy > small,
.heritage-section-title small {
  color: #9d6a28;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.heritage-profile-copy h3,
.heritage-profile-copy p {
  margin: 0;
}

.heritage-profile-copy h3 {
  overflow: hidden;
  color: #5d1f1d;
  font: 700 clamp(22px, 3vw, 31px)/1.15 var(--font-title);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.heritage-profile-copy p {
  color: #77675d;
  font-size: 11px;
}

.heritage-profile-copy > span {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e8f2ed;
  color: #1d6755;
  font-size: 9px;
  font-weight: 700;
}

.heritage-profile-copy > span .icon {
  width: 13px;
  height: 13px;
}

.heritage-profile-open {
  z-index: 2;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid #ddc998;
  border-radius: 50%;
  background: #fff9e9;
  color: #8a2b26;
}

.heritage-quick-section {
  grid-area: quick;
  padding: 18px;
}

.heritage-section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.heritage-section-title span {
  display: grid;
  gap: 2px;
}

.heritage-section-title h3 {
  margin: 0;
  color: #492c26;
  font: 700 19px var(--font-title);
}

.heritage-section-title > b {
  padding: 5px 8px;
  border-radius: 999px;
  background: #f5e6be;
  color: #8b5720;
  font-size: 8px;
}

.heritage-quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.heritage-quick-grid button {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 3px 9px;
  align-items: center;
  min-height: 72px;
  padding: 11px;
  border: 1px solid #e2d8c4;
  border-radius: 7px;
  background: #fff;
  color: #452b26;
  text-align: left;
}

.heritage-quick-grid button:hover {
  border-color: #b9853c;
  background: #fffaf0;
  transform: translateY(-1px);
}

.heritage-quick-grid button > span {
  grid-row: 1 / 3;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 7px;
  background: #8b2622;
  color: #f9df93;
}

.heritage-quick-grid button > span .icon {
  width: 20px;
  height: 20px;
}

.heritage-quick-grid strong {
  overflow: hidden;
  font: 700 11px var(--font-title);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.heritage-quick-grid small {
  color: #89786d;
  font-size: 8px;
}

.heritage-event-section {
  grid-area: events;
  padding: 18px;
}

.heritage-event-list {
  display: grid;
  gap: 7px;
}

.heritage-event-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 16px;
  gap: 10px;
  align-items: center;
  min-height: 62px;
  padding: 8px;
  border: 1px solid #e4dac5;
  border-radius: 7px;
  background: #fff;
  color: #472d26;
  text-align: left;
}

.heritage-event-row time {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  align-content: center;
  border-radius: 7px;
  background: #f4e4bc;
  color: #7d2822;
}

.heritage-event-row.memorial time {
  background: #8a2723;
  color: #ffe8ab;
}

.heritage-event-row time strong {
  font-size: 17px;
  line-height: 1;
}

.heritage-event-row time small {
  margin-top: 3px;
  font-size: 7px;
  font-weight: 800;
}

.heritage-event-row > span {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.heritage-event-row > span small {
  color: #9b682b;
  font-size: 7px;
  font-weight: 800;
  text-transform: uppercase;
}

.heritage-event-row > span strong {
  overflow: hidden;
  font: 600 11px var(--font-title);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.heritage-event-row > span em {
  color: #8a7a6f;
  font-size: 8px;
  font-style: normal;
}

.heritage-event-row > .icon {
  width: 14px;
  height: 14px;
  color: #a99579;
}

.heritage-event-empty {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  min-height: 74px;
  padding: 12px;
  border: 1px dashed #d5c29a;
  border-radius: 7px;
  color: #79695f;
}

.heritage-event-empty > .icon {
  width: 28px;
  height: 28px;
  color: #9c3b31;
}

.heritage-event-empty span {
  display: grid;
  gap: 3px;
}

.heritage-event-empty strong {
  font: 600 11px var(--font-title);
}

.heritage-event-empty small {
  font-size: 8px;
}

.heritage-dashboard > .heritage-glance {
  grid-area: glance;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  padding: 0;
}

.heritage-dashboard > .heritage-glance .heritage-stat {
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  gap: 4px;
  min-height: 112px;
  padding: 12px 7px;
  border: 0;
  border-right: 1px solid #e4d9c1;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
}

.heritage-dashboard > .heritage-glance .heritage-stat:last-child {
  border-right: 0;
}

.heritage-dashboard > .heritage-glance .heritage-stat > span {
  grid-row: auto;
  width: 34px;
  height: 34px;
  background: #f3e4bd;
  color: #842622;
}

.heritage-dashboard > .heritage-glance .heritage-stat strong {
  color: #65211f;
  font-size: 21px;
}

@media (max-width: 900px) {
  .heritage-dashboard {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "profile" "glance" "quick" "events";
  }
}

@media (max-width: 640px) {
  .view-landing .workspace {
    min-height: calc(100dvh - 72px);
    padding: 7px 7px 88px;
  }

  .view-landing .heritage-home {
    width: 100%;
    gap: 8px;
  }

  .view-landing .heritage-home-cover {
    grid-template-columns: minmax(0, 1fr) 112px;
    min-height: 184px;
    gap: 10px;
    padding: 25px 20px;
    border-radius: 8px;
  }

  .heritage-cover-copy p {
    font-size: 7px;
    letter-spacing: 0.7px;
  }

  .heritage-cover-copy h2 {
    max-width: 210px;
    margin: 4px 0 6px;
    font-size: clamp(24px, 7.8vw, 32px);
  }

  .heritage-cover-copy span {
    font-size: 8px;
  }

  .heritage-home-cover blockquote {
    margin-top: -19px;
    font-size: 10px;
  }

  .heritage-emblem {
    width: 108px;
    height: 108px;
  }

  .heritage-emblem::before { width: 76px; height: 76px; }
  .heritage-emblem::after { width: 90px; height: 90px; }
  .heritage-emblem i { width: 135px; height: 34px; }

  .heritage-emblem > span {
    width: 68px;
    height: 68px;
    box-shadow: inset 0 0 0 3px #f5d779, inset 0 0 13px rgba(38, 4, 8, 0.55);
  }

  .heritage-emblem strong { font-size: 35px; }
  .heritage-emblem small { margin-top: 4px; font-size: 5px; }

  .heritage-dashboard {
    gap: 8px;
  }

  .heritage-profile-card {
    grid-template-columns: 82px minmax(0, 1fr) 30px;
    gap: 11px;
    min-height: 112px;
    padding: 12px;
  }

  .heritage-profile-visual {
    width: 82px;
    height: 82px;
  }

  .heritage-profile-copy h3 {
    font-size: 18px;
  }

  .heritage-profile-copy p {
    font-size: 8px;
  }

  .heritage-profile-copy > span {
    margin-top: 3px;
    padding: 4px 6px;
    font-size: 7px;
  }

  .heritage-profile-open {
    width: 29px;
    height: 29px;
  }

  .heritage-dashboard > .heritage-glance {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .heritage-dashboard > .heritage-glance .heritage-stat {
    min-height: 78px;
    padding: 8px 3px;
  }

  .heritage-dashboard > .heritage-glance .heritage-stat > span {
    width: 28px;
    height: 28px;
  }

  .heritage-dashboard > .heritage-glance .heritage-stat strong {
    font-size: 18px;
  }

  .heritage-dashboard > .heritage-glance .heritage-stat small {
    font-size: 7px;
  }

  .heritage-quick-section,
  .heritage-event-section {
    padding: 13px;
  }

  .heritage-section-title {
    margin-bottom: 10px;
  }

  .heritage-section-title h3 {
    font-size: 16px;
  }

  .heritage-quick-grid {
    gap: 6px;
  }

  .heritage-quick-grid button {
    grid-template-columns: minmax(0, 1fr);
    place-items: center;
    gap: 4px;
    min-height: 86px;
    padding: 8px 4px;
    text-align: center;
  }

  .heritage-quick-grid button > span {
    grid-row: auto;
    width: 34px;
    height: 34px;
  }

  .heritage-quick-grid strong {
    width: 100%;
    font-size: 9px;
  }

  .heritage-quick-grid small {
    font-size: 7px;
  }

  .heritage-event-list {
    gap: 6px;
  }

  .heritage-event-row {
    min-height: 58px;
  }
}

/* Heritage portal v28: ceremonial homepage, kinship lookup and profile. */
.view-landing {
  --heritage-red: #7d1818;
  --heritage-red-dark: #540b0c;
  --heritage-gold: #bd812c;
  --heritage-gold-light: #f0ce82;
  --heritage-ink: #381a12;
  --heritage-line: rgba(174, 114, 37, 0.25);
}

.view-landing,
.view-landing .workspace {
  background:
    linear-gradient(rgba(251, 247, 238, 0.9), rgba(249, 241, 226, 0.92)),
    url("images/nen-di-san-nguyen-huu-v28.webp") center top / cover fixed,
    #faf4e8;
}

.heritage-home-v28 {
  width: min(1120px, calc(100vw - 40px));
  gap: 20px;
  color: var(--heritage-ink);
}

.photo-with-fallback {
  position: relative;
  overflow: hidden;
}

.photo-with-fallback > .image-error-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
}

.photo-with-fallback > img {
  position: relative;
  z-index: 1;
  opacity: 0;
}

.photo-with-fallback > img.is-loaded {
  opacity: 1;
}

.photo-with-fallback > img.is-broken {
  display: none;
}

.heritage-portal-cover {
  position: relative;
  display: grid;
  min-height: 560px;
  place-items: center;
  align-content: center;
  gap: 22px;
  overflow: hidden;
  padding: 50px 28px 42px;
  border: 1px solid rgba(185, 126, 48, 0.38);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 251, 242, 0.25), rgba(250, 239, 218, 0.32)),
    url("images/nen-di-san-nguyen-huu-v28.webp") center / cover no-repeat,
    #fbf5e9;
  box-shadow: 0 22px 60px rgba(91, 47, 24, 0.12), inset 0 0 0 7px rgba(255, 255, 255, 0.44);
  text-align: center;
}

.heritage-portal-cover::before {
  position: absolute;
  inset: 15px;
  border: 1px solid rgba(170, 101, 28, 0.23);
  border-radius: 6px;
  content: "";
  pointer-events: none;
}

.heritage-portal-cover::after {
  position: absolute;
  bottom: -90px;
  width: min(760px, 82%);
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(201, 144, 60, 0.2), transparent 66%);
  content: "";
  pointer-events: none;
}

.heritage-cover-title,
.heritage-portal-emblem,
.heritage-portal-cover blockquote,
.heritage-portal-cover > small {
  position: relative;
  z-index: 2;
}

.heritage-cover-title p,
.heritage-cover-title h2,
.heritage-portal-cover blockquote {
  margin: 0;
}

.heritage-cover-title p,
.heritage-cover-title h2 {
  color: var(--heritage-red);
  font-family: var(--font-title);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.heritage-cover-title p {
  font-size: 31px;
  line-height: 1.05;
}

.heritage-cover-title h2 {
  margin-top: 7px;
  font-size: clamp(43px, 5.3vw, 70px);
  line-height: 1.08;
}

.heritage-title-ornament {
  display: flex;
  width: 190px;
  align-items: center;
  gap: 9px;
  margin: 18px auto 0;
}

.heritage-title-ornament i {
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, #c08c42);
}

.heritage-title-ornament i:last-child {
  background: linear-gradient(90deg, #c08c42, transparent);
}

.heritage-title-ornament b {
  width: 9px;
  height: 9px;
  border: 2px solid #c08c42;
  transform: rotate(45deg);
}

.heritage-emblem.heritage-portal-emblem {
  width: 222px;
  height: 222px;
  background: radial-gradient(circle, #f7d681 0 57%, rgba(179, 116, 32, 0.2) 58% 72%, transparent 73%);
}

.heritage-portal-emblem > span {
  width: 134px;
  height: 134px;
}

.heritage-portal-emblem strong {
  font-size: 67px;
}

.heritage-portal-emblem i {
  width: 290px;
  border-color: rgba(174, 119, 46, 0.25);
}

.heritage-portal-cover blockquote {
  color: #4b281b;
  font: 600 22px/1.25 var(--font-title);
  letter-spacing: 0;
}

.heritage-portal-cover blockquote b {
  margin: 0 6px;
  color: #bb7f2b;
}

.heritage-portal-cover > small {
  margin-top: -12px;
  color: #896847;
  font-size: 11px;
  font-weight: 700;
}

.heritage-portal-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(330px, 0.78fr);
  grid-template-areas:
    "clan stats"
    "functions events";
  gap: 18px;
}

.heritage-clan-card {
  grid-area: clan;
  display: grid;
  grid-template-columns: 106px minmax(0, 1fr) 38px;
  gap: 20px;
  align-items: center;
  min-height: 150px;
  padding: 20px 24px;
  border: 1px solid #e1cba6;
  border-radius: 8px;
  background: rgba(255, 252, 246, 0.96);
  color: var(--heritage-ink);
  box-shadow: 0 13px 34px rgba(85, 45, 24, 0.08);
  text-align: left;
}

.heritage-clan-card:hover {
  border-color: #bb853d;
  transform: translateY(-2px);
}

.heritage-clan-seal {
  display: grid;
  width: 102px;
  height: 102px;
  place-items: center;
  border: 1px solid #d0a452;
  border-radius: 50%;
  background:
    repeating-conic-gradient(from 45deg, rgba(132, 62, 23, 0.14) 0 4deg, transparent 4deg 14deg),
    radial-gradient(circle, #f2cd7a, #dca552);
  box-shadow: inset 0 0 0 7px #f8dfaa, inset 0 0 0 9px rgba(129, 43, 28, 0.45);
}

.heritage-clan-seal strong {
  color: #8a3a1f;
  font-family: "Noto Serif CJK SC", "Songti SC", "SimSun", serif;
  font-size: 49px;
}

.heritage-clan-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.heritage-clan-copy > small {
  color: #a36d27;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.heritage-clan-copy > strong {
  color: #64201b;
  font: 700 28px var(--font-title);
}

.heritage-clan-copy > em {
  color: #745f50;
  font-size: 13px;
  font-style: normal;
}

.heritage-clan-copy > span {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.heritage-clan-copy > span b {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #7c3a22;
  font-size: 11px;
}

.heritage-clan-copy > span .icon {
  width: 15px;
  height: 15px;
}

.heritage-clan-copy > span i {
  width: 1px;
  height: 18px;
  background: #d6b881;
}

.heritage-clan-open {
  color: #8c331f;
}

.heritage-stat-section,
.heritage-function-section,
.heritage-portal-dashboard .heritage-event-section {
  padding: 19px;
  border: 1px solid #e1cba6;
  border-radius: 8px;
  background: rgba(255, 252, 246, 0.96);
  box-shadow: 0 13px 34px rgba(85, 45, 24, 0.07);
}

.heritage-stat-section { grid-area: stats; }
.heritage-function-section { grid-area: functions; }
.heritage-portal-dashboard .heritage-event-section { grid-area: events; }

.heritage-stat-section > h3,
.heritage-function-section > h3 {
  margin: 0 0 14px;
  color: #4b2a20;
  font: 700 21px var(--font-title);
}

.heritage-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.heritage-stat-grid article {
  display: grid;
  min-width: 0;
  min-height: 105px;
  place-items: center;
  align-content: center;
  gap: 3px;
  padding: 10px 5px;
  border: 1px solid #eadcc3;
  border-radius: 7px;
  background: #fffdfa;
  text-align: center;
}

.heritage-stat-grid article > span {
  display: flex;
  min-height: 27px;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #b27726;
}

.heritage-stat-grid article > span .icon {
  width: 25px;
  height: 25px;
}

.heritage-stat-grid article > small {
  overflow: hidden;
  color: #62493c;
  font-size: 9px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.heritage-stat-grid article > strong {
  color: #562019;
  font: 700 24px var(--font-title);
}

.heritage-gender-stat > span .icon:first-child,
.heritage-gender-stat strong em { color: #c6586a; }
.heritage-gender-stat > span .icon:last-child,
.heritage-gender-stat strong b { color: #466b7e; }
.heritage-gender-stat strong b,
.heritage-gender-stat strong em { font-style: normal; }

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

.heritage-function-grid button {
  display: grid;
  min-height: 112px;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 12px 7px;
  border: 1px solid #ead8bd;
  border-radius: 7px;
  background: #fffdfa;
  color: #39231c;
  box-shadow: 0 5px 13px rgba(78, 41, 22, 0.04);
  text-align: center;
}

.heritage-function-grid button:hover {
  border-color: #c79346;
  background: #fff8ea;
  transform: translateY(-2px);
}

.heritage-function-grid button > span {
  display: grid;
  width: 47px;
  height: 47px;
  place-items: center;
  border-radius: 7px;
  background: #fbefd7;
  color: #a4621d;
}

.heritage-function-grid button > span .icon {
  width: 27px;
  height: 27px;
}

.heritage-function-grid button strong {
  font-size: 12px;
  line-height: 1.3;
}

.heritage-function-grid button.featured {
  border-color: #9e3a24;
  background: linear-gradient(145deg, #a12819, #711111);
  color: #fff9e9;
  box-shadow: 0 12px 24px rgba(112, 20, 17, 0.18);
}

.heritage-function-grid button.featured > span {
  background: transparent;
  color: #f2c86d;
}

/* Kinship lookup v28. */
.kinship-backdrop {
  background: rgba(47, 28, 17, 0.45);
  backdrop-filter: blur(4px);
}

.kinship-panel {
  width: min(820px, calc(100vw - 28px));
  max-height: min(880px, calc(100dvh - 28px));
  padding: 24px;
  border-color: #d3ae6e;
  background:
    linear-gradient(rgba(255, 250, 229, 0.78), rgba(250, 237, 194, 0.84)),
    var(--family-tree-paper) center / cover no-repeat,
    #f7e8b8;
  box-shadow: 0 32px 90px rgba(47, 25, 14, 0.34);
}

.kinship-head h2 {
  color: #691b1a;
  font: 700 30px var(--font-title);
}

.kinship-head h2 .icon {
  width: 27px;
  height: 27px;
  color: #a56921;
}

.kinship-head p {
  color: #83694f;
  font-weight: 600;
}

.kinship-fields {
  grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
  align-items: center;
  gap: 13px;
  margin-top: 20px;
  padding: 18px;
  border: 1px solid #e4cfaa;
  border-radius: 8px;
  background: rgba(255, 248, 226, 0.82);
}

.kinship-fields .field {
  min-width: 0;
}

.kinship-fields label {
  display: block;
  margin-bottom: 8px;
  color: #68221d;
  font: 700 15px var(--font-title);
}

.kinship-fields .person-combobox input.person-select-input {
  min-height: 48px;
  padding-left: 43px;
  border-color: #dfbd82;
  background: rgba(255, 251, 242, 0.97);
}

.kinship-swap {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  align-content: center;
  padding: 0;
  border: 1px solid #d6b677;
  border-radius: 50%;
  background: #fff8e9;
  color: #8f1f1c;
}

.kinship-swap .icon {
  width: 18px;
  height: 13px;
  margin: -3px 0;
}

.kinship-person-preview {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #ead4ad;
  border-radius: 7px;
  background: #fff9ec;
}

.kinship-person-photo {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid #9d2d25;
  border-radius: 50%;
  object-fit: cover;
  background: #f0ddb7;
  color: #741b17;
  font-weight: 800;
}

.kinship-person-preview > span {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.kinship-person-preview strong,
.kinship-person-preview small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kinship-person-preview strong {
  color: #5d1917;
  font: 700 15px var(--font-title);
}

.kinship-person-preview small {
  color: #816e5d;
  font-size: 10px;
}

.kinship-result {
  min-height: 280px;
  padding: 26px;
  border-color: #dfc393;
  background: rgba(255, 248, 226, 0.84);
}

.kinship-answer {
  justify-items: center;
  gap: 13px;
  text-align: center;
}

.kinship-answer > small {
  color: #96692f;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.kinship-answer h3 {
  margin: 0;
  color: #801b1a;
  font: 700 38px var(--font-title);
}

.kinship-answer p {
  font-weight: 600;
}

.kinship-answer .kinship-reverse {
  color: #5f3928;
  font-size: 13px;
}

.kinship-portraits {
  display: grid;
  grid-template-columns: 92px 116px 92px;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
}

.kinship-result-photo {
  display: grid;
  width: 92px;
  height: 92px;
  place-items: center;
  border: 2px solid #8e1c1b;
  border-radius: 50%;
  object-fit: cover;
  background: #f1dbb2;
  color: #6d1c18;
  font: 700 20px var(--font-title);
}

.kinship-portraits > i {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
}

.kinship-portraits > i::before {
  position: absolute;
  right: 0;
  left: 0;
  height: 1px;
  background: #b26f55;
  content: "";
}

.kinship-portraits > i b {
  z-index: 1;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9a1f1d;
}

/* Person profile v28. */
.detail-drawer {
  width: min(560px, calc(100vw - 32px));
  border-color: #cda968;
  background:
    linear-gradient(rgba(255, 252, 246, 0.95), rgba(255, 250, 240, 0.97)),
    url("images/nen-di-san-nguyen-huu-v28.webp") center / cover no-repeat,
    #fffaf0;
  box-shadow: 0 24px 70px rgba(50, 27, 15, 0.3);
}

.detail-drawer .drawer-head {
  align-items: center;
  padding: 14px 18px;
  border-color: #e0c79d;
  background: linear-gradient(135deg, #7c1717, #4f0b0d);
  color: #fff7e5;
}

.detail-drawer .drawer-head p,
.detail-drawer .drawer-head h2 {
  margin: 0;
  color: inherit;
}

.detail-drawer .drawer-head p {
  margin-bottom: 2px;
  color: #e9c878;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.detail-drawer .drawer-head .ghost-btn {
  border-color: rgba(244, 215, 154, 0.65);
  background: transparent;
  color: #fff9ec;
}

.detail-drawer .drawer-body {
  padding: 16px 18px 28px;
}

.detail-profile-cover {
  position: relative;
  display: grid;
  min-height: 228px;
  place-items: end center;
  overflow: hidden;
  margin-bottom: 10px;
  padding: 20px 18px 18px;
  border: 1px solid #d5b477;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(249, 230, 183, 0.2), rgba(50, 20, 10, 0.82)),
    url("images/nen-di-san-nguyen-huu-v28.webp") center / cover no-repeat,
    #b68b55;
  text-align: center;
}

.detail-profile-cover::after {
  position: absolute;
  inset: auto 0 0;
  height: 53%;
  background: linear-gradient(transparent, rgba(43, 17, 10, 0.86));
  content: "";
}

.detail-profile-cover > .photo-button,
.detail-profile-cover > .avatar-fallback {
  position: absolute;
  top: 21px;
  z-index: 2;
  width: 112px;
  height: 112px;
  border: 3px solid #8a1c1b;
  border-radius: 50%;
  background: #f1dfbd;
  box-shadow: 0 8px 18px rgba(48, 19, 11, 0.25);
}

.detail-profile-cover > .photo-button > .image-error-fallback {
  border: 0;
  border-radius: 50%;
  background: #f1dfbd;
  color: #721c18;
  font: 700 25px var(--font-title);
}

.detail-cover-photo {
  width: 106px;
  height: 106px;
  border-radius: 50%;
  object-fit: cover;
}

.detail-profile-cover > .avatar-fallback {
  display: grid;
  place-items: center;
  color: #721c18;
  font: 700 25px var(--font-title);
}

.detail-profile-cover > div:last-child {
  position: relative;
  z-index: 3;
  display: grid;
  justify-items: center;
  gap: 2px;
  color: #fff9e9;
}

.detail-profile-cover h3,
.detail-profile-cover p {
  margin: 0;
}

.detail-profile-cover h3 {
  font: 700 27px var(--font-title);
}

.detail-profile-cover p {
  font-size: 13px;
}

.detail-profile-cover span {
  margin-top: 5px;
  padding: 4px 11px;
  border: 1px solid rgba(241, 202, 112, 0.7);
  border-radius: 999px;
  background: rgba(79, 19, 14, 0.72);
  color: #f5d483;
  font-size: 10px;
  font-weight: 700;
}

.detail-drawer .compact-personal-kinship {
  margin: 8px 0 0;
  border-color: #d7b372;
  background: #fff4d8;
  color: #6f211c;
  text-align: center;
}

.detail-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 10px;
  border-bottom: 1px solid #e4cfaa;
}

.detail-tabs button {
  position: relative;
  min-height: 45px;
  padding: 7px 4px;
  background: transparent;
  color: #6e594a;
  font-size: 11px;
  font-weight: 700;
}

.detail-tabs button.active {
  color: #851d1b;
}

.detail-tabs button.active::after {
  position: absolute;
  right: 10%;
  bottom: -1px;
  left: 10%;
  height: 2px;
  background: #8b201d;
  content: "";
}

.detail-tab-panel {
  padding: 16px 4px 0;
}

.detail-section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 11px;
  color: #6f241e;
}

.detail-section-title > .icon {
  width: 23px;
  height: 23px;
  padding: 4px;
  border-radius: 5px;
  background: #f5e2b9;
  color: #a56b26;
}

.detail-section-title h3,
.detail-section-title p {
  margin: 0;
}

.detail-section-title h3 {
  font: 700 16px var(--font-title);
}

.detail-section-title p {
  color: #8a7767;
  font-size: 9px;
}

.detail-tab-panel > .info-grid {
  padding: 15px;
  border: 1px solid #eadac0;
  border-radius: 7px;
  background: rgba(255, 254, 250, 0.92);
}

.detail-tab-panel .info-grid dt {
  color: #806b59;
}

.detail-tab-panel .info-grid dd {
  color: #30221c;
  font-weight: 600;
}

.detail-children,
.detail-story-block,
.detail-tab-panel .grave-section,
.detail-tab-panel .gallery-section,
.detail-tab-empty {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #ead7b7;
  border-radius: 7px;
  background: rgba(255, 254, 249, 0.92);
}

.detail-children h3,
.detail-story-block h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 10px;
  color: #6d211d;
  font: 700 16px var(--font-title);
}

.detail-story-block > p {
  margin: 0;
  line-height: 1.6;
}

.privacy-hidden,
.privacy-notice p {
  color: #7a685d !important;
  font-style: italic;
}

.privacy-notice {
  border-style: dashed;
  background: #f8f3e9;
}

.privacy-access-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 14px 0;
  padding: 12px 14px;
  border: 1px solid #dfc58d;
  border-radius: 10px;
  background: #fff7e4;
  color: #6b4a20;
}

.privacy-access-banner > .icon,
.privacy-archive-icon .icon,
.privacy-photo .icon {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
}

.privacy-access-banner div {
  display: grid;
  gap: 2px;
}

.privacy-access-banner span {
  font-size: 13px;
  line-height: 1.45;
}

.privacy-photo {
  display: grid !important;
  place-items: center;
  color: #826b4e;
  background: #efe8dc !important;
}

.privacy-archive-notice {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-height: 360px;
  padding: 70px 24px;
  text-align: center;
}

.privacy-archive-notice h2,
.privacy-archive-notice p {
  max-width: 620px;
  margin: 0;
}

.privacy-archive-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #f4e4bd;
  color: #7b511b;
}

.detail-children > div {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  gap: 7px;
}

.detail-children button {
  display: grid;
  grid-template-columns: 43px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 7px;
  border: 1px solid #ead9be;
  border-radius: 6px;
  background: #fffaf0;
  color: #42251d;
  text-align: left;
}

.detail-child-photo {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border: 1px solid #c69b58;
  border-radius: 50%;
  object-fit: cover;
  background: #f0dfbe;
  color: #7b271d;
  font-size: 10px;
  font-weight: 800;
}

.detail-children button span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.detail-children button strong,
.detail-children button small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-children button strong { font-size: 10px; }
.detail-children button small { color: #8a7462; font-size: 8px; }

.detail-tab-empty {
  display: grid;
  min-height: 140px;
  place-items: center;
  align-content: center;
  gap: 9px;
  color: #8a7767;
  text-align: center;
}

.detail-tab-empty .icon {
  width: 32px;
  height: 32px;
  color: #b6843c;
}

.detail-tab-empty p { margin: 0; }

@media (max-width: 900px) {
  .heritage-portal-dashboard {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "clan" "stats" "functions" "events";
  }
}

@media (max-width: 640px) {
  .view-landing .workspace {
    padding: 0 0 calc(82px + env(safe-area-inset-bottom));
  }

  .heritage-home-v28 {
    width: 100%;
    gap: 0;
  }

  .heritage-portal-cover {
    min-height: 545px;
    gap: 17px;
    padding: 46px 18px 36px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .heritage-portal-cover::before {
    inset: 9px;
  }

  .heritage-cover-title p {
    font-size: 26px;
  }

  .heritage-cover-title h2 {
    max-width: 360px;
    margin-top: 4px;
    font-size: 38px;
  }

  .heritage-title-ornament {
    width: 145px;
    margin-top: 14px;
  }

  .heritage-emblem.heritage-portal-emblem {
    width: 205px;
    height: 205px;
  }

  .heritage-portal-emblem > span {
    width: 123px;
    height: 123px;
  }

  .heritage-portal-emblem strong {
    font-size: 62px;
  }

  .heritage-portal-cover blockquote {
    font-size: 18px;
  }

  .heritage-portal-dashboard {
    gap: 11px;
    padding: 12px 12px 20px;
    background: linear-gradient(180deg, #fcf6e9, #f8ecda);
  }

  .heritage-clan-card {
    grid-template-columns: 78px minmax(0, 1fr) 25px;
    gap: 12px;
    min-height: 116px;
    padding: 14px;
  }

  .heritage-clan-seal {
    width: 76px;
    height: 76px;
    box-shadow: inset 0 0 0 5px #f8dfaa, inset 0 0 0 7px rgba(129, 43, 28, 0.45);
  }

  .heritage-clan-seal strong {
    font-size: 37px;
  }

  .heritage-clan-copy > strong {
    font-size: 20px;
  }

  .heritage-clan-copy > em {
    font-size: 10px;
  }

  .heritage-stat-section,
  .heritage-function-section,
  .heritage-portal-dashboard .heritage-event-section {
    padding: 14px;
  }

  .heritage-stat-section > h3,
  .heritage-function-section > h3 {
    margin-bottom: 11px;
    font-size: 18px;
  }

  .heritage-stat-grid {
    gap: 6px;
  }

  .heritage-stat-grid article {
    min-height: 94px;
    padding: 8px 3px;
  }

  .heritage-stat-grid article > span .icon {
    width: 23px;
    height: 23px;
  }

  .heritage-stat-grid article > small {
    font-size: 8px;
  }

  .heritage-stat-grid article > strong {
    font-size: 21px;
  }

  .heritage-function-grid {
    gap: 7px;
  }

  .heritage-function-grid button {
    min-height: 98px;
    gap: 7px;
  }

  .heritage-function-grid button > span {
    width: 42px;
    height: 42px;
  }

  .heritage-function-grid button > span .icon {
    width: 24px;
    height: 24px;
  }

  .heritage-function-grid button strong {
    font-size: 10px;
  }

  .kinship-modal {
    padding: 0;
  }

  .kinship-panel {
    width: 100vw;
    max-height: 100dvh;
    min-height: 100dvh;
    padding: 15px 13px calc(18px + env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
  }

  .kinship-head {
    align-items: center;
    flex-direction: row;
  }

  .kinship-head h2 {
    font-size: 23px;
  }

  .kinship-head p {
    display: none;
  }

  .kinship-fields {
    grid-template-columns: minmax(0, 1fr) 38px minmax(0, 1fr);
    gap: 7px;
    padding: 11px;
  }

  .kinship-fields label {
    min-height: 34px;
    font-size: 12px;
  }

  .kinship-fields .person-combobox input.person-select-input {
    min-height: 43px;
    padding: 8px 8px 8px 34px;
    font-size: 10px;
  }

  .kinship-fields .person-combobox > .icon {
    left: 9px;
    width: 15px;
  }

  .kinship-swap {
    width: 36px;
    height: 36px;
    margin-top: 28px;
  }

  .kinship-person-preview {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 6px;
    padding: 6px;
  }

  .kinship-person-photo {
    width: 40px;
    height: 40px;
    font-size: 9px;
  }

  .kinship-person-preview strong {
    font-size: 10px;
  }

  .kinship-person-preview small {
    font-size: 8px;
  }

  .kinship-result {
    min-height: 300px;
    padding: 19px 12px;
  }

  .kinship-answer h3 {
    font-size: 31px;
  }

  .kinship-answer p {
    font-size: 12px;
  }

  .kinship-portraits {
    grid-template-columns: 76px 82px 76px;
  }

  .kinship-result-photo {
    width: 76px;
    height: 76px;
  }

  .detail-drawer {
    top: 54px;
    width: 100vw;
  }

  .detail-drawer .drawer-head {
    padding: 10px 12px;
  }

  .detail-drawer .drawer-head h2 {
    font-size: 18px;
  }

  .detail-drawer .drawer-body {
    padding: 10px 10px 24px;
  }

  .detail-profile-cover {
    min-height: 204px;
  }

  .detail-profile-cover > .photo-button,
  .detail-profile-cover > .avatar-fallback {
    width: 96px;
    height: 96px;
  }

  .detail-cover-photo {
    width: 90px;
    height: 90px;
  }

  .detail-profile-cover h3 {
    font-size: 23px;
  }

  .detail-tab-panel {
    padding-top: 12px;
  }

  .detail-tab-panel > .info-grid {
    grid-template-columns: minmax(86px, 34%) minmax(0, 1fr);
    padding: 12px;
  }
}

@media (max-width: 390px) {
  .heritage-cover-title h2 {
    font-size: 34px;
  }

  .heritage-portal-cover blockquote {
    font-size: 16px;
  }

  .heritage-stat-grid article > small {
    font-size: 7px;
  }

  .kinship-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .kinship-swap {
    width: 34px;
    height: 34px;
    margin: 0 auto;
    transform: rotate(90deg);
  }

  .kinship-fields label {
    min-height: auto;
  }
}

/* Heritage tree v29: keep the diagram in the same warm lacquer-and-parchment palette as the home screen. */
.view-tree {
  --tree-paper: #f7e8bf;
  --tree-paper-deep: #ecd49b;
  --tree-red: #7d1818;
  --tree-red-dark: #581011;
  --tree-gold: #b77a24;
  --tree-ink: #44251b;
}

.view-tree .viewer-topbar {
  border-bottom: 1px solid #c99c55;
  background:
    linear-gradient(90deg, rgba(255, 247, 224, 0.96), rgba(244, 223, 177, 0.97)),
    url("images/nen-di-san-nguyen-huu-v28.webp") center 42% / cover no-repeat;
  box-shadow: 0 8px 28px rgba(91, 44, 21, 0.14);
}

.view-tree .viewer-topbar .brand-mark {
  border-color: #d3a64f;
  background: linear-gradient(145deg, #9d2a1d, #651112);
  color: #f7d980;
  box-shadow: inset 0 0 0 3px rgba(255, 229, 158, 0.13), 0 7px 18px rgba(101, 17, 18, 0.24);
}

.view-tree .viewer-topbar .brand h1 {
  color: #541b18;
}

.view-tree .viewer-topbar .brand p {
  color: #79573f;
}

.view-tree .viewer-topbar .btn {
  border-color: #731616;
  background: linear-gradient(145deg, #9d291d, #6c1113);
  color: #fff3cf;
  box-shadow: 0 8px 18px rgba(108, 17, 19, 0.18);
}

.view-tree .viewer-topbar .ghost-btn {
  border-color: #c79850;
  background: #f7e7be;
  color: #63221c;
}

.view-tree .workspace {
  background: linear-gradient(180deg, #ead8aa, #e3cc93);
}

.view-tree .tree-viewport {
  border-color: #ad7935;
  background:
    linear-gradient(rgba(255, 244, 207, 0.5), rgba(250, 232, 177, 0.58)),
    var(--family-bg) center center / cover no-repeat,
    #f0dda5;
  box-shadow: 0 20px 44px rgba(93, 48, 22, 0.18), inset 0 0 0 7px rgba(255, 225, 151, 0.25);
}

.view-tree .edge-halo {
  stroke: rgba(255, 238, 193, 0.96);
}

.view-tree .edge {
  stroke: #7c6950;
}

.view-tree .spouse-line {
  stroke: #a43a2e;
}

.view-tree .person-card {
  border-color: rgba(174, 132, 66, 0.42);
  border-left-color: #27705f;
  background: linear-gradient(145deg, rgba(253, 248, 235, 0.98), rgba(246, 235, 210, 0.98));
  box-shadow: 0 5px 14px rgba(83, 46, 24, 0.12), inset 0 1px rgba(255, 252, 242, 0.72);
}

/* Ceremonial paper tree: calm enough for living and ancestral generations alike. */
.view-tree .workspace {
  background: linear-gradient(180deg, #e8d4a4 0, #ddc68f 100%);
}

.view-tree .tree-viewport {
  border: 1px solid #a87938;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 249, 224, 0.2), rgba(250, 237, 193, 0.24)),
    var(--family-tree-paper) center / cover no-repeat,
    #f7e8b8;
  box-shadow:
    0 18px 40px rgba(86, 48, 21, 0.14),
    inset 0 0 0 5px rgba(151, 103, 39, 0.08);
}

.view-tree .person-card {
  border-color: rgba(151, 111, 55, 0.27);
  border-left-color: #4d7969;
  background: linear-gradient(145deg, rgba(255, 252, 239, 0.97), rgba(249, 239, 211, 0.96));
  box-shadow: 0 4px 11px rgba(82, 49, 25, 0.1), inset 0 1px rgba(255, 255, 248, 0.76);
}

.view-tree .person-card.female {
  border-left-color: #a94a41;
}

/* Bring summary and discovery views into the app's burgundy, gold and paper palette. */
.family-overview-page {
  color: #43251a;
}

.overview-hero {
  border-color: #b9853f;
  background: linear-gradient(135deg, #751719 0%, #8d2b1f 58%, #5a1916 100%);
  color: #fff3d2;
  box-shadow: 0 16px 36px rgba(91, 24, 18, 0.2);
}

.overview-emblem {
  border-color: rgba(245, 211, 139, 0.78);
  background: #541113;
  color: #efc66f;
}

.overview-hero p,
.overview-hero > div:nth-child(2) > span {
  color: #efd9b1;
}

.overview-hero h2 {
  color: #fff5d8;
}

.overview-hero > button {
  border-color: #d5ab69;
  background: #fff5dd;
  color: #5e1b18;
}

.overview-hero > button .icon {
  color: #9b271c;
}

.overview-hero > button small {
  color: #7d5d43;
}

.overview-stat-grid article,
.overview-panel {
  border-color: #dec595;
  background: rgba(255, 250, 236, 0.97);
  box-shadow: 0 7px 20px rgba(91, 52, 24, 0.08);
}

.overview-stat-grid article > span,
.overview-stat-grid article:nth-child(3) > span,
.overview-stat-grid article:nth-child(4) > span {
  background: #f3dfb7;
  color: #8c291e;
}

.overview-stat-grid strong,
.overview-panel header h3,
.overview-panel > header > strong,
.generation-bars strong,
.profile-health-panel > p b {
  color: #642019;
}

.overview-stat-grid small,
.overview-stat-grid em,
.overview-panel header p,
.generation-bars span,
.profile-health-panel > p,
.gender-legend span,
.overview-place-list button small {
  color: #79644c;
}

.overview-stat-grid em,
.overview-place-list button {
  border-color: #ead9b6;
}

.generation-bars i,
.gender-meter {
  background: #eee0c2;
}

.generation-bars b,
.gender-meter .male {
  background: #a56c2b;
}

.completion-ring {
  background: conic-gradient(#9a2b20 var(--completion), #eadbbd 0);
}

.completion-ring::before {
  background: #fff8e8;
}

.completion-ring strong,
.places-overview-panel header button {
  color: #85251d;
}

.places-overview-panel header button {
  background: #f3dfb7;
}

.overview-place-list button:hover {
  background: #faeed2;
}

/* Installation help remains available even when mobile browsers delay their native prompt. */
.install-guide {
  position: fixed;
  z-index: 1300;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
}

.install-guide-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(49, 23, 15, 0.55);
  backdrop-filter: blur(5px);
}

.install-guide-panel {
  z-index: 1;
  width: min(440px, calc(100vw - 28px));
  padding: 22px;
  border: 1px solid #c9964b;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 249, 229, 0.9), rgba(249, 232, 190, 0.94)),
    var(--family-tree-paper) center / cover no-repeat,
    #f7e8b8;
  color: #4d281b;
  box-shadow: 0 28px 70px rgba(52, 23, 13, 0.34);
}

.install-guide-panel header {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 38px;
  gap: 11px;
  align-items: center;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(170, 116, 48, 0.32);
}

.install-guide-panel header > span,
.install-guide-panel li > span {
  display: grid;
  place-items: center;
  border: 1px solid #d7aa63;
  background: #f3dba7;
  color: #861f1b;
}

.install-guide-panel header > span {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.install-guide-panel header .icon {
  width: 23px;
  height: 23px;
}

.install-guide-panel header small,
.install-guide-panel header h2,
.install-guide-panel p {
  margin: 0;
}

.install-guide-panel header small {
  color: #98692e;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.install-guide-panel header h2 {
  margin-top: 2px;
  color: #681a17;
  font: 700 22px var(--font-title);
}

.install-guide-panel > p {
  margin: 16px 0 12px;
  color: #72533d;
  line-height: 1.55;
}

.install-guide-panel ol {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.install-guide-panel li {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  padding: 11px;
  border: 1px solid rgba(181, 134, 67, 0.28);
  border-radius: 7px;
  background: rgba(255, 251, 237, 0.72);
}

.install-guide-panel li > span {
  width: 42px;
  height: 42px;
  border-radius: 7px;
}

.install-guide-panel li div {
  display: grid;
  gap: 3px;
}

.install-guide-panel li strong {
  color: #5f211a;
}

.install-guide-panel li small {
  color: #79604b;
  line-height: 1.4;
}

.install-guide-panel > .btn {
  width: 100%;
  min-height: 48px;
}

@media (max-width: 640px) {
  .install-guide {
    align-items: end;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .install-guide-panel {
    width: 100%;
    padding: 17px;
  }

  .install-guide-panel header h2 {
    font-size: 19px;
  }
}

.view-tree .person-card:hover {
  border-color: rgba(164, 111, 35, 0.68);
  background: linear-gradient(145deg, #fffaf0, #f6ead0);
  box-shadow: 0 11px 24px rgba(83, 46, 24, 0.18), inset 0 1px rgba(255, 253, 245, 0.86);
}

.view-tree .person-card.is-viewer {
  outline-color: #a82d22;
  box-shadow: 0 0 0 5px rgba(168, 45, 34, 0.16), 0 13px 28px rgba(83, 46, 24, 0.2);
}

.view-tree .person-card.male { border-left-color: #236958; }
.view-tree .person-card.female { border-left-color: #b64035; }
.view-tree .person-card.other { border-left-color: #9a6b2c; }

.view-tree .person-photo,
.view-tree .avatar-fallback {
  border-color: rgba(177, 132, 62, 0.48);
  background: #f2e8d2;
}

.view-tree .avatar-fallback,
.view-tree .person-name {
  color: #552019;
}

.view-tree .person-meta {
  color: #765742;
}

.view-tree .menu-toggle {
  border-color: #b98235;
  background: linear-gradient(180deg, #faeac0, #edcf8e);
  color: #761b18;
  box-shadow: 0 10px 26px rgba(89, 43, 20, 0.2);
}

.view-tree .menu-panel {
  border-color: #c89c56;
  background: rgba(249, 235, 198, 0.985);
  box-shadow: 0 20px 48px rgba(81, 40, 20, 0.23);
}

.view-tree .menu-section {
  border-color: #d9bd83;
}

.view-tree .menu-section h3 {
  color: #76251e;
}

.view-tree .searchbar,
.view-tree .segmented,
.view-tree .zoom-controls,
.view-tree .branch-segmented,
.view-tree .stats-menu div:not(:first-child) {
  border-color: #d0aa67;
  background: #f5e2b5;
}

.view-tree .searchbar input {
  background: transparent;
  color: var(--tree-ink);
}

.view-tree .segmented button.active,
.view-tree .zoom-controls button.active,
.view-tree .branch-segmented button.active {
  background: var(--tree-red);
  color: #fff0c5;
}

.view-tree .stats-menu strong {
  color: var(--tree-red);
}

.view-tree .ritual-switch-fab,
.view-tree .view-switch-fab,
.view-tree .kinship-fab {
  border-color: #d6ad5c;
  background: linear-gradient(145deg, #98271c, #661012);
  color: #ffe9a5;
  box-shadow: 0 11px 24px rgba(91, 29, 18, 0.25);
}

.view-tree .view-switch-fab {
  background: linear-gradient(145deg, #b17b27, #805016);
}

.view-tree .mobile-bottom-nav {
  border-top-color: #c89c56;
  background: rgba(248, 232, 193, 0.985);
  box-shadow: 0 -9px 28px rgba(85, 42, 21, 0.16);
}

.view-tree .mobile-bottom-nav button {
  color: #725846;
}

.view-tree .mobile-bottom-nav button.active {
  color: var(--tree-red);
}

.view-tree .mobile-bottom-nav button.active::before {
  background: #efd18a;
}

@media (max-width: 640px) {
  .view-tree .workspace {
    background: #e6d09a;
  }

  .view-tree .menu-panel {
    background: rgba(249, 235, 198, 0.995);
  }
}

/* Ceremonial workspace v32: formal family, members and account tabs. */
.view-home,
.view-list,
.view-more {
  --ceremonial-red: #731719;
  --ceremonial-red-dark: #4b0c0e;
  --ceremonial-red-soft: #982d29;
  --ceremonial-gold: #c39542;
  --ceremonial-gold-soft: #ead5a4;
  --ceremonial-paper: #faf6ee;
  --ceremonial-surface: #fffdfa;
  --ceremonial-ink: #3b211d;
  --ceremonial-muted: #796861;
}

.view-home .viewer-topbar,
.view-list .viewer-topbar,
.view-more .viewer-topbar {
  border-bottom-color: #a66f30;
  background:
    linear-gradient(90deg, rgba(75, 12, 14, 0.985), rgba(120, 25, 26, 0.98)),
    url("images/nen-di-san-nguyen-huu-v28.webp") center 44% / cover no-repeat;
  box-shadow: 0 8px 28px rgba(63, 13, 13, 0.2);
}

.view-home .viewer-topbar .brand-mark,
.view-list .viewer-topbar .brand-mark,
.view-more .viewer-topbar .brand-mark {
  border: 1px solid #d9b666;
  background: #fff8e9;
  color: var(--ceremonial-red);
  box-shadow: inset 0 0 0 3px rgba(115, 23, 25, 0.08), 0 6px 16px rgba(35, 8, 9, 0.24);
}

.view-home .viewer-topbar .brand h1,
.view-list .viewer-topbar .brand h1,
.view-more .viewer-topbar .brand h1 {
  color: #fffaf0;
}

.view-home .viewer-topbar .brand p,
.view-list .viewer-topbar .brand p,
.view-more .viewer-topbar .brand p {
  color: #e8cc92;
}

.view-home .viewer-topbar .btn,
.view-list .viewer-topbar .btn,
.view-more .viewer-topbar .btn {
  border-color: #e0bd71;
  background: #fff9ec;
  color: var(--ceremonial-red);
  box-shadow: none;
}

.view-home .viewer-topbar .ghost-btn,
.view-list .viewer-topbar .ghost-btn,
.view-more .viewer-topbar .ghost-btn {
  border-color: rgba(255, 242, 209, 0.52);
  background: rgba(255, 250, 236, 0.08);
  color: #fff9ec;
}

.view-home .workspace,
.view-list .workspace,
.view-more .workspace {
  background:
    linear-gradient(rgba(250, 246, 238, 0.94), rgba(245, 237, 224, 0.97)),
    url("images/nen-di-san-nguyen-huu-v28.webp") center top / cover fixed no-repeat,
    var(--ceremonial-paper);
}

.view-home .my-family-dashboard {
  border-color: #d4b77e;
  background: rgba(250, 246, 238, 0.97);
  box-shadow: 0 20px 46px rgba(76, 27, 20, 0.14);
}

.view-home .my-family-hero {
  border-color: #b8873f;
  background:
    radial-gradient(circle at 90% 15%, rgba(234, 199, 117, 0.18), transparent 32%),
    linear-gradient(135deg, var(--ceremonial-red) 0%, var(--ceremonial-red-dark) 100%);
  color: #fffaf1;
  box-shadow: inset 0 0 0 1px rgba(255, 234, 184, 0.13);
}

.view-home .my-family-hero p {
  color: #e8c77c;
}

.view-home .my-family-hero h2,
.view-home .my-family-hero > div:nth-child(2) > span {
  color: #fffaf1;
}

.view-home .my-family-summary {
  border-left-color: rgba(255, 241, 207, 0.34);
}

.view-home .my-family-summary strong {
  color: #f0cf81;
}

.view-home .my-family-summary span {
  color: #f4e8cf;
}

.view-home .dashboard-actions button,
.view-home .my-family-group,
.view-home .upcoming-panel {
  border-color: #dbc59b;
  background: var(--ceremonial-surface);
  box-shadow: 0 7px 18px rgba(72, 28, 21, 0.07);
}

.view-home .dashboard-actions button {
  --action-accent: var(--ceremonial-red);
  --action-soft: #f5e8dd;
  box-shadow: inset 3px 0 0 var(--ceremonial-red), 0 7px 18px rgba(72, 28, 21, 0.07);
}

.view-home .dashboard-actions button:nth-child(2) {
  --action-accent: #8b5b23;
  --action-soft: #f5edd8;
}

.view-home .dashboard-actions button:hover,
.view-home .my-family-person:hover,
.view-home .upcoming-item:hover {
  border-color: #bd8e47;
  background: #fff8ed;
}

.view-home .my-family-group h3,
.view-home .section-heading h3 {
  color: var(--ceremonial-red-dark);
}

.view-home .my-family-person {
  border-color: transparent;
  background: #fcf8f1;
}

.view-home .my-family-person strong,
.view-home .upcoming-item strong {
  color: var(--ceremonial-ink);
}

.view-home .my-family-person small,
.view-home .upcoming-item small,
.view-home .section-heading p {
  color: var(--ceremonial-muted);
}

.view-home .section-heading > span {
  border-color: #d6b36e;
  background: #f8ead0;
  color: var(--ceremonial-red);
}

.view-list .list-panel {
  border-color: #d4b77e;
  background: rgba(250, 246, 238, 0.97);
  box-shadow: 0 20px 46px rgba(76, 27, 20, 0.14);
}

.view-list .directory-head {
  padding: 18px;
  border: 1px solid #a87535;
  border-radius: 8px;
  background:
    radial-gradient(circle at 92% 12%, rgba(245, 216, 143, 0.17), transparent 34%),
    linear-gradient(135deg, #7a191b, #4b0c0e);
  color: #fffaf1;
}

.view-list .directory-head > div:first-child > span {
  border: 1px solid #dfbf73;
  background: #fff7e6;
  color: var(--ceremonial-red);
}

.view-list .directory-head p,
.view-list .directory-head > div:first-child > div > small {
  color: #e8c77c;
}

.view-list .directory-head h2 {
  color: #fffaf1;
}

.view-list .directory-counts span {
  border-color: rgba(255, 242, 211, 0.3);
  background: rgba(255, 250, 238, 0.09);
  color: #f1e5cd;
}

.view-list .directory-counts strong {
  color: #f0cf81;
}

.view-list .directory-search {
  border-color: #c9a05c;
  background: #fffdfa;
  box-shadow: 0 6px 16px rgba(72, 28, 21, 0.08);
}

.view-list .directory-search .search-icon,
.view-list .directory-search > button {
  color: var(--ceremonial-red);
}

.view-list .directory-search > button {
  background: #f7e9df;
}

.view-list .mobile-directory-card,
.view-list .list-panel .mobile-directory-card {
  border-color: #dfcfb2;
  background: #fffdfa;
  box-shadow: 0 7px 18px rgba(72, 28, 21, 0.07);
}

.view-list .mobile-directory-card:hover,
.view-list .mobile-directory-card:active,
.view-list .list-panel .mobile-directory-card:hover {
  border-color: #bd8e47;
  background: #fff7ec;
}

.view-list .mobile-directory-main strong {
  color: var(--ceremonial-red-dark);
}

.view-list .mobile-directory-main small,
.view-list .mobile-directory-main em {
  color: var(--ceremonial-muted);
}

.view-list .mobile-directory-visual b {
  border-color: #c99a4f;
  background: #f8ead0;
  color: var(--ceremonial-red);
}

.view-list .mini-person-initials {
  background: linear-gradient(145deg, #821d1e, #541012);
  color: #ffe6a9;
}

.view-list .mobile-directory-status {
  background: #e5f0e9;
  color: #246451;
}

.view-list .mobile-directory-status.deceased {
  background: #f5e1de;
  color: #9c322d;
}

.more-page {
  width: min(980px, calc(100vw - 36px));
  margin: 0 auto;
  padding-bottom: 24px;
  color: var(--ceremonial-ink);
}

.more-page-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 150px;
  padding: 24px;
  border: 1px solid #ad7a39;
  border-radius: 8px;
  background:
    radial-gradient(circle at 88% 12%, rgba(239, 204, 126, 0.2), transparent 34%),
    linear-gradient(135deg, #7b191b, #490b0d);
  color: #fffaf1;
  box-shadow: 0 18px 38px rgba(75, 12, 14, 0.18);
}

.more-page-seal {
  display: grid;
  width: 82px;
  height: 82px;
  flex: 0 0 82px;
  place-items: center;
  border: 2px solid #e2bf70;
  border-radius: 50%;
  background: #fff6df;
  color: var(--ceremonial-red);
  box-shadow: inset 0 0 0 5px rgba(115, 23, 25, 0.08);
}

.more-page-seal strong {
  font: 700 38px var(--font-title);
}

.more-page-hero p,
.more-page-hero h2,
.more-page-hero small {
  margin: 0;
}

.more-page-hero p {
  color: #e8c77c;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.more-page-hero h2 {
  margin: 4px 0 6px;
  color: #fffaf1;
  font: 700 30px/1.2 var(--font-title);
}

.more-page-hero small {
  color: #f1e3c9;
}

.more-identity {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 22px;
  align-items: center;
  gap: 13px;
  width: 100%;
  margin: 14px 0 24px;
  padding: 13px;
  border: 1px solid #d7bc88;
  border-radius: 8px;
  background: #fffdfa;
  color: var(--ceremonial-ink);
  text-align: left;
  box-shadow: 0 8px 20px rgba(72, 28, 21, 0.08);
}

.more-identity-photo {
  display: grid;
  width: 58px;
  height: 64px;
  place-items: center;
  border: 1px solid #d1ae6c;
  border-radius: 7px;
  background: #f5e5c6;
  color: var(--ceremonial-red);
  object-fit: cover;
  font-weight: 800;
}

.more-identity > span:not(.more-identity-photo) {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.more-identity small,
.more-identity em {
  color: var(--ceremonial-muted);
  font-size: 10px;
  font-style: normal;
}

.more-identity strong {
  overflow: hidden;
  color: var(--ceremonial-red-dark);
  font: 700 17px var(--font-title);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.more-identity > .icon {
  color: #9d6b2d;
}

.more-identity-empty {
  grid-template-columns: 36px minmax(0, 1fr);
}

.more-section {
  margin-top: 24px;
}

.more-section > header {
  margin-bottom: 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid #dcc59a;
}

.more-section > header p,
.more-section > header h3 {
  margin: 0;
}

.more-section > header p {
  color: #9a6c32;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.more-section > header h3 {
  margin-top: 2px;
  color: var(--ceremonial-red-dark);
  font: 700 20px var(--font-title);
}

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

.more-feature-grid button {
  display: grid;
  min-height: 130px;
  place-items: center;
  align-content: center;
  gap: 6px;
  padding: 14px 10px;
  border: 1px solid #dec9a3;
  border-radius: 8px;
  background: #fffdfa;
  color: var(--ceremonial-ink);
  box-shadow: 0 7px 18px rgba(72, 28, 21, 0.06);
}

.more-feature-grid button:hover {
  border-color: #bd8e47;
  background: #fff7ec;
  transform: translateY(-1px);
}

.more-feature-grid button > span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid #d7b56f;
  border-radius: 50%;
  background: #f7ead1;
  color: var(--ceremonial-red);
}

.more-feature-grid .icon {
  width: 21px;
  height: 21px;
}

.more-feature-grid strong {
  color: var(--ceremonial-red-dark);
  font-size: 13px;
}

.more-feature-grid small {
  color: var(--ceremonial-muted);
  font-size: 9px;
  text-align: center;
}

.more-tool-list {
  display: grid;
  gap: 8px;
}

.more-tool-list button,
.more-tool-list a {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 11px;
  min-height: 66px;
  padding: 10px 12px;
  border: 1px solid #dec9a3;
  border-radius: 8px;
  background: #fffdfa;
  color: var(--ceremonial-ink);
  text-align: left;
}

.more-tool-list button > .icon:first-child,
.more-tool-list a > .icon:first-child {
  width: 38px;
  height: 38px;
  padding: 8px;
  border-radius: 7px;
  background: #f7ead1;
  color: var(--ceremonial-red);
}

.more-tool-list button > span,
.more-tool-list a > span {
  display: grid;
  gap: 2px;
}

.more-tool-list small {
  color: var(--ceremonial-muted);
  font-size: 9px;
}

.more-tool-list > * > .icon:last-child {
  width: 16px;
  color: #a16e2d;
}

.more-tool-list .more-logout {
  border-color: #e2c6c1;
}

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

.more-update-actions a {
  position: relative;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 18px;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 2px 12px;
  min-height: 88px;
  padding: 14px;
  overflow: hidden;
  border: 1px solid #d7b875;
  border-radius: 8px;
  background: #fffdfa;
  color: var(--ceremonial-ink);
  box-shadow: 0 9px 24px rgba(72, 28, 21, 0.08);
}

.more-update-actions a > span {
  grid-row: 1 / 3;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid #d5b165;
  border-radius: 50%;
  background: #f7ead1;
  color: var(--ceremonial-red);
}

.more-update-actions a > span .icon {
  width: 23px;
  height: 23px;
}

.more-update-actions a > strong,
.more-update-actions a > small {
  grid-column: 2;
}

.more-update-actions a > strong {
  align-self: end;
  color: var(--ceremonial-red-dark);
  font-size: 14px;
}

.more-update-actions a > small {
  align-self: start;
  color: var(--ceremonial-muted);
  font-size: 10px;
  line-height: 1.35;
}

.more-update-actions a > .icon:last-child {
  grid-column: 3;
  grid-row: 1 / 3;
  width: 17px;
  color: #9d6b2d;
}

.more-update-actions a.featured {
  border-color: #8f2525;
  background: linear-gradient(135deg, #861f20, #5a0f12);
  color: #fff9ed;
}

.more-update-actions a.featured > span {
  border-color: #e0bd70;
  background: rgba(255, 246, 221, 0.12);
  color: #f1cd7d;
}

.more-update-actions a.featured > strong {
  color: #fffaf1;
}

.more-update-actions a.featured > small {
  color: #ecdcbc;
}

.more-update-actions a.featured > .icon:last-child {
  color: #f1cd7d;
}

.more-update-note {
  margin: 9px 2px 0;
  color: var(--ceremonial-muted);
  font-size: 10px;
  line-height: 1.45;
}

/* Focused phone editor opened from the More tab. */
.mobile-admin-hero {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 13px;
  margin: 0 auto 10px;
  padding: 18px;
  border: 1px solid #a86e34;
  border-radius: 8px;
  background:
    radial-gradient(circle at 90% 10%, rgba(239, 204, 126, 0.2), transparent 36%),
    linear-gradient(135deg, #7b191b, #4b0c0e);
  color: #fffaf1;
  box-shadow: 0 14px 32px rgba(75, 12, 14, 0.17);
}

.mobile-admin-back {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(235, 202, 128, 0.65);
  border-radius: 50%;
  background: rgba(255, 248, 226, 0.08);
  color: #f1cd7d;
}

.mobile-admin-back .icon {
  width: 21px;
  height: 21px;
}

.mobile-admin-hero p,
.mobile-admin-hero h1,
.mobile-admin-hero small {
  margin: 0;
}

.mobile-admin-hero p {
  color: #e8c77c;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.mobile-admin-hero h1 {
  margin: 2px 0 3px;
  color: #fffaf1;
  font: 700 25px/1.15 var(--font-title);
}

.mobile-admin-hero small {
  color: #eddcbd;
  font-size: 11px;
}

.mobile-admin-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 auto 10px;
  padding: 5px;
  border: 1px solid #d8bc87;
  border-radius: 8px;
  background: #f4e8d6;
}

.mobile-admin-switch a {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #695046;
}

.mobile-admin-switch a > .icon {
  width: 34px;
  height: 34px;
  padding: 7px;
  border-radius: 50%;
  background: #fffaf1;
  color: var(--ceremonial-red);
}

.mobile-admin-switch a span {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.mobile-admin-switch a strong,
.mobile-admin-switch a small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-admin-switch a strong {
  font-size: 12px;
}

.mobile-admin-switch a small {
  font-size: 9px;
}

.mobile-admin-switch a.active {
  border-color: #8d2424;
  background: linear-gradient(135deg, #861f20, #641416);
  color: #fff9ed;
  box-shadow: 0 7px 16px rgba(80, 13, 15, 0.15);
}

.mobile-admin-switch a.active > .icon {
  background: rgba(255, 248, 226, 0.12);
  color: #f1cd7d;
}

.mobile-focused-layout {
  grid-template-columns: minmax(250px, 330px) minmax(0, 1fr);
}

.mobile-focused-admin.mobile-new-mode .admin-sidebar {
  display: none;
}

.mobile-focused-admin.mobile-new-mode .mobile-focused-layout {
  grid-template-columns: minmax(0, 1fr);
}

.mobile-focused-admin .admin-panel {
  min-height: 0;
  border-color: #d2b47e;
  background: #fffaf2;
}

.mobile-focused-admin .person-list {
  height: auto;
  min-height: 0;
  max-height: 330px;
}

.mobile-focused-admin .admin-person-row {
  min-height: 56px;
  border: 1px solid transparent;
}

.mobile-focused-admin .admin-person-row.active {
  border-color: #c69c55;
  background: #f7ead4;
}

.mobile-picker-help {
  margin: 8px 0 0;
  color: var(--ceremonial-muted);
  font-size: 10px;
  line-height: 1.4;
}

.mobile-person-form {
  max-height: none;
  background: #fffaf2;
}

.mobile-form-heading {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  margin-bottom: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid #dcc49a;
}

.mobile-form-heading > span {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  background: #f3e1c5;
  color: var(--ceremonial-red);
}

.mobile-form-heading .icon {
  width: 22px;
  height: 22px;
}

.mobile-form-heading small,
.mobile-form-heading h2 {
  margin: 0;
}

.mobile-form-heading small {
  color: #a26b30;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.mobile-form-heading h2 {
  margin-top: 2px;
  overflow-wrap: anywhere;
  color: var(--ceremonial-red-dark);
  font: 700 21px/1.2 var(--font-title);
}

.detail-profile-cover {
  display: flex;
  min-height: 292px;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px 18px 18px;
}

.detail-profile-cover > .photo-button,
.detail-profile-cover > .avatar-fallback {
  position: relative;
  top: auto;
  flex: 0 0 112px;
}

.detail-profile-cover > div:last-child {
  width: 100%;
  margin-top: 14px;
}

.detail-profile-cover h3 {
  max-width: 100%;
  line-height: 1.16;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

@media (max-width: 640px) {
  .mobile-bottom-nav,
  .view-tree .mobile-bottom-nav {
    position: fixed !important;
    inset: auto 0 0 !important;
    z-index: 1000;
    width: 100%;
    height: calc(80px + env(safe-area-inset-bottom));
    padding: 7px 5px max(7px, env(safe-area-inset-bottom));
    border-top: 1px solid #b98a49;
    background: rgba(255, 250, 241, 0.99);
    box-shadow: 0 -10px 30px rgba(64, 16, 16, 0.18);
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    will-change: transform;
  }

  .mobile-bottom-nav button,
  .view-tree .mobile-bottom-nav button {
    min-height: 60px;
    color: #715e57;
  }

  .mobile-bottom-nav button .icon,
  .view-tree .mobile-bottom-nav button .icon {
    width: 31px;
    height: 31px;
    border-radius: 8px;
  }

  .mobile-bottom-nav button.active,
  .view-tree .mobile-bottom-nav button.active {
    color: var(--ceremonial-red, #731719);
  }

  .mobile-bottom-nav button.active .icon,
  .view-tree .mobile-bottom-nav button.active .icon {
    border-color: #d6ae67;
    background: #f5e4cd;
    color: var(--ceremonial-red, #731719);
  }

  .mobile-bottom-nav button.active::before,
  .view-tree .mobile-bottom-nav button.active::before {
    top: -7px;
    background: #7d1819;
  }

  .mobile-bottom-nav span {
    color: inherit;
    font-size: 10px;
    font-weight: 750;
  }

  .workspace,
  .view-tree .workspace {
    padding-bottom: calc(98px + env(safe-area-inset-bottom));
  }

  .view-home .viewer-topbar,
  .view-list .viewer-topbar,
  .view-more .viewer-topbar {
    background: linear-gradient(100deg, #671315, #861f20);
  }

  .view-home .viewer-topbar .brand h1,
  .view-list .viewer-topbar .brand h1,
  .view-more .viewer-topbar .brand h1 {
    font-size: 14px;
  }

  .view-home .my-family-dashboard,
  .view-list .list-panel {
    width: 100%;
    padding: 10px;
    border-color: #d2b278;
    background: #f9f3e9;
  }

  .view-home .mobile-family-hub {
    margin: 0 0 12px;
  }

  .view-home .mobile-hub-family {
    min-height: 88px;
    border-color: #a87035;
    background:
      radial-gradient(circle at 90% 5%, rgba(237, 203, 124, 0.19), transparent 40%),
      linear-gradient(135deg, #7b191b, #4b0c0e);
    box-shadow: inset 0 0 0 1px rgba(255, 236, 193, 0.1);
  }

  .view-home .mobile-hub-monogram {
    border-color: #dfbd6f;
    background: #fff6df;
    color: var(--ceremonial-red);
  }

  .view-home .mobile-hub-family small {
    color: #e8c77c;
  }

  .view-home .mobile-hub-family h2 {
    color: #fffaf1;
    font-size: 16px;
  }

  .view-home .mobile-hub-family p {
    color: #f0dfbf;
  }

  .view-home .mobile-hub-overview {
    border-color: #d3b176;
    background: #fffdfa;
  }

  .view-home .mobile-hub-overview span {
    color: var(--ceremonial-muted);
  }

  .view-home .mobile-hub-overview strong {
    color: var(--ceremonial-red);
  }

  .view-home .mobile-hub-event {
    border-color: #d6bc8b;
    background: #fffdfa;
    color: var(--ceremonial-ink);
    box-shadow: 0 7px 18px rgba(72, 28, 21, 0.07);
  }

  .view-home .my-family-relations {
    grid-template-columns: minmax(0, 1fr);
  }

  .view-home .my-family-group,
  .view-home .upcoming-panel {
    padding: 13px;
  }

  .view-list .directory-head {
    padding: 15px;
    border-top: 1px solid #a87535;
  }

  .view-list .directory-search {
    top: 58px;
    border-color: #c79c56;
    background: rgba(255, 253, 250, 0.99);
  }

  .view-list .mobile-directory-card {
    min-height: 90px;
  }

  .more-page {
    width: 100%;
    padding: 2px 2px 20px;
  }

  .more-page-hero {
    min-height: 122px;
    gap: 13px;
    padding: 17px 15px;
  }

  .more-page-seal {
    width: 64px;
    height: 64px;
    flex-basis: 64px;
  }

  .more-page-seal strong {
    font-size: 30px;
  }

  .more-page-hero h2 {
    font-size: 23px;
  }

  .more-page-hero small {
    display: block;
    font-size: 10px;
    line-height: 1.4;
  }

  .more-identity {
    margin-bottom: 20px;
  }

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

  .more-feature-grid button {
    min-height: 118px;
  }

  .more-update-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .more-update-actions a {
    min-height: 82px;
  }

  .mobile-focused-shell {
    min-height: 100dvh;
    background: #f3e7d4;
  }

  .mobile-focused-shell .admin-topbar {
    display: none;
  }

  .mobile-focused-admin {
    padding: 8px 8px calc(86px + env(safe-area-inset-bottom));
  }

  .mobile-admin-hero {
    margin-bottom: 8px;
    padding: 14px 12px;
  }

  .mobile-admin-hero h1 {
    font-size: 22px;
  }

  .mobile-admin-switch {
    position: sticky;
    top: 0;
    z-index: 40;
    margin-bottom: 8px;
    box-shadow: 0 8px 20px rgba(76, 28, 18, 0.1);
  }

  .mobile-focused-layout,
  .mobile-focused-admin.mobile-new-mode .mobile-focused-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .mobile-focused-admin .admin-sidebar {
    min-height: 0;
  }

  .mobile-focused-admin .panel-head {
    padding: 12px;
  }

  .mobile-focused-admin .panel-head h2 {
    color: var(--ceremonial-red-dark);
    font: 700 18px var(--font-title);
  }

  .mobile-focused-admin .person-list {
    max-height: 310px;
    padding: 6px;
  }

  .mobile-focused-admin .admin-person-row {
    margin-bottom: 4px;
    padding: 7px;
  }

  .mobile-focused-admin .form-wrap {
    padding: 13px 12px 8px;
  }

  .mobile-focused-admin .form-grid {
    gap: 13px;
  }

  .mobile-focused-admin .field input,
  .mobile-focused-admin .field select,
  .mobile-focused-admin .field textarea,
  .mobile-focused-admin .person-select-input {
    min-height: 48px;
    border-color: #d3b47a;
    background: #fffdf8;
    font-size: 16px;
  }

  .mobile-focused-admin .field textarea {
    min-height: 104px;
  }

  .mobile-focused-admin .form-actions {
    position: sticky;
    right: -12px;
    bottom: 0;
    left: -12px;
    z-index: 30;
    margin: 18px -12px -8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid #cda660;
    background: rgba(255, 250, 242, 0.98);
    box-shadow: 0 -9px 22px rgba(65, 22, 17, 0.1);
  }

  .mobile-focused-admin .form-actions .btn {
    min-height: 50px;
    flex: 1 1 180px;
    font-size: 15px;
  }

  .mobile-focused-admin .form-actions .danger-btn {
    min-height: 50px;
  }

  .detail-profile-cover {
    min-height: 270px;
    padding: 16px 14px;
  }

  .detail-profile-cover > .photo-button,
  .detail-profile-cover > .avatar-fallback {
    width: 96px;
    height: 96px;
    flex-basis: 96px;
  }

  .detail-profile-cover > div:last-child {
    margin-top: 12px;
  }

  .detail-profile-cover h3 {
    font-size: 22px;
  }
}
