:root {
  --paper: #f6f0e4;
  --paper-deep: #ece0cd;
  --paper-light: #fffaf1;
  --ink: #2f2823;
  --ink-soft: #5d5146;
  --muted: #8a7c6d;
  --line: #dacbb8;
  --line-strong: #c4b09a;
  --cinnabar: #a84432;
  --cinnabar-deep: #873224;
  --gold: #b28a52;
  --green: #586f5b;
  --danger: #a13d33;
  --shadow: 0 18px 50px rgba(66, 48, 30, .12);
  --shadow-soft: 0 8px 24px rgba(66, 48, 30, .08);
  --serif: "Noto Serif SC", "Songti SC", "STSong", "Batang", "Times New Roman", serif;
  --sans: "PingFang SC", "Apple SD Gothic Neo", "Noto Sans KR", "Microsoft YaHei", system-ui, sans-serif;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(255,255,255,.78), transparent 65%),
    radial-gradient(900px 600px at 100% 100%, rgba(177, 137, 84, .10), transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  opacity: .22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.22'/%3E%3C/svg%3E");
  z-index: -1;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--cinnabar-deep); text-decoration: none; }
img { max-width: 100%; }

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 8px;
}
.brand-mark {
  width: 68px; height: 68px; margin: 0 auto 8px;
  display: grid; place-items: center;
  background: var(--cinnabar);
  color: #fff8ee;
  font-family: var(--serif);
  font-size: 34px;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 12px 30px rgba(168, 68, 50, .22);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; width: 12px; height: 12px; border-radius: 50%;
  right: -4px; bottom: -4px; background: var(--gold);
}
.brand-name { font-family: var(--serif); font-size: 26px; letter-spacing: .12em; margin: 0; }
.brand-sub { color: var(--muted); margin: 0; letter-spacing: .08em; font-size: 12px; }
.loading-dots { display: flex; gap: 6px; justify-content: center; margin-top: 18px; }
.loading-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--cinnabar); animation: pulse 1.2s infinite; }
.loading-dots i:nth-child(2) { animation-delay: .15s; }
.loading-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-left)) 10px;
  background: rgba(246, 240, 228, .86);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(196, 176, 154, .5);
}
.topbar .brand-mini { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand-seal {
  width: 34px; height: 34px; border-radius: 10px 10px 10px 3px;
  display: grid; place-items: center; flex: none;
  background: var(--cinnabar); color: #fff9ef; font-family: var(--serif); font-size: 18px;
}
.brand-copy { min-width: 0; }
.brand-title { font-family: var(--serif); font-size: 17px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-kicker { font-size: 10px; letter-spacing: .18em; color: var(--muted); text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  border: 1px solid transparent; background: transparent; border-radius: 10px;
  min-width: 36px; height: 36px; display: inline-grid; place-items: center;
  color: var(--ink-soft);
}
.icon-btn:hover { background: rgba(255,255,255,.55); border-color: var(--line); }
.icon-btn.small { min-width: 30px; height: 30px; font-size: 13px; }

.page { max-width: 1120px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-left)) 90px; }
.view-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 6px 2px 14px; }
.view-head h1 { font-family: var(--serif); font-size: 28px; line-height: 1.2; margin: 0; letter-spacing: .03em; }
.view-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.eyebrow { color: var(--cinnabar); letter-spacing: .18em; font-size: 10px; text-transform: uppercase; font-weight: 700; }

