:root {
  --bg: #f4efe5;
  --paper: rgba(252, 248, 241, 0.92);
  --paper-strong: #fbf6ed;
  --ink: #1d1916;
  --muted: #6a6055;
  --accent: #7b2011;
  --accent-soft: rgba(123, 32, 17, 0.1);
  --line: rgba(62, 44, 30, 0.14);
  --shadow: 0 18px 48px rgba(53, 36, 22, 0.12);
  --mono: "Bahnschrift", "Segoe UI Variable", "Consolas", monospace;
  --sans: "Microsoft YaHei UI", "PingFang SC", "Segoe UI Variable", sans-serif;
  --serif: "STZhongsong", "Songti SC", "SimSun", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(circle at top left, rgba(123, 32, 17, 0.09), transparent 28%),
    linear-gradient(135deg, rgba(0, 0, 0, 0.03), transparent 40%),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(62, 44, 30, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(62, 44, 30, 0.05) 1px, transparent 1px);
  background-size: 100% 40px, 40px 100%;
  opacity: 0.32;
  pointer-events: none;
}

.app-shell {
  position: relative;
  padding: 28px;
}

[hidden] {
  display: none !important;
}

.topbar,
.control-strip,
.panel {
  position: relative;
  z-index: 1;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr);
  gap: 28px;
  padding: 28px 30px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(251, 246, 237, 0.95), rgba(243, 234, 220, 0.92));
  box-shadow: var(--shadow);
}

.eyebrow,
.panel-kicker {
  margin: 0 0 10px;
  font: 700 11px/1.2 var(--mono);
  letter-spacing: 0.24em;
  color: var(--accent);
}

.brand-block h1,
.panel h2,
.subpanel h3 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
}

.brand-block h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.06;
}

.page-home .brand-block {
  display: grid;
  justify-items: center;
  align-content: center;
  text-align: center;
}

.page-home .brand-block h1 {
  font-size: clamp(1.3rem, 2.6vw, 2.3rem);
  font-weight: 800;
  line-height: 1.12;
}

.lead {
  max-width: 34rem;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.8;
}

