:root {
  --bg: #f4f1ea;
  --bg-secondary: #ece7dc;
  --surface: #fbf8f2;
  --surface-subtle: #f3eee4;
  --surface-elevated: #fffdf8;
  --border: #e0d9cc;
  --border-strong: #cfc6b6;
  --text: #2c2a26;
  --text-muted: #6f6a62;
  --accent: #5f7d62;
  --accent-hover: #4e6a51;
  --accent-soft: rgba(95, 125, 98, 0.12);
  --accent-secondary: #b69a69;
  --on-accent: #f7f4ee;
  --male: #6d7f93;
  --female: #9a6e76;
  --unknown: #7d8478;
  --shadow: 0 1px 2px rgba(44, 42, 38, 0.06), 0 8px 24px rgba(44, 42, 38, 0.05);
  --shadow-soft: 0 1px 2px rgba(44, 42, 38, 0.05);
  --header: rgba(251, 248, 242, 0.92);
  --radius: 5px;
  --radius-sm: 5px;
  --font: "Manrope", system-ui, sans-serif;
  --font-serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --paper-noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.15  0 0 0 0 0.13  0 0 0 0 0.1  0 0 0 0.035 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

html[data-tree-theme="dark"] {
  --bg: #0F1417;
  --bg-secondary: #141b1f;
  --surface: #171E22;
  --surface-subtle: #1a2227;
  --surface-elevated: #1C252A;
  --border: #293238;
  --border-strong: #334046;
  --text: #EEEAE2;
  --text-muted: #9EA6A3;
  --accent: #789B78;
  --accent-hover: #8AAD8A;
  --accent-soft: rgba(120, 155, 120, 0.14);
  --accent-secondary: #B89A68;
  --on-accent: #F4F1EA;
  --male: #7b8fa6;
  --female: #b4848c;
  --unknown: #8b9388;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.28), 0 10px 28px rgba(0, 0, 0, 0.22);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.2);
  --header: rgba(15, 20, 23, 0.92);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--paper-noise);
  letter-spacing: -0.01em;
}
.grain { display: none; }

a { color: var(--accent); }
h1, h2, h3 { letter-spacing: -0.03em; }
h1 {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: clamp(1.95rem, 3.4vw, 2.7rem);
  font-weight: 600;
}
h2 {
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 600;
}
h3 { margin: 0 0 8px; font-family: var(--font-serif); font-weight: 600; }

.site-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--header);
  border-bottom: 1px solid var(--border);
}
.top, main, footer {
  position: relative;
  width: min(1260px, calc(100% - 48px));
  margin: 0 auto;
}
.top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  height: 66px;
  padding: 0;
  color: var(--text);
}
.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px 22px;
  min-width: 0;
}
.nav-links a, .who {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 0 6px;
  border-bottom: 2px solid transparent;
}
.nav-links a:hover { color: var(--text); }
.nav-links a.on {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.nav-cta {
  color: var(--accent) !important;
  border-bottom-color: transparent !important;
}
.nav-cta:hover { color: var(--text) !important; }
.top-end {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-toggle {
  display: none;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.site-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(220px, 26vw);
  height: 34px;
  padding: 0 10px;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
}
.site-search svg { flex: none; }
.bell {
  position: relative;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--text-muted);
  text-decoration: none;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
}
.bell:hover { color: var(--text); }
.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle .theme-icon-sun,
.theme-toggle .theme-icon-moon { display: block; }
html[data-tree-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }
html[data-tree-theme="light"] .theme-toggle .theme-icon-sun { display: none; }
.badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 9px;
  font-weight: 800;
  line-height: 15px;
  text-align: center;
}
.brand { margin: 0; }
.logo {
  display: flex;
  align-items: center;
  flex: none;
  text-decoration: none;
  line-height: 0;
}
.logo-img {
  display: block;
  height: 48px;
  width: auto;
  max-width: min(220px, 54vw);
}
.logo-light { display: none; }
html[data-tree-theme="light"] .logo-dark { display: none; }
html[data-tree-theme="light"] .logo-light { display: block; }
.account { position: relative; flex: none; }
.avatar-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 220px;
  padding: 10px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
}
.account-menu[hidden] { display: none; }
.account-menu p {
  margin: 0 0 6px;
  padding: 4px 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 650;
}
.account-menu p small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
}
.account-menu button,
.account-menu .menu-link {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}
.account-menu button:hover,
.account-menu .menu-link:hover { background: var(--accent-soft); }
.account-menu button.on { color: var(--accent); }
.inline { display: inline; }
.linkish {
  background: none;
  border: 0;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.linkish:hover { color: var(--accent); }

.eyebrow,
.eyebrow.dark {
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-secondary);
  margin: 0 0 10px;
}
.eyebrow a,
.eyebrow.dark a {
  color: var(--accent-secondary);
  text-decoration: none;
}
.eyebrow a:hover { color: var(--text); }
.lede, footer p { color: var(--text-muted); line-height: 1.65; max-width: 62ch; }
.section-lead {
  margin: 0 0 22px;
  max-width: 54ch;
  color: var(--text-muted);
  font-size: 1.08rem;
  line-height: 1.58;
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(220px, 0.85fr);
  gap: 32px;
  align-items: center;
  padding: 36px 0 18px;
}
.lede a { color: var(--accent); }
a.primary { color: var(--on-accent); }
a.primary:hover { color: var(--on-accent); }
.hero-tree { position: relative; min-height: 220px; }
.mini-card {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 168px;
  padding: 7px 10px 7px 7px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-soft);
  font-size: 12px;
  font-weight: 650;
}
.mini-card span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  flex: none;
  font-size: 12px;
}
.mini-card.m { left: 8px; top: 8px; }
.mini-card.m span { background: var(--male); }
.mini-card.f { right: 0; top: 8px; }
.mini-card.f span { background: var(--female); }
.mini-card.c { left: 52px; top: 118px; }
.mini-card.c span { background: var(--accent); }
.mini-line {
  position: absolute;
  background: var(--border-strong);
  left: 50%;
  top: 50px;
  width: 1.5px;
  height: 68px;
  transform: translateX(-1px);
}
.mini-line.h {
  top: 36px;
  left: 88px;
  width: 92px;
  height: 1.5px;
}

.sheet, .about-wrap {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 28px 0 56px;
  border-radius: 0;
  margin: 0;
}
.narrow { max-width: 36rem; }
.hint, .meta { color: var(--text-muted); }
.hint.warn { color: #c45b4a; font-weight: 600; }
html[data-tree-theme="dark"] .hint.warn { color: #e0a090; }
.flash {
  max-width: 36rem;
  margin: 12px auto 0;
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-elevated));
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border));
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 650;
  font-size: 14.5px;
  text-align: center;
}
html[data-tree-theme="dark"] .flash {
  background: color-mix(in srgb, #6fbf78 34%, #17241b);
  border-color: #6fbf78;
  color: #e9f8ec;
}
.error-page {
  max-width: 36rem;
  padding: 56px 0 72px;
}
.error-page .error-code {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-secondary);
}
.error-page h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 2.8rem);
}
.error-page .lede {
  margin: 0;
  max-width: 38ch;
}
.error-page .actions {
  margin-top: 28px;
}
.stack, .grid { display: grid; gap: 14px; }
.grid { grid-template-columns: 1fr 1fr; }
.wide { grid-column: 1 / -1; }
.row-head, .actions, .inline-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.row-head { justify-content: space-between; }
.inline-form .ghost,
.inline-form .primary,
.tree-delete .ghost,
.member-list .ghost {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
}
label[hidden],
[data-maiden-row][hidden] {
  display: none !important;
}
.check { flex-direction: row; align-items: center; font-weight: 500; }
input, select, textarea, button { font: inherit; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
  padding: 11px 12px;
  border-radius: var(--radius-sm);
}
.site-search input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]) {
  flex: 1;
  width: auto;
  min-width: 0;
  height: 32px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 13px;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
}
.site-search input:focus { outline: none; }
.site-search input::-webkit-search-decoration,
.site-search input::-webkit-search-cancel-button {
  appearance: none;
  -webkit-appearance: none;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%239EA6A3' stroke-width='1.4' stroke-linecap='round' d='M1.5 1.5 6 6 10.5 1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
html[data-tree-theme="light"] select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%236f6a62' stroke-width='1.4' stroke-linecap='round' d='M1.5 1.5 6 6 10.5 1.5'/></svg>");
}
.primary, .ghost, .btn-quiet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  border: 0;
  cursor: pointer;
  font-weight: 650;
  font-size: 14.5px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}