.auth-layout {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
  max-width: 1080px; margin: 0 auto; padding: 40px 24px;
  gap: 40px; align-items: center;
}
.auth-story { padding: 32px 8px; position: relative; }
.auth-story .brand-mark { margin: 0 0 22px; width: 78px; height: 78px; font-size: 40px; }
.auth-story h1 { font-family: var(--serif); font-size: clamp(34px, 4vw, 50px); line-height: 1.22; margin: 0 0 14px; letter-spacing: .04em; }
.auth-story h1 span { color: var(--cinnabar); }
.auth-story .ko { color: var(--muted); font-size: 14px; letter-spacing: .12em; margin-bottom: 26px; }
.auth-story .manifesto { max-width: 430px; color: var(--ink-soft); font-size: 15px; line-height: 1.9; }
.auth-story .rule { width: 56px; height: 2px; background: var(--gold); margin: 28px 0; }
.auth-story .small-note { color: var(--muted); font-size: 12px; margin-top: 20px; }
.auth-card {
  background: rgba(255, 250, 241, .82);
  border: 1px solid rgba(196, 176, 154, .72);
  border-radius: 22px;
  padding: 30px;
  box-shadow: var(--shadow);
  position: relative;
}
.auth-card::before {
  content: ""; position: absolute; inset: 7px; border: 1px solid rgba(196, 176, 154, .34); border-radius: 17px; pointer-events: none;
}
.auth-card h2 { font-family: var(--serif); font-size: 22px; margin: 0 0 6px; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.auth-tip {
  display: flex; gap: 8px; align-items: flex-start;
  background: rgba(177, 138, 84, .10);
  border: 1px solid rgba(177, 138, 84, .18);
  border-radius: 12px; padding: 10px 12px; color: var(--ink-soft); font-size: 12px; margin: 14px 0 6px;
}
.auth-tip b { color: var(--cinnabar-deep); }

.device-entry { margin: 14px 0 4px; }
#auth-fallback { display: none; }
#auth-fallback.show { display: block; }
.auth-other { display: block; width: 100%; border: 0; background: transparent; color: var(--muted); font-size: 11px; padding: 8px 0 0; text-decoration: underline; text-underline-offset: 3px; }
.device-check { color: var(--muted); font-size: 12px; padding: 4px 0; }
.device-hint {
  display: flex; gap: 7px; align-items: flex-start;
  color: var(--muted); font-size: 11px; line-height: 1.7;
  border-bottom: 1px dashed rgba(196, 176, 154, .5); padding-bottom: 12px; margin-bottom: 14px;
}
.device-hint span { color: var(--green); }
.device-card {
  background: linear-gradient(135deg, rgba(88, 111, 91, .08), rgba(177, 138, 84, .08));
  border: 1px solid rgba(88, 111, 91, .24);
  border-radius: 15px; padding: 14px; margin-bottom: 16px;
}
.device-top { display: flex; align-items: center; gap: 11px; margin-bottom: 11px; }
.device-badge {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(88, 111, 91, .14); color: var(--green); font-weight: 800;
}
.device-title { font-size: 13px; font-weight: 700; color: var(--ink); }
.device-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.device-foot { text-align: center; color: var(--muted); font-size: 10px; line-height: 1.6; margin-top: 8px; }

.field { margin: 0 0 15px; }
.field label { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; letter-spacing: .04em; }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 5px; }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line);
  background: rgba(255, 253, 248, .86);
  border-radius: 12px; padding: 12px 13px;
  outline: none; transition: border-color .18s, box-shadow .18s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--cinnabar); box-shadow: 0 0 0 3px rgba(168, 68, 50, .10); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