.topbar-side {
  display: grid;
  align-content: space-between;
  gap: 18px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.page-home .topbar {
  grid-template-columns: minmax(0, 1fr) minmax(520px, 1fr);
}

.page-home .topbar-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.page-home .topbar-button {
  min-width: 0;
}

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

.topbar-button {
  min-width: 120px;
}

.session-pill {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid rgba(123, 32, 17, 0.18);
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.session-pill.is-success {
  border-color: rgba(28, 106, 59, 0.28);
  color: #1c6a3b;
}

.session-pill.is-error {
  border-color: rgba(159, 29, 29, 0.28);
  color: #9f1d1d;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-self: end;
  max-width: 420px;
  justify-self: end;
  width: 100%;
}

.stat {
  padding: 9px 10px;
  border-top: 1px solid var(--accent);
  background: rgba(255, 255, 255, 0.46);
}

.stat strong {
  display: block;
  font: 700 1.18rem/1 var(--serif);
}

.stat span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
}

.control-strip {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(160px, 0.85fr) minmax(220px, 1fr);
  gap: 14px;
  align-items: end;
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  background: rgba(252, 248, 241, 0.82);
  backdrop-filter: blur(10px);
}

.auth-status {
  min-height: 52px;
  width: 100%;
  padding: 12px 14px;
  border-left: 2px solid var(--accent);
  background: rgba(255, 255, 255, 0.48);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.auth-status.is-success {
  border-left-color: #1c6a3b;
  color: #1c6a3b;
}

.auth-status.is-error {
  border-left-color: #9f1d1d;
  color: #9f1d1d;
}

.auth-hint {
  margin-top: 8px;
}

.ghost-button {
  align-self: center;
  padding: 12px 18px;
  border: 1px solid rgba(123, 32, 17, 0.35);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease;
}

.ghost-button:hover {
  transform: translateY(-1px);
  background: rgba(123, 32, 17, 0.08);
}

.admin-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 17, 12, 0.44);
  backdrop-filter: blur(8px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  padding: 24px;
  border: 1px solid rgba(62, 44, 30, 0.18);
  background:
    linear-gradient(180deg, rgba(123, 32, 17, 0.06), transparent 26%),
    var(--paper-strong);
  box-shadow: 0 28px 80px rgba(23, 17, 12, 0.28);
  animation: rise 220ms ease both;
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.modal-close {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(123, 32, 17, 0.18);
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.modal-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.modal-submit {
  justify-self: start;
  margin-top: 6px;
}

.import-status {
  min-height: 52px;
  padding: 12px 14px;
  border-left: 2px solid var(--accent);
  background: rgba(255, 255, 255, 0.48);
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.import-status.is-success {
  border-left-color: #1c6a3b;
  color: #1c6a3b;
}

.import-status.is-error {
  border-left-color: #9f1d1d;
  color: #9f1d1d;
}

.control,
.toggle {
  display: grid;
  gap: 8px;
}

.control span,
.toggle span {
  color: var(--muted);
  font-size: 0.82rem;
}

.status-filter-control {
  align-self: stretch;
}

.status-filter-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.status-filter-button {
  padding: 12px 14px;
  border: 1px solid rgba(62, 44, 30, 0.18);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.status-filter-button:hover,
.status-filter-button.active {
  transform: translateY(-1px);
  border-color: rgba(123, 32, 17, 0.35);
  background: rgba(123, 32, 17, 0.08);
  color: var(--ink);
}

.status-filter-button.is-alive.active {
  border-color: rgba(28, 106, 59, 0.3);
  background: rgba(28, 106, 59, 0.1);
  color: #1c6a3b;
}

.status-filter-button.is-deceased.active {
  border-color: rgba(159, 29, 29, 0.3);
  background: rgba(159, 29, 29, 0.1);
  color: #9f1d1d;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(62, 44, 30, 0.18);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  transition: border-color 180ms ease, transform 180ms ease, background 180ms ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.95);
}

.toggle {
  grid-template-columns: 18px auto;
  align-items: center;
  padding-top: 22px;
}

.toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.reset-button {
  align-self: center;
  margin-top: 20px;
  padding: 12px 18px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff8f2;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease;
}

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

.reset-button:disabled,
.ghost-button:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.5fr) minmax(320px, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.page-home .workspace {
  grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.5fr);
}

.page-home .generation-panel {
  display: none;
}

.home-admin-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  background: rgba(252, 248, 241, 0.72);
}

.comparison-panel {
  min-height: auto;
  margin-top: 18px;
}

.comparison-page-layout {
  display: grid;
  margin-top: 18px;
}

.generation-page-layout {
  display: grid;
  margin-top: 18px;
}

.gallery-page-layout {
  display: grid;
  margin-top: 18px;
}

.comparison-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 14px;
  align-items: end;
}

.comparison-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.comparison-action-button {
  margin-top: 0;
}

.comparison-candidate-grid,
.comparison-path-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

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

.comparison-candidate-panel,
.comparison-path-card,
.comparison-summary-card {
  min-width: 0;
}

.comparison-candidate-list,
.comparison-lineage-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.comparison-candidate-button,
.comparison-lineage-step {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(62, 44, 30, 0.14);
  background: rgba(255, 255, 255, 0.52);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.comparison-candidate-button:hover,
.comparison-candidate-button.active,
.comparison-lineage-step:hover {
  transform: translateY(-1px);
  border-color: rgba(123, 32, 17, 0.38);
  background: rgba(123, 32, 17, 0.08);
}

.comparison-candidate-button strong,
.comparison-summary-card h3,
.comparison-lineage-step strong {
  font-family: var(--serif);
}

.comparison-candidate-button span,
.comparison-summary-meta {
  font-size: 0.84rem;
}

.comparison-summary-card {
  margin-top: 16px;
  padding: 16px 18px;
  border: 1px solid rgba(62, 44, 30, 0.14);
  background:
    linear-gradient(180deg, rgba(123, 32, 17, 0.06), transparent 30%),
    rgba(255, 255, 255, 0.46);
}

.comparison-summary-card h3 {
  margin: 0;
  font-size: 1.4rem;
}

.comparison-summary-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.comparison-path-card {
  padding: 16px;
}

.panel {
  min-height: 720px;
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
  animation: rise 520ms ease both;
}

.panel:nth-child(2) {
  animation-delay: 80ms;
}

.panel:nth-child(3) {
  animation-delay: 140ms;
}

.panel-head,
.subpanel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

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

.panel h2 {
  font-size: 1.5rem;
}

.summary-text,
.subpanel-head p,
.empty-state p,
.person-meta,
.list-note,
.node-note,
.child-note,
.board-note {
  color: var(--muted);
}

.summary-text,
.subpanel-head p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.6;
}

.person-list,
.generation-board {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 280px);
  overflow: auto;
  padding-right: 4px;
}

.person-row,
.board-row,
.child-card,
.empty-state,
.detail-card,
.subpanel {
  border: 1px solid rgba(62, 44, 30, 0.14);
  background: rgba(255, 255, 255, 0.4);
}

.person-row,
.board-row {
  padding: 14px;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.person-row:hover,
.person-row.active,
.board-row:hover,
.board-row.active {
  transform: translateX(4px);
  border-color: rgba(123, 32, 17, 0.4);
  background: rgba(123, 32, 17, 0.08);
}

.person-row-head,
.board-row-head,
.detail-top,
.detail-actions {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.person-row strong,
.board-row strong,
.detail-name,
.child-name,
.tree-node-title {
  font-family: var(--serif);
  font-weight: 700;
}

.person-id,
.detail-id,
.chip,
.tree-node-meta {
  font: 700 0.74rem/1.2 var(--mono);
  color: var(--accent);
  letter-spacing: 0.04em;
}

.pill,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--accent-soft);
}

.person-meta,
.child-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  font-size: 0.88rem;
}