.primary { background: var(--accent); color: var(--on-accent); }
.primary:hover { background: var(--accent-hover); }
.ghost, .btn-quiet {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.ghost:hover, .btn-quiet:hover { border-color: var(--accent); color: var(--accent); }
.home-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}
.home-pills li {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-muted);
}
.home-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.home-split article {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.home-split h3 { margin: 0 0 6px; font-size: 1.05rem; }
.home-split p { margin: 0; color: var(--text-muted); font-size: 14px; line-height: 1.5; }
.home-steps {
  margin: 0;
  padding-left: 1.2em;
  color: var(--text-muted);
  line-height: 1.6;
}
.home-steps li { margin: 0 0 10px; }
.home-steps strong { color: var(--text); }
.home-faq { display: grid; gap: 8px; }
.home-faq details {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  padding: 10px 14px;
}
.home-faq summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
}
.home-faq p { margin: 8px 0 4px; color: var(--text-muted); line-height: 1.55; }
.home-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 20px 0 8px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.home-cta h2 { margin: 0 0 6px; }
.home-cta p { margin: 0; color: var(--text-muted); }
.about-wrap .section-lead { margin: 0 0 22px; max-width: 62ch; }
.steps article {
  padding: 4px 0 0;
  border: 0;
  background: none;
}
.step-n {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-secondary);
}
.steps h3 { margin: 0 0 6px; font-size: 1.02rem; font-family: var(--font-serif); font-weight: 600; }
.steps p { color: var(--text-muted); font-size: 14px; margin: 0; line-height: 1.5; }
.tree-list, .matches { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.tree-list a {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  background: none;
  border-radius: 0;
  border-left: 0;
}
.tree-list a:hover { color: var(--accent); }
.tree-list a strong {
  font-family: var(--font-serif);
  font-size: 1.22rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.tree-list span, .matches span { color: var(--text-muted); font-size: 13.5px; }
.search-next {
  display: flex;
  gap: 12px;
  padding: 0 4px 10px;
  margin: -4px 0 0;
}
.search-next a {
  padding: 0;
  display: inline;
  font-size: 13.5px;
}

.person-profile { max-width: 44rem; }
.person-hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin: 8px 0 22px;
}
.person-hero h1 { margin: 0 0 6px; }
.person-ava {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  background: var(--accent-soft);
}
.person-ava img { width: 100%; height: 100%; object-fit: cover; }
.person-kv {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  display: grid;
  gap: 8px;
}
.person-kv li {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.person-kv .k { color: var(--text-muted); font-weight: 650; }
.person-kv .v { color: var(--text); }
.person-notes { color: var(--text); line-height: 1.5; }
.person-rels {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}
.person-rels a { font-weight: 650; }
.person-rels small {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
}
.person-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.person-photos img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}
.person-photos figcaption {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.person-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.tree-row a {
  flex: 1;
  min-width: 0;
  border-bottom: 0;
}
.tree-delete { margin: 0; flex-shrink: 0; }
.tree-delete button { font-size: 13px; }
.settings { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 10px; align-items: end; margin: 18px 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); }
.rel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.photos { display: flex; gap: 12px; flex-wrap: wrap; }
.photos img {
  width: 168px;
  height: 168px;
  object-fit: cover;
  background: var(--surface-subtle);
  border: 5px solid #eadcc4;
  border-radius: 0;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}
.matches li {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  background: none;
  border-radius: 0;
  border-left: 0;
}
.matches li a {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 600;
  text-decoration: none;
}
.bell-wrap { position: relative; }
.notif-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(320px, 84vw);
  padding: 10px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
  z-index: 50;
}
.notif-menu[hidden] { display: none; }
.notif-head {
  margin: 0 0 6px;
  padding: 4px 8px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent-secondary);
}
.notif-item {
  display: grid;
  gap: 2px;
  padding: 8px;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  font-size: 13px;
}
.notif-item span { color: var(--text-muted); font-size: 12.5px; }
.notif-item:hover { background: var(--accent-soft); }
.notif-item.unread strong { color: var(--accent); }
.toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: min(100%, 28rem);
  margin: 12px auto 0;
  padding: 10px 8px 10px 14px;
  background: color-mix(in srgb, var(--accent) 20%, var(--surface-elevated));
  border: 1px solid color-mix(in srgb, var(--accent) 48%, var(--border));
  border-radius: 10px;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.4;
}
html[data-tree-theme="dark"] .toast {
  background: color-mix(in srgb, #7dca86 24%, #152018);
  border-color: #7dca86;
  color: #eaf8ed;
}
.toast a { color: inherit; text-decoration: none; flex: 1; min-width: 0; }
.toast a strong { display: block; margin-bottom: 2px; font-size: 13.5px; }
.toast-close {
  flex: none;
  width: 32px;
  height: 32px;
  margin: -2px 0 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  appearance: none;
  -webkit-appearance: none;
}
html[data-tree-theme="dark"] .toast-close { color: #c5e6cb; }
.toast-close svg { display: block; }
.toast-close:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}
.cookie-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 70;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 12px 14px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.cookie-bar[hidden] { display: none; }
.cookie-bar p {
  margin: 0;
  flex: 1 1 16rem;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-muted);
}
.cookie-bar a { color: var(--accent); font-weight: 650; text-decoration: none; }
.cookie-bar a:hover { color: var(--text); }
.cookie-bar .primary {
  flex: none;
  min-height: 40px;
  padding: 0 16px;
  font-size: 14px;
}
body:has(#cookie-bar:not([hidden])) .mh-fab {
  bottom: max(92px, calc(env(safe-area-inset-bottom) + 80px));
}
.search-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 18px;
  align-items: stretch;
  margin: 8px 0 22px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.search-form > label {
  justify-content: flex-start;
}
.search-form > label input,
.search-form > label select {
  margin-top: auto;
}
.search-form .search-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 4px 0 0;
}
.search-form .search-actions .primary,
.search-form .search-actions .ghost {
  width: auto;
}