.otp-row { display: flex; gap: 8px; }
.otp-row .input { flex: 1; }
.btn {
  border: 1px solid var(--cinnabar); background: var(--cinnabar); color: #fff9f0;
  border-radius: 12px; padding: 12px 18px; font-weight: 700; letter-spacing: .04em;
  transition: transform .15s, background .15s, box-shadow .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { background: var(--cinnabar-deep); box-shadow: 0 8px 20px rgba(168, 68, 50, .20); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.block { width: 100%; }
.btn.secondary { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { background: rgba(255,255,255,.6); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--ink-soft); border-color: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: rgba(161, 61, 51, .35); }
.btn.small { padding: 8px 11px; border-radius: 9px; font-size: 12px; }
.btn.send { white-space: nowrap; padding-left: 14px; padding-right: 14px; }
.dev-code {
  display: none; margin-top: 10px; padding: 10px 12px;
  border-radius: 10px; background: rgba(88, 111, 91, .10);
  color: var(--green); font-size: 12px; border: 1px dashed rgba(88, 111, 91, .3);
}
.dev-code.show { display: block; }
.auth-switch { text-align: center; color: var(--muted); font-size: 12px; margin-top: 15px; }
.auth-switch a { margin-left: 4px; }

.invite-banner {
  background: linear-gradient(135deg, rgba(168, 68, 50, .08), rgba(177, 138, 84, .10));
  border: 1px solid rgba(196, 176, 154, .6);
  border-radius: 18px; padding: 18px; margin-bottom: 18px;
}
.invite-banner .label { color: var(--muted); font-size: 11px; letter-spacing: .12em; }
.invite-banner .family { font-family: var(--serif); font-size: 24px; margin: 2px 0 8px; }
.invite-banner .rel { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--ink-soft); font-size: 13px; }
.invite-banner .rel strong { color: var(--cinnabar-deep); }
.invite-status { text-align: center; padding: 28px 8px; }
.invite-status .tick { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: rgba(88, 111, 91, .12); color: var(--green); font-size: 26px; margin: 0 auto 12px; }
.invite-status h2 { font-family: var(--serif); font-size: 24px; margin: 0 0 6px; }
.invite-status p { color: var(--muted); font-size: 13px; margin: 0 auto 18px; max-width: 380px; }

.empty-state {
  max-width: 640px; margin: 6vh auto; background: rgba(255, 250, 241, .78);
  border: 1px solid var(--line); border-radius: 22px; padding: 34px; box-shadow: var(--shadow-soft);
}
.empty-state h2 { font-family: var(--serif); font-size: 26px; margin: 0 0 6px; }
.empty-state p { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

.tree-toolbar {
  display: flex; gap: 10px; align-items: center;
  background: rgba(255,250,241,.72); border: 1px solid var(--line);
  border-radius: 14px; padding: 8px; margin-bottom: 12px; box-shadow: var(--shadow-soft);
}
.search-wrap { position: relative; flex: 1; }
.search-wrap .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; pointer-events: none; }
.search-wrap .input { padding-left: 36px; border-color: transparent; background: transparent; }
.search-wrap .input:focus { background: rgba(255,255,255,.66); border-color: var(--line); }
.tree-mode { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tree-mode button { border: 0; background: transparent; padding: 7px 10px; font-size: 12px; color: var(--muted); }
.tree-mode button.active { background: var(--ink); color: var(--paper-light); }
.search-results {
  position: absolute; z-index: 25; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--paper-light); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; max-height: 300px; overflow-y: auto;
}
.search-results button { display: flex; width: 100%; text-align: left; gap: 10px; align-items: center; border: 0; border-bottom: 1px solid rgba(218,203,184,.5); background: transparent; padding: 10px 12px; }
.search-results button:hover { background: rgba(177,138,84,.08); }
.search-results .sr-name { font-weight: 700; }
.search-results .sr-rel { color: var(--cinnabar-deep); font-size: 12px; }
.search-results .sr-path { color: var(--muted); font-size: 11px; }
.search-empty { padding: 14px; color: var(--muted); font-size: 12px; text-align: center; }

.stage-wrap { position: relative; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: #efe6d7; box-shadow: var(--shadow-soft); }
.three-stage { width: 100%; height: min(68vh, 640px); min-height: 440px; position: relative; touch-action: none; background: radial-gradient(circle at 50% 40%, #fff9ee 0%, #efe4d3 48%, #e4d5c1 100%); }
.three-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.three-stage .stage-grain { position: absolute; inset: 0; pointer-events: none; opacity: .28; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='.2'/%3E%3C/svg%3E"); }
.stage-hud { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; }
.stage-hud > * { pointer-events: auto; }
.stage-chip { background: rgba(255,250,241,.78); border: 1px solid rgba(196,176,154,.55); backdrop-filter: blur(10px); border-radius: 10px; padding: 7px 10px; font-size: 11px; color: var(--ink-soft); }
.stage-help { color: var(--muted); font-size: 11px; max-width: 230px; text-align: right; line-height: 1.5; }
.stage-controls { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px; border-top: 1px solid rgba(196,176,154,.45); background: rgba(255,250,241,.78); }
.stage-controls .control { background: rgba(255,250,241,.88); border: 1px solid rgba(196,176,154,.65); border-radius: 10px; width: 38px; height: 38px; display: grid; place-items: center; color: var(--ink-soft); box-shadow: 0 4px 14px rgba(66,48,30,.08); }
.stage-controls .control.wide { width: auto; padding: 0 12px; font-size: 12px; }
.stage-controls .control:hover { background: #fffdf8; color: var(--cinnabar-deep); }
.stage-controls .control:active { transform: scale(.96); }
.stage-foot { position: absolute; right: 12px; bottom: 12px; color: var(--muted); font-size: 10px; background: rgba(255,250,241,.62); padding: 5px 8px; border-radius: 8px; }
.three-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 20px; }
.three-empty strong { display: block; font-family: var(--serif); font-size: 20px; color: var(--ink); margin-bottom: 4px; }

.tree-viewport { position: relative; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,250,241,.52); overflow: auto; height: min(68vh, 640px); min-height: 440px; scrollbar-width: thin; }
.tree-canvas { position: relative; min-width: 100%; }
.tree-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.tree-svg path { fill: none; stroke: rgba(138, 124, 108, .45); stroke-width: 1.3; }
.tree-svg path.inferred { stroke-dasharray: 6 5; }
.tree-svg path.focus-line { stroke: rgba(168, 68, 50, .62); stroke-width: 1.8; }
.tree-svg .sib-line { stroke: rgba(177,138,84,.55); stroke-dasharray: 4 4; }
.tree-row {
  position: absolute; left: 0; right: 0; display: flex; justify-content: center; gap: 14px; padding: 0 30px;
}
.person-card {
  width: 116px; min-height: 76px; flex: none; position: relative;
  border: 1px solid var(--line); background: rgba(255,250,241,.92);
  border-radius: 13px; padding: 9px 9px 8px;
  text-align: center; color: var(--ink);
  box-shadow: 0 5px 16px rgba(66,48,30,.06);
  transition: transform .16s, border-color .16s, box-shadow .16s;
}
.person-card:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: 0 10px 22px rgba(66,48,30,.12); }
.person-card.focus { border-color: var(--cinnabar); box-shadow: 0 0 0 2px rgba(168,68,50,.12), 0 10px 26px rgba(168,68,50,.15); background: #fff8ed; }
.person-card.inferred { border-style: dashed; }
.person-card .avatar {
  width: 30px; height: 30px; margin: 0 auto 4px; border-radius: 50%;
  background: var(--paper-deep); color: var(--ink-soft); display: grid; place-items: center;
  font-family: var(--serif); font-size: 14px; overflow: hidden;
}
.person-card .avatar img { width: 100%; height: 100%; object-fit: cover; }
.person-card .p-name { font-family: var(--serif); font-size: 14px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-card .p-rel { color: var(--cinnabar-deep); font-size: 10px; line-height: 1.3; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-card .p-year { color: var(--muted); font-size: 9px; }
.person-card .p-me { position: absolute; top: -7px; right: -6px; background: var(--cinnabar); color: #fff; border-radius: 6px; padding: 2px 5px; font-size: 9px; letter-spacing: .05em; }
.person-card .p-photo-dot { position: absolute; top: 7px; left: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.row-label { position: absolute; left: 10px; color: var(--muted); font-size: 10px; letter-spacing: .12em; writing-mode: horizontal-tb; background: rgba(246,240,228,.8); padding: 2px 5px; border-radius: 5px; }

.floating-return {
  position: fixed; z-index: 25; right: max(18px, env(safe-area-inset-right)); bottom: 88px;
  border: 1px solid rgba(196,176,154,.7); background: rgba(255,250,241,.94); color: var(--cinnabar-deep);
  border-radius: 20px; padding: 10px 14px; box-shadow: var(--shadow-soft); font-size: 12px; display: inline-flex; align-items: center; gap: 6px;
}
.floating-return:hover { background: #fff; }
.tree-footer-note { color: var(--muted); font-size: 11px; text-align: center; margin-top: 12px; }

.bottom-nav {
  position: fixed; z-index: 40; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(47, 40, 35, .94); color: #fff7ea; border-radius: 18px;
  display: flex; align-items: center; gap: 2px; padding: 6px;
  box-shadow: 0 14px 34px rgba(30,20,12,.24);
}
.bottom-nav button { border: 0; background: transparent; color: rgba(255,247,234,.62); padding: 8px 13px; border-radius: 12px; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.bottom-nav button span { font-size: 15px; line-height: 1.1; }
.bottom-nav button.active { background: rgba(255,247,234,.14); color: #fff9ef; }

.sheet-backdrop, .modal-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(35, 27, 20, .38); backdrop-filter: blur(3px); }
.sheet {
  position: fixed; z-index: 70; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(680px, 100%); max-height: 90vh; overflow: auto;
  background: var(--paper-light); border-radius: 24px 24px 0 0;
  box-shadow: 0 -20px 60px rgba(35,27,20,.22); padding: 0 0 max(20px, env(safe-area-inset-bottom));
  animation: sheet-in .24s ease-out;
}
@keyframes sheet-in { from { transform: translate(-50%, 30px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.sheet-grabber { width: 40px; height: 4px; background: var(--line-strong); border-radius: 2px; margin: 10px auto 0; }
.sheet-head { display: flex; align-items: flex-start; gap: 14px; padding: 18px 22px 12px; }
.sheet-title { font-family: var(--serif); font-size: 23px; line-height: 1.2; margin: 0; }
.sheet-sub { color: var(--cinnabar-deep); font-size: 12px; margin-top: 2px; }
.sheet-body { padding: 0 22px 22px; }
.person-hero { display: flex; gap: 16px; align-items: flex-start; margin: 4px 0 16px; }
.person-avatar-large { width: 76px; height: 76px; flex: none; border-radius: 20px 20px 20px 6px; background: var(--paper-deep); display: grid; place-items: center; font-family: var(--serif); font-size: 30px; overflow: hidden; border: 1px solid var(--line); }
.person-avatar-large img { width: 100%; height: 100%; object-fit: cover; }
.person-path { color: var(--muted); font-size: 12px; line-height: 1.6; margin-top: 4px; }
.detail-block { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.detail-block h3 { font-family: var(--serif); font-size: 16px; margin: 0 0 6px; }
.detail-block p { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.8; white-space: pre-wrap; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.photo-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.photo-preview { width: 100%; border-radius: 14px; border: 1px solid var(--line); margin-top: 10px; }
.audio-player { width: 100%; margin-top: 8px; }
.invite-result { margin-top: 12px; padding: 12px; background: rgba(177,138,84,.10); border: 1px dashed var(--line-strong); border-radius: 12px; }
.invite-result .link { word-break: break-all; font-size: 12px; color: var(--ink-soft); margin: 6px 0 10px; }
.empty-note { color: var(--muted); font-size: 12px; padding: 10px 0; }

.modal {
  position: fixed; z-index: 70; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--paper-light); border-radius: 18px; box-shadow: 0 24px 70px rgba(35,27,20,.26); padding: 24px;
}
.modal h2 { font-family: var(--serif); font-size: 22px; margin: 0 0 4px; }
.modal .sub { color: var(--muted); font-size: 12px; margin: 0 0 18px; }
.modal-close { position: absolute; right: 12px; top: 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }

.admin-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.metric { background: rgba(255,250,241,.78); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.metric .n { font-family: var(--serif); font-size: 28px; line-height: 1.1; }
.metric .l { color: var(--muted); font-size: 11px; margin-top: 3px; }
.admin-section { background: rgba(255,250,241,.72); border: 1px solid var(--line); border-radius: 16px; margin-bottom: 14px; overflow: hidden; }
.admin-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid rgba(218,203,184,.55); }
.admin-section-head h2 { font-family: var(--serif); font-size: 18px; margin: 0; }
.admin-list { padding: 6px 10px 10px; }
.admin-item { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 10px 6px; border-bottom: 1px solid rgba(218,203,184,.42); }
.admin-item:last-child { border-bottom: 0; }
.admin-item .who { font-weight: 700; font-size: 13px; }
.admin-item .meta { color: var(--muted); font-size: 11px; line-height: 1.55; }
.admin-item .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: rgba(177,138,84,.12); color: var(--ink-soft); font-size: 10px; }
.pill.ok { background: rgba(88,111,91,.12); color: var(--green); }
.pill.warn { background: rgba(168,68,50,.10); color: var(--cinnabar-deep); }
.empty-admin { padding: 18px 6px; color: var(--muted); font-size: 12px; text-align: center; }

.settings-wrap { max-width: 760px; }
.settings-card { background: rgba(255,250,241,.78); border: 1px solid var(--line); border-radius: 18px; padding: 20px; margin-bottom: 14px; }
.settings-card h2 { font-family: var(--serif); font-size: 19px; margin: 0 0 4px; }
.settings-card .sub { color: var(--muted); font-size: 12px; margin: 0 0 14px; }
.channel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.channel-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.channel-dot.cn { background: var(--cinnabar); }
.channel-dot.kr { background: var(--green); }
.settings-note { font-size: 11px; color: var(--muted); background: rgba(177,138,84,.08); border-radius: 10px; padding: 9px 11px; margin: 10px 0; line-height: 1.6; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkline { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 12px; }
.checkline i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); display: inline-block; }
.checkline.ok i { background: var(--green); }

.toast {
  position: fixed; z-index: 100; left: 50%; bottom: 92px; transform: translate(-50%, 20px);
  background: rgba(47, 40, 35, .95); color: #fff8ee; padding: 10px 16px; border-radius: 12px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .22s; max-width: calc(100vw - 40px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: rgba(135, 50, 36, .96); }

@media (max-width: 820px) {
  .auth-layout { grid-template-columns: 1fr; padding: 26px 16px; gap: 12px; }
  .auth-story { padding: 8px 4px 0; }
  .auth-story .brand-mark { width: 58px; height: 58px; font-size: 30px; margin-bottom: 16px; }
  .auth-story h1 { font-size: 34px; }
  .auth-story .manifesto { font-size: 13px; line-height: 1.75; }
  .auth-story .rule, .auth-story .small-note { display: none; }
  .auth-card { padding: 22px; }
  .admin-grid { grid-template-columns: 1fr 1fr; }
  .three-stage, .tree-viewport { height: 62vh; min-height: 380px; }
  .stage-help { display: none; }
  .bottom-nav { width: calc(100% - 24px); justify-content: space-around; }
  .bottom-nav button { flex: 1; padding: 8px 8px; }
  .page { padding-bottom: 100px; }
}
@media (max-width: 520px) {
  .view-head h1 { font-size: 24px; }
  .view-head p { font-size: 12px; }
  .brand-title { display: none; }
  .brand-kicker { display: none; }
  .topbar { gap: 8px; padding-left: 12px; padding-right: 10px; }
  .topbar .brand-mini { gap: 8px; }
  .topbar-actions { gap: 2px; }
  .topbar-actions .icon-btn.small { min-width: 28px; }
  .tree-toolbar { flex-wrap: nowrap; padding: 7px; gap: 7px; }
  .search-wrap { flex: 1 1 auto; min-width: 0; }
  .search-wrap .input { font-size: 13px; padding-left: 32px; }
  .search-wrap .search-icon { left: 10px; }
  .tree-mode { margin-left: 0; flex: none; }
  .tree-mode button { padding: 7px 9px; }
  .form-grid, .two-col { grid-template-columns: 1fr; }
  .sheet-head { padding: 16px 16px 10px; }
  .sheet-body { padding: 0 16px 18px; }
  .person-avatar-large { width: 62px; height: 62px; font-size: 25px; }
  .person-card { width: 104px; }
  .three-stage, .tree-viewport { height: 58vh; min-height: 400px; }
  .stage-chip { font-size: 10px; max-width: 230px; white-space: normal; }
  .view-head { display: none; }
  .tree-footer-note { display: none; }
  .floating-return { display: none; }
  .stage-controls { gap: 5px; padding: 7px 10px; }
  .stage-controls .control { width: 34px; height: 34px; font-size: 15px; }
  .stage-controls .control.wide { padding: 0 10px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* 海外分享码 */
.share-entry { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line, #ded1bf); }
.share-toggle { width: 100%; text-align: center; }
.share-box { margin-top: 12px; padding: 12px; border: 1px solid rgba(168,68,50,.22); border-radius: 10px; background: rgba(168,68,50,.035); }
.share-box .field { margin-bottom: 9px; }
.share-help { margin: 8px 0 0; color: var(--muted); font-size: 10px; line-height: 1.65; text-align: center; }
.share-wait { display: flex; gap: 12px; align-items: flex-start; margin: 10px 0; padding: 12px; border: 1px solid var(--line, #ded1bf); border-radius: 10px; background: rgba(255,250,241,.58); }
.share-wait-mark { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: rgba(88,111,91,.12); color: #586f5b; font-weight: 700; }
.share-wait b { display: block; font-size: 12px; }
.share-wait span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.6; }

/* 私密联系资料：只保存不显示 */
.private-block { margin: 12px 0 4px; padding: 12px 12px 4px; border: 1px dashed rgba(88,111,91,.28); border-radius: 10px; background: rgba(88,111,91,.035); }
.private-head { margin-bottom: 9px; }
.private-head b { display: inline-block; font-size: 11px; color: #4e614f; }
.private-head span { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.private-block .two-col { gap: 10px; }
.share-code-result .link { letter-spacing: .08em; font-weight: 700; color: #6d3a2c; }
.private-status { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: rgba(88,111,91,.08); color: #4e614f; font-size: 11px; line-height: 1.5; }
.spouse-line { stroke: #c08a52; stroke-width: 2; stroke-dasharray: 3 4; opacity: .9; }

/* 한국어 우선 · 중국어는 작은 주석으로 */
.zh-inline { display:inline; margin-left:.3em; color:var(--muted, #8a7c6d); font-size:.78em; font-style:normal; font-weight:400; opacity:.82; }
.zh { display:block; margin-top:.35rem; color:var(--muted, #8a7c6d); font-size:.78em; font-weight:400; line-height:1.6; opacity:.9; }
.bottom-nav .zh-inline { display:block; margin:0; font-size:9px; line-height:1.25; letter-spacing:0; }
.btn .zh-inline, .bottom-nav .zh-inline { color:rgba(255,255,255,.78); }
.bottom-nav .zh-inline { color:var(--muted,#8a7c6d); }
.admin-section .admin-item .btn { white-space: nowrap; }
@media (max-width: 520px) {
  .page:has(.admin-grid) .view-head { display: block; }
  .page:has(.admin-grid) .view-head h1 { font-size: 22px; }
  .admin-section .admin-item .btn { padding-left: 10px; padding-right: 10px; }
}