.detail-meta {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.list-note,
.board-note {
  margin-top: 8px;
  font-size: 0.84rem;
  line-height: 1.55;
}

.detail-card {
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(123, 32, 17, 0.06), transparent 30%),
    var(--paper-strong);
}

.detail-name {
  font-size: 2.05rem;
  line-height: 1.06;
  letter-spacing: 0.01em;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.detail-fact,
.detail-meta-line,
.detail-contact-item {
  border: 1px solid rgba(123, 32, 17, 0.14);
  background: rgba(255, 255, 255, 0.72);
}

.detail-fact {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 16px;
}

.detail-fact-label,
.detail-meta-label,
.detail-contact-label {
  font-size: 0.72rem;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(106, 96, 85, 0.86);
}

.detail-fact strong,
.detail-meta-line strong,
.detail-contact-item strong {
  font-family: var(--serif);
  font-size: 1.02rem;
  line-height: 1.35;
  color: var(--ink);
}

.detail-meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
}

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

.detail-contact-item {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  min-width: 0;
}

.detail-contact-item strong {
  font-size: 0.98rem;
  word-break: break-word;
}

.detail-note {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(123, 32, 17, 0.14);
  font-size: 0.96rem;
  line-height: 1.8;
  color: rgba(50, 41, 33, 0.9);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.subpanel {
  padding: 16px;
}

.collapsible-panel {
  display: block;
}

.collapsible-panel > summary {
  cursor: pointer;
  list-style: none;
}

.collapsible-panel > summary::-webkit-details-marker {
  display: none;
}

.collapsible-panel > summary.subpanel-head {
  align-items: flex-start;
}

.collapsible-panel > summary.subpanel-head::after {
  content: "+";
  display: grid;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  place-items: center;
  margin-left: auto;
  border: 1px solid rgba(123, 32, 17, 0.22);
  background: rgba(255, 255, 255, 0.62);
  color: var(--accent);
  font: 700 1.1rem/1 var(--mono);
}

.collapsible-panel[open] > summary.subpanel-head::after {
  content: "-";
}

.tree-panel {
  margin-top: 16px;
}

.ancestry-path,
.next-generation,
.subtree-preview {
  margin-top: 14px;
}

.ancestry-path {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.path-node {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.58);
  border-left: 2px solid var(--accent);
}

.path-node button,
.detail-actions button,
.child-card button,
.tree-node button,
.child-chip button {
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.detail-actions {
  margin-top: 18px;
  flex-wrap: wrap;
}

.detail-actions button {
  padding: 10px 12px;
  border: 1px solid rgba(123, 32, 17, 0.22);
  background: rgba(255, 255, 255, 0.55);
  transition: background 180ms ease, transform 180ms ease;
}

.detail-actions button:hover,
.child-card button:hover {
  background: rgba(123, 32, 17, 0.1);
  transform: translateY(-1px);
}

.next-generation {
  display: grid;
  gap: 10px;
}

.child-card {
  padding: 14px;
  background: rgba(255, 255, 255, 0.56);
}

.child-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.child-meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.child-note {
  margin-top: 8px;
  font-size: 0.84rem;
  line-height: 1.5;
}

.tree-root,
.tree-children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-root {
  display: grid;
  gap: 10px;
}

.tree-node {
  position: relative;
  padding-left: 18px;
}

.tree-node::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: -8px;
  width: 1px;
  background: rgba(123, 32, 17, 0.2);
}

.tree-node:last-child::before {
  bottom: 18px;
}

.tree-node::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 18px;
  width: 10px;
  height: 1px;
  background: rgba(123, 32, 17, 0.2);
}