.form-page {
  max-width: 40rem;
}
.form-page .section-lead {
  max-width: none;
}
.form-card {
  display: grid;
  gap: 16px;
  width: 100%;
  max-width: none;
  margin: 8px 0 28px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.form-card .primary {
  width: fit-content;
  min-width: 8.5rem;
}
.file-field .file-ui {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-top: auto;
  padding: 8px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  color: var(--text-muted);
  font-weight: 500;
}
.file-field .file-ui input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.file-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 650;
}
.file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.import-progress {
  display: grid;
  gap: 8px;
  margin: 2px 0 0;
}
.import-progress[hidden] {
  display: none;
}
.import-progress-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}
.import-progress-meta strong {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.import-progress-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--border);
}
.import-progress-bar > i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}
.import-progress.is-failed .import-progress-meta {
  color: #c45b4a;
  font-weight: 650;
}
.import-progress.is-failed .import-progress-bar > i {
  background: #c45b4a;
}
html[data-tree-theme="dark"] .import-progress.is-failed .import-progress-meta {
  color: #f0c4b8;
}
.import-alert {
  margin: 8px 0 0;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, #c45b4a 42%, var(--border));
  background: color-mix(in srgb, #c45b4a 12%, var(--surface));
  color: #b24a3c;
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.5;
}
html[data-tree-theme="dark"] .import-alert {
  color: #f0c4b8;
  background: color-mix(in srgb, #c45b4a 16%, var(--surface));
}
.import-alert[hidden] { display: none; }
.form-card.is-busy .file-field,
.form-card.is-busy .primary {
  opacity: 0.55;
  pointer-events: none;
}
.match-kicker {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent-secondary);
}
.match-actions { display: grid; gap: 8px; justify-items: start; }
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 18px 0 24px;
}
.compare-col {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.compare-fields, .compare-facts { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.compare-import { margin: 8px 0 28px; }
.compare-thread { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.thread { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; }
.thread li {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.thread li.mine { border-color: var(--accent); }
.thread li span { display: block; color: var(--text-muted); font-size: 12px; margin-bottom: 4px; }
.thread li p { margin: 0; white-space: pre-wrap; }
footer { padding: 0; }
.site-foot {
  display: grid;
  gap: 16px;
  padding: 36px 0 48px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.site-foot .foot-brand {
  display: inline-flex;
  text-decoration: none;
  line-height: 0;
}
.site-foot .foot-brand img {
  display: block;
  height: 40px;
  width: auto;
}
.site-foot .foot-brand .logo-light { display: none; }
html[data-tree-theme="light"] .site-foot .foot-brand .logo-dark { display: none; }
html[data-tree-theme="light"] .site-foot .foot-brand .logo-light { display: block; }
.site-foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
}
.site-foot nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.site-foot nav a:hover { color: var(--text); }
.site-foot .foot-copy {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 12.5px;
}
body.is-home main,
body.is-auth main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

/* —— Tree workspace —— */
body:has(.mh-page) {
  background-color: var(--bg);
  background-image: var(--paper-noise);
  touch-action: pan-y;
  overscroll-behavior: none;
}
body:has(.mh-page) main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}
body:has(.mh-page) .top {
  width: min(1480px, calc(100% - 28px));
}
body:has(.mh-page) footer { display: none; }
body:has(.mh-page) .flash,
body:has(.mh-page) .toast { margin: 10px auto 0; }

.mh-page {
  --mh-page: var(--bg);
  --mh-border: var(--border);
  --mh-text: var(--text);
  --mh-muted: var(--text-muted);
  --mh-accent: var(--accent);
  --mh-gold: var(--accent-secondary);
  --mh-side: var(--bg-secondary);
  --mh-canvas: var(--bg);
  --mh-input: var(--surface);
  --mh-input-border: var(--border);
  --mh-card: var(--surface-elevated);
  --mh-card-border: var(--border);
  --mh-ava: var(--unknown);
  --mh-ava-m: var(--male);
  --mh-ava-f: var(--female);
  --mh-line: color-mix(in srgb, var(--text-muted) 72%, transparent);
  --mh-ring-fill: var(--surface);
  --mh-ring-stroke: var(--accent-secondary);
  --mh-shadow: var(--shadow-soft);
  --mh-surface: var(--surface);
  --mh-doc: var(--surface-subtle);
  --mh-on-accent: var(--on-accent);
  color: var(--mh-text);
  background: transparent;
  min-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
}
.mh-page input,
.mh-page select,
.mh-page textarea {
  background: var(--mh-input);
  color: var(--mh-text);
  border-color: var(--mh-input-border);
}
.mh-page .primary,
.mh-page .ghost,
.mh-page .btn-quiet {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}
.mh-page .primary {
  background: var(--mh-accent);
  color: var(--mh-on-accent);
}
.mh-page .ghost { color: var(--mh-text); border-color: var(--mh-input-border); }

.mh-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 18px 22px 14px;
}
.mh-head h1 {
  margin: 0;
  font-size: 1.85rem;
  line-height: 1.12;
  color: var(--mh-text);
}
.mh-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.mh-title-row h1 { min-width: 0; overflow-wrap: anywhere; }
.mh-rename-btn {
  flex: none;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--mh-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.mh-rename-btn:hover {
  color: var(--mh-text);
  border-color: var(--mh-border);
  background: var(--surface-elevated);
}
.mh-rename {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 6px;
  max-width: 420px;
}
.mh-rename[hidden] { display: none; }
.mh-rename input {
  flex: 1 1 180px;
  min-width: 0;
  margin: 0;
}
.mh-head-meta {
  display: flex;
  gap: 16px;
  margin: 6px 0 0;
  color: var(--mh-muted);
  font-size: 13px;
  font-weight: 550;
}
.mh-head-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mh-head-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-bottom: 2px;
}
.mh-more { position: relative; }
.btn-icon {
  width: 34px;
  height: 34px;
  border: 1px solid var(--mh-input-border);
  background: var(--mh-input);
  color: var(--mh-text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.mh-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  padding: 6px;
  background: var(--surface-elevated);
  border: 1px solid var(--mh-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  z-index: 8;
}
.mh-more-menu[hidden] { display: none; }
.mh-more-menu a,
.mh-more-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  color: var(--mh-text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}
.mh-more-menu a:hover,
.mh-more-menu button:hover { background: var(--accent-soft); }
.mh-more-menu form { margin: 0; }
.mh-more-menu button.danger { color: #c45b4a; }
.mh-more-menu button.danger:hover {
  background: color-mix(in srgb, #c45b4a 12%, transparent);
}

.mh-poster {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 11, 13, 0.62);
}
.mh-poster[hidden] { display: none; }
.mh-poster-box {
  width: min(980px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 22px 24px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.mh-poster-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}
.mh-poster-head h2 { margin: 0; }
.mh-poster-preview {
  margin: 16px 0 14px;
  padding: 16px;
  overflow: auto;
  max-height: min(58vh, 640px);
  background: #d9d0c0;
  border: 1px solid var(--border);
}
.mh-poster-preview svg {
  display: block;
  width: 100%;
  height: auto;
  background: #f3eee4;
  box-shadow: 0 10px 28px rgba(44, 42, 38, 0.18);
}
.mh-poster-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
}

.mh-tree-prefs-box {
  width: min(440px, 100%);
}
.mh-tree-prefs {
  display: grid;
  gap: 22px;
  margin-top: 16px;
}
.mh-tree-pref {
  display: grid;
  gap: 8px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--mh-border);
}
.mh-tree-pref:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}
.mh-tree-pref h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--mh-text);
}
.mh-tree-pref p {
  margin: 0;
  font-size: 13px;
  color: var(--mh-muted);
}
.mh-tree-pref .mh-name-mode {
  justify-content: flex-start;
}
.mh-tree-pref .mh-color-legend,
.mh-tree-pref .mh-line-legend {
  justify-content: flex-start;
  margin-top: 2px;
}

.mh-settings {
  margin: 0 22px 8px;
  padding: 12px 14px;
  border: 1px solid var(--mh-border);
  border-radius: var(--radius);
  background: var(--mh-side);
  color: var(--mh-muted);
  font-size: 13px;
}
.mh-settings[hidden] { display: none; }
.mh-settings summary { cursor: pointer; color: var(--mh-text); font-weight: 650; }
.mh-danger-zone {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--mh-border);
}
.mh-danger-zone h3 {
  margin: 0 0 4px;
  font-size: 14px;
  color: #c45b4a;
}
.mh-danger-zone p {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.45;
}