.tree-node-card {
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(62, 44, 30, 0.12);
}

.tree-node-card[data-generation-tone="1"] {
  background: rgba(137, 164, 141, 0.16);
  border-color: rgba(137, 164, 141, 0.32);
}

.tree-node-card[data-generation-tone="2"] {
  background: rgba(184, 149, 112, 0.16);
  border-color: rgba(184, 149, 112, 0.3);
}

.tree-node-card[data-generation-tone="3"] {
  background: rgba(113, 151, 174, 0.15);
  border-color: rgba(113, 151, 174, 0.3);
}

.tree-node-card[data-generation-tone="4"] {
  background: rgba(174, 125, 126, 0.14);
  border-color: rgba(174, 125, 126, 0.28);
}

.tree-node-card[data-generation-tone="5"] {
  background: rgba(143, 133, 177, 0.13);
  border-color: rgba(143, 133, 177, 0.28);
}

.tree-node-card[data-generation-tone="6"] {
  background: rgba(191, 170, 92, 0.14);
  border-color: rgba(191, 170, 92, 0.28);
}

.tree-node-card[data-generation-tone="7"] {
  background: rgba(98, 159, 151, 0.14);
  border-color: rgba(98, 159, 151, 0.28);
}

.tree-node-card[data-generation-tone="8"] {
  background: rgba(157, 143, 125, 0.14);
  border-color: rgba(157, 143, 125, 0.28);
}

.tree-node-title {
  font-size: 0.98rem;
}

.tree-node-meta {
  margin-top: 6px;
}

.tree-node-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
}

.tree-children {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding-left: 8px;
}

.board-toolbar {
  margin-bottom: 14px;
}

.generation-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.generation-stat-card {
  border: 1px solid rgba(62, 44, 30, 0.14);
  background: rgba(255, 255, 255, 0.46);
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.generation-stat-card:hover,
.generation-stat-card.active {
  transform: translateY(-1px);
  border-color: rgba(123, 32, 17, 0.4);
  background: rgba(123, 32, 17, 0.08);
}

.generation-stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.generation-stat-head strong {
  font-family: var(--serif);
  font-weight: 700;
}

.generation-stat-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.detail-pill-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-chip,
.status-meta,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-chip {
  padding: 4px 8px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.72);
}

.status-chip-button {
  border: 0;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease;
}

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

.status-chip.is-alive,
.status-meta.is-alive,
.status-pill.is-alive {
  color: #1c6a3b;
}

.status-chip.is-deceased,
.status-meta.is-deceased,
.status-pill.is-deceased {
  color: #9f1d1d;
}

.status-pill.is-alive {
  background: rgba(28, 106, 59, 0.1);
}

.status-pill.is-deceased {
  background: rgba(159, 29, 29, 0.1);
}

.control.compact {
  max-width: 180px;
}

.board-row-children {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.child-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.66);
  border-left: 2px solid rgba(123, 32, 17, 0.45);
  font-size: 0.84rem;
}

.empty-state {
  padding: 22px 18px;
  background: rgba(255, 255, 255, 0.36);
}

.empty-state strong {
  display: block;
  font-family: var(--serif);
  font-size: 1rem;
}

.empty-state p {
  margin: 8px 0 0;
  font-size: 0.9rem;
  line-height: 1.65;
}

.gallery-panel {
  margin-top: 18px;
  min-height: auto;
}

.gallery-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.6fr);
  gap: 18px;
}

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

.gallery-side,
.gallery-main {
  min-width: 0;
}

.album-list {
  display: grid;
  gap: 12px;
}

.album-card {
  width: 100%;
  padding: 0;
  border: 1px solid rgba(62, 44, 30, 0.14);
  background: rgba(255, 255, 255, 0.52);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  overflow: hidden;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.album-card:hover,
.album-card.active {
  transform: translateY(-2px);
  border-color: rgba(123, 32, 17, 0.38);
  background: rgba(123, 32, 17, 0.08);
}

.album-cover,
.album-hero-cover {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: rgba(123, 32, 17, 0.08);
}

.album-cover.placeholder,
.album-hero-cover.placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.album-card-body {
  display: grid;
  gap: 6px;
  padding: 14px;
}

.album-card-body strong,
.album-hero-copy h3,
.photo-card-copy strong {
  font-family: var(--serif);
}

.album-card-body span {
  color: var(--accent);
  font: 700 0.78rem/1.2 var(--mono);
}

.album-card-body p,
.photo-card-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.album-hero {
  min-height: 140px;
}

.album-hero-card {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
  padding: 14px;
  border: 1px solid rgba(62, 44, 30, 0.14);
  background: rgba(255, 255, 255, 0.46);
}

.album-hero-cover {
  height: 240px;
}

.album-hero-copy {
  display: grid;
  align-content: start;
  gap: 12px;
}

.album-hero-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.album-photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.photo-card {
  overflow: hidden;
}

.photo-card-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.photo-card-button img {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: cover;
  transition: transform 220ms ease;
}

.photo-card:hover .photo-card-button img {
  transform: scale(1.04);
}

.photo-card-copy {
  display: grid;
  gap: 6px;
  padding: 12px 14px 14px;
}

.viewer-shell {
  z-index: 40;
}

.viewer-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 1080px);
  padding: 24px;
  border: 1px solid rgba(62, 44, 30, 0.18);
  background:
    linear-gradient(180deg, rgba(123, 32, 17, 0.06), transparent 26%),
    var(--paper-strong);
  box-shadow: 0 28px 80px rgba(23, 17, 12, 0.28);
  animation: rise 220ms ease both;
}

.viewer-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.viewer-body {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  gap: 18px;
  margin-top: 18px;
}

.viewer-image {
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
  background: rgba(62, 44, 30, 0.08);
}

.viewer-meta {
  display: grid;
  align-content: start;
  gap: 10px;
}

.viewer-meta strong {
  font-family: var(--serif);
  font-size: 1.35rem;
}

.viewer-meta p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

mark {
  background: rgba(123, 32, 17, 0.16);
  color: inherit;
  padding: 0 2px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: minmax(260px, 0.85fr) minmax(0, 1.25fr);
  }

  .comparison-path-grid {
    grid-template-columns: 1fr;
  }

  .generation-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }

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