.mh-empty {
  margin: 24px auto 48px;
  max-width: 420px;
  padding: 28px 20px 48px;
  text-align: center;
}
.mh-empty-art {
  width: 120px;
  height: 88px;
  margin: 0 auto 16px;
  color: var(--mh-gold);
  opacity: 0.85;
}
.mh-empty h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.35rem;
}
.mh-empty p { color: var(--mh-muted); line-height: 1.55; }

.mh-workspace {
  display: grid;
  grid-template-columns: 324px minmax(0, 1fr);
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.mh-workspace.is-side-collapsed {
  grid-template-columns: minmax(0, 1fr);
}
.mh-workspace.is-side-collapsed .mh-side {
  display: none;
}
.mh-side {
  border-right: 1px solid var(--mh-border);
  padding: 18px 16px 16px;
  background: var(--mh-side);
  overflow-x: hidden;
  overflow-y: auto;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  font-size: 14.5px;
  animation: mh-side-in 220ms ease;
}
.mh-side input,
.mh-side select,
.mh-side textarea,
.mh-side button,
.mh-side .primary,
.mh-side .ghost {
  max-width: 100%;
}
.mh-side input:not([type="checkbox"]):not([type="hidden"]):not([type="file"]),
.mh-side select,
.mh-side textarea {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
}
.mh-side .stack { gap: 8px; }
.mh-side .hint { font-size: 13px; line-height: 1.45; }
.mh-side h2 {
  font-size: 1.28rem;
}
.mh-edit-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 0;
}
.mh-edit-row label { min-width: 0; }
@keyframes mh-side-in {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: none; }
}
.mh-canvas {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  touch-action: none;
  background-color: var(--mh-canvas);
  background-image:
    radial-gradient(ellipse 90% 55% at 50% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    var(--paper-noise);
  background-repeat: no-repeat, repeat;
  background-position: center, 0 0;
  background-size: 100% 100%, 140px 140px;
}
.mh-side-toggle {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 8;
  width: 22px;
  height: 58px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--mh-border);
  border-left: 0;
  border-radius: 0 9px 9px 0;
  background: var(--mh-side);
  color: var(--mh-text);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.12);
}
.mh-side-toggle svg { display: block; }
.mh-workspace.is-side-collapsed .mh-side-toggle {
  background: color-mix(in srgb, var(--mh-gold) 22%, var(--mh-side));
  border-color: color-mix(in srgb, var(--mh-gold) 50%, var(--mh-border));
}
.mh-workspace.is-side-collapsed .mh-side-toggle svg {
  transform: scaleX(-1);
}
.mh-side-toggle:hover {
  background: color-mix(in srgb, var(--mh-gold) 18%, var(--mh-side));
}
.mh-stage {
  flex: 1;
  overflow: hidden;
  cursor: grab;
  min-width: 0;
  min-height: 640px;
  width: 100%;
  position: relative;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
.mh-stage.grabbing { cursor: grabbing; }
.mh-world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.mh-world.is-animating {
  transition: left 320ms cubic-bezier(0.22, 0.61, 0.36, 1), top 320ms cubic-bezier(0.22, 0.61, 0.36, 1), zoom 320ms cubic-bezier(0.22, 0.61, 0.36, 1), transform 320ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.mh-toolbar {
  position: absolute;
  z-index: 6;
  left: 16px;
  right: 16px;
  top: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  touch-action: manipulation;
}
.mh-tools-toggle {
  display: none;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--mh-border);
  border-radius: 12px;
  background: var(--surface-elevated);
  color: var(--mh-text);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  pointer-events: auto;
}
.mh-tools-toggle svg { display: block; }
.mh-toolbar.is-open .mh-tools-toggle {
  background: color-mix(in srgb, var(--mh-gold) 22%, var(--surface-elevated));
  border-color: color-mix(in srgb, var(--mh-gold) 50%, var(--mh-border));
}
.mh-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  flex: 1;
  pointer-events: none;
}
.mh-toolbar > *,
.mh-tools > * { pointer-events: auto; }
.mh-find {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: min(280px, 42vw);
  height: 38px;
  padding: 0 12px;
  background: var(--surface-elevated);
  border: 1px solid var(--mh-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.mh-find svg {
  flex: none;
  color: var(--mh-muted);
  display: block;
}
.mh-find input,
.mh-page .mh-find input {
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  height: 38px;
  line-height: 38px;
  width: 100%;
  min-width: 0;
  box-shadow: none;
  font-size: 13px;
  font-weight: 500;
}
.mh-tool-group {
  display: flex;
  align-items: center;
  margin-left: auto;
  background: var(--surface-elevated);
  border: 1px solid var(--mh-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.mh-tool-group button,
.mh-zoom-pct {
  border: 0;
  background: transparent;
  color: var(--mh-text);
  height: 38px;
  min-width: 36px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.mh-zoom-pct {
  min-width: 48px;
  color: var(--mh-muted);
  cursor: default;
  border-left: 1px solid var(--mh-border);
  border-right: 1px solid var(--mh-border);
  display: grid;
  place-items: center;
}
.mh-view-wrap { position: relative; }
.mh-view-btn {
  height: 38px;
  padding: 0 12px;
  background: var(--surface-elevated);
  border: 1px solid var(--mh-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  color: var(--mh-text);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.mh-view-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 190px;
  padding: 6px;
  background: var(--surface-elevated);
  border: 1px solid var(--mh-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
}
.mh-view-menu[hidden] { display: none; }
.mh-view-menu button {
  text-align: left;
  border: 0;
  background: none;
  color: var(--mh-text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.mh-view-menu button:hover { background: var(--accent-soft); }
.mh-view-menu button.on { color: var(--accent); }
.mh-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 38px;
  padding: 0 12px 0 10px;
  background: color-mix(in srgb, var(--mh-gold) 22%, var(--surface-elevated));
  border: 1px solid color-mix(in srgb, var(--mh-gold) 58%, var(--mh-border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  color: var(--mh-text);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.mh-home-btn svg { display: block; }
.mh-home-btn:hover {
  background: color-mix(in srgb, var(--mh-gold) 32%, var(--surface-elevated));
}
.mh-home-btn[hidden] { display: none; }
.mh-view-menu b {
  display: block;
  padding: 8px 10px 4px;
  color: var(--mh-muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mh-lines { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.mh-lines path,
.mh-lines line {
  fill: none;
  stroke: var(--mh-line);
  stroke-width: 1.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mh-lines path.dash {
  stroke-dasharray: 3 5;
}
.mh-world.is-rel-hover .mh-lines path,
.mh-world.is-rel-hover .mh-ring,
.mh-world.is-rel-focus .mh-lines path,
.mh-world.is-rel-focus .mh-ring {
  opacity: 0.28;
}
.mh-world.is-rel-hover .mh-lines path.is-hot,
.mh-world.is-rel-hover g.is-hot .mh-ring,
.mh-world.is-rel-hover .mh-lines path.is-path,
.mh-world.is-rel-hover g.is-path .mh-ring,
.mh-world.is-rel-focus .mh-lines path.is-hot,
.mh-world.is-rel-focus g.is-hot .mh-ring,
.mh-world.is-rel-focus .mh-lines path.is-path,
.mh-world.is-rel-focus g.is-path .mh-ring {
  opacity: 1;
  stroke: var(--mh-gold);
  stroke-width: 1.85;
}
.mh-lines path.is-path,
g.is-path .mh-ring {
  stroke: color-mix(in srgb, var(--mh-gold) 70%, var(--mh-line));
  stroke-width: 1.45;
}
.mh-ring {
  fill: none;
  stroke: var(--mh-ring-stroke);
  stroke-width: 1.35;
}
.mh-ring.engagement,
.mh-ring.partner {
  stroke-dasharray: 2.4 2;
}
.mh-gen {
  fill: var(--mh-muted);
  font-size: 9px;
  font-family: var(--font);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.4;
}
.mh-clan {
  fill: var(--mh-muted);
  font-size: 12px;
  font-family: var(--font);
  letter-spacing: 0.04em;
  opacity: 0.55;
}

.mh-card {
  position: absolute;
  width: 216px;
  height: 66px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px 5px 7px;
  border-radius: 7px;
  border: 1px solid color-mix(in srgb, var(--mh-text) 22%, var(--mh-card-border));
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--mh-ava) 70%, transparent), 0 1px 2px rgba(28, 24, 18, 0.08), 0 8px 18px rgba(28, 24, 18, 0.06);
  background: var(--mh-card);
  cursor: pointer;
  z-index: 1;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}
html[data-tree-theme="dark"] .mh-card {
  background: #2A353C;
  border-color: #4a5c66;
}
html[data-tree-theme="light"] .mh-card,
html[data-tree-theme="light"] .mh-card.M,
html[data-tree-theme="light"] .mh-card.F {
  background: #fffdf8;
  border-color: #c4b49a;
}
.mh-card.private {
  background: var(--mh-card);
  border-color: var(--mh-card-border);
}
html[data-tree-theme="dark"] .mh-card.private {
  background: #2A353C;
}
.mh-card.private .mh-ava {
  background: color-mix(in srgb, var(--mh-gold) 28%, var(--mh-ava));
  color: #f4f1ea;
}
.mh-card.private .mh-years {
  font-style: italic;
  color: var(--mh-muted);
  white-space: normal;
  text-overflow: unset;
  line-height: 1.2;
}
.mh-card.M {
  background: var(--mh-card);
  border-color: color-mix(in srgb, var(--mh-text) 22%, var(--mh-card-border));
  box-shadow: inset 3px 0 0 var(--mh-ava-m), 0 1px 2px rgba(28, 24, 18, 0.08), 0 8px 18px rgba(28, 24, 18, 0.06);
}
.mh-card.F {
  background: var(--mh-card);
  border-color: color-mix(in srgb, var(--mh-text) 22%, var(--mh-card-border));
  box-shadow: inset 3px 0 0 var(--mh-ava-f), 0 1px 2px rgba(28, 24, 18, 0.08), 0 8px 18px rgba(28, 24, 18, 0.06);
}
html[data-tree-theme="dark"] .mh-card.M,
html[data-tree-theme="dark"] .mh-card.F {
  background: #2A353C;
}
.mh-page.sex-colors .mh-card.M {
  background: color-mix(in srgb, #6ea0d4 46%, var(--mh-card));
  border-color: color-mix(in srgb, #8eb8e4 58%, var(--mh-card-border));
}
.mh-page.sex-colors .mh-card.F {
  background: color-mix(in srgb, #d4849e 44%, var(--mh-card));
  border-color: color-mix(in srgb, #e4a8bc 58%, var(--mh-card-border));
}
html[data-tree-theme="light"] .mh-page.sex-colors .mh-card.M {
  background: #d7e8f8;
  border-color: #9bb9d8;
}
html[data-tree-theme="light"] .mh-page.sex-colors .mh-card.F {
  background: #f8dbe4;
  border-color: #d9a3b4;
}
.mh-page.sex-colors .mh-card.private {
  background: var(--mh-card);
  border-color: var(--mh-card-border);
}
.mh-page.sex-colors .mh-card.focus {
  border-color: var(--mh-gold);
}
.mh-page.line-colors .mh-card.line-pgf {
  background: color-mix(in srgb, #3d6b9a 42%, var(--mh-card));
  border-color: color-mix(in srgb, #5a88b4 55%, var(--mh-card-border));
}
.mh-page.line-colors .mh-card.line-pgm {
  background: color-mix(in srgb, #2d7a78 40%, var(--mh-card));
  border-color: color-mix(in srgb, #4a9a96 55%, var(--mh-card-border));
}
.mh-page.line-colors .mh-card.line-father {
  background: color-mix(in srgb, #4a7eb5 44%, var(--mh-card));
  border-color: color-mix(in srgb, #6a9ad0 55%, var(--mh-card-border));
}
.mh-page.line-colors .mh-card.line-mgf {
  background: color-mix(in srgb, #a67c3a 40%, var(--mh-card));
  border-color: color-mix(in srgb, #c49a58 55%, var(--mh-card-border));
}
.mh-page.line-colors .mh-card.line-mgm {
  background: color-mix(in srgb, #a45d72 40%, var(--mh-card));
  border-color: color-mix(in srgb, #c47a90 55%, var(--mh-card-border));
}
.mh-page.line-colors .mh-card.line-mother {
  background: color-mix(in srgb, #c46b7a 42%, var(--mh-card));
  border-color: color-mix(in srgb, #d88896 55%, var(--mh-card-border));
}
.mh-page.line-colors .mh-card.line-desc {
  background: color-mix(in srgb, #4a7a5c 38%, var(--mh-card));
  border-color: color-mix(in srgb, #6a9a7c 55%, var(--mh-card-border));
}
.mh-page.line-colors .mh-card.line-inlaw {
  background: color-mix(in srgb, #5a5e62 28%, var(--mh-card));
  border-color: color-mix(in srgb, #7a7e82 50%, var(--mh-card-border));
}
.mh-page.line-colors .mh-card.line-self {
  background: color-mix(in srgb, #b89a68 40%, var(--mh-card));
  border-color: color-mix(in srgb, #d4b888 55%, var(--mh-card-border));
}
html[data-tree-theme="light"] .mh-page.line-colors .mh-card.line-pgf { background: #c5d6ea; border-color: #8aa6c4; }
html[data-tree-theme="light"] .mh-page.line-colors .mh-card.line-pgm { background: #c5e2df; border-color: #7ab0ac; }
html[data-tree-theme="light"] .mh-page.line-colors .mh-card.line-father { background: #d2e4f6; border-color: #8eb4d6; }
html[data-tree-theme="light"] .mh-page.line-colors .mh-card.line-mgf { background: #f0e2c2; border-color: #c4a66a; }
html[data-tree-theme="light"] .mh-page.line-colors .mh-card.line-mgm { background: #edd4e0; border-color: #c490a6; }
html[data-tree-theme="light"] .mh-page.line-colors .mh-card.line-mother { background: #f4d5dc; border-color: #d498a6; }
html[data-tree-theme="light"] .mh-page.line-colors .mh-card.line-desc { background: #d2e6da; border-color: #8ab49a; }
html[data-tree-theme="light"] .mh-page.line-colors .mh-card.line-inlaw { background: #e4e5e8; border-color: #b4b6ba; }
html[data-tree-theme="light"] .mh-page.line-colors .mh-card.line-self { background: #eadcc0; border-color: #c4a878; }
.mh-page.line-colors .mh-card.private {
  background: var(--mh-card);
  border-color: var(--mh-card-border);
}
.mh-page.line-colors .mh-card.focus {
  border-color: var(--mh-gold);
}
.mh-card:hover {
  border-color: color-mix(in srgb, var(--mh-gold) 50%, var(--mh-card-border));
  z-index: 3;
}
.mh-card.focus {
  z-index: 4;
  border-color: var(--mh-gold);
  box-shadow: inset 3px 0 0 var(--mh-gold), 0 0 0 1px color-mix(in srgb, var(--mh-gold) 70%, transparent), 0 0 18px rgba(182, 154, 105, 0.28);
}
.mh-card.menu-open {
  z-index: 20;
}
.mh-card.is-path:not(.focus) {
  border-color: color-mix(in srgb, var(--mh-accent) 55%, var(--mh-card-border));
}
.mh-world.is-rel-hover .mh-card,
.mh-world.is-rel-focus .mh-card {
  opacity: 0.52;
}
.mh-world.is-rel-hover .mh-card.is-hot,
.mh-world.is-rel-hover .mh-card.focus,
.mh-world.is-rel-hover .mh-card.is-path,
.mh-world.is-rel-focus .mh-card.is-hot,
.mh-world.is-rel-focus .mh-card.focus,
.mh-world.is-rel-focus .mh-card.is-path {
  opacity: 1;
}
.mh-ava {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex: none;
  background: var(--mh-ava);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  position: relative;
}
.mh-card.M .mh-ava { background: var(--mh-ava-m); }
.mh-card.F .mh-ava { background: var(--mh-ava-f); }
.mh-card.deceased .mh-ava::before,
.mh-profile-ava.deceased::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  background: linear-gradient(
    135deg,
    transparent 0 12%,
    #1a1a1a 14%,
    #0a0a0a 16% 30%,
    #1a1a1a 32%,
    transparent 34%
  );
}
.kir { color: var(--mh-muted); font-weight: 600; margin-left: 1px; }
.mh-ava img { width: 100%; height: 100%; object-fit: cover; }
.mh-ava.editable,
.mh-profile-ava.editable { cursor: pointer; }
.mh-ava.editable::after,
.mh-profile-ava.editable::after {
  content: "＋";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(20, 24, 28, 0.5);
  color: #fff;
  opacity: 0;
  transition: opacity 0.16s ease;
  font-size: 16px;
  font-weight: 700;
  pointer-events: none;
}
.mh-profile-ava.editable::after {
  content: "dodaj zdjęcie";
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-align: center;
  padding: 8px;
  line-height: 1.25;
}
.mh-profile-ava.editable.has-photo::after { content: "zmień zdjęcie"; }
.mh-ava.editable:hover::after,
.mh-profile-ava.editable:hover::after { opacity: 1; }
.mh-meta {
  min-width: 0;
  flex: 1;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  line-height: 1.15;
}
.mh-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  min-width: 0;
  color: var(--mh-text);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}
.mh-maiden,
.mh-years {
  display: block;
  min-width: 0;
  color: var(--mh-muted);
  font-size: 9.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mh-maiden {
  font-style: normal;
}
.mh-years {
  font-style: normal;
}

.mh-doc-mark {
  position: absolute;
  right: 8px;
  bottom: 7px;
  color: var(--mh-gold);
  opacity: 0.8;
}
.mh-plus-dot {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: 1px solid var(--mh-input-border);
  border-radius: 50%;
  background: var(--mh-card);
  color: var(--mh-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 160ms ease, color 160ms ease, border-color 160ms ease;
}
.mh-card:hover .mh-plus-dot,
.mh-card.focus .mh-plus-dot,
.mh-card.menu-open .mh-plus-dot { opacity: 1; }
.mh-plus-dot:hover { color: var(--mh-accent); border-color: var(--mh-accent); }
.mh-add-slot {
  position: absolute;
  box-sizing: border-box;
  width: 102px;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 0;
  padding: 2px 4px;
  border: 1.5px dashed color-mix(in srgb, var(--mh-text) 32%, transparent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--mh-surface, #fff) 88%, transparent);
  color: var(--mh-muted);
  cursor: pointer;
  z-index: 3;
  font: inherit;
  touch-action: none;
}
html[data-tree-theme="dark"] .mh-add-slot {
  border-color: color-mix(in srgb, #c5d0d6 38%, transparent);
  color: #9aa8b0;
  background: var(--mh-canvas);
}
.mh-add-slot:hover,
.mh-add-slot:focus-visible {
  border-color: var(--mh-gold);
  color: var(--mh-text);
  background: color-mix(in srgb, var(--mh-gold) 10%, transparent);
  outline: none;
}
.mh-add-slot-plus {
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
}
.mh-add-slot span:last-child {
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}
.mh-card-menu {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  min-width: 148px;
  padding: 6px;
  background: var(--surface-elevated);
  border: 1px solid var(--mh-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 6;
  display: grid;
}
.mh-card-menu[hidden] { display: none; }
.mh-card-menu b {
  display: block;
  padding: 4px 8px 6px;
  color: var(--mh-muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.mh-card-menu button {
  text-align: left;
  border: 0;
  background: none;
  color: var(--mh-text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
}
.mh-card-menu button:hover { background: var(--accent-soft); }

.mh-profile { text-align: center; margin-bottom: 14px; }
.mh-profile-ava {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  margin: 0 auto 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 32px;
  color: #fff;
  background: var(--mh-ava);
  position: relative;
  box-shadow: 0 0 0 3px var(--mh-side), 0 0 0 4px color-mix(in srgb, var(--mh-gold) 45%, transparent);
}
.mh-profile.M .mh-profile-ava { background: var(--mh-ava-m); }
.mh-profile.F .mh-profile-ava { background: var(--mh-ava-f); }
.mh-profile-ava img { width: 100%; height: 100%; object-fit: cover; }
.mh-profile h2 {
  margin: 0;
  font-size: 1.38rem;
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--mh-text);
  overflow-wrap: anywhere;
  padding: 0 2px;
}
.mh-dates {
  margin: 6px 0 0;
  color: var(--mh-text);
  font-size: 15.5px;
  font-weight: 650;
}
.mh-rel { color: var(--mh-muted); margin: 6px 0 0; font-size: 14px; }
.mh-vitals {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  text-align: left;
  display: grid;
  gap: 8px;
}
.mh-vitals li {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  font-size: 14.5px;
  color: var(--mh-text);
}
.mh-vitals div { min-width: 0; overflow-wrap: anywhere; }
.mh-vitals svg { color: var(--mh-gold); margin-top: 2px; }
.mh-vitals span { color: var(--mh-muted); display: block; font-size: 12.5px; }
.place-index {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  display: grid;
  gap: 28px;
}
.place-index h2 { margin-bottom: 8px; }
.meta { color: var(--text-muted); font-weight: 500; font-size: 0.78em; }
.mh-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: auto;
  padding-top: 12px;
}
.mh-round.primary {
  background: var(--mh-accent);
  color: var(--mh-on-accent);
  border-color: var(--mh-accent);
}
.mh-kv {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  text-align: left;
}
.mh-kv li {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--mh-border);
  font-size: 14.5px;
}
.mh-kv .v { overflow-wrap: anywhere; }
.mh-kv dt, .mh-kv .k { color: var(--mh-muted); }
.mh-kv .v { color: var(--mh-text); font-weight: 600; }
.mh-kv-link {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--mh-accent);
  font: inherit;
  font-weight: 650;
  text-align: left;
  cursor: pointer;
}
.mh-kv-link:hover { text-decoration: underline; }
.mh-display-opts {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  justify-items: center;
}
.mh-name-mode {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
}
.mh-color-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  font-size: 11px;
  color: var(--mh-muted);
}
.mh-color-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.mh-color-legend i.m { background: #6ea0d4; }
.mh-color-legend i.f { background: #d4849e; }
.mh-line-legend {
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px 10px;
  max-width: 100%;
}
.mh-line-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.mh-line-legend i.father { background: #4a7eb5; }
.mh-line-legend i.pgf { background: #3d6b9a; }
.mh-line-legend i.pgm { background: #2d7a78; }
.mh-line-legend i.mother { background: #c46b7a; }
.mh-line-legend i.mgf { background: #a67c3a; }
.mh-line-legend i.mgm { background: #a45d72; }
.mh-line-legend i.desc { background: #4a7a5c; }
.mh-line-legend i.inlaw { background: #8a8e92; }
.mh-name-mode span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mh-muted);
  margin-right: 2px;
}
.mh-name-mode button {
  border: 1px solid var(--mh-border);
  background: transparent;
  color: var(--mh-muted);
  font-size: 12px;
  font-weight: 650;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.mh-name-mode button.on {
  background: var(--accent-soft);
  color: var(--mh-text);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--mh-border));
}
.mh-block-title {
  margin: 4px 0 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mh-muted);
  font-weight: 700;
  text-align: left;
}
.mh-fab {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 7;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(120, 155, 120, 0.28);
}
.mh-fab:hover { background: var(--accent-hover); }
.mh-round {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--mh-input-border);
  background: transparent;
  color: var(--mh-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 650;
  cursor: pointer;
  min-width: 0;
  padding: 0 8px;
}
.mh-round:hover { border-color: var(--mh-accent); color: var(--mh-accent); }
.mh-fs-link {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0 0;
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--mh-input-border);
  color: var(--mh-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 650;
}
.mh-fs-link:hover { border-color: var(--mh-accent); color: var(--mh-accent); }
.mh-facts { padding: 2px 0 8px; }
.mh-facts h3 {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--mh-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.mh-facts p { margin: 0 0 8px; font-size: 15px; color: var(--mh-text); }
.mh-link { display: inline-block; margin-top: 14px; color: var(--mh-accent); font-weight: 600; text-decoration: none; }
.mh-back {
  border: 0;
  background: none;
  color: var(--mh-accent);
  cursor: pointer;
  padding: 0 0 10px;
  font-weight: 600;
}
.mh-add-list { display: grid; gap: 4px; }
.mh-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 8px 0 12px;
  border-bottom: 1px solid var(--mh-border);
  flex: none;
}
.mh-tab {
  border: 0;
  background: transparent;
  color: var(--mh-muted);
  font-size: 13px;
  font-weight: 650;
  padding: 6px 6px 7px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.mh-tab-body { flex: 1; min-height: 0; }
.mh-tab.on {
  color: var(--mh-text);
  border-bottom-color: var(--mh-accent);
}
.mh-fact-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 12px;
}
.mh-fact-list li { display: grid; gap: 2px; font-size: 14.5px; }
.mh-fact-list span, .mh-fact-list em, .mh-fact-list small {
  color: var(--mh-muted);
  font-style: normal;
}
.mh-fact-tools {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.mh-fact-tools button,
.mh-fact-tools form button {
  border: 0;
  background: none;
  padding: 0;
  color: var(--mh-accent);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.mh-fact-tools form button { color: #c45b4a; }
.mh-fact-edit { margin-top: 8px; }
.mh-empty-mini {
  padding: 18px 4px 8px;
  color: var(--mh-muted);
  font-size: 14px;
  line-height: 1.5;
}
.mh-timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 10px;
  border-left: 1px solid var(--mh-border);
}
.mh-timeline li { position: relative; padding: 0 0 16px 16px; }
.mh-timeline .dot {
  position: absolute;
  left: -5px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mh-accent);
}
.mh-timeline strong { font-size: 14.5px; }
.mh-timeline p { margin: 4px 0 0; color: var(--mh-muted); font-size: 14px; }
.mh-gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.mh-shot-wrap {
  position: relative;
}
.mh-shot-wrap.mini { display: inline-flex; }
.mh-shot-del {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  margin: 0;
}
.mh-shot-del button {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 24, 28, 0.72);
  color: #f4f1ea;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.mh-shot-del button:hover { background: #c45b4a; }
.mh-ava-del {
  margin: 8px 0 0;
}
.mh-ava-del button {
  border: 0;
  background: none;
  color: var(--mh-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.mh-rel-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 6px;
}
.mh-rel-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  min-width: 0;
}
.mh-rel-list li span { min-width: 0; overflow-wrap: anywhere; }
.mh-inline-rel { margin: 0; }
.mh-danger,
.mh-danger-round {
  color: #c45b4a !important;
  border-color: color-mix(in srgb, #c45b4a 45%, var(--mh-border)) !important;
}
.mh-card-menu button.danger {
  color: #c45b4a;
  border-top: 1px solid var(--mh-border);
  margin-top: 4px;
  padding-top: 8px;
}
.mh-confirm {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: color-mix(in srgb, #000 55%, transparent);
}
.mh-confirm-card {
  width: min(420px, 100%);
  padding: 22px 22px 18px;
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.mh-confirm-card p {
  margin: 0 0 8px;
  font-size: 1.05rem;
  line-height: 1.45;
  font-weight: 650;
}
.mh-confirm-note {
  color: var(--text-muted) !important;
  font-size: 13px !important;
  font-weight: 500 !important;
}
.mh-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.mh-shot {
  display: block;
  background: var(--mh-surface);
  border: 1px solid var(--mh-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  text-decoration: none;
  color: var(--mh-text);
  font-size: 11px;
}
.mh-shot img {
  width: 100%;
  height: 92px;
  object-fit: cover;
  display: block;
  background: var(--mh-doc);
}
.mh-shot span, .mh-shot small { display: block; padding: 6px 8px; }
.mh-shot.doc {
  min-height: 92px;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--mh-doc);
}
.mh-stats p { margin: 0 0 8px; font-size: 14px; }
.mh-stats h3 {
  margin: 16px 0 8px;
  font-size: 11px;
  color: var(--mh-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.mh-mini { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--mh-border); }
.mh-mini h3 { margin: 0 0 8px; font-size: 14px; }
.mh-fact-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mh-fact-file {
  display: block;
  width: 52px;
  height: 52px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--mh-border);
  background: var(--mh-doc);
}
.mh-fact-file img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mh-fact-file.doc {
  width: auto;
  height: auto;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--mh-accent);
  text-decoration: none;
}
.mh-add-list button {
  border: 0;
  border-bottom: 1px solid var(--mh-input-border);
  background: transparent;
  color: var(--mh-text);
  border-radius: 0;
  padding: 11px 2px;
  text-align: left;
  cursor: pointer;
  font-weight: 600;
}
.mh-add-list button:hover { color: var(--mh-accent); }

.invite-grid {
  display: grid;
  grid-template-columns: 1fr 180px auto;
  gap: 10px;
  align-items: end;
  margin: 12px 0 8px;
}
.member-list { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 0; }
.member-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: none;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  border-left: 0;
}
.member-list span { display: block; color: var(--text-muted); font-size: 13px; font-weight: 500; }
.role-form { display: flex; gap: 8px; align-items: center; }
.sheet .linkish.dark { color: var(--accent); }
.invite-banner { margin: 0 0 20px; }
.invite-banner h2 { font-size: 1.15rem; margin: 0 0 10px; }

.quota-bar {
  position: relative;
  margin: 0 0 18px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
  background: var(--surface);
}
.quota-bar span {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  pointer-events: none;
}
.quota-bar p {
  position: relative;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.admin-page h2 { margin: 18px 0 6px; }
.admin-form { margin: 8px 0 28px; }
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  margin: 4px 0 22px;
  border-bottom: 1px solid var(--border);
}
.admin-tabs a {
  padding: 8px 0 10px;
  border-radius: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
}
.admin-tabs a:hover { color: var(--text); }
.admin-tabs a.on {
  color: var(--text);
  background: none;
  border-bottom-color: var(--accent);
}
.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px 28px;
  margin: 0 0 28px;
  padding: 0 0 22px;
  border-bottom: 1px solid var(--border);
}
.admin-stats a {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  text-decoration: none;
  color: inherit;
}
.admin-stats a:hover { color: var(--accent); }
.admin-stats strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.85rem;
  font-weight: 600;
}
.admin-stats span { color: var(--text-muted); font-size: 12px; font-weight: 600; }
.admin-table-wrap { overflow: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th {
  text-align: left;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 8px 8px 0;
  border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: 12px 8px 12px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.admin-table td strong { display: block; }
.admin-table td span { color: var(--text-muted); font-size: 13px; }
.admin-table td > span { display: block; }
.admin-thumb {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 0;
  border: 3px solid #eadcc4;
  background: var(--bg);
}
.admin-user-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-plan-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.admin-plan-row input,
.admin-plan-row select {
  min-width: 0;
}
.admin-plan-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.admin-plan-row label input { width: 88px; }
.admin-plan-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.pill {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.pill.ok { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.pill.wait { color: #b69a69; }

.mh-phone-action { display: none; }
.mh-sheet-bar { display: none; }

@media (max-width: 1100px) {
  .nav-toggle { display: grid; }
  .top {
    grid-template-columns: minmax(0, 1fr) auto;
    height: 56px;
    min-height: 56px;
    padding: 0;
    gap: 10px;
  }
  .top-end { justify-self: end; }
  body:has(.mh-page) .top {
    width: 100%;
    max-width: none;
    padding: 0 12px;
  }
  .logo-img { height: 36px; width: auto; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    padding: 8px 16px 12px;
    background: var(--header);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  body.nav-open .nav-links { display: flex; }
  .nav-links a, .who {
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
  }
  .nav-links a.on {
    border-bottom-color: var(--border);
    color: var(--accent);
  }
  .nav-cta { border-bottom-color: var(--border) !important; }
}

@media (max-width: 900px) {
  .admin-stats { grid-template-columns: 1fr 1fr; }
  .top, main, footer { width: min(1260px, calc(100% - 24px)); }
  body:has(.mh-page) .top {
    width: 100%;
    padding: 0 12px;
  }
  .cookie-bar {
    left: 10px;
    right: 10px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .cookie-bar .primary {
    width: 100%;
  }
  .nav-toggle {
    width: 44px;
    height: 44px;
  }
  .mh-page { min-height: calc(100dvh - 56px); }
  .mh-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 10px;
    padding: 8px 12px 6px;
  }
  .mh-head h1 { font-size: 1.12rem; }
  .mh-head-meta {
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-top: 2px;
    font-size: 12px;
  }
  .mh-head-actions {
    margin-left: 0;
    padding-bottom: 0;
    align-self: center;
  }
  .site-search { display: none; }
  .grid, .steps, .rel, .settings, .matches li, .search-form, .compare-grid, .person-kv li { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  .home-split, .home-cta { grid-template-columns: 1fr; }
  .sheet { padding: 16px 0 40px; }
  .row-head { align-items: stretch; }
  .row-head .actions { width: 100%; }
  .row-head .actions .primary,
  .row-head .actions .ghost { flex: 1 1 auto; }
  .invite-grid { grid-template-columns: 1fr; }
  .tree-row { gap: 8px; }
  .person-hero { flex-wrap: wrap; }
  .mh-desk-action { display: none; }
  .mh-phone-action { display: block; }
  .mh-more-menu { z-index: 45; min-width: 220px; }
  .mh-more-menu a,
  .mh-more-menu button { min-height: 44px; padding: 10px 12px; }
  .mh-workspace { grid-template-columns: 1fr; }
  .mh-workspace.is-side-collapsed .mh-side { display: flex; }
  .mh-side-toggle { display: none !important; }
  .mh-stage {
    min-height: 0;
    height: 100%;
    flex: 1;
  }
  .mh-canvas { min-height: calc(100dvh - 7rem); }
  .mh-toolbar {
    left: auto;
    right: 10px;
    top: 10px;
    width: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
  }
  .mh-tools-toggle { display: grid; }
  .mh-tools {
    display: none;
    flex: none;
    flex-direction: column;
    align-items: stretch;
    width: min(calc(100vw - 24px), 320px);
    padding: 10px;
    background: var(--surface-elevated);
    border: 1px solid var(--mh-border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    pointer-events: auto;
  }
  .mh-toolbar.is-open .mh-tools { display: flex; }
  .mh-find {
    grid-column: auto;
    flex: none;
    width: 100%;
    max-width: none;
    height: 44px;
  }
  .mh-side {
    position: fixed;
    z-index: 36;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    inset: auto 0 0 0;
    max-height: min(72dvh, 560px);
    width: 100%;
    border-right: 0;
    border-bottom: 0;
    border-top: 1px solid var(--mh-border);
    border-radius: 16px 16px 0 0;
    padding: 0 14px max(12px, env(safe-area-inset-bottom));
    box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.4);
  }
  .mh-side:empty { display: none; }
  .mh-sheet-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0 -14px 8px;
    padding: 8px 10px 0;
    background: var(--mh-side);
  }
  .mh-sheet-grip {
    position: absolute;
    left: 50%;
    top: 8px;
    width: 36px;
    height: 4px;
    margin-left: -18px;
    border-radius: 999px;
    background: var(--mh-border);
  }
  .mh-panel-close {
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--mh-text);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
  }
  .mh-side input:not([type="checkbox"]):not([type="hidden"]):not([type="file"]),
  .mh-side select,
  .mh-side textarea {
    font-size: 16px;
    min-height: 44px;
  }
  .mh-find input,
  .mh-page .mh-find input {
    font-size: 16px;
    min-height: 0;
    height: 100%;
  }
  .mh-home-btn {
    grid-column: auto;
    justify-content: center;
    width: 100%;
    height: 42px;
  }
  .mh-tool-group {
    margin-left: 0;
    justify-content: space-evenly;
    flex: none;
    width: 100%;
  }
  .mh-view-wrap { min-width: 0; width: 100%; }
  .mh-view-btn {
    width: 100%;
    min-width: 0;
  }
  .mh-zoom-pct { display: none; }
  .mh-tool-group button,
  .mh-view-btn,
  .mh-home-btn { height: 42px; min-height: 42px; }
  .btn-icon { width: 44px; height: 44px; }
  .tree-delete button { min-height: 44px; padding: 0 14px; }
  .mh-edit-row { grid-template-columns: 1fr; }
  .mh-kv li { grid-template-columns: 1fr; gap: 2px; padding: 8px 0; }
  .mh-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .mh-tab { flex: none; padding: 10px 10px 8px; font-size: 13px; }
  .mh-actions { padding-bottom: 4px; }
  .mh-add-list button { min-height: 44px; }
  .mh-fab {
    right: 14px;
    bottom: max(16px, env(safe-area-inset-bottom));
  }
  body:has(#cookie-bar:not([hidden])) .mh-fab {
    bottom: max(92px, calc(env(safe-area-inset-bottom) + 80px));
  }
  body:has(.mh-side:not(:empty)) .mh-fab { display: none; }
  .mh-poster { padding: 10px; align-items: end; }
  .mh-poster-box {
    width: 100%;
    max-height: min(92dvh, 100%);
    padding: 16px 14px max(14px, env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
  }
  .mh-poster-preview { max-height: min(42vh, 320px); }
  .mh-rename { max-width: none; }
  .site-foot nav a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 8px 6px;
  }
}