@media (max-width: 920px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    gap: 20px;
    padding: 20px 18px;
  }

  .page-home .topbar {
    grid-template-columns: 1fr;
  }

  .topbar,
  .control-strip,
  .comparison-toolbar,
  .comparison-candidate-grid,
  .comparison-path-grid,
  .workspace,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .page-home .control-strip {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .page-home .control-strip .control:first-child {
    grid-column: 1 / -1;
  }

  body {
    padding-bottom: 76px;
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
    border: 1px solid rgba(62, 44, 30, 0.16);
    background: rgba(251, 246, 237, 0.94);
    box-shadow: 0 14px 34px rgba(53, 36, 22, 0.2);
    backdrop-filter: blur(12px);
  }

  .mobile-bottom-link {
    display: grid;
    min-height: 44px;
    place-items: center;
    border: 1px solid rgba(123, 32, 17, 0.16);
    background: rgba(255, 255, 255, 0.58);
    color: var(--muted);
    text-decoration: none;
    font-size: 0.92rem;
  }

  .mobile-bottom-link.active {
    border-color: rgba(123, 32, 17, 0.38);
    background: rgba(123, 32, 17, 0.1);
    color: var(--accent);
    font-weight: 700;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
  }

  .page-home .workspace {
    grid-template-columns: 1fr;
  }

  .home-admin-footer {
    justify-content: stretch;
  }

  .home-admin-footer .topbar-button {
    flex: 1 1 0;
  }

  .topbar-button,
  .session-pill {
    width: 100%;
    min-width: 0;
  }

  .modal-shell {
    padding: 16px;
  }

  .hero-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    max-width: none;
  }

  .stat {
    padding: 8px 9px;
  }

  .stat strong {
    font-size: 1.1rem;
  }

  .lead {
    max-width: none;
    line-height: 1.7;
  }

  .reset-button {
    margin-top: 0;
  }

  .panel {
    min-height: auto;
    padding: 18px 16px;
  }

  .comparison-actions {
    justify-content: stretch;
  }

  .comparison-action-button {
    width: 100%;
  }

  .person-list,
  .generation-board {
    max-height: none;
  }

  .panel-head,
  .person-row-head,
  .board-row-head,
  .detail-top,
  .detail-actions,
  .child-top,
  .album-hero-head,
  .viewer-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .subpanel-head:not(summary),
  .collapsible-panel > summary.subpanel-head {
    flex-direction: row;
    align-items: flex-start;
  }

  .detail-pill-group {
    justify-content: flex-start;
  }

  .detail-name {
    font-size: 1.7rem;
  }

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

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

  .generation-stat-card {
    min-height: 108px;
  }

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

  .gallery-layout,
  .album-hero-card,
  .viewer-body {
    grid-template-columns: 1fr;
  }

  .gallery-side {
    overflow-x: auto;
    padding-bottom: 6px;
  }

  .album-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 72vw);
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
  }

  .album-card {
    scroll-snap-align: start;
  }

  .album-hero-cover {
    height: 220px;
  }

  .album-photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .photo-card-button img {
    height: 200px;
  }

  .viewer-panel {
    padding: 18px;
  }

  .viewer-image {
    max-height: 58vh;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    padding: 18px 14px;
  }

  .brand-block h1 {
    font-size: clamp(1.7rem, 9vw, 2.3rem);
  }

  .eyebrow,
  .panel-kicker {
    letter-spacing: 0.18em;
  }

  .lead {
    margin-top: 10px;
    font-size: 0.92rem;
  }

  .album-photo-grid {
    grid-template-columns: 1fr;
  }

  .hero-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .stat {
    padding: 7px 6px;
  }

  .stat strong {
    font-size: 0.95rem;
  }

  .stat span {
    font-size: 0.64rem;
    line-height: 1.2;
  }

  .page-home .control-strip {
    margin-top: 12px;
    padding: 10px;
  }

  .mobile-bottom-nav {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }

  .status-filter-group {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .status-filter-button {
    min-height: 42px;
    padding: 9px 8px;
    font-size: 0.88rem;
  }

  .page-home .control-strip input,
  .page-home .control-strip select {
    min-height: 42px;
    padding: 9px 10px;
  }

  .page-home .control-strip .control {
    gap: 6px;
  }

  .panel {
    padding: 16px 14px;
  }

  .panel h2 {
    font-size: 1.28rem;
  }

  .person-row,
  .board-row,
  .child-card,
  .generation-stat-card,
  .subpanel,
  .detail-card,
  .comparison-summary-card,
  .comparison-path-card {
    padding: 12px;
  }

  .detail-name {
    font-size: 1.5rem;
  }

  .person-meta,
  .child-meta,
  .comparison-summary-meta {
    gap: 6px 10px;
  }

  .detail-meta {
    gap: 10px;
  }

  .detail-facts,
  .detail-contact {
    grid-template-columns: 1fr;
  }

  .detail-fact,
  .detail-meta-line,
  .detail-contact-item {
    padding: 11px 12px;
  }

  .detail-fact strong,
  .detail-meta-line strong,
  .detail-contact-item strong {
    font-size: 0.96rem;
  }

  .detail-note {
    font-size: 0.92rem;
    line-height: 1.72;
  }

  .generation-stats-grid,
  .comparison-summary-meta {
    grid-template-columns: 1fr;
  }

  .comparison-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .album-list {
    grid-auto-columns: minmax(240px, 88vw);
  }

  .album-cover,
  .photo-card-button img {
    height: 190px;
  }

  .album-hero-cover {
    height: 200px;
  }

  .album-hero-card {
    padding: 12px;
  }

  .viewer-panel {
    padding: 14px;
  }

  .viewer-image {
    max-height: 50vh;
  }
}

@media (max-width: 480px) {
  .topbar-actions,
  .comparison-actions {
    grid-template-columns: 1fr;
  }
}
