/* Aono Family Tree. One stylesheet, three themes. */

@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400 600; font-display: swap; src: url("../fonts/newsreader-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Newsreader"; font-style: normal; font-weight: 400 600; font-display: swap; src: url("../fonts/newsreader-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF; }
@font-face { font-family: "Newsreader"; font-style: italic; font-weight: 400 600; font-display: swap; src: url("../fonts/newsreader-italic-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F; }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 400 600; font-display: swap; src: url("../fonts/hanken-grotesk-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 400 600; font-display: swap; src: url("../fonts/hanken-grotesk-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF; }
@font-face { font-family: "Shippori Mincho"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/shippori-mincho-400-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F; }
@font-face { font-family: "Shippori Mincho"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/shippori-mincho-400-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+1E00-1E9F; }
@font-face { font-family: "Shippori Mincho"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/shippori-mincho-600-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F; }
@font-face { font-family: "Shippori Mincho"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/shippori-mincho-600-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+1E00-1E9F; }

:root {
  /* Motion scale, shared by every transition on the page. */
  --duration-stagger: 40ms;
  --duration-micro: 80ms;
  --duration-quick: 150ms;
  --duration-fast: 250ms;
  --duration-medium: 350ms;
  --duration-slow: 400ms;
  --duration-very-slow: 500ms;
  --ease-smooth-out: cubic-bezier(0.22, 1, 0.36, 1);
  --distance-base: 8px;
  --distance-medium: 12px;
  --blur-small: 2px;
  --blur-medium: 3px;

  --jp-serif: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif CJK JP", "Noto Serif JP", serif;
  --jp-sans: "Hiragino Sans", "Yu Gothic", "Noto Sans CJK JP", "Noto Sans JP", sans-serif;
  --font-ui: "Hanken Grotesk", "Helvetica Neue", Arial, var(--jp-sans);
  --bar-h: 64px;
  --rail-w: 60px;
  --rail-h: 44px;
  --panel-w: 408px;
  --tab-h: 0px;
  font-size: 100%;
}
:root[data-large] { font-size: 118.75%; }

/* Paper and ink: the framed chart. Cream paper, deep green ink, gold hairlines. */
:root, :root[data-theme="paper"] {
  --bg: #f3ecdc;
  --bg-2: #ece3cf;
  --surface: #fbf7ec;
  --raised: #fffdf6;
  --ink: #1b2a21;
  --ink-2: #4c5a4d;
  --ink-3: #5d6753;
  --line: #d2c5a3;
  --line-2: #b9a878;
  --accent: #8f6a1c;
  --accent-ink: #fffaf0;
  --branch: #47604d;
  --focus: #1f5a3c;
  --ok: #24583c;
  --ok-tint: #dfe8d2;
  --warn: #8a5a0b;
  --warn-tint: #f1e1b9;
  --none: #8a4634;
  --none-tint: #f0dccd;
  --l1: #2f5d47; --l1-tint: #dce7d3;
  --l2: #8f6a1c; --l2-tint: #f0e2b8;
  --l3: #315a78; --l3-tint: #d8e4e6;
  --l4: #8a4634; --l4-tint: #f0dccd;
  --shadow: 0 1px 1px rgb(60 48 20 / 0.06), 0 6px 18px -8px rgb(60 48 20 / 0.28);
  --shadow-pop: 0 2px 4px rgb(60 48 20 / 0.08), 0 18px 44px -14px rgb(60 48 20 / 0.42);
  --radius: 10px;
  --font-display: "Newsreader", Georgia, var(--jp-serif);
  --font-name: "Newsreader", Georgia, var(--jp-serif);
  --font-kanji: var(--jp-serif);
  --name-weight: 600;
  --display-weight: 500;
  --grain: 0.5;
  --crest-ink: var(--ink);
  --crest-lit: var(--accent);
  --crest-wash: 0.075;
  color-scheme: light;
}

/* Night archive: the reading room after hours. Warm black, ivory type, brass. */
:root[data-theme="night"] {
  --bg: #0f100e;
  --bg-2: #151613;
  --surface: #1b1d19;
  --raised: #23261f;
  --ink: #efe9d9;
  --ink-2: #b4ad9b;
  --ink-3: #8f8978;
  --line: #33362d;
  --line-2: #4b4e41;
  --accent: #d9b25c;
  --accent-ink: #17140a;
  --branch: #6f7361;
  --focus: #e3c173;
  --ok: #8fc7a0;
  --ok-tint: #1e2c22;
  --warn: #e0b765;
  --warn-tint: #2e2715;
  --none: #e08f76;
  --none-tint: #32201a;
  --l1: #8fc7a0; --l1-tint: #1e2c22;
  --l2: #e0b765; --l2-tint: #2e2715;
  --l3: #8cb8dc; --l3-tint: #19262f;
  --l4: #e08f76; --l4-tint: #32201a;
  --shadow: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 8px 22px -10px rgb(0 0 0 / 0.8);
  --shadow-pop: 0 1px 0 rgb(255 255 255 / 0.05) inset, 0 22px 50px -14px rgb(0 0 0 / 0.9);
  --radius: 12px;
  --font-display: "Hanken Grotesk", "Helvetica Neue", Arial, var(--jp-sans);
  --font-name: "Hanken Grotesk", "Helvetica Neue", Arial, var(--jp-sans);
  --font-kanji: var(--jp-sans);
  --name-weight: 600;
  --display-weight: 600;
  --grain: 0;
  --crest-ink: var(--accent);
  --crest-lit: var(--ink);
  --crest-wash: 0.1;
  color-scheme: dark;
}

/* Sumi and washi: brush ink on handmade paper, one vermilion seal. */
:root[data-theme="sumi"] {
  --bg: #f3f0e8;
  --bg-2: #eae6db;
  --surface: #faf8f2;
  --raised: #ffffff;
  --ink: #171615;
  --ink-2: #4f4c47;
  --ink-3: #6d6962;
  --line: #cfc9bb;
  --line-2: #9d978a;
  --accent: #b5321f;
  --accent-ink: #fff8f2;
  --branch: #2a2826;
  --focus: #b5321f;
  --ok: #1f1e1c;
  --ok-tint: #e6e2d7;
  --warn: #7a5a12;
  --warn-tint: #efe5c6;
  --none: #b5321f;
  --none-tint: #f3dcd5;
  --l1: #1f1e1c; --l1-tint: #e2ded3;
  --l2: #7a5a12; --l2-tint: #efe5c6;
  --l3: #2c5a66; --l3-tint: #d9e5e3;
  --l4: #b5321f; --l4-tint: #f3dcd5;
  --shadow: 0 1px 0 rgb(20 18 12 / 0.05), 0 8px 20px -12px rgb(20 18 12 / 0.3);
  --shadow-pop: 0 2px 4px rgb(20 18 12 / 0.08), 0 20px 44px -16px rgb(20 18 12 / 0.4);
  --radius: 2px;
  --font-display: "Shippori Mincho", var(--jp-serif);
  --font-name: "Shippori Mincho", var(--jp-serif);
  --font-kanji: "Shippori Mincho", var(--jp-serif);
  --name-weight: 600;
  --display-weight: 600;
  --grain: 0.7;
  --crest-ink: var(--accent);
  --crest-lit: var(--ink);
  --crest-wash: 0.07;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; margin: 0; }
body {
  overflow-x: clip;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
::selection { background: var(--accent); color: var(--accent-ink); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
h1, h2, h3, p, ul, ol, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.86em; background: var(--bg-2); padding: 0.1em 0.35em; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 50; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 8px; text-decoration: none; transition: top var(--duration-quick) var(--ease-smooth-out); }
.skip:focus { top: 10px; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

/* ---------- Top bar ---------- */

.archive { --archive-height: calc(100dvh - var(--bar-h) - var(--tab-h)); overflow-anchor: none; }
.bar {
  position: sticky; top: 0; z-index: 20; height: var(--bar-h);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-name { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.375rem; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transform-origin: 0 50%; transition: transform var(--duration-medium) var(--ease-smooth-out); }
/* Once the tree is scrolled, the bar draws in a little and takes a shadow. */
.bar::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 14px; pointer-events: none; background: linear-gradient(to bottom, rgb(0 0 0 / 0.1), transparent); opacity: 0; transition: opacity var(--duration-medium) var(--ease-smooth-out); }
:root[data-scrolled] .bar::after { opacity: 1; }
:root[data-scrolled] .brand-name { transform: scale(0.92); }
:root[data-scrolled] .crest-mark { transform: scale(0.88); }
.crest-btn { flex: none; display: grid; place-items: center; width: 40px; height: 40px; margin-left: -6px; border-radius: 50%; transition: background-color var(--duration-quick) var(--ease-smooth-out), transform var(--duration-micro) var(--ease-smooth-out); }
.crest-btn:hover { background: var(--bg-2); }
.crest-btn:hover .crest-mark, .crest-btn:focus-visible .crest-mark { transform: scale(1.08); }
.crest-btn:active { transform: scale(0.94); }
.crest-mark { display: block; width: 30px; height: 30px; background: var(--crest-ink); -webkit-mask: var(--crest) center / contain no-repeat; mask: var(--crest) center / contain no-repeat; transition: transform var(--duration-fast) var(--ease-smooth-out); }
.chip {
  flex: none; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--ink-2); font-size: 0.8125rem; font-weight: 500; white-space: nowrap;
  transition: background-color var(--duration-quick) var(--ease-smooth-out), color var(--duration-quick) var(--ease-smooth-out), transform var(--duration-micro) var(--ease-smooth-out);
}
.chip:hover, .chip[aria-expanded="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip:active { transform: scale(0.97); }
.chip-short { display: none; }

.views { position: relative; justify-self: center; display: flex; padding: 4px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); }
.views-ink { position: absolute; left: 0; top: 4px; bottom: 4px; width: 0; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); transition: transform var(--duration-fast) var(--ease-smooth-out), width var(--duration-fast) var(--ease-smooth-out); }
.views [role="tab"] { position: relative; display: flex; align-items: center; gap: 7px; padding: 7px 16px 7px 12px; border-radius: 999px; font-weight: 500; color: var(--ink-2); transition: color var(--duration-quick) var(--ease-smooth-out); }
.views [role="tab"] .ic { transition: transform var(--duration-quick) var(--ease-smooth-out), color var(--duration-quick) var(--ease-smooth-out); }
.views [role="tab"]:hover, .views [role="tab"]:focus-visible { color: var(--ink); }
.views [role="tab"]:hover .ic, .views [role="tab"]:focus-visible .ic { transform: translateY(-1.5px); }
.views [role="tab"]:active .ic { transform: scale(0.9); }
.views [role="tab"][aria-selected="true"] { color: var(--ink); }
.views [role="tab"][aria-selected="true"] .ic { color: var(--accent); }

.tools { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 500; white-space: nowrap;
  transition: background-color var(--duration-quick) var(--ease-smooth-out), border-color var(--duration-quick) var(--ease-smooth-out), transform var(--duration-micro) var(--ease-smooth-out), box-shadow var(--duration-quick) var(--ease-smooth-out);
}
.btn:hover { background: var(--raised); border-color: var(--ink-3); box-shadow: var(--shadow); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); box-shadow: none; }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { background: var(--ink); border-color: var(--ink); filter: brightness(1.18); }
:root[data-theme="night"] .btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
:root[data-theme="sumi"] .btn, :root[data-theme="sumi"] .chip, :root[data-theme="sumi"] .views, :root[data-theme="sumi"] .views-ink, :root[data-theme="sumi"] .views [role="tab"] { border-radius: 3px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; color: var(--ink-2); transition: background-color var(--duration-quick) var(--ease-smooth-out), color var(--duration-quick) var(--ease-smooth-out), transform var(--duration-micro) var(--ease-smooth-out); }
.icon-btn:hover, .icon-btn:focus-visible { background: var(--bg-2); color: var(--ink); }
.icon-btn:active { transform: scale(0.94); }

.search { position: relative; }
.search-open, .search-close { display: none; }
.search-field { position: relative; display: flex; align-items: center; }
.search-field > .ic { position: absolute; left: 11px; width: 17px; height: 17px; color: var(--ink-3); pointer-events: none; }
.search input { width: 216px; height: 38px; padding: 0 34px 0 36px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); outline-offset: 1px; transition: width var(--duration-fast) var(--ease-smooth-out), border-color var(--duration-quick) var(--ease-smooth-out), background-color var(--duration-quick) var(--ease-smooth-out); }
.search input::placeholder { color: var(--ink-3); }
.search input:focus { width: 264px; border-color: var(--ink-3); background: var(--raised); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd { position: absolute; right: 9px; font: 500 0.75rem var(--font-ui); color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 5px; padding: 0 6px; line-height: 1.5; pointer-events: none; }
.search input:focus ~ kbd { opacity: 0; }
.results { position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; width: 340px; max-width: calc(100vw - 24px); padding: 6px; background: var(--raised); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--shadow-pop); animation: pop-in var(--duration-fast) var(--ease-smooth-out); transform-origin: top right; }
.results li { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; padding: 9px 11px; border-radius: 8px; cursor: pointer; }
.results li { transition: background-color var(--duration-quick) var(--ease-smooth-out); }
.results li[aria-selected="true"], .results li[data-id]:hover { background: var(--bg-2); }
.results li[data-id] .hit-name { transition: transform var(--duration-quick) var(--ease-smooth-out); }
.results li[aria-selected="true"] .hit-name, .results li[data-id]:hover .hit-name { transform: translateX(3px); }
.results li[data-id]:active { background: var(--line); }
.results .hit-name { font-family: var(--font-name); font-weight: var(--name-weight); font-size: 1.0625rem; }
.results .hit-kanji { font-family: var(--font-kanji); color: var(--ink-2); justify-self: end; }
.results .hit-meta { grid-column: 1 / -1; color: var(--ink-2); font-size: 0.8125rem; }
.results .none { display: block; color: var(--ink-2); cursor: default; }

.themes { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; }
.themes button { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; transition: transform var(--duration-micro) var(--ease-smooth-out), background-color var(--duration-quick) var(--ease-smooth-out); }
.themes button:hover, .themes button:focus-visible { background: var(--bg-2); }
.themes button:hover .sw, .themes button:focus-visible .sw { transform: scale(1.12); }
.themes button:active { transform: scale(0.9); }
.sw { display: block; width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgb(0 0 0 / 0.28); transition: box-shadow var(--duration-quick) var(--ease-smooth-out), transform var(--duration-quick) var(--ease-smooth-out); }
.sw-paper { background: linear-gradient(135deg, #f3ecdc 50%, #1f4a35 50%); }
.sw-night { background: linear-gradient(135deg, #0f100e 50%, #d9b25c 50%); border-color: rgb(255 255 255 / 0.3); }
.sw-sumi { background: linear-gradient(135deg, #f3f0e8 50%, #b5321f 50%); }
[aria-checked="true"] > .sw { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--ink); }

/* ---------- Stage ---------- */

.stage { position: relative; display: flow-root; min-height: var(--archive-height); overflow: clip; background: var(--bg); outline: none; }
.stage::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: var(--grain); mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.28 0 0 0 0 0.14 0 0 0 0.16 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
}
.stage-dock { position: absolute; inset: 0 0 auto; height: 0; z-index: 6; }
.stage-controls { position: absolute; inset: 0 0 auto; height: var(--archive-height); pointer-events: none; }
.stage-controls > :is(.rail, .mini, .legend, .zoom, .timebar) { pointer-events: auto; }
.stage[data-mode="scroll"] .stage-dock, .stage-backdrop { position: sticky; inset: var(--bar-h) 0 auto; height: 0; }
.stage-backdrop { z-index: 0; pointer-events: none; }
:root:not([data-archive-active]) .panel { visibility: hidden; pointer-events: none; }
.scroller { position: absolute; inset: 0; overflow: hidden; }
.chart { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.chart.panning { cursor: grabbing; }
#vp { transform-origin: 0 0; will-change: transform; }
#vp.glide { transition: transform var(--duration-very-slow) var(--ease-smooth-out); }

.stage-head { position: absolute; left: 24px; top: 20px; z-index: 5; max-width: min(520px, calc(100% - 48px)); pointer-events: none; }
.stage-head > * { pointer-events: auto; }
/* A soft wash of paper behind the heading, so cards passing underneath never tangle with the words. */
.stage-head::before { content: ""; position: absolute; z-index: -1; inset: -20px -90px -44px -24px; background: var(--bg); pointer-events: none; -webkit-mask-image: linear-gradient(to bottom, #000 58%, transparent), linear-gradient(to right, #000 72%, transparent); -webkit-mask-composite: source-in; mask-image: linear-gradient(to bottom, #000 58%, transparent), linear-gradient(to right, #000 72%, transparent); mask-composite: intersect; }
.stage-head h2 { font-family: var(--font-display); font-weight: var(--display-weight); font-size: clamp(1.625rem, 1.1rem + 1.5vw, 2.375rem); line-height: 1.12; letter-spacing: -0.02em; text-wrap: balance; }
.stage-head p { margin-top: 8px; max-width: 46ch; color: var(--ink-2); text-wrap: pretty; }
.link-btn { display: inline-flex; align-items: center; gap: 7px; margin-top: 12px; padding: 6px 12px 6px 9px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 500; font-size: 0.875rem; transition: background-color var(--duration-quick) var(--ease-smooth-out), transform var(--duration-micro) var(--ease-smooth-out); }
.link-btn .ic { width: 17px; height: 17px; }
.link-btn:hover { background: var(--raised); transform: translateY(-1px); }
.link-btn:active { transform: scale(0.98); }
.stage-msg { position: absolute; left: 24px; top: 120px; max-width: 46ch; padding: 14px 16px; border: 1px solid var(--none); border-radius: var(--radius); background: var(--none-tint); color: var(--ink); }

.legend { position: absolute; left: 20px; bottom: 18px; transition: opacity var(--duration-fast) var(--ease-smooth-out); z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; max-width: calc(100% - 190px); padding: 5px 6px 5px 12px; background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); }
.legend-title { font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); margin-right: 4px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 0.8125rem; font-weight: 500; white-space: nowrap; }
button.legend-item { transition: background-color var(--duration-quick) var(--ease-smooth-out), transform var(--duration-micro) var(--ease-smooth-out); }
button.legend-item:hover, button.legend-item:focus-visible { background: var(--bg-2); }
button.legend-item:active { transform: scale(0.96); }
button.legend-item[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
button.legend-item[aria-pressed="true"] .mark { --mark: var(--bg); --mark-bg: var(--ink); }
.legend .count { color: var(--ink-3); font-variant-numeric: tabular-nums; }
button.legend-item[aria-pressed="true"] .count { color: inherit; opacity: 0.75; }
.legend .dot { width: 11px; height: 11px; border-radius: 3px; border: 1.5px solid var(--lc); background: var(--lt); }
.dot.ln-1 { --lc: var(--l1); --lt: var(--l1-tint); } .dot.ln-2 { --lc: var(--l2); --lt: var(--l2-tint); }
.dot.ln-3 { --lc: var(--l3); --lt: var(--l3-tint); } .dot.ln-4 { --lc: var(--l4); --lt: var(--l4-tint); }
:root[data-theme="sumi"] .legend, :root[data-theme="sumi"] .legend-item, :root[data-theme="sumi"] .link-btn, :root[data-theme="sumi"] .zoom, :root[data-theme="sumi"] .timebar { border-radius: 3px; }

.zoom { position: absolute; right: 20px; bottom: 18px; z-index: 5; display: flex; padding: 3px; background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); transition: transform var(--duration-slow) var(--ease-smooth-out); }
.zoom .icon-btn { width: 36px; height: 36px; }

.timebar { position: absolute; left: 50%; bottom: 74px; z-index: 5; translate: -50% 0; display: flex; align-items: center; gap: 12px; width: min(560px, calc(100% - 40px)); padding: 6px 16px 6px 6px; background: color-mix(in srgb, var(--surface) 94%, transparent); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); }
.timebar[hidden] { display: none; }
.timebar output { flex: none; min-width: 12.5em; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
#playBtn { background: var(--ink); color: var(--bg); border-radius: 50%; }
#playBtn:hover { filter: brightness(1.2); }
#playBtn .ic-play { fill: currentColor; stroke: none; }
#playBtn .ic-pause { display: none; stroke-width: 2.4; }
#playBtn[aria-pressed="true"] .ic-play { display: none; }
#playBtn[aria-pressed="true"] .ic-pause { display: block; }
input[type="range"] { flex: 1; min-width: 0; height: 24px; margin: 0; background: transparent; appearance: none; -webkit-appearance: none; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--line-2); }
input[type="range"]::-moz-range-track { height: 3px; border-radius: 2px; background: var(--line-2); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7.5px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / 0.35); transition: transform var(--duration-micro) var(--ease-smooth-out); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / 0.35); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }

/* ---------- Chart drawing ---------- */

.chart text { font-family: var(--font-ui); fill: var(--ink); }
.next-generation-link { fill: none; stroke: var(--branch); stroke-width: 1.5; stroke-dasharray: 2 3; }
.next-generation-plate { fill: var(--surface); stroke: var(--line-2); stroke-dasharray: 3 2; }
.chart .next-generation-title { font: 650 13px var(--font-display); }
.chart .next-generation-caption { font-size: 10px; fill: var(--ink-2); }
.link { fill: none; stroke: var(--branch); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; opacity: 0.6; transition: opacity var(--duration-quick) var(--ease-smooth-out), stroke var(--duration-quick) var(--ease-smooth-out), stroke-width var(--duration-quick) var(--ease-smooth-out); }
:root[data-theme="sumi"] .link { stroke-width: 1.5; stroke-linecap: square; stroke-linejoin: miter; opacity: 0.7; }
/* The spine: the chosen person's own line carries a heavier stroke. */
.link.spine { stroke-width: 2.1; opacity: 0.95; }
:root[data-theme="sumi"] .link.spine { stroke-width: 2.3; opacity: 1; }
.link.couple { stroke: var(--line-2); stroke-width: 2.5; opacity: 1; }
:root[data-theme="paper"] .link.couple { stroke: var(--accent); stroke-width: 2; }
/* Entrances: "pre" is the waiting state and exists only while a script has set it. */
.link.rise { transition: opacity var(--duration-medium) var(--ease-smooth-out) var(--d, 0ms), stroke-dashoffset 700ms var(--ease-smooth-out) var(--d, 0ms); }
.link.spine.rise { stroke-dasharray: 1; stroke-dashoffset: 0; }
.link.pre { opacity: 0; }
.link.spine.pre { opacity: 0.95; stroke-dasharray: 1; stroke-dashoffset: 1; }

.card, .cell, .life, .fold { cursor: pointer; outline: none; }
.hit { fill: transparent; stroke: none; }
.card, .fold { transition: transform var(--duration-very-slow) var(--ease-smooth-out), opacity var(--duration-fast) var(--ease-smooth-out); }
.card.exit, .fold.exit { opacity: 0; transition: opacity var(--duration-quick) var(--ease-smooth-out); pointer-events: none; }
.card-in { transition: transform var(--duration-fast) var(--ease-smooth-out), opacity var(--duration-fast) var(--ease-smooth-out), filter var(--duration-fast) var(--ease-smooth-out); }
.card.rise .card-in { transition: opacity var(--duration-slow) var(--ease-smooth-out) var(--d, 0ms), transform var(--duration-very-slow) var(--ease-smooth-out) var(--d, 0ms), filter var(--duration-slow) var(--ease-smooth-out) var(--d, 0ms); }
.card.pre .card-in { opacity: 0; transform: translateY(10px); filter: blur(var(--blur-small)); }
.fold-in { transition: opacity var(--duration-fast) var(--ease-smooth-out); }
.fold.rise .fold-in { transition: opacity var(--duration-slow) var(--ease-smooth-out) calc(var(--d, 0ms) + 120ms); }
.fold.pre .fold-in { opacity: 0; }
@media (hover: hover) { .card:hover .card-in { transform: translateY(-3px); } }
.card:focus-visible .card-in { transform: translateY(-3px); }
.card:active .card-in { transform: translateY(0); }

/* A portrait tile: medallion above, name plate below. */
.card-bg { fill: var(--surface); stroke: var(--line-2); stroke-width: 1; transition: fill var(--duration-quick) var(--ease-smooth-out), stroke var(--duration-quick) var(--ease-smooth-out), stroke-width var(--duration-quick) var(--ease-smooth-out); }
.card-ring { fill: none; stroke: transparent; stroke-width: 2; transition: stroke var(--duration-quick) var(--ease-smooth-out); }
/* Sumi sets the caption straight on the paper, with no plate. */
:root[data-theme="sumi"] .card-bg { fill: transparent; stroke: transparent; }
.card:hover .card-bg, .card:focus-visible .card-bg { fill: var(--raised); stroke: var(--ink-2); }
:root[data-theme="sumi"] .card:hover .card-bg, :root[data-theme="sumi"] .card:focus-visible .card-bg { fill: transparent; stroke: var(--line-2); }
.card:focus-visible .card-ring { stroke: var(--focus); }
.card.role-side .card-bg { fill: transparent; stroke: var(--line); }
.card.role-side .nm { fill: var(--ink-2); }
.card.role-side .frame { fill: transparent; }
:root[data-theme="sumi"] .card.role-side .frame { fill: var(--ink-3); }
.card.role-focal .card-bg { stroke: var(--ink); stroke-width: 1.8; fill: var(--raised); }
.card.role-focal .frame { stroke: var(--ink); stroke-width: 2; }
:root[data-theme="sumi"] .card.role-focal .card-bg { fill: transparent; stroke: var(--ink); stroke-width: 1.6; }
:root[data-theme="sumi"] .card.role-focal .frame-out { stroke-width: 2.2; }
.card.selected .card-bg { stroke: var(--accent); stroke-width: 2.4; }
.card .nm { font-family: var(--font-name); font-weight: var(--name-weight); font-size: 14.5px; letter-spacing: -0.005em; }
.card .fm { font-family: var(--font-name); font-size: 12.5px; fill: var(--ink-2); }
.card .kj { font-family: var(--font-kanji); font-size: 12px; fill: var(--ink-2); }
.card .yr { font-size: 11.5px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.card .rel-tag { font-size: 10.5px; font-weight: 600; letter-spacing: 0.03em; fill: var(--ink-2); }
:root[data-theme="sumi"] .card .nm { font-size: 15px; }
.card.is-small .nm { font-size: 13.5px; }
.card.is-small .fm { font-size: 12px; }
.card.is-small .kj { font-size: 11.5px; }
.card.is-small .yr { font-size: 11px; }
.card.is-small .rel-tag { font-size: 10px; }
.frame-out { fill: none; stroke: var(--ink); stroke-width: 1; }

/* The fold count is its own button. Its type is larger than the dates line on the same tile. */
.fold-bg { fill: var(--ink); stroke: var(--bg); stroke-width: 1.5; transition: fill var(--duration-quick) var(--ease-smooth-out), stroke var(--duration-quick) var(--ease-smooth-out); }
.chart .fold-n { font-size: 12.5px; font-weight: 600; fill: var(--bg); font-variant-numeric: tabular-nums; }
.fold-mark { fill: none; stroke: var(--ink-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fold.is-open .fold-bg { fill: var(--surface); stroke: var(--line-2); stroke-width: 1; }
.fold:hover .fold-bg, .fold:focus-visible .fold-bg { fill: var(--focus); }
.fold.is-open:hover .fold-bg, .fold.is-open:focus-visible .fold-bg { fill: var(--bg-2); stroke: var(--ink-2); }
.fold:focus-visible .fold-bg { stroke: var(--focus); stroke-width: 3; }
.fold:active .fold-bg { fill: var(--ink-2); }
:root[data-theme="night"] .chart .fold:hover .fold-n, :root[data-theme="night"] .chart .fold:focus-visible .fold-n { fill: var(--accent-ink); }

/* Shelves: one heading per generation, and the chart's own title above them all. */
/* Heading words carry a halo of paper, so a connector passing behind them never tangles with the letters. */
.shelf-title, .shelf-meta { paint-order: stroke; stroke: var(--bg); stroke-width: 6px; stroke-linejoin: round; }
.shelf-title { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 17px; letter-spacing: -0.005em; }
.chart .shelf-meta { font-size: 12px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.chart .shelf-era { font-size: 11.5px; font-weight: 600; fill: var(--ink-2); paint-order: stroke; stroke: var(--bg); stroke-width: 5px; stroke-linejoin: round; }
.chart .shelf-era-mark { fill: none; stroke: var(--accent); stroke-width: 1.2px; stroke-linecap: round; stroke-linejoin: round; }
.shelf-rule { fill: none; stroke: var(--line); stroke-width: 1; transition: stroke var(--duration-quick) var(--ease-smooth-out), stroke-width var(--duration-quick) var(--ease-smooth-out); }
.shelf.hot .shelf-rule { stroke: var(--ink-2); stroke-width: 1.6; }
.shelf.rise { transition: opacity var(--duration-slow) var(--ease-smooth-out) var(--d, 0ms); }
.shelf.pre { opacity: 0; }
.poster-kanji { font-family: var(--font-kanji); font-size: 34px; font-weight: 600; letter-spacing: 0.12em; }
.chart .poster-name { font-family: var(--font-display); font-size: 16px; letter-spacing: 0.14em; fill: var(--ink-2); }
.chart .poster-fact { font-size: 12.5px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.poster.is-small .poster-kanji { font-size: 28px; }
.chart .poster.is-small .poster-name { font-size: 14px; }
.chart .poster.is-small .poster-fact { font-size: 12px; }
.poster-rule { fill: none; stroke: var(--line-2); stroke-width: 1; }
.poster-gem { fill: var(--accent); }
#vp.exporting, #vp.exporting * { transition: none !important; animation: none !important; }
.frame { fill: var(--bg-2); stroke: var(--line-2); stroke-width: 1.2; }
:root[data-theme="paper"] .frame { stroke: var(--accent); }
.frame-in { fill: none; stroke: var(--line-2); stroke-width: 0.6; }
:root[data-theme="sumi"] .frame { fill: var(--accent); stroke: none; }
:root[data-theme="sumi"] .mono { fill: var(--accent-ink); }
:root[data-theme="sumi"] .is-private .frame { fill: var(--bg-2); stroke: var(--line-2); stroke-width: 1.2; }
.mono { font-family: var(--font-kanji); font-size: 20px; font-weight: 600; fill: var(--ink-2); }
.lock { fill: none; stroke: var(--ink-3); stroke-width: 1.4; stroke-linecap: round; }
.is-private .nm, .is-private .fm { fill: var(--ink-2); font-style: italic; }
:root[data-theme="night"] .is-private .nm, :root[data-theme="sumi"] .is-private .nm, :root[data-theme="night"] .is-private .fm, :root[data-theme="sumi"] .is-private .fm { font-style: normal; }
.is-private .card-bg { stroke-dasharray: 4 3; }

/* Proof marks: shape and colour both carry the level. */
.pm, .mark { --mark: var(--ok); --mark-bg: var(--surface); }
.pm-claimed, .pf-claimed .mark, .pf-claimed > .pm { --mark: var(--warn); }
.pm-unproven, .pf-unproven .mark { --mark: var(--none); }
.pm-solid { fill: var(--mark); }
.pm-tick-inv { fill: none; stroke: var(--mark-bg); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.pm-ring { fill: none; stroke: var(--mark); stroke-width: 1.5; }
.pm-tick { fill: none; stroke: var(--mark); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.pm-dash { stroke-dasharray: 2.6 2.1; }
.pm-dots { stroke-dasharray: 0.4 2.75; stroke-linecap: round; stroke-width: 1.8; }
.pm-dot { fill: var(--mark); }
.mark { width: 16px; height: 16px; flex: none; overflow: visible; }

/* Colour by proof: only the weak facts take a tint, so the eye goes to what needs work. */
:root[data-colorby="proof"] .card.pf-claimed .card-bg { fill: color-mix(in srgb, var(--warn-tint) 55%, var(--surface)); }
:root[data-colorby="proof"] .card.pf-unproven .card-bg { fill: color-mix(in srgb, var(--none-tint) 60%, var(--surface)); }

:root[data-colorby="lineage"] .card.ln-1 .card-bg, :root[data-colorby="lineage"] .cell.ln-1 .cell-bg { fill: var(--l1-tint); stroke: var(--l1); }
:root[data-colorby="lineage"] .card.ln-2 .card-bg, :root[data-colorby="lineage"] .cell.ln-2 .cell-bg { fill: var(--l2-tint); stroke: var(--l2); }
:root[data-colorby="lineage"] .card.ln-3 .card-bg, :root[data-colorby="lineage"] .cell.ln-3 .cell-bg { fill: var(--l3-tint); stroke: var(--l3); }
:root[data-colorby="lineage"] .card.ln-4 .card-bg, :root[data-colorby="lineage"] .cell.ln-4 .cell-bg { fill: var(--l4-tint); stroke: var(--l4); }

/* Tracing a line of descent, and filtering by proof. */
#vp.tracing .card:not(.on), #vp.tracing .cell:not(.on), #vp.tracing .cell-empty { opacity: 0.5; }
#vp.tracing .link:not(.on) { opacity: 0.16; }
#vp.tracing .link.on { stroke: var(--accent); stroke-width: 2.6; opacity: 1; }
#vp.tracing .card.on .card-bg { stroke: var(--accent); stroke-width: 1.8; }
#vp.tracing .card.on .frame { stroke: var(--accent); }
#vp.filtering [data-id]:not(.match) { opacity: 0.26; }
#vp.filtering .link { opacity: 0.14; }
.cell, .life { transition: opacity var(--duration-quick) var(--ease-smooth-out); }

/* Fan */
.cell-bg { fill: var(--surface); stroke: var(--bg); stroke-width: 3; transition: fill var(--duration-quick) var(--ease-smooth-out); }
:root[data-colorby="lineage"] .cell .cell-bg { stroke: var(--bg); }
:root[data-colorby="proof"] .cell.pf-corroborated .cell-bg { fill: color-mix(in srgb, var(--ok-tint) 90%, var(--surface)); }
:root[data-colorby="proof"] .cell.pf-sourced .cell-bg { fill: color-mix(in srgb, var(--ok-tint) 45%, var(--surface)); }
:root[data-colorby="proof"] .cell.pf-claimed .cell-bg { fill: var(--warn-tint); }
:root[data-colorby="proof"] .cell.pf-unproven .cell-bg { fill: var(--none-tint); }
.cell:hover .cell-bg, .cell:focus-visible .cell-bg { fill: var(--raised); }
.cell:focus-visible .cell-bg { stroke: var(--focus); }
.cell.selected .cell-bg { stroke: var(--accent); }
:root[data-colorby] .cell.hub .cell-bg { fill: var(--ink); stroke: var(--bg); }
.cell.hub text { fill: var(--bg); }
:root[data-colorby] .cell.hub:hover .cell-bg { fill: var(--ink); }
:root[data-colorby] .cell.hub.selected .cell-bg { stroke: var(--accent); }
.cell-empty { fill: none; stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.cell .nm { font-family: var(--font-name); font-weight: var(--name-weight); font-size: 14px; }
.cell.hub .nm { font-size: 16.5px; }
.cell .yr { font-size: 10.5px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.cell.hub .yr { fill: var(--bg); opacity: 0.8; }
.guide { fill: none; stroke: none; }
.cell.rise, .fan-notes.rise { transition: opacity var(--duration-slow) var(--ease-smooth-out) var(--d, 0ms), filter var(--duration-slow) var(--ease-smooth-out) var(--d, 0ms); }
.cell.pre { opacity: 0; filter: blur(var(--blur-medium)); }
.fan-notes { --d: 320ms; }
.fan-notes.pre { opacity: 0; }
.chart .ring-label, .chart .side-label { font-size: 12px; font-weight: 500; fill: var(--ink-2); letter-spacing: 0.02em; }

/* Timeline */
.grid { stroke: var(--line); stroke-width: 1; opacity: 0.6; fill: none; }
.grid.major { stroke: var(--line-2); opacity: 0.9; }
.tick { font-size: 12px; fill: var(--ink-2); font-variant-numeric: tabular-nums; }
.life .bar { fill: var(--surface); stroke: var(--line-2); stroke-width: 1; transition: fill var(--duration-quick) var(--ease-smooth-out), stroke var(--duration-quick) var(--ease-smooth-out); }
.life.pf-claimed .bar { fill: color-mix(in srgb, var(--warn-tint) 55%, var(--surface)); }
.life.pf-unproven .bar { fill: color-mix(in srgb, var(--none-tint) 60%, var(--surface)); }
.life.is-living .bar { stroke-dasharray: 5 3; }
.life .est { stroke: var(--ink-3); stroke-width: 2; stroke-dasharray: 2 3; fill: none; }
.life .nm { font-family: var(--font-name); font-weight: var(--name-weight); font-size: 13.5px; fill: var(--ink-2); transition: fill var(--duration-quick) var(--ease-smooth-out); }
.life .age { font-size: 11px; fill: var(--accent-ink); font-variant-numeric: tabular-nums; }
.life.alive .bar { fill: var(--ink); stroke: var(--ink); }
.life.alive .nm { fill: var(--bg); }
.life.alive .age { fill: var(--bg); opacity: 0.78; }
:root[data-theme="night"] .life.alive .bar { fill: var(--accent); stroke: var(--accent); }
:root[data-theme="night"] .life.alive .nm, :root[data-theme="night"] .life.alive .age { fill: var(--accent-ink); }
.life:hover .bar, .life:focus-visible .bar { stroke: var(--ink); stroke-width: 2; }
.life:focus-visible .bar { stroke: var(--focus); stroke-width: 2.5; }
.life.is-focal .bar, .life.selected .bar { stroke: var(--accent); stroke-width: 2.5; }
.cursor { cursor: ew-resize; }
.cursor-line { stroke: var(--accent); stroke-width: 1.5; fill: none; }
.cursor-tag { fill: var(--accent); }
.cursor-year { font-size: 13px; font-weight: 600; fill: var(--accent-ink); font-variant-numeric: tabular-nums; }
.cursor-hit { fill: transparent; }
.life .bar { transform-box: fill-box; transform-origin: 0 50%; }
.life.rise { transition: opacity var(--duration-slow) var(--ease-smooth-out) var(--d, 0ms); }
.life.rise .bar { transition: transform var(--duration-very-slow) var(--ease-smooth-out) var(--d, 0ms); }
.life.pre { opacity: 0; }
.life.pre .bar { transform: scaleX(0.72); }

/* ---------- Person panel ---------- */

.panel {
  position: fixed; z-index: 15; top: var(--bar-h); right: 0; bottom: 0; width: var(--panel-w); max-width: 100vw;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-pop);
  transform: translateX(104%); visibility: hidden;
  transition: transform var(--duration-medium) var(--ease-smooth-out), visibility 0s linear var(--duration-medium);
}
.panel:not([data-state="closed"]) { transform: none; visibility: visible; transition: transform var(--duration-slow) var(--ease-smooth-out), visibility 0s; }
.panel-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 22px 24px 40px; }
:root[data-panel="open"] .zoom { transform: translateX(calc(var(--panel-w) * -1)); }
.p-head { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center; padding-right: 40px; }
.p-close { position: absolute; right: -8px; top: -6px; }
.p-portrait { display: grid; place-items: center; width: 68px; height: 84px; border-radius: 50%; background: var(--bg-2); border: 1.5px solid var(--accent); box-shadow: inset 0 0 0 4px var(--surface), inset 0 0 0 5px var(--line-2); overflow: hidden; font: 600 2rem var(--font-kanji); color: var(--ink-2); }
:root[data-theme="night"] .p-portrait { width: 72px; height: 72px; border-color: var(--line-2); box-shadow: none; }
:root[data-theme="sumi"] .p-portrait { width: 68px; height: 68px; border-radius: 3px; background: var(--accent); border: 0; box-shadow: none; color: var(--accent-ink); }
.p-portrait img { width: 100%; height: 100%; object-fit: cover; }
.p-lock { width: 30px; height: 30px; fill: none; stroke: var(--ink-3); stroke-width: 1.4; stroke-linecap: round; }
:root[data-theme="sumi"] .p-lock { stroke: var(--accent-ink); }
.p-id h2 { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.6875rem; line-height: 1.12; letter-spacing: -0.015em; text-wrap: balance; outline: none; }
.p-kanji { margin-top: 5px; font-family: var(--font-kanji); font-size: 1.0625rem; }
.p-reading { margin-left: 10px; font-size: 0.8125rem; color: var(--ink-2); }
.p-life { margin-top: 5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.p-where { color: var(--ink-2); font-size: 0.875rem; }
.p-proof { display: flex; gap: 10px; align-items: flex-start; margin-top: 18px; padding: 11px 13px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); font-size: 0.875rem; color: var(--ink-2); }
.p-proof strong { color: var(--ink); margin-right: 4px; }
.p-proof .mark { margin-top: 2px; --mark-bg: var(--bg); }
.p-proof.pf-claimed { background: color-mix(in srgb, var(--warn-tint) 60%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 35%, var(--line)); }
.p-proof.pf-unproven { background: color-mix(in srgb, var(--none-tint) 60%, var(--surface)); border-color: color-mix(in srgb, var(--none) 35%, var(--line)); }
.p-expand { display: none; }
.p-body section { margin-top: 30px; }
.p-body h3 { font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.p-story { margin-top: 12px; font-family: var(--font-display); font-size: 1.125rem; line-height: 1.55; max-width: 60ch; text-wrap: pretty; }
:root[data-theme="night"] .p-story { font-size: 1rem; line-height: 1.6; }
.p-story-source { margin-top: 10px; color: var(--ink-2); font-size: .8125rem; }
.p-record-note { margin-top: 12px; }
.p-record-note summary { color: var(--ink-2); cursor: pointer; font-size: .875rem; }
.p-artifacts ul { margin: 12px 0 18px; padding: 0; list-style: none; }
.p-artifacts li { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.p-artifacts li + li { margin-top: 8px; }
.p-artifact { display: grid; gap: 8px; color: var(--ink); overflow-wrap: anywhere; }
.p-artifact img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 4px; }
.p-artifacts li p { margin-top: 5px; color: var(--ink-2); font-size: .875rem; line-height: 1.5; }
.p-narrative + .link-btn { margin-top: 16px; }
.p-private { margin-top: 20px; color: var(--ink-2); max-width: 46ch; }
.fact { padding: 13px 0; border-bottom: 1px solid var(--line); }
.fact-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 14px; align-items: baseline; }
.fact-type { font-weight: 600; }
.fact-when { justify-self: end; font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.fact-place { grid-column: 1 / -1; color: var(--ink-2); font-size: 0.875rem; }
.fact-note { margin-top: 5px; color: var(--ink-2); font-size: 0.875rem; max-width: 52ch; }
.src-btn { display: inline-flex; align-items: center; gap: 7px; margin-top: 8px; padding: 4px 6px 4px 5px; margin-left: -5px; border-radius: 7px; font-size: 0.8125rem; font-weight: 500; color: var(--ink-2); transition: background-color var(--duration-quick) var(--ease-smooth-out), color var(--duration-quick) var(--ease-smooth-out); }
.src-btn:hover, .src-btn:focus-visible { background: var(--bg-2); color: var(--ink); }
.src-btn:active { transform: scale(0.98); }
.src-btn .chev { width: 15px; height: 15px; transition: transform var(--duration-fast) var(--ease-smooth-out); }
.src-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.cites { margin-top: 8px; padding: 10px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); animation: cite-in var(--duration-fast) var(--ease-smooth-out); }
.cites li + li { margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line-2); }
.cites strong { display: block; font-size: 0.875rem; }
.cites span { display: block; font-size: 0.8125rem; color: var(--ink-2); }
@keyframes cite-in { from { opacity: 0; transform: translateY(-4px); filter: blur(var(--blur-small)); } }
.rels { display: grid; gap: 2px; margin-top: 8px; }
.rel { display: grid; text-align: left; padding: 9px 10px; margin: 0 -10px; border-radius: 8px; transition: background-color var(--duration-quick) var(--ease-smooth-out), transform var(--duration-micro) var(--ease-smooth-out); }
.rel:hover, .rel:focus-visible { background: var(--bg-2); }
.rel:active { transform: scale(0.99); }
.rel-name { font-family: var(--font-name); font-weight: var(--name-weight); font-size: 1.0625rem; }
.rel-meta { color: var(--ink-2); font-size: 0.8125rem; }
.rel-name::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 8px; border-top: 1.5px solid var(--accent); border-right: 1.5px solid var(--accent); rotate: 45deg; vertical-align: 0.12em; opacity: 0; transform: translate(-3px, 3px); transition: opacity var(--duration-quick) var(--ease-smooth-out), transform var(--duration-quick) var(--ease-smooth-out); }
.rel:hover .rel-name::after, .rel:focus-visible .rel-name::after { opacity: 1; transform: none; }

/* ---------- Popovers ---------- */

.pop {
  position: fixed; z-index: 40; width: 300px; max-width: calc(100vw - 24px); padding: 18px;
  background: var(--raised); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(-4px) scale(0.97); transform-origin: var(--ox, 80%) 0; pointer-events: none;
  transition: opacity var(--duration-quick) var(--ease-smooth-out), transform var(--duration-quick) var(--ease-smooth-out);
}
.pop.open { opacity: 1; transform: none; pointer-events: auto; transition-duration: var(--duration-fast); }
.pop[hidden] { display: none; }
.pop-wide { width: 380px; }
:root[data-theme="sumi"] .pop, :root[data-theme="sumi"] .results, :root[data-theme="sumi"] .seg, :root[data-theme="sumi"] .seg button { border-radius: 3px; }
.pop h3 { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.3125rem; line-height: 1.2; letter-spacing: -0.01em; }
.pop p { margin-top: 10px; max-width: 46ch; }
.pop-note { color: var(--ink-2); font-size: 0.875rem; }
.pop-note[data-ok="false"] { color: var(--none); }
.credit { margin-top: 16px; }
.pop fieldset + fieldset, .pop h3 ~ fieldset, .pop .switch { margin-top: 16px; }
.pop legend { font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.themes-row { display: none; }
.seg { display: flex; gap: 3px; padding: 3px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; }
.seg-wrap { flex-wrap: wrap; }
.seg button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 0 10px; border-radius: 7px; font-weight: 500; font-size: 0.875rem; color: var(--ink-2); white-space: nowrap; transition: background-color var(--duration-quick) var(--ease-smooth-out), color var(--duration-quick) var(--ease-smooth-out), transform var(--duration-micro) var(--ease-smooth-out); }
.seg button:hover, .seg button:focus-visible { color: var(--ink); background: color-mix(in srgb, var(--surface) 55%, transparent); }
.seg button:active { transform: scale(0.97); }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg .sw { width: 14px; height: 14px; }
.seg [aria-checked="true"] > .sw { box-shadow: none; }
.switch { display: flex; align-items: center; gap: 11px; font-weight: 500; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 40px; height: 24px; border-radius: 999px; background: var(--line-2); transition: background-color var(--duration-fast) var(--ease-smooth-out); }
.switch-track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--raised); box-shadow: 0 1px 2px rgb(0 0 0 / 0.3); transition: transform var(--duration-fast) var(--ease-smooth-out); }
.switch input:checked + .switch-track { background: var(--ok); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch:hover .switch-track::after { box-shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 0 0 5px color-mix(in srgb, var(--ink) 10%, transparent); }
.legible { margin-top: 12px; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); font-size: 0.875rem; }
.legible[data-ok="true"] { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.legible[data-ok="false"] { border-color: var(--none); background: var(--none-tint); }
.pop-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.97); } }

/* ---------- Tree view: one tall chart that scrolls, with a rail of generations ---------- */

.stage[data-mode="scroll"] .scroller { position: relative; z-index: 1; inset: auto; margin-left: var(--rail-w); overflow: clip; padding: 0 24px 130px 14px; }
.stage[data-mode="scroll"] .chart { position: relative; z-index: 1; inset: auto; display: block; height: auto; touch-action: auto; cursor: default; }
.stage[data-mode="scroll"] #vp { will-change: auto; }
.stage[data-mode="scroll"] .stage-head { position: relative; left: 0; top: 0; z-index: 2; max-width: 64ch; padding: 22px 0 2px 10px; }
.stage[data-mode="scroll"] .stage-head::before { display: none; }
.stage[data-mode="scroll"] .stage-head h2 { font-size: clamp(1.375rem, 1rem + 1vw, 1.875rem); }
.stage[data-mode="scroll"] .zoom { display: none; }
.stage[data-mode="scroll"] .legend { left: calc(var(--rail-w) + 16px); }
.stage[data-mode="pan"] .rail, .stage[data-mode="pan"] .mini { display: none; }


.rail { position: absolute; z-index: 6; left: 0; top: 0; bottom: 0; width: var(--rail-w); display: flex; flex-direction: column; padding: 14px 0 76px; background: var(--bg); border-right: 1px solid var(--line); }
/* Fixed size: the caption has to fit the 60px rail in larger type mode too. */
.rail-cap { margin-bottom: 6px; text-align: center; font-size: 11px; font-weight: 600; color: var(--ink-2); }
.rail-list { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; max-height: 640px; }
.rail-list::before { content: ""; position: absolute; left: 6px; right: 6px; top: 0; height: calc(100% / var(--n, 11)); border-radius: 9px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow); transform: translateY(calc(var(--at, 0) * 100%)); transition: transform var(--duration-medium) var(--ease-smooth-out); }
.rail-list li { flex: 1; display: flex; min-height: 0; }
.rail-item { position: relative; flex: 1; display: grid; place-content: center; justify-items: center; margin: 2px 6px; border-radius: 8px; color: var(--ink-2); transition: color var(--duration-quick) var(--ease-smooth-out), background-color var(--duration-quick) var(--ease-smooth-out), transform var(--duration-micro) var(--ease-smooth-out); }
.rail-n { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.0625rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.rail-y { min-height: 0.8em; font-size: 0.6875rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.rail-item:hover, .rail-item.hot { color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, transparent); }
.rail-item:active { transform: scale(0.94); }
.rail-item[aria-current] { color: var(--ink); font-weight: 600; }
:root[data-theme="sumi"] .rail-list::before, :root[data-theme="sumi"] .rail-item { border-radius: 3px; }

/* The heading, condensed: it slides in once the full heading has scrolled away. */
.mini { position: absolute; z-index: 5; left: var(--rail-w); right: 0; top: 0; height: 48px; display: flex; align-items: center; gap: 14px; padding: 0 24px; background: color-mix(in srgb, var(--bg) 95%, transparent); border-bottom: 1px solid var(--line); opacity: 0; visibility: hidden; transform: translateY(-10px); transition: opacity var(--duration-fast) var(--ease-smooth-out), transform var(--duration-fast) var(--ease-smooth-out), visibility 0s linear var(--duration-fast); }
:root[data-scrolled] .mini { opacity: 1; visibility: visible; transform: none; transition: opacity var(--duration-medium) var(--ease-smooth-out), transform var(--duration-medium) var(--ease-smooth-out), visibility 0s; }
.mini-text { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
#miniTitle { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#miniGen { flex: none; color: var(--ink-2); font-size: 0.8125rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini .link-btn { flex: none; margin: 0 0 0 auto; }

@media (min-width: 821px) {
  :root[data-panel="open"] .stage[data-mode="scroll"] .scroller { padding-right: calc(var(--panel-w) + 20px); }
  :root[data-panel="open"] .mini { right: var(--panel-w); }
}

/* ---------- The crest cover ---------- */

.crest-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.cover { position: relative; outline: none; }
.crest-art { display: block; fill: currentColor; overflow: visible; }
.hero-crest { width: min(44vh, 64vw, 330px); height: auto; color: var(--crest-ink); transform-origin: 50% 50%; transition: transform 600ms var(--ease-smooth-out); }
.cover-name { --d: 600ms; margin-top: 10px; font-family: var(--font-display); font-weight: var(--display-weight); font-size: clamp(1.25rem, 1.05rem + 0.9vw, 1.75rem); line-height: 1.2; }
.cover-about { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; gap: clamp(32px, 6vw, 96px); max-width: 1080px; margin: 0 auto; padding: clamp(56px, 11vh, 128px) 32px 24px; }
.about-art { position: sticky; top: 12vh; display: grid; justify-items: center; gap: 16px; }
.about-art .parts {
  opacity: var(--crest-arrival, 1);
}
.about-art .part-reading { opacity: var(--crest-reveal-opacity, 1); }
.about-text > * {
  opacity: var(--story-reveal-opacity, 1);
  transform: translateY(var(--story-reveal-rise, 0px));
}
.about-art:focus-within .parts {
  clip-path: none;
  opacity: 1;
  transform: none;
}
.about-art:focus-within .part-reading, .about-title:focus-visible { opacity: 1; }
.parts { width: min(100%, 400px); height: auto; color: var(--crest-ink); }
.part, .part-still { transition: opacity var(--duration-fast) var(--ease-smooth-out), color var(--duration-fast) var(--ease-smooth-out); }
.part { cursor: pointer; outline: none; }
.part use { stroke: transparent; stroke-width: 5; stroke-linejoin: round; paint-order: stroke; transition: stroke var(--duration-quick) var(--ease-smooth-out); }
.parts.choosing .part:not(.on), .parts.choosing .part-still { opacity: 0.2; }
.part.on { color: var(--crest-lit); }
.part:focus-visible use { stroke: var(--focus); }
.part:active { opacity: 0.8; }
.part-label { min-height: 1.5em; font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.3125rem; line-height: 1.3; color: var(--ink-2); text-align: center; transition: color var(--duration-quick) var(--ease-smooth-out); }
.part-label.has { color: var(--ink); }
.about-title { margin-top: 12px; font-family: var(--font-display); font-weight: var(--display-weight); font-size: clamp(2rem, 1.45rem + 2.3vw, 3rem); line-height: 1.08; letter-spacing: -0.02em; text-wrap: balance; }
.about-kanji { margin-top: 12px; font-family: var(--font-kanji); font-size: 1.5rem; letter-spacing: 0.1em; }
.gloss { margin-top: 4px; font-family: var(--font-display); font-size: 1.125rem; color: var(--ink-2); }
:root[data-theme="paper"] .gloss { font-style: italic; }
.prose, .honest { margin-top: 26px; max-width: 62ch; font-size: 1.0625rem; line-height: 1.65; text-wrap: pretty; }
.gloss + .prose { margin-top: 30px; }
.honest { padding-top: 20px; border-top: 1px solid var(--line-2); color: var(--ink-2); }

/* ---------- Theme change, as one soft dissolve ---------- */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: var(--duration-slow); animation-timing-function: var(--ease-smooth-out); }

.print-sheet { display: none; }

/* ---------- Narrow screens ---------- */

@media (max-width: 1240px) {
  .chip-long { display: none; }
  .chip-short { display: inline; }
  .btn span { display: none; }
  .btn { padding: 0; width: 38px; }
  .search input { width: 168px; }
  .search input:focus { width: 208px; }
  .bar { gap: 10px; padding: 0 14px; }
}
@media (max-width: 1000px) {
  .themes { display: none; }
  .themes-row { display: block; }
  .pop .themes-row + fieldset { margin-top: 16px; }
}
@media (max-width: 820px) {
  :root { --bar-h: 56px; --tab-h: calc(58px + env(safe-area-inset-bottom)); --panel-w: 100vw; }
  .bar { grid-template-columns: minmax(0, 1fr) auto; padding: 0 8px 0 14px; }
  .brand-name { font-size: 1rem; }
  .brand { gap: 8px; }
  .chip { padding: 4px 9px; font-size: 0.75rem; }
  .chip-long { display: none; }
  .chip-short { display: inline; }
  .stage-head::before { inset: -14px -16px -40px -16px; -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent); mask-image: linear-gradient(to bottom, #000 62%, transparent); }
  .views { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; justify-self: stretch; width: 100%; height: var(--tab-h); padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); border-radius: 0; border: 0; border-top: 1px solid var(--line); background: var(--bg); }
  :root:not([data-archive-active]) .views { visibility: hidden; }
  .views [role="tab"] { flex: 1; flex-direction: column; justify-content: center; gap: 1px; padding: 4px; font-size: 0.75rem; min-height: 44px; }
  .views-ink { top: 6px; bottom: calc(6px + env(safe-area-inset-bottom)); border-radius: 10px; }
  .tools { gap: 2px; }
  .btn, .btn-primary { width: 44px; height: 44px; min-height: 44px; border: 0; background: none; color: var(--ink-2); box-shadow: none; }
  :root[data-theme="night"] .btn-primary { background: none; color: var(--ink-2); }
  .btn:hover { transform: none; box-shadow: none; background: var(--bg-2); }
  .btn-primary:hover { filter: none; }
  .icon-btn { width: 44px; height: 44px; }
  .search { position: static; }
  .search-open { display: inline-grid; }
  .search-field { display: none; position: absolute; inset: 0; z-index: 3; padding: 0 6px 0 12px; background: var(--bg); gap: 4px; }
  .bar.searching .search-field { display: flex; animation: pop-in var(--duration-fast) var(--ease-smooth-out); }
  .search-field > .ic { left: 24px; }
  .search input, .search input:focus { flex: 1; width: auto; height: 42px; font-size: 1rem; }
  .search kbd { display: none; }
  .search-close { display: inline-grid; flex: none; }
  .results { left: 8px; right: 8px; top: calc(100% + 6px); width: auto; }
  .stage-head { left: 16px; top: 14px; max-width: calc(100% - 32px); }
  .crest-btn { width: 36px; height: 36px; margin-left: -8px; }
  .crest-mark { width: 26px; height: 26px; }
  .stage[data-mode="scroll"] .scroller { margin: var(--rail-h) 0 0; padding: 0 10px 150px 6px; }
  .stage[data-mode="scroll"] .stage-head { padding: 14px 0 0 8px; max-width: none; }
  .stage[data-mode="scroll"] .legend { left: 10px; }
  .rail { right: 0; bottom: auto; width: auto; height: var(--rail-h); flex-direction: row; align-items: center; padding: 0 8px 0 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-cap { margin: 0 6px 0 0; }
  .rail-list { flex-direction: row; max-height: none; height: 100%; }
  .rail-list::before { left: 0; right: auto; top: 6px; bottom: 6px; width: calc(100% / var(--n, 11)); height: auto; transform: translateX(calc(var(--at, 0) * 100%)); }
  .rail-item { margin: 6px 0; }
  .rail-y { display: none; }
  .mini { left: auto; right: 10px; top: auto; bottom: 66px; height: auto; padding: 0; background: none; border: 0; }
  .mini-text { display: none; }
  .mini .link-btn { box-shadow: var(--shadow); min-height: 40px; }
  :root[data-panel="peek"] .mini, :root[data-panel="open"] .mini { opacity: 0; pointer-events: none; }
  .hero-crest { width: min(34vh, 62vw, 260px); }
  .cover-about { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 48px 20px 16px; }
  .about-art { position: static; order: 2; margin: 26px 0 6px; }
  .about-text { display: contents; }
  .about-text > * { order: 3; }
  .about-text > .about-title, .about-text > .about-kanji, .about-text > .gloss { order: 1; }
  .parts { width: min(78vw, 320px); }
  .stage-head p { font-size: 0.875rem; margin-top: 5px; }
  .legend { left: 10px; right: 10px; bottom: 10px; max-width: none; border-radius: 14px; padding: 4px 4px 4px 10px; gap: 0; overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .legend::-webkit-scrollbar { display: none; }
  .legend-item { padding: 8px 9px; min-height: 40px; }
  .zoom { right: 10px; bottom: 66px; flex-direction: column; }
  .zoom .icon-btn { width: 42px; height: 42px; }
  :root[data-panel="open"] .zoom { transform: none; }
  :root[data-panel="peek"] .zoom, :root[data-panel="peek"] .legend { opacity: 0; pointer-events: none; }
  .timebar { bottom: 62px; width: calc(100% - 74px); left: 10px; translate: none; gap: 8px; padding-right: 12px; }
  .timebar output { min-width: 0; font-size: 0.8125rem; }
  .timebar input { min-width: 60px; }

  .panel { top: auto; left: 0; right: 0; bottom: var(--tab-h); width: auto; height: min(78dvh, calc(100dvh - var(--bar-h) - var(--tab-h) - 24px)); border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; transform: translateY(104%); }
  :root[data-theme="sumi"] .panel { border-radius: 3px 3px 0 0; }
  .panel[data-state="peek"] { transform: translateY(calc(100% - 152px)); }
  .panel[data-state="peek"] .panel-scroll { overflow: hidden; }
  .panel[data-state="peek"] .p-proof, .panel[data-state="peek"] .p-body, .panel[data-state="peek"] .p-where { display: none; }
  .panel-scroll { padding: 16px 16px 32px; }
  .p-head { gap: 12px; padding-right: 44px; }
  .p-close { right: -6px; top: -8px; }
  .p-portrait, :root[data-theme="night"] .p-portrait, :root[data-theme="sumi"] .p-portrait { width: 52px; height: 62px; font-size: 1.5rem; }
  :root[data-theme="night"] .p-portrait, :root[data-theme="sumi"] .p-portrait { height: 52px; }
  .p-id h2 { font-size: 1.3125rem; }
  .p-kanji { font-size: 0.9375rem; margin-top: 2px; }
  .p-life { margin-top: 2px; font-size: 0.875rem; }
  .p-expand { display: inline-flex; position: absolute; right: 16px; top: 96px; min-height: 40px; width: auto; height: 40px; padding: 0 14px; border: 1px solid var(--line-2); background: var(--raised); color: var(--ink); }
  .panel[data-state="open"] .p-expand { position: static; margin-top: 14px; }
  .panel[data-state="open"] .p-proof { margin-top: 14px; }

  .pop, .pop-wide { left: 8px !important; right: 8px; top: auto !important; bottom: calc(var(--tab-h) + 8px); width: auto; max-width: none; transform: translateY(12px); transform-origin: 50% 100%; max-height: calc(100dvh - var(--bar-h) - var(--tab-h) - 24px); overflow-y: auto; }
  .seg button { min-height: 44px; }
  .pop-actions .btn { width: auto; flex: 1 1 100%; height: 44px; padding: 0 14px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); }
  .pop-actions .btn span { display: inline; }
  .pop-actions .btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
  :root[data-theme="night"] .pop-actions .btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
}

/* The cover is a lit miniature behind one sheet of glass. */
.cover {
  --glass-ink: #fbf4e8;
  --cover-ink: #101923;
  --cover-paper: #f6eedc;
  --cover-dissolve: clamp(62px, 10vh, 96px);
  --paper-wash: clamp(74px, 12vh, 132px);
  --glass-gold: #f4d49c;
  --focus: #f4d49c;
  background: var(--cover-ink);
  scrollbar-color: #697b88 #17232e;
}
.cover::before, .cover::after { display: none; }
.cover-hero {
  display: block;
  min-height: 0;
  text-align: left;
}
.cover-frame {
  position: relative;
  isolation: isolate;
  min-height: max(540px, 100svh);
  overflow: hidden;
  display: grid;
  place-items: center start;
  color: var(--glass-ink);
  background: #263b4e;
  mask-image: linear-gradient(to bottom, #000 calc(100% - var(--cover-dissolve)), transparent 100%);
}
.cover-frame::before {
  position: absolute;
  content: "";
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgb(11 21 32 / .95), rgb(15 26 38 / .71) 24%, rgb(15 26 38 / .08) 57%, transparent 78%),
    linear-gradient(180deg, rgb(8 17 25 / .44), transparent 27%, transparent 78%, rgb(8 17 25 / .53));
}
.cover-scene {
  position: absolute;
  z-index: -2;
  inset: 0;
  container-type: size;
  pointer-events: none;
  transform: translate3d(calc(var(--scene-x, 0px) * var(--cover-chrome, 1)), calc(var(--scene-y, 0px) * var(--cover-chrome, 1)), 0);
  transition: transform 650ms var(--ease-smooth-out);
}
.cover-estate {
  --estate-width: max(100cqw, 197cqh);
  --estate-height: calc(var(--estate-width) * 941 / 1672);
  position: absolute;
  width: var(--estate-width);
  left: calc((100cqw - var(--estate-width)) * var(--estate-focus, .5));
  top: calc((100cqh - var(--estate-height)) * .5);
  transform-origin: 0 0;
  transform: translate3d(var(--estate-x, 0px), var(--estate-y, 0px), 0) scale(var(--estate-zoom, 1));
}
.cover-estate img { display: block; width: 100%; height: auto; }
.estate-facade { position: relative; }
.estate-shoji, .crest-runway { display: none; }
.estate-crest {
  position: absolute;
  width: 2.02%;
  left: 69.54%;
  top: 36.45%;
  transform: translate(-50%, -50%);
  fill: #e5bd79;
  filter: drop-shadow(0 1px 1px #1c0f04);
}
.cover-intro {
  position: relative;
  justify-self: start;
  margin: 42px 0 46px clamp(32px, 7vw, 114px);
  max-width: 580px;
  transform: translateY(var(--cover-word-drift, 0px));
}
.crest-entry {
  display: grid;
  width: clamp(108px, 10vw, 146px);
  aspect-ratio: 1;
  place-items: center;
  padding: clamp(14px, 1.25vw, 20px);
  border-radius: 50%;
  border: 1px solid rgb(244 212 156 / .49);
  background: radial-gradient(ellipse at 22% 13%, rgb(239 219 178 / .17), transparent 62%), rgb(48 63 75 / .5);
  box-shadow: 0 14px 32px rgb(5 10 18 / .24), inset 0 0 0 4px rgb(235 201 140 / .09);
  backdrop-filter: blur(10px);
  transition: background-color var(--duration-fast), box-shadow var(--duration-fast), transform var(--duration-fast);
}
.crest-entry:hover, .crest-entry:focus-visible {
  background-color: rgb(91 85 68 / .72);
  box-shadow: 0 13px 38px rgb(232 183 99 / .17), inset 0 0 0 4px rgb(235 201 140 / .12);
  transform: translateY(-3px);
}
.crest-entry .hero-crest { width: 100%; color: var(--glass-gold); filter: drop-shadow(0 3px 6px rgb(0 0 0 / .38)); }
.cover-name {
  margin: clamp(22px, 4.2vh, 42px) 0 0;
  font: 400 clamp(3.9rem, 7.7vw, 6rem)/.88 "Newsreader", Georgia, serif;
  letter-spacing: -.036em;
}
.cover-fact { margin-top: 18px; max-width: 36ch; color: #f4e9d7; font-size: .96rem; }
.estate-water, .estate-mist, .estate-light, .estate-petals { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .estate-water, .estate-mist, .estate-light, .estate-petals { display: block; }
  .estate-water {
    position: absolute;
    inset: 59.6317% 0 0 11.4833%;
    overflow: hidden;
    pointer-events: none;
  }
  .estate-water canvas {
    width: 100%;
    height: 100%;
    opacity: .81;
  }
  .estate-mist {
    position: absolute;
    inset: 1% -6% auto 50%;
    height: 24%;
    background: radial-gradient(ellipse at 63% 30%, rgb(162 185 219 / .18), transparent 59%);
    animation: estate-mist 17s ease-in-out infinite alternate;
  }
  .estate-light {
    position: absolute;
    inset: 42% 5% 39% 49%;
    background:
      radial-gradient(ellipse at 43% 36%, rgb(255 184 105 / .24), transparent 32%),
      radial-gradient(ellipse at 64% 75%, rgb(252 177 89 / .15), transparent 22%);
    mix-blend-mode: screen;
    animation: estate-lantern 8.5s ease-in-out infinite alternate;
  }
  .estate-petals { inset: 6% 23% 12% 27%; }
  .estate-petals i:nth-child(odd) { --petal-size: 5px; }
  .cover-frame:not(.scene-visible) :is(.estate-light, .estate-mist, .estate-petals i) {
    animation-play-state: paused;
  }
}
@keyframes estate-mist {
  from { transform: translate3d(-7%, -7px, 0); opacity: .35; }
  to { transform: translate3d(5%, 4px, 0); opacity: .94; }
}
@keyframes estate-lantern {
  0%, 53% { opacity: .44; }
  26%, 100% { opacity: .9; }
}
.cover-story {
  position: relative;
  margin-top: -24px;
  padding-top: calc(var(--paper-wash) + 24px);
  background:
    linear-gradient(to bottom, var(--story-seam, var(--cover-ink)), var(--story-mid, #ac9375) 38%, var(--story-near, #d4c1a5) 70%, var(--cover-paper))
    center top / 100% var(--paper-wash) no-repeat,
    linear-gradient(to bottom, transparent, var(--bg)) center bottom / 100% 52px no-repeat,
    var(--cover-paper);
}
.story-crane {
  position: absolute;
  z-index: 1;
  width: clamp(130px, 14vw, 214px);
  height: auto;
  inset: calc(var(--paper-wash) * .28) clamp(24px, 12vw, 200px) auto auto;
  filter: drop-shadow(8px 15px 12px rgb(28 23 29 / .27));
  transform: translateY(-23%) rotate(-7deg);
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  .story-crane {
    position: fixed;
    z-index: 8;
    inset: 0 auto auto 0;
    transform: translate3d(var(--tsuru-x, 0px), var(--tsuru-y, 0px), 0) rotate(var(--tsuru-angle, 0deg)) scale(var(--tsuru-scale, 1));
    transform-origin: 0 0;
    opacity: var(--tsuru-opacity, 0);
  }
  :root[data-panel="open"] .story-crane, :root[data-panel="peek"] .story-crane { opacity: 0; }
  :root[data-realm-active] .story-crane { opacity: 0; }
}
.cover-about, .crest-history, .story-archive-links {
  --ink: #32281c;
  --ink-2: #655137;
  --line-2: #b6a07c;
  --crest-ink: #644b2c;
  --crest-lit: #805421;
  --font-display: "Newsreader", Georgia, var(--jp-serif);
  color: var(--ink);
}
.cover-about {
  position: relative;
  max-width: 1260px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 60px) clamp(20px, 6vw, 94px) clamp(32px, 5vw, 76px);
}
.about-art { padding: 22px 10px; }
.about-title { margin: 0 0 14px; font-size: clamp(2.6rem, 5vw, 4.3rem); }
.crest-name { font: 500 clamp(1.2rem, 2.2vw, 1.7rem)/1.1 var(--font-display); }
.cover-about .honest { border-color: var(--line-2); }
.part-reading { width: 100%; max-width: 400px; min-height: 8.4em; }
.part-detail { margin: 6px auto 0; max-width: 40ch; color: var(--ink-2); font-size: .875rem; line-height: 1.5; text-align: center; }
.crest-history {
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(18px, 4vw, 58px);
  max-width: 1260px;
  margin: 0 auto;
  padding: 0 clamp(20px, 6vw, 94px) clamp(38px, 6vw, 84px);
}
.crest-history figure { margin: 0; }
.crest-history img { display: block; width: 100%; height: auto; border-radius: 6px; }
.crest-history figcaption, .crest-history details { margin-top: 10px; color: var(--ink-2); font-size: .82rem; }
.crest-history h3 { margin: 0 0 12px; font: 500 clamp(1.9rem, 3.3vw, 3rem)/1.05 var(--font-display); }
.crest-history p { margin-top: 10px; font-size: .95rem; line-height: 1.65; }
.crest-history a, .story-archive-links .link-btn { color: inherit; }
@media (max-width: 820px) { .crest-history { grid-template-columns: 1fr; } }
.story-archive-links { display: flex; flex-wrap: wrap; gap: 10px; max-width: 1260px; margin-inline: auto; padding: 0 clamp(20px, 6vw, 94px) clamp(88px, 12svh, 142px); }
.story-archive-links .link-btn { min-height: 44px; margin: 0; text-decoration: none; }
.family-photos {
  background: linear-gradient(var(--bg), transparent 58px), var(--bg-2);
  padding: clamp(50px, 9vw, 116px) clamp(22px, 10vw, 165px) 48px;
  min-height: 100svh;
}
.family-photos h2 { font: var(--display-weight) clamp(2.5rem, 6vw, 4.3rem)/1 var(--font-display); letter-spacing: -.025em; }
.album-manage { text-decoration: none; min-height: 44px; }
.family-photos p { margin-top: 20px; color: var(--ink-2); }
.photo-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: clamp(20px, 5vw, 58px); margin-top: 30px; }
.photo-gallery figure { margin: 0; max-width: 540px; scroll-margin-top: 24px; }
.photo-gallery img { display: block; width: 100%; height: auto; padding: 8px; background: var(--raised); box-shadow: var(--shadow); }
.photo-gallery figcaption { margin-top: 10px; font-family: var(--font-name); }
.photo-people { display: block; margin-top: 4px; }
.photo-gallery a { color: var(--ink); text-underline-offset: 3px; }
.p-album { text-decoration: none; }
.family-photos .archive-credit { margin-top: clamp(44px, 12vh, 105px); font-size: .82rem; }
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    .family-photos > :not(.archive-credit) { animation: album-unfold linear both; animation-timeline: view(); animation-range: entry 0% entry 85%; }
  }
}
@keyframes album-unfold { from { opacity: .64; transform: translateY(22px); } to { opacity: 1; transform: none; } }
.cover ::selection { color: #13202c; background: #f7d9a2; }

/* Washi, bronze and ink for the archive. */
:root[data-theme="paper"], :root:not([data-theme]) {
  --bg: #f2e9d6;
  --bg-2: #e8d9bd;
  --surface: #fff9ee;
  --raised: #fffcf3;
  --ink: #2d251a;
  --ink-2: #584932;
  --ink-3: #6b563c;
  --accent: #8a581f;
  --line: #c9b18c;
  --line-2: #af9061;
  --branch: #795832;
  --focus: #754317;
  --crest-wash: .055;
}
:root[data-theme="night"] {
  --bg: #16212c;
  --bg-2: #1d2c39;
  --surface: #233442;
  --raised: #2a3d4b;
  --line: #41525f;
  --line-2: #677986;
  --ink-2: #d6cdbb;
  --ink-3: #c4baaa;
  --branch: #a39478;
  --font-display: "Newsreader", Georgia, var(--jp-serif);
}
.bar, .rail, .mini, .panel {
  background-color: color-mix(in srgb, var(--surface) 88%, var(--bg-2));
}
.bar { box-shadow: 0 3px 15px rgb(32 23 12 / .08); }
.views { background: color-mix(in srgb, var(--bg-2) 72%, var(--surface)); }
.panel, .pop { box-shadow: var(--shadow-pop); }
.stage::before { display: none; }
/* One sakura spans the generations, from the crown to the exposed roots. */
.stage[data-mode="scroll"] {
  background: linear-gradient(90deg, var(--bg-2), var(--bg) 12%, var(--bg) 88%, var(--bg-2));
}
.stage[data-mode="scroll"] .scroller {
  background: transparent;
  scrollbar-color: var(--line-2) var(--bg);
}
.tree-relief { display: none; }
.stage[data-mode="scroll"] .tree-relief {
  position: absolute;
  inset: 0 0 auto var(--rail-w);
  height: var(--archive-height);
  display: block;
  overflow: hidden;
  pointer-events: none;
}
.tree-relief::before {
  --relief-pan: 54.13%;
  --relief-shadow: drop-shadow(9px 15px 13px rgb(57 39 52 / .28));
  position: absolute;
  content: "";
  left: 53%;
  top: 2%;
  width: clamp(790px, 87%, 1320px);
  height: 218%;
  background: center / 100% 100% no-repeat;
  opacity: .65;
  filter: var(--relief-shadow);
  transform: translate3d(-50%, calc(var(--relief-shift, 0) * var(--relief-pan)), 0);
}
/* The relief is a large picture far down the page. main.js sets data-relief as the chart comes near. */
[data-relief] .tree-relief::before { background-image: url("../art/sakura-relief-detail.webp"); }
:root[data-theme="night"] .tree-relief::before { opacity: .45; }
:root[data-theme="sumi"] .tree-relief::before { filter: grayscale(1) var(--relief-shadow); opacity: .48; }
.tree-petals { position: absolute; inset: 0; overflow: hidden; }
.tree-petals i {
  position: absolute;
  inset: -5% auto auto var(--petal-x);
  width: var(--petal-size, 9px);
  aspect-ratio: .72;
  opacity: 0;
  border-radius: 65% 34% 66% 38%;
  background: linear-gradient(151deg, #f7dce9 13%, #e7bacd 51%, #c58fae 54%, #d5a4bc 87%);
  box-shadow: inset 0 1px 0 #fff5;
  transform-origin: 48% 55%;
  animation: sakura-fall var(--fall-time) linear var(--fall-delay) infinite;
}
.tree-petals i:nth-child(1) { --petal-x: 16%; --fall-time: 23s; --fall-delay: -3s; --petal-drift: 69px; --petal-size: 7px; }
.tree-petals i:nth-child(2) { --petal-x: 27%; --fall-time: 29s; --fall-delay: -13s; --petal-drift: -53px; }
.tree-petals i:nth-child(3) { --petal-x: 37%; --fall-time: 26s; --fall-delay: -8s; --petal-drift: 82px; --petal-size: 6px; }
.tree-petals i:nth-child(4) { --petal-x: 49%; --fall-time: 31s; --fall-delay: -23s; --petal-drift: -48px; }
.tree-petals i:nth-child(5) { --petal-x: 61%; --fall-time: 24s; --fall-delay: -16s; --petal-drift: 58px; --petal-size: 7px; }
.tree-petals i:nth-child(6) { --petal-x: 72%; --fall-time: 30s; --fall-delay: -10s; --petal-drift: -72px; }
.tree-petals i:nth-child(7) { --petal-x: 83%; --fall-time: 26s; --fall-delay: -1s; --petal-drift: 46px; --petal-size: 6px; }
.tree-petals i:nth-child(8) { --petal-x: 90%; --fall-time: 28s; --fall-delay: -20s; --petal-drift: -67px; --petal-size: 8px; }
:root[data-theme="sumi"] .tree-petals { filter: grayscale(1); }
@keyframes sakura-fall {
  0% { opacity: 0; transform: translate3d(0, 0, 0) rotate(-30deg) rotateY(18deg); }
  13% { opacity: .62; }
  30% { transform: translate3d(calc(var(--petal-drift) * .65), 31vh, 0) rotate(46deg) rotateY(68deg); }
  55% { transform: translate3d(calc(var(--petal-drift) * .25), 56vh, 0) rotate(138deg) rotateY(155deg); }
  80% { opacity: .5; transform: translate3d(calc(var(--petal-drift) * 1.15), 82vh, 0) rotate(217deg) rotateY(244deg); }
  100% { opacity: 0; transform: translate3d(var(--petal-drift), 104vh, 0) rotate(274deg) rotateY(338deg); }
}
.stage[data-mode="scroll"] .stage-head {
  max-width: min(550px, 96%);
  padding: 24px 14px 8px 12px;
  text-shadow: 0 0 12px var(--bg), 0 0 6px var(--bg);
}
.stage[data-mode="scroll"] .stage-head::before {
  display: block;
  inset: 0 -18px -14px -12px;
  background: linear-gradient(90deg, var(--bg) 46%, transparent);
  mask-image: linear-gradient(#000 63%, transparent);
}
.stage[data-mode="scroll"] .stage-head h2 { font-size: clamp(1.6rem, 2.5vw, 2.4rem); }
.chart[data-view="tree"] .poster text {
  paint-order: stroke;
  stroke: var(--bg);
  stroke-linejoin: round;
  stroke-width: 4px;
}
.chart[data-view="tree"] .shelf-title, .chart[data-view="tree"] .shelf-meta { stroke-width: 4px; }
.chart[data-view="tree"] .shelf-rule { opacity: .76; }
.chart[data-view="tree"] .link {
  --relief-link: color-mix(in srgb, var(--branch) 88%, var(--ink));
  stroke: var(--relief-link);
  stroke-width: 1.7;
  opacity: .84;
  filter: drop-shadow(0 1px 0 var(--surface));
}
.chart[data-view="tree"] .link.spine { stroke-width: 2.65px; opacity: 1; }
.chart[data-view="tree"] .link.couple { stroke: var(--accent); stroke-width: 2.15px; }
.chart[data-view="tree"] .link.pre:not(.spine) { opacity: 0; }
.chart[data-view="tree"] .plate-tether { stroke: var(--branch); stroke-width: 1.8; stroke-linecap: round; }
.chart[data-view="tree"] .card .card-bg {
  fill: var(--surface);
  stroke: var(--line-2);
  filter: drop-shadow(0 3px 2px rgb(35 23 11 / .20));
}
.chart[data-view="tree"] .card .frame { fill: var(--bg-2); }
:root[data-theme="sumi"] .chart[data-view="tree"] .card:not(.is-private) .frame { fill: var(--accent); }
.chart[data-view="tree"] .card.role-focal .card-bg,
.chart[data-view="tree"] .card.selected .card-bg { fill: var(--raised); stroke: var(--accent); }
.chart[data-view="tree"] .card:focus-visible .card-bg { fill: var(--raised); stroke: var(--focus); }
@media (hover: hover) {
  .chart[data-view="tree"] .card:hover .card-bg { fill: var(--raised); stroke: var(--accent); }
  .chart[data-view="tree"] .card:hover .frame { stroke: var(--accent); }
}
@media (min-width: 821px) {
  .stage[data-mode="scroll"] .scroller { padding-inline: clamp(20px, 4vw, 76px); }
  :root[data-panel="open"] .stage[data-mode="scroll"] .scroller { padding-right: calc(var(--panel-w) + 20px); }
  :root[data-panel="open"] .tree-relief { right: var(--panel-w); }
}
@media (max-width: 820px) {
  .stage[data-mode="scroll"] .tree-relief { inset: var(--rail-h) 0 auto; height: calc(var(--archive-height) - var(--rail-h)); }
  .tree-relief::before {
    --relief-pan: 41.86%;
    left: 52%;
    width: clamp(475px, 130vw, 730px);
    height: 172%;
    opacity: .57;
  }
  .tree-petals i:nth-child(2n) { display: none; }
  .stage[data-mode="scroll"] .stage-head { padding: 17px 8px 12px; }
}
@media (max-width: 820px) {
  .cover { --cover-dissolve: 56px; }
  .cover-frame { min-height: max(620px, 100svh); align-items: start; }
  .cover-estate { --estate-focus: .69; --estate-width: max(100cqw, 132cqh); top: calc(101cqh - var(--estate-height)); }
  .cover-frame::before {
    background: linear-gradient(180deg, #182a3b 8%, rgb(17 33 47 / .98) 27%, rgb(18 33 46 / .52) 55%, transparent 77%, rgb(13 24 35 / .54));
  }
  .cover-intro { align-self: start; margin: clamp(36px, 8vh, 100px) 20px 0 25px; }
  .crest-entry { width: 82px; padding: 12px; }
  .cover-name { font-size: clamp(3.1rem, 12vw, 5.1rem); margin-top: 22px; }
  .cover-fact { margin-top: 13px; max-width: 29ch; font-size: .89rem; }
  .story-crane { width: clamp(107px, 30vw, 150px); inset-inline-end: 22px; }
  .cover-about .crest-name { order: 1; }
  .about-art { margin: 12px 0 2px; }
  .stage[data-mode="scroll"] .stage-head h2 { font-size: 1.55rem; text-wrap: initial; }
}
@media (prefers-reduced-motion: reduce) {
  .cover-scene, .cover-estate, .cover-intro, .about-art .parts, .about-text > * { transform: none; }
  .about-art .parts { clip-path: none; }
  .about-art .parts, .about-art .part-reading, .about-text > * { opacity: 1; }
  .tree-relief::before { top: 0; height: 100%; width: 100%; background-size: contain; transform: translateX(-50%); }
  .tree-petals { display: none; }
  .story-crane { transform: translateY(-23%) rotate(-7deg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}

@media print {
  @page { margin: 10mm; }
  body { display: block; overflow: visible; background: #fff; }
  body > :not(.print-sheet) { display: none !important; }
  .print-sheet { display: block; }
  .print-sheet svg { display: block; width: 100%; height: auto; max-height: 100vh; }
}

/* Ancestors in reading order, with each pair grouped under their child's name. */
.stage[data-mode="guide"] .scroller {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px clamp(16px, 5vw, 75px) 45px;
  background: linear-gradient(90deg, var(--bg-2), var(--bg) 13%, var(--bg) 89%, var(--bg-2));
}
.stage[data-mode="guide"] .stage-head {
  position: relative;
  inset: auto;
  max-width: 940px;
  margin: 0 auto;
}
.stage[data-mode="guide"] .stage-head::before { display: none; }
.stage[data-mode="guide"] .stage-head p { max-width: 58ch; }
.stage[data-mode="guide"] .chart { opacity: 0; pointer-events: none; }
.stage[data-mode="guide"] .zoom, .stage[data-mode="guide"] .mini { display: none; }
.ancestor-controls { position: absolute; top: 18px; right: 20px; z-index: 6; }
.stage[data-mode="guide"] .ancestor-controls { position: relative; inset: auto; max-width: 940px; margin: 0 auto; }
.stage[data-mode="guide"] .ancestor-controls .link-btn { margin-top: 12px; }
.ancestor-guide { max-width: 940px; margin: 20px auto 0; }
.ancestor-start {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px clamp(13px, 2vw, 25px);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--surface);
}
.ancestor-start h3, .ancestor-generation h3 {
  font: 600 clamp(1.35rem, 1.1rem + 1vw, 2rem)/1.15 var(--font-display);
}
.ancestor-start p, .ancestor-role, .ancestor-years { color: var(--ink-2); font-size: .86rem; }
.ancestor-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ancestor-actions .link-btn { margin: 0; }
.ancestor-generation { margin-top: 25px; }
.ancestor-generation h3 { margin-bottom: 10px; }
.ancestor-generation ul { display: grid; gap: 10px; list-style: none; padding: 0; }
.ancestor-family { padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg-2); }
.ancestor-family h4 { margin: 0 0 8px; color: var(--ink); font-weight: 600; font-size: .94rem; }
.ancestor-parents { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ancestor-person, .ancestor-missing {
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: 80px;
  padding: 10px;
  border-radius: 8px;
  text-align: left;
  overflow-wrap: anywhere;
}
.ancestor-person { border: 1px solid var(--line-2); background: var(--surface); }
.ancestor-person strong { font: 600 clamp(1rem, .9rem + .5vw, 1.35rem)/1.16 var(--font-name); }
.ancestor-person:hover, .ancestor-person:focus-visible { background: var(--raised); border-color: var(--accent); }
.ancestor-missing { border: 1px dashed var(--line-2); color: var(--ink-2); font-size: .86rem; }
.ancestor-missing:only-child { grid-column: 1 / -1; min-height: 44px; }
@media (min-width: 821px) {
  :root[data-panel="open"] .stage[data-mode="guide"] .scroller { padding-right: calc(var(--panel-w) + 24px); }
  .ancestor-generation ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ancestor-family:only-child { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .stage[data-mode="guide"] .scroller { padding-top: 16px; padding-bottom: 165px; }
  .ancestor-guide { margin-top: 14px; }
  .ancestor-controls .link-btn, .ancestor-actions .link-btn { min-height: 44px; }
  .ancestor-controls { top: auto; bottom: 66px; right: 10px; }
}

.kin-jumps { display: flex; flex-wrap: wrap; gap: 6px; }
.kin-jumps .link-btn { margin: 0; padding-inline: 10px; }
.stage-head .kin-jumps { margin-top: 10px; }
.mini .kin-jumps { flex: none; margin-left: auto; }
.mini .kin-jumps + .link-btn { margin-left: 0; }
.mini .kin-jumps[hidden] + .link-btn { margin-left: auto; }
.p-body .kin-jumps { margin: 10px 0; }
@media (max-width: 820px) {
  .mini { gap: 6px; max-width: calc(100% - 20px); flex-wrap: wrap; justify-content: flex-end; background: none; }
  .mini .kin-jumps + .link-btn span { max-width: 16ch; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .kin-jumps .link-btn { min-height: 44px; }
}

@media (821px <= width <= 1080px) {
  :root[data-panel="open"] #miniGen { display: none; }
}

@media (max-width: 420px) {
  .mini .kin-jumps:not([hidden]) + #homeMini { justify-content: center; min-width: 44px; min-height: 44px; padding: 0; }
  .mini .kin-jumps:not([hidden]) + #homeMini span { display: none; }
}

.descendant-list, .descendant-family ul { padding: 0; list-style: none; }
.descendant-list { display: grid; gap: 8px; margin-top: 10px; }
.descendant-family { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.descendant-family p { font-size: .82rem; color: var(--ink-2); }
.descendant-family ul { margin-top: 4px; padding-left: 12px; }
.descendant-family button { min-height: 36px; padding: 4px 0; text-align: left; }
.descendant-family button:hover, .descendant-family button:focus-visible { text-decoration: underline; }
.descendant-child { font-family: var(--font-name); font-weight: var(--name-weight); font-size: 1.12rem; }
@media (max-width: 420px) {
  .mini .kin-jumps { gap: 4px; }
  .mini .kin-jumps .link-btn { padding-inline: 7px; }
}

/* Phone generation navigation leaves the chart itself available for reading. */
.rail-picker { display: none; }
@media (max-width: 820px) {
  :root { --rail-h: 50px; }
  .rail { padding: 0 8px; }
  .rail > .rail-cap, .rail > .rail-list { display: none; }
  .rail-picker {
    display: grid;
    width: 100%;
    grid-template-columns: 44px minmax(0, 1fr) 44px auto;
    align-items: center;
    gap: 2px;
  }
  .rail-picker .icon-btn { color: var(--ink); border-radius: 10px; }
  .rail-picker .icon-btn:disabled { opacity: .37; cursor: default; }
  #genSelect, #legendToggle {
    min-width: 0;
    min-height: 44px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 9px;
  }
  #genSelect { font: 500 16px var(--font-ui); padding: 0 5px 0 8px; }
  #legendToggle { padding: 0 9px; font-size: .82rem; font-weight: 600; }
  #legendToggle:is([aria-expanded="true"], .is-filtered) { border-color: var(--accent); background: var(--bg-2); }
  .stage[data-mode="scroll"] .legend {
    display: none;
    top: calc(var(--rail-h) + 5px);
    bottom: auto;
    overflow: visible;
    flex-wrap: wrap;
    gap: 4px;
    background: var(--surface);
    box-shadow: var(--shadow-pop);
  }
  .stage[data-mode="scroll"][data-legend-open] .legend { display: flex; }
  .stage[data-mode="scroll"] .mini { bottom: 10px; }
}

.stage[data-mode="guide"] .ancestor-controls { display: flex; flex-wrap: wrap; gap: 0 8px; }
.ancestor-history { margin-top: 44px; padding-top: 20px; border-top: 1px solid var(--line-2); }
.history-heading { display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between; gap: 12px; }
.history-heading h3 { font: var(--display-weight) clamp(1.75rem, 3vw, 2.65rem)/1.08 var(--font-display); }
.history-heading p, .history-empty { color: var(--ink-2); margin-top: 6px; }
.history-records { margin-top: 18px; border-top: 1px solid var(--line-2); }
.history-record { border-bottom: 1px solid var(--line); }
.history-record summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 10px;
  cursor: pointer;
  list-style: none;
}
.history-record summary::-webkit-details-marker { display: none; }
.history-record summary strong { display: block; font: var(--name-weight) 1.23rem/1.15 var(--font-name); }
.history-record summary small { color: var(--ink-2); font-size: .84rem; }
.history-record summary:hover, .history-record[open] summary { background: var(--bg-2); }
.history-record[open] summary svg { transform: rotate(180deg); }
.history-body { background: var(--surface); padding: 12px 16px 20px; }
.history-body .p-story { margin-top: 0; }
.history-body .facts { margin-top: 12px; padding-left: 0; }
.history-body .link-btn { min-height: 44px; }

@media (max-width: 520px) {
  .bar { gap: 7px; padding-inline: 10px 6px; }
  .brand { gap: 5px; }
  .brand-name { font-size: .955rem; }
}

:root { -webkit-tap-highlight-color: color-mix(in srgb, var(--accent) 22%, transparent); }

/* Hover keeps the chart in place while the usual person panel slides in over it. */
.chart .card.previewed .card-bg, .chart .cell.previewed .cell-bg {
  stroke: var(--accent);
  stroke-width: 2px;
}
.panel[data-state="preview"] .p-focus { margin-top: 12px; }
@media (prefers-reduced-motion: reduce) {
  .panel { transition: none !important; }
}

#vp .trace-overlay { pointer-events: none; }
#vp .trace-ink {
  fill: none;
  stroke: color-mix(in srgb, var(--accent) 70%, var(--ink));
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4.8;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 1px 0 var(--surface));
  animation: draw-parent-route 660ms cubic-bezier(.2,.65,.3,1) both;
}
#vp .trace-pair { stroke-width: 3.6; animation-duration: 240ms; }
#vp.tracing .link.trace-direct { opacity: .62; }
#vp .card.trace-parent .card-bg, #vp .card.trace-target .card-bg { stroke: var(--accent); stroke-width: 2.6; fill: var(--raised); }
#vp .card.trace-parent .frame, #vp .card.trace-target .frame { stroke: var(--accent); stroke-width: 2.2; }
#vp .card.trace-parent .nm { fill: var(--ink); }
.card.trace-parent .rel-tag { display: none; }
[data-parent-role="Father"] { --parent-tone: #245e61; --parent-rim: #80b9b0; }
[data-parent-role="Mother"] { --parent-tone: #8a4358; --parent-rim: #dfa5ae; }
#vp .card.trace-parent[data-parent-role] .frame { stroke: var(--parent-rim, var(--accent)); }
.trace-role[hidden] { display: none; }
.trace-role { pointer-events: none; }
.trace-role rect { fill: var(--parent-tone, #5d4533); stroke: var(--parent-rim, #dfbe91); stroke-width: 1; }
.trace-role text { fill: #fff8ec; font-size: 10.5px; font-weight: 700; }
@keyframes draw-parent-route { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.p-ancestry { margin-top: 15px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.p-ancestry h3 { color: var(--ink-2); font-size: .82rem; font-weight: 600; }
.p-ancestry p { margin-top: 3px; font: var(--name-weight) 1.12rem/1.32 var(--font-name); }
.p-ancestry .link-btn { margin-top: 8px; }
@media (max-width: 820px) { .panel[data-state="peek"] .p-ancestry { display: none; } }
@media (prefers-reduced-motion: reduce) { #vp .trace-ink { animation: none; } }

.cursor-trail { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 45; pointer-events: none; }
.crest-flight {
  position: fixed;
  z-index: 12;
  inset: 0 auto auto 0;
  width: 380px;
  height: 380px;
  perspective: 780px;
  pointer-events: none;
  transform-origin: 0 0;
  transform: translate3d(var(--flight-x), var(--flight-y), 0) scale(var(--flight-scale));
  opacity: var(--flight-opacity);
  color: color-mix(in srgb, color-mix(in srgb, #513018, var(--flight-landing-ink, #644b2c) var(--flight-paper)), #f4d49c var(--flight-glint));
}
.crest-flight-core {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateX(var(--flight-pitch)) rotateY(var(--flight-turn));
}
.flight-part {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: translate3d(calc(var(--dx, 0px) * var(--flight-spread)), calc(var(--dy, 0px) * var(--flight-spread)), calc(var(--dz, 0px) * var(--flight-spread)))
    rotateX(calc(var(--rx, 0deg) * var(--flight-spread))) rotateY(calc(var(--ry, 0deg) * var(--flight-spread)));
}
.flight-part svg { position: absolute; inset: 0; overflow: visible; fill: currentColor; }
.flight-part .flight-back { color: #684324; transform: translateZ(-18px); }
.flight-part .flight-edge-a { color: #886039; stroke: #886039; stroke-width: 1.4px; transform: translateZ(-12px); }
.flight-part .flight-edge-b { color: #b1834b; stroke: #b1834b; stroke-width: 1.25px; transform: translateZ(-6px); }
.flight-part .flight-face { stroke: color-mix(in srgb, currentColor 71%, #fff4d2); stroke-width: .8px; transform: translateZ(0); }
.flight-ring { --dy: -5px; --dz: -61px; --rx: -27deg; }
.flight-leaves { --dy: 52px; --dz: 23px; --rx: -37deg; }
.flight-hub { --dz: 72px; --ry: -28deg; }
.flight-centre { --dy: -78px; --dz: 24px; --rx: 43deg; }
.flight-left { --dx: -70px; --dy: -29px; --dz: 37px; --ry: -48deg; }
.flight-right { --dx: 70px; --dy: -15px; --dz: 18px; --ry: 48deg; }
@media (prefers-reduced-motion: reduce) {
  .crest-flight { display: none; }
  .about-art .parts { opacity: 1; }
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  :root { --crane-pointer: url("../art/tsuru-cursor.png") 1 7; cursor: var(--crane-pointer), auto; }
  :is(a, button, .card, .cell, .life, .fold, .part, .switch, .results li) { cursor: var(--crane-pointer), pointer; }
  .stage[data-mode="scroll"] .chart { cursor: var(--crane-pointer), default; }
  :root .story-crane { opacity: 0; }
}

/* The scroll walk stays inside the estate until the room is fully in view. */
.estate-passage {
  position: relative;
  height: min(77svh, 800px);
  isolation: isolate;
  overflow: clip;
  background: #15100d;
  pointer-events: none;
}
.tatami-view {
  position: absolute;
  inset: 0;
  container-type: size;
  overflow: clip;
  background: #1d140d;
}
.tatami-art {
  --room-width: max(100cqw, 177.68cqh);
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--room-width);
  background: #76502d url("../art/aono-tatami-preview.webp") center / 100% 100% no-repeat;
  transform: translate(calc(-50% + var(--room-x, 0px)), calc(-50% + var(--room-y, 0px)))
    scale(var(--room-scale, 1)) scale(var(--room-push, 1));
}
.tatami-room { display: block; width: 100%; height: auto; }
.tatami-scroll, .tatami-roller {
  position: absolute;
  inset: 0;
  background: url("../art/aono-tatami-room-detail.webp") center / 100% 100% no-repeat;
}
.tatami-scroll {
  clip-path: inset(29.3% 41.4% calc(100% - var(--scroll-edge, 63.78%)) 41.4%);
}
.tatami-hanger {
  position: absolute;
  inset: 26.8% 47.2% 70.1%;
  background: linear-gradient(90deg, #997047 0 4%, transparent 4% 96%, #997047 96% 100%);
}
.tatami-roller {
  clip-path: inset(63.53% 40.9% 33.67% 40.9% round 2px);
  transform: translateY(var(--roller-rewind, 0%));
}
.tatami-crest {
  position: absolute;
  left: 50%;
  top: 48.23%;
  width: 8%;
  transform: translate(-50%, -50%);
  color: #513018;
  fill: currentColor;
  opacity: var(--room-crest, 1);
  mix-blend-mode: multiply;
}
.seiza-lines { position: absolute; inset: 0; }
.seiza-guard {
  position: absolute;
  left: var(--line-x);
  top: var(--floor-y);
  width: var(--figure);
  aspect-ratio: 4 / 5;
  transform: translate(-50%, -100%) scaleX(var(--facing, 1));
  filter: brightness(var(--lantern, .85)) saturate(.91);
}
.guard-right { left: calc(100% - var(--line-x)); --facing: -1; }
.guard-far { --line-x: 39%; --floor-y: 70.5%; --figure: 7.6%; --lantern: .76; }
.guard-middle { --line-x: 31.8%; --floor-y: 81.2%; --figure: 10%; --lantern: .84; }
.guard-near { --line-x: 23.1%; --floor-y: 95%; --figure: 13%; --lantern: .92; }
.guard-right.guard-near { --lantern: .86; }
.seiza-guard::before {
  content: "";
  position: absolute;
  bottom: -3%;
  inset-inline: 7% 1%;
  height: 11%;
  background: radial-gradient(ellipse, rgb(24 12 8 / .78), transparent 70%);
  transform: skewX(-23deg);
}
.seiza-pose {
  position: absolute;
  inset: 0;
  width: 138.46%;
  background: url("../art/seiza-kamishimo-frames.webp") left center / 1600% 100% no-repeat;
}
.guard-attendant .seiza-pose { background-image: url("../art/seiza-attendant-frames.webp"); }
.guard-senior .seiza-pose { background-image: url("../art/seiza-senior-frames.webp"); }
.guard-right.guard-attendant .seiza-pose { filter: hue-rotate(-18deg) saturate(.79); }
@media (prefers-reduced-motion: no-preference) {
  .seiza-pose { background-position-x: var(--bow-frame, 0%); }
}
@media (max-width: 820px) {
  .guard-far { --line-x: 45.1%; --floor-y: 70.5%; --figure: 5.9%; }
  .guard-middle { --line-x: 43.2%; --floor-y: 82%; --figure: 7.2%; }
  .guard-near { --line-x: 41.4%; --floor-y: 96%; --figure: 8.3%; }
}
@media (prefers-reduced-motion: no-preference) {
  .cover-hero { min-height: calc(262svh + clamp(240px, 43svh, 450px)); }
  .crest-runway { display: block; height: clamp(240px, 43svh, 450px); }
  .estate-sticky { position: sticky; top: 0; height: 100svh; }
  .cover-frame { z-index: 1; height: 100%; min-height: 0; background: transparent; mask-image: none; }
  .cover-frame::before, .cover-intro { opacity: var(--cover-chrome, 1); }
  .cover-scene { opacity: var(--facade-opacity, 1); }
  .estate-passage { position: absolute; inset: 0; height: auto; }
  .tatami-view { opacity: var(--room-visibility, 0); }
  .cover-estate {
    --door-left: calc(1121 / 1672 * 100%);
    --door-right: calc(1208 / 1672 * 100%);
    --door-top: calc(386 / 941 * 100%);
    --door-bottom: calc(457 / 941 * 100%);
  }
  .cover-estate[data-doorway] .estate-facade {
    clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0,
      var(--door-left) var(--door-top), var(--door-right) var(--door-top),
      var(--door-right) var(--door-bottom), var(--door-left) var(--door-bottom),
      var(--door-left) var(--door-top), 0 0);
  }
  .estate-shoji {
    position: absolute;
    inset: var(--door-top) 0 auto var(--door-left);
    width: calc(var(--door-right) - var(--door-left));
    height: calc(var(--door-bottom) - var(--door-top));
    display: grid;
    grid-template-columns: 1fr 1fr;
    visibility: hidden;
  }
  .cover-estate[data-doorway] .estate-shoji { visibility: visible; }
  .estate-shoji span {
    background: #9b5831 url("../art/aono-shoji-detail.webp") left / 200% 100% no-repeat;
    transform: translateX(calc(-100% * var(--door-opening, 0)));
  }
  .estate-shoji span + span { background-position: right; transform: translateX(calc(100% * var(--door-opening, 0))); }
  .cover-intro:focus-within { opacity: 1; }
  .estate-sticky[data-inside] .cover-intro { visibility: hidden; }
  .estate-passage::before {
    content: "";
    position: absolute;
    z-index: 1;
    inset: 84% 0 0;
    background: linear-gradient(transparent, var(--story-seam, var(--cover-ink)));
    opacity: var(--room-seam, 0);
    pointer-events: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .tatami-art { transform: translate(-50%, -50%); }
  .tatami-scroll { --scroll-edge: 63.78%; }
  .tatami-roller { transform: none; }
  .tatami-crest { opacity: 1; }
}

/* Cool light in the water and on the paper, with the timber and lanterns left warm. */
.estate-moonlight {
  position: absolute;
  inset: 60% -3% -4% 51%;
  background:
    radial-gradient(ellipse at 58% 79%, rgb(67 138 240 / .26), transparent 54%),
    radial-gradient(ellipse at 90% 86%, rgb(132 202 255 / .23), transparent 38%);
  mix-blend-mode: screen;
  pointer-events: none;
}
.estate-passage::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: radial-gradient(ellipse at 51% 83%, rgb(130 174 245 / .21), transparent 55%);
  mix-blend-mode: screen;
  opacity: calc(.4 + var(--room-visibility, 1) * .28);
}
.tatami-view::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 55%, transparent 49%, rgb(17 14 15 / .39) 100%);
}
.tatami-moonlight {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 49%, rgb(255 203 119 / .21), transparent 24%),
    radial-gradient(ellipse at 16% 59%, rgb(77 133 224 / .24), transparent 22%),
    radial-gradient(ellipse at 85% 62%, rgb(97 154 238 / .26), transparent 19%),
    radial-gradient(ellipse at 50% 96%, rgb(128 183 255 / .32), transparent 44%);
  mix-blend-mode: screen;
  pointer-events: none;
}

/* Engraved brass edges on the archive's nameplates. */
.chart[data-view="tree"] .card .card-bg {
  stroke: color-mix(in srgb, var(--accent) 56%, var(--line-2));
  stroke-width: 1.25;
  filter: drop-shadow(0 1px 0 var(--raised)) drop-shadow(0 3px 2px rgb(35 23 11 / .22));
}
.chart[data-view="tree"] .plate-inlay {
  fill: none;
  stroke: color-mix(in srgb, var(--accent) 66%, var(--line-2));
  stroke-width: .7;
  opacity: .64;
  pointer-events: none;
}
.chart[data-view="tree"] .card .frame { stroke-width: 1.7; }
.chart[data-view="tree"] .card .frame-in { stroke: var(--accent); opacity: .66; }
.chart[data-view="tree"] .card .plate-tether { stroke: var(--accent); }
.chart[data-view="tree"] .card .nm { font-weight: 650; }
.chart[data-view="tree"] .card:is(:focus-visible, .selected, .previewed) .card-bg { stroke: var(--accent); stroke-width: 2; }
.chart[data-view="tree"] .card:focus-visible .card-bg { stroke: var(--focus); }
.tree-dimensions {
  --view-ink: var(--ink);
  --view-line: var(--line-2);
  --view-accent: var(--accent);
  display: inline-flex;
  align-self: start;
  flex: 0 0 auto;
  align-items: stretch;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--view-line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--view-accent) 8%, transparent);
  white-space: nowrap;
}
.tree-dimensions > * {
  display: grid;
  place-items: center;
  min-height: 34px;
  padding: 4px 8px;
  color: var(--view-ink);
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  text-decoration: none;
  font: 600 .74rem/1 "Hanken Grotesk", sans-serif;
}
.tree-dimensions [aria-current="true"] {
  background: color-mix(in srgb, var(--view-accent) 18%, transparent);
  border-color: var(--view-line);
}
.tree-dimensions > :is(a, button):hover { background: color-mix(in srgb, var(--view-accent) 24%, transparent); }
.realm-dimensions {
  --view-ink: var(--realm-ink);
  --view-line: var(--realm-line);
  --view-accent: var(--realm-gold);
  margin-top: 10px;
}
@media (max-width: 600px) {
  .brand:has(.archive-dimensions:not([hidden])) .brand-name {
    position: absolute;
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
  }
  .tree-dimensions > * { padding-inline: 6px; min-height: 37px; }
}

.realms {
  --realm-ink: #f7e9d3;
  --realm-muted: #c3b5a2;
  --realm-line: #d6b17a50;
  --realm-gold: #f1ca92;
  position: relative;
  background: #141d2a;
  color: var(--realm-ink);
  scroll-margin-top: 0;
}
.realms-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(345px, 1fr);
  max-width: 1780px;
  margin-inline: auto;
  min-height: min(735px, 100svh);
}
@media (prefers-reduced-motion: no-preference) {
  .realms[data-journey="ready"] { height: calc(146svh + var(--realm-steps, 10) * 44svh); }
  .realms[data-journey="ready"] .realms-layout { position: sticky; top: 0; height: 100svh; min-height: 0; }
  .realms[data-journey="ready"] .realms-scene { min-height: 0; }
}
.realms-scene {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 500px;
  background:
    radial-gradient(ellipse at 50% 46%, #344255 0, #202c40 36%, #141d2a 70%, #0d141e 100%);
}
.realms-scene::after {
  position: absolute;
  z-index: -1;
  inset: 9% 14%;
  content: "";
  border: 1px solid #f4c28719;
  border-radius: 50%;
}
.realms-poster, .realms-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.realms-poster { object-fit: contain; }
.realms-canvas { display: block; cursor: grab; touch-action: pan-y pinch-zoom; }
.realms-canvas:active { cursor: grabbing; }
.realms-canvas:focus-visible { outline: 2px solid var(--realm-gold); outline-offset: -3px; }
.realm-layer-turn {
  position: absolute;
  z-index: 2;
  inset-inline-end: 12px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 4px 3px 10px;
  border: 1px solid #b39065;
  border-radius: 7px;
  background: #182535f0;
  color: #fae9ce;
  font-size: .8rem;
}
.realm-layer-turn button {
  min-width: 39px;
  min-height: 39px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #fae9ce;
  font-size: 1.4rem;
}
.realm-layer-turn button:hover { background: #e5b47127; }
.realm-layer-turn .realm-layer-reset {
  min-width: 0;
  padding: 0 8px 0 2px;
  font: inherit;
  font-size: .8rem;
  letter-spacing: .01em;
  cursor: pointer;
}
.realm-layer-turn .realm-layer-reset:hover,
.realm-layer-turn .realm-layer-reset:focus-visible { color: #ffd98a; text-decoration: underline; text-underline-offset: 3px; }
.realm-person-place { display: block; margin-top: 4px; font: 600 .72rem/1.2 var(--font-ui); color: #6d3a37; }
.realm-person-relationship { display: block; margin-top: 3px; font: 600 .72rem/1.35 var(--font-ui); color: #634424; }
.descendant-parents { margin-block: 8px; color: var(--ink-2); font-size: .84rem; }
.realms-mode:empty { display: none; }
.realms-mode { position: absolute; top: 12px; padding: 0 18px; width: 100%; text-align: center; font-size: .82rem; color: var(--realm-muted); pointer-events: none; }
.realms-orbit {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  max-width: calc(100% - 22px);
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--realm-line);
  border-radius: 9px;
  background: #111b27e8;
}
.realms button { cursor: pointer; }
.realms :is(button, a):focus-visible { outline: 2px solid var(--realm-gold); outline-offset: 2px; }
.realms-orbit button, .realms-generations button {
  min-width: 44px;
  min-height: 44px;
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--realm-ink);
}
.realms-orbit button { font-size: .86rem; white-space: nowrap; }
.realms-orbit :is(button:first-child, button:last-child) { font-size: 1.65rem; line-height: 1; color: var(--realm-gold); }
.realms-orbit button:hover:enabled { background: #e5b47127; }
.realms-orbit button:disabled { opacity: .38; cursor: default; }
#orbitReset { min-width: 0; }
#orbitPerson {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  font: 550 1.02rem/1.12 "Newsreader", Georgia, serif;
}
#orbitPosition { display: block; margin-top: 2px; font-size: .6875rem; color: var(--realm-gold); }
#orbitPosition:empty { display: none; }
.realms-sidebar {
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  overflow: auto;
  padding: clamp(20px, 3.2vw, 47px);
  border-inline-start: 1px solid var(--realm-line);
  background: linear-gradient(145deg, #202838, #141e2b 68%);
  color: var(--realm-ink);
}
.realms-heading { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.realms-heading h2, .realms-reading h3 { font-family: "Newsreader", Georgia, serif; font-weight: 500; text-wrap: balance; }
.realms-heading h2 { margin: 0; font-size: clamp(2rem, 3.6vw, 3.25rem); line-height: .96; }
.realms-instruction { color: var(--realm-muted); margin-top: 12px; font-size: .9rem; line-height: 1.5; }
.realms-generations {
  margin: 19px 0 23px;
  display: grid;
  grid-template-columns: repeat(6, minmax(44px, 1fr));
  gap: 4px;
}
.realms-generations button { border-color: var(--realm-line); font-variant-numeric: tabular-nums; }
.realms-generations button:hover { background: #e5b47127; }
.realms-generations button[aria-pressed="true"] { color: #20212a; background: var(--realm-gold); border-color: var(--realm-gold); }
.realms-reading { min-height: 140px; border-top: 1px solid var(--realm-line); padding: 18px 0 12px; }
.realms-date { font-size: .83rem; color: var(--realm-gold); }
.realms-reading h3 { margin: 7px 0; font-size: 1.67rem; line-height: 1.05; }
#realmStory { font-size: .92rem; line-height: 1.57; color: var(--realm-muted); }
.realms-note { margin-top: 16px; color: var(--realm-muted); font-size: .78rem; line-height: 1.42; }
.realms-note p { margin-top: 6px; }
.realms-note a { color: var(--realm-gold); text-underline-offset: 2px; }
@media (max-width: 760px) {
  .realms-layout { grid-template-columns: minmax(0, 1fr); }
  .realms-scene { min-height: clamp(275px, 49dvh, 455px); }
  .realms-sidebar { padding: 18px; border-inline-start: 0; border-top: 1px solid var(--realm-line); }
  .realms-heading h2 { font-size: 1.65rem; }
  .realms-sidebar { position: relative; }
  .realms-heading { align-items: center; }
  .realms-heading .realm-light { margin: 0; min-height: 36px; }
  .realms-instruction { margin-top: 5px; font-size: .8rem; }
  .realms-generations { margin-block: 9px; }
  .realms-reading { min-height: 0; padding: 9px 0 7px; }
  .realms-reading h3 { font-size: 1.32rem; margin-block: 4px; }
  .realms-note { margin-top: 8px; }
  .realms-rotation { top: 8px; left: 8px; }
  .realms-orbit { bottom: 8px; }
  .realms-sidebar .realm-people { flex-shrink: 0; max-height: 92px; margin-bottom: 8px; }
  @media (prefers-reduced-motion: no-preference) {
    .realms[data-journey="ready"] .realms-layout { grid-template-rows: minmax(0, 1fr) minmax(0, 46svh); }
  }
}
@media (max-width: 345px) {
  .realms-generations { grid-template-columns: repeat(5, minmax(44px, 1fr)); }
}
.realm-people {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(122px, 1fr));
  gap: 5px;
  max-height: 147px;
  margin: 0 0 15px;
  padding: 2px 4px 2px 0;
  overflow: auto;
  list-style: none;
  scrollbar-color: #9c805b #202838;
}
.realm-people button {
  width: 100%;
  min-height: 43px;
  padding: 7px;
  border: 1px solid var(--realm-line);
  border-radius: 4px;
  background: #202a37;
  color: var(--realm-ink);
  font: 500 1rem/1.1 "Newsreader", Georgia, serif;
}
.realm-people button:hover { border-color: var(--realm-gold); }
.realm-people button small { display: block; margin-top: 3px; color: var(--realm-muted); font: 400 .7rem/1.1 "Hanken Grotesk", sans-serif; }
.realms-rotation {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--realm-line);
  border-radius: 7px;
  background: #111b27e8;
}
.realms-rotation button {
  min-height: 38px;
  padding: 5px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--realm-ink);
  font-size: .82rem;
}
.realms-rotation button[aria-pressed="true"] { background: #ddac703a; color: var(--realm-gold); }
.realms-island-navigation {
  position: absolute;
  z-index: 1;
  top: 14px;
  inset-inline-end: 14px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding-inline: 3px;
  border: 1px solid var(--realm-line);
  border-radius: 7px;
  background: #111b27e8;
  color: var(--realm-ink);
  font-size: .86rem;
}
.realms-island-navigation button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--realm-gold);
  font-size: 1.65rem;
  line-height: 1;
}
.realms-island-navigation button:hover:enabled { background: #e5b47127; }
.realms-island-navigation button:disabled { opacity: .38; cursor: default; }
.realms-island-navigation span { min-inline-size: 7rem; text-align: center; }
@media (max-width: 960px) {
  .realms-island-navigation { top: 64px; inset-inline-end: 8px; }
}
.aono-name {
  color: #342a1f;
  display: grid;
  gap: clamp(16px, 4vw, 60px);
  grid-template-columns: 1fr 1fr;
  margin: 0 auto clamp(36px, 6vw, 70px);
  max-width: 1070px;
  width: calc(100% - clamp(40px, 12vw, 188px));
  padding-top: 24px;
  border-top: 1px solid #bda482;
}
.aono-name h3, .aono-name h4 { margin: 0 0 12px; font-family: "Newsreader", Georgia, serif; font-weight: 500; }
.aono-name h3 { font-size: clamp(1.9rem, 3.5vw, 2.8rem); }
.aono-name h4 { font-size: 1.52rem; }
.aono-name p { margin: 0 0 10px; font-size: .91rem; line-height: 1.57; text-wrap: pretty; }
.aono-name dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 12px; }
.aono-name dl div { padding: 7px 10px 9px; border: 1px solid #c6ad8d; border-radius: 5px; }
.aono-name dt { display: flex; align-items: baseline; gap: 8px; color: #465f56; }
.aono-name dt span { font: 400 2rem/1.12 var(--jp-serif); }
.aono-name dt i { color: #765633; font: italic 1.13rem/1 "Newsreader", Georgia, serif; }
.aono-name dd { margin: 4px 0 0; font-size: .78rem; }
.aono-name a { color: inherit; text-underline-offset: 2px; }
@media (max-width: 650px) { .aono-name { grid-template-columns: 1fr; } }

/* One lighting choice across the story, archive and 3D exhibit. */
.light-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 5px 11px;
  border-radius: 7px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  white-space: nowrap;
  font-size: .83rem;
  font-weight: 600;
}
.light-symbol { font-size: 1.15rem; line-height: 1; }
.cover-light, .realm-light {
  color: #f9e8cc;
  border-color: #e8ba7e75;
  background: #111b29d9;
}
.cover-light {
  position: absolute;
  z-index: 3;
  top: max(17px, env(safe-area-inset-top));
  right: clamp(14px, 3vw, 46px);
  backdrop-filter: blur(8px);
}
.language-menu {
  min-height: 40px;
  padding: 4px 6px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: 600 .76rem/1 var(--font-ui);
}
.cover-language {
  position: absolute;
  z-index: 3;
  top: max(17px, env(safe-area-inset-top));
  right: calc(clamp(14px, 3vw, 46px) + 86px);
  color: #f9e8cc;
  border-color: #e8ba7e75;
  background: #111b29d9;
}
.realm-view-controls { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.realm-view-controls .realm-dimensions { margin-top: 0; }
.realm-language { background: transparent; border-color: var(--realm-line); color: var(--realm-ink); }
.realm-language option { background: var(--surface); color: var(--ink); }
.bar-language { flex: 0 0 auto; min-width: 49px; }
@media (max-width: 380px) {
  .bar-language { width: 61px; }
}
@media (max-width: 370px) {
  .bar .bar-light { display: none; }
}
@media (max-width: 600px) {
  .archive-dimensions > * { min-width: 36px; padding-inline: 4px; font-size: 0; }
  .archive-dimensions > *::after { font-size: .75rem; }
  .archive-dimensions a::after { content: "3D"; }
  .archive-dimensions [aria-current="true"]::after { content: "2D"; }
  .realms-sidebar:has(.realm-next-branch:not([hidden])) .realms-reading { order: 1; }
  .realms-sidebar:has(.realm-next-branch:not([hidden])) .realms-note { order: 2; }
}
:root[lang="ja"] :is(.cover-name, .about-title, .realms-heading h2, .realms-reading h3) { font-family: var(--jp-serif); }
:root[lang="ja"] .cover-name { line-height: 1.12; }
.realm-light { margin-top: 8px; align-self: start; }
:root[data-theme="night"] .cover {
  --cover-paper: #192735;
  --seam-paper: #25343e;
  --story-mid: #253441;
  --story-near: #1e2b39;
  --flight-landing-ink: #ebc898;
}
:root[data-theme="night"] :is(.cover-about, .crest-history, .story-archive-links, .aono-name) {
  --ink: #f6e6cf;
  --ink-2: #d4c2aa;
  --line-2: #8e7862;
  --crest-ink: #ebc898;
  --crest-lit: #ffe0a9;
  color: var(--ink);
}
:root[data-theme="night"] .aono-name :is(dt, dt i) { color: #eac58d; }
:root[data-theme="night"] .aono-name, :root[data-theme="night"] .aono-name dl div { border-color: #9a7d5a75; }
:root[data-castle-lighting="day"] .estate-shoji span { background-image: url("../art/aono-shoji-day.webp"); }
:root:not([data-theme="night"]) .tatami-art { filter: brightness(1.18) saturate(.80); }
:root:not([data-theme="night"]) .tatami-moonlight { opacity: .47; }
:root:not([data-theme="night"]) .estate-light { display: none; }
:root[data-theme="night"] .estate-light {
  inset: 27% 4% 28% 23%;
  background:
    radial-gradient(ellipse at 63% 37%, #ffbc674d, transparent 20%),
    radial-gradient(ellipse at 44% 56%, #ffb05727, transparent 15%),
    radial-gradient(ellipse at 79% 54%, #ffb05730, transparent 14%);
}
:root:not([data-theme="night"]) .realms-scene {
  background: radial-gradient(ellipse at 46% 43%, #708b91, #4c6873 50%, #263945 100%);
}
:root:not([data-theme="night"]) .realms-sidebar {
  --realm-gold: #6c452b;
  --realm-line: #99765265;
  --realm-ink: #28231e;
  --realm-muted: #594e40;
  background: linear-gradient(140deg, #f0e9d8, #e1d5bf);
}
:root:not([data-theme="night"]) .realms-sidebar :is(.realm-people button, .realm-light) { background: #f7eedf; color: #28231e; }
:root:not([data-theme="night"]) .realms-generations button[aria-pressed="true"] { background: #805235; color: #fff2db; }
.fireflies, .butterflies { position: absolute; display: none; inset: 0; pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  :root[data-theme="night"] .fireflies { display: block; }
  :root:not([data-theme="night"]) .butterflies { display: block; }
  .fireflies i {
    position: absolute;
    left: var(--fly-x, 62%);
    top: var(--fly-y, 54%);
    width: clamp(3px, .32vw, 5px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: #ffe3a0;
    box-shadow: 0 0 5px 2px #ffcf79a8, 0 0 13px 3px #ffc88879;
    opacity: 0;
    animation: firefly-hover var(--fly-time, 7s) ease-in-out infinite;
    animation-delay: var(--fly-delay, -2s);
  }
  .fireflies i:nth-child(2) { --fly-x: 48%; --fly-y: 59%; --fly-time: 8.5s; --fly-delay: -4s; }
  .fireflies i:nth-child(3) { --fly-x: 72%; --fly-y: 66%; --fly-time: 6.8s; --fly-delay: -5s; }
  .fireflies i:nth-child(4) { --fly-x: 35%; --fly-y: 67%; --fly-time: 9.1s; --fly-delay: -4s; }
  .fireflies i:nth-child(5) { --fly-x: 84%; --fly-y: 57%; --fly-time: 8s; --fly-delay: -6s; }
  .fireflies i:nth-child(6) { --fly-x: 59%; --fly-y: 76%; --fly-time: 7.4s; --fly-delay: -5s; }
  .fireflies i:nth-child(7) { --fly-x: 81%; --fly-y: 73%; --fly-time: 8.4s; --fly-delay: -1s; }
  .fireflies i:nth-child(8) { --fly-x: 68%; --fly-y: 78%; --fly-time: 7.3s; --fly-delay: -2.3s; }
  .fireflies i:nth-child(9) { --fly-x: 76%; --fly-y: 53%; --fly-time: 8.9s; --fly-delay: -4.1s; }
  .fireflies i:nth-child(10) { --fly-x: 90%; --fly-y: 66%; --fly-time: 7.8s; --fly-delay: -3.1s; }
  .estate-fireflies i { --fly-x: 62%; --fly-y: 70%; }
  .butterflies i {
    position: absolute;
    left: var(--flutter-x, 42%);
    top: var(--flutter-y, 58%);
    width: clamp(7px, .8vw, 13px);
    height: clamp(7px, .8vw, 13px);
    opacity: 0;
    animation: butterfly-flight var(--flutter-time, 13s) ease-in-out infinite;
    animation-delay: var(--flutter-delay, -3s);
  }
  .butterflies i::before, .butterflies i::after {
    content: "";
    position: absolute;
    inset: 0 50% 0 0;
    border-radius: 76% 52% 62% 62%;
    transform-origin: right center;
    background: linear-gradient(30deg, #e3a163, var(--wing, #fff0b9) 71%);
    border: 1px solid #9a604a77;
    animation: butterfly-wing .51s ease-in-out infinite alternate;
  }
  .butterflies i::after { inset: 0 0 0 50%; transform-origin: left center; border-radius: 52% 76% 62% 62%; }
  .butterflies i:nth-child(2) { --flutter-x: 68%; --flutter-y: 70%; --flutter-time: 17s; --flutter-delay: -7s; --wing: #f3baa8; }
  .butterflies i:nth-child(3) { --flutter-x: 28%; --flutter-y: 31%; --flutter-time: 15s; --flutter-delay: -11s; --wing: #f8e6bd; }
  .estate-butterflies i { --flutter-x: 72%; --flutter-y: 64%; }
  .estate-butterflies i:nth-child(2) { --flutter-x: 81%; --flutter-y: 56%; }
  .estate-butterflies i:nth-child(3) { --flutter-x: 57%; --flutter-y: 69%; }
  .cover-frame:not(.scene-visible) :is(.fireflies, .butterflies) i,
  .cover-frame:not(.scene-visible) .butterflies i::before,
  .cover-frame:not(.scene-visible) .butterflies i::after,
  :root:not([data-realm-active]) :is(.realm-fireflies, .realm-butterflies) i,
  :root:not([data-realm-active]) .realm-butterflies i::before,
  :root:not([data-realm-active]) .realm-butterflies i::after { animation-play-state: paused; }
}
@keyframes firefly-hover {
  0%, 100% { opacity: 0; transform: translate3d(0, 9px, 0); }
  25% { opacity: .73; transform: translate3d(5px, 2px, 0); }
  52% { opacity: .12; transform: translate3d(12px, -9px, 0); }
  78% { opacity: .81; transform: translate3d(16px, -4px, 0); }
}
@keyframes butterfly-flight {
  0%, 100% { opacity: 0; transform: translate3d(-12px, 16px, 0) rotate(-22deg); }
  18% { opacity: .78; transform: translate3d(2px, -1px, 0) rotate(-12deg); }
  43% { opacity: .88; transform: translate3d(22px, -17px, 0) rotate(12deg); }
  67% { opacity: .64; transform: translate3d(41px, -9px, 0) rotate(29deg); }
  86% { opacity: 0; transform: translate3d(58px, -29px, 0) rotate(-17deg); }
}
@keyframes butterfly-wing {
  from { transform: perspective(25px) rotateY(63deg) scaleY(.86); }
  to { transform: perspective(25px) rotateY(7deg) scaleY(1); }
}
@media (max-width: 820px) {
  .bar-light { min-width: 39px; min-height: 40px; padding-inline: 6px; }
  .bar-light .light-name { display: none; }
  .bar.searching .bar-light { display: none; }
}
:root[data-castle-lighting="day"] .cover-frame { color: #202d35; }
:root[data-castle-lighting="day"] .cover-fact { color: #233642; }
:root[data-castle-lighting="day"] .cover-frame::before {
  background: linear-gradient(90deg, #c8d9e5bf, #c1d1db58 29%, transparent 63%);
}
@media (max-width: 820px) {
  :root[data-castle-lighting="day"] .cover-frame::before {
    background: linear-gradient(180deg, #c5d8e6 3%, #c6d5e0ba 35%, transparent 65%);
  }
}
.realms-scene .realms-canvas { bottom: 65px; height: calc(100% - 65px); }
.realms-scene .realms-rotation { z-index: 1; }
.realms-sidebar > * { flex-shrink: 0; }
:root[data-realm-preview] .panel[data-state="preview"] { visibility: visible; pointer-events: auto; top: 0; z-index: 21; }
@media (max-width: 820px) {
  :root[data-realm-preview] .panel[data-state="preview"] { top: auto; bottom: 0; }
}

/* Warm washi, a scored corner fold, and inset patterns. */
:root[data-theme] .realms-sidebar .realm-people button {
  --plaque-print: #467c7566;
  position: relative;
  padding-inline: 12px;
  background: linear-gradient(132deg, #fff8e8b3 32%, #f0d9b280 74%, #ddbe8d85), url("../art/realms-washi.webp") center / cover;
  border-color: #ac885b;
  border-radius: 3px 2px 5px 5px;
  clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 11px, 100% 100%, 0 100%);
  box-shadow: inset 0 0 0 2px #fff8e688, inset 0 -4px 6px #ad784122;
  color: #32231a;
}
.realm-people button::after {
  content: "";
  position: absolute;
  inset: 0 0 auto auto;
  width: 11px;
  height: 11px;
  clip-path: polygon(0 0, 100% 100%, 0 100%);
  background: linear-gradient(140deg, #fff7e3, #c69457);
  border-bottom: 1px solid #a77b50;
}
.realm-people button::before {
  content: "";
  position: absolute;
  inset: auto 0 0 auto;
  width: 24px;
  height: 13px;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  background: repeating-radial-gradient(ellipse at 50% 110%, transparent 0 2px, var(--plaque-print) 2.5px 3px, transparent 3.5px 4px) 0 0 / 12px 8px;
}
:root[data-theme] .realms-sidebar .realm-people li:nth-child(3n + 2) button { --plaque-print: #9c693c85; }
:root[data-theme] .realms-sidebar .realm-people li:nth-child(3n) button { --plaque-print: #57688780; }
:root[data-theme] .realms-sidebar .realm-people button:is(:hover, :focus-visible) {
  border-color: #845326;
  box-shadow: inset 0 0 0 2px #845326aa;
}
.realms-sidebar .realm-people button small { color: #6a5038; }
.realm-plaque-kanji {
  display: block;
  margin-block: 3px 2px;
  font: 600 .83rem/1.25 var(--jp-serif);
}
:root[lang="ja"] .realm-plaque-kanji,
:root[lang="ja"] .p-kanji:not(:has(.p-reading)) { display: none; }
.realms-lineage {
  margin-bottom: 10px;
  padding: 9px 10px 8px;
  border: 1px solid var(--realm-line);
  border-inline-start: 3px solid var(--realm-gold);
  border-radius: 3px 8px 8px 3px;
  background: color-mix(in srgb, var(--realm-gold) 9%, transparent);
}
.realm-lineage-heading, .realm-lineage-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.realm-lineage-heading h3 {
  margin: 0;
  font: 550 1.22rem/1.06 "Newsreader", Georgia, serif;
}
#realmLineageParents { margin: 2px 0 3px; font-size: .82rem; color: var(--realm-muted); }
#realmLineageParents span, .p-ancestry p span { display: block; }
.realm-branch-label { margin-bottom: 6px; color: var(--realm-muted); font-size: .83rem; }
.realm-next-branch {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 0;
  color: var(--realm-muted);
  font-size: .8rem;
}
.realm-next-branch > :first-child { font: 650 1.28rem/1 var(--font-display); color: var(--realm-gold); }
#realmLineageParents strong {
  display: inline-block;
  min-width: 3.9em;
  margin-inline-end: 3px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--parent-tone, #5d4533);
  color: #fff8ec;
  text-align: center;
}
.realms-lineage button {
  min-height: 34px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--realm-line);
  background: transparent;
  color: var(--realm-ink);
  font-size: .78rem;
}
.realms-lineage button:hover:enabled { background: color-mix(in srgb, var(--realm-gold) 18%, transparent); }
.realms-lineage button:disabled { opacity: .46; cursor: default; }
.realms-generations button[data-lineage] { box-shadow: inset 0 -3px var(--realm-gold); }
.realms-generations button[data-lineage][aria-pressed="true"] { box-shadow: inset 0 -3px #fff6ce; }
:root[data-theme] .realms-sidebar .realm-people button[data-lineage="Ancestor"] {
  border-color: #98502d;
  box-shadow: inset 0 0 0 2px #bc8750bf;
}
:root[data-theme] .realms-sidebar .realm-people button[data-lineage="Selected person"] {
  border-color: #71361f;
  box-shadow: inset 0 0 0 2px #98502deb;
}
:root[data-theme] .realms-sidebar .realm-people .realm-main-line {
  border: 3px double #b0894e;
  clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 0 calc(100% - 6px), 0 6px);
  box-shadow: inset 0 0 0 2px #283b4e;
}
:root[data-theme] .realms-sidebar .realm-people .realm-main-line:is(:hover, :focus-visible, [data-lineage]) {
  box-shadow: inset 0 0 0 2px #283b4e, inset 0 0 0 4px #b0894e;
}
.realm-main-line::after { display: none; }
.realm-main-line-label {
  display: block;
  margin-top: 4px;
  color: #36485d;
  font: 700 .69rem/1.2 var(--font-ui);
}
.chart[data-view="tree"] .plate-motif {
  fill: none;
  stroke: color-mix(in srgb, var(--accent) 73%, var(--line-2));
  stroke-width: .65;
  opacity: .64;
}
.chart[data-view="tree"] .plate-fold {
  fill: color-mix(in srgb, var(--accent) 50%, var(--surface));
  stroke: color-mix(in srgb, var(--accent) 78%, var(--line-2));
  stroke-width: .65;
  pointer-events: none;
}

.family-atlas {
  width: min(100%, 1320px);
  margin-inline: auto;
  padding: clamp(54px, 9vw, 118px) clamp(18px, 5vw, 76px);
  scroll-margin-top: 74px;
}
.family-atlas-header { max-width: 660px; margin-bottom: 30px; }
.family-atlas-header h2 {
  font: var(--display-weight) clamp(2.55rem, 6vw, 4.5rem)/1.02 var(--font-display);
  letter-spacing: -.03em;
  text-wrap: balance;
}
.family-atlas-header p, .family-research header p {
  max-width: 60ch;
  margin-block: 12px 8px;
  line-height: 1.6;
  color: var(--ink-2);
  text-wrap: pretty;
}
.family-atlas a { color: inherit; text-underline-offset: .24em; }
.family-map-tabs, .family-map-places {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.family-map-tabs { margin-bottom: 12px; }
.family-map-tabs button, .family-map-places button {
  min-height: 44px;
  padding: 7px 14px;
  border-radius: 5px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font: 500 .85rem/1.2 var(--font-ui);
  cursor: pointer;
}
.family-map-tabs button[aria-pressed="true"], .family-map-places button[aria-pressed="true"] {
  color: var(--surface);
  background: var(--ink);
  border-color: var(--ink);
}
.family-map-tabs button:hover, .family-map-places button:hover { border-color: var(--accent); }
.family-map-layout { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); gap: clamp(16px, 3vw, 34px); align-items: start; }
.family-map-graphic {
  position: relative;
  isolation: isolate;
  aspect-ratio: 5 / 3;
  overflow: hidden;
  border-radius: 9px;
  border: 1px solid #6b766a;
  background: radial-gradient(ellipse at 76% 30%, #22414e, #172c3b 72%);
}
.family-map-graphic::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, #b0c5b520 1px, transparent 1px) 0 0 / 12.5% 100%,
    linear-gradient(to bottom, #b0c5b520 1px, transparent 1px) 0 0 / 100% 16.666%;
}
.family-map-base { position: absolute; inset: 0; width: 100%; height: 100%; }
.family-map-water, .family-map-lake {
  position: absolute;
  z-index: 1;
  left: 61%;
  top: 76%;
  transform: translate(-50%, -50%);
  color: #bacdc9;
  font: italic 500 clamp(.71rem, 1.55vw, 1.05rem)/1.2 var(--font-name);
  letter-spacing: .075em;
  white-space: nowrap;
}
[data-map-region="hokkaido"] .family-map-water { left: 22%; top: 70%; }
.family-map-lake { left: 57%; top: 30%; font-size: clamp(.63rem, 1.2vw, .85rem); }
[data-map-region="pacific"] .family-map-water { left: 52%; top: 65%; }
[data-map-region="honshu"] .family-map-water { left: 82%; top: 78%; }
.family-map-pins { position: absolute; inset: 0; z-index: 2; }
.family-map-pin {
  position: absolute;
  top: var(--map-y);
  left: var(--map-x);
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  padding: 0;
  background: transparent;
  color: transparent;
  font-size: 0;
  cursor: pointer;
}
.family-map-pin::before {
  content: "";
  width: 11px;
  height: 11px;
  border: 2px solid #172c3b;
  border-radius: 50%;
  background: #f1dfae;
  box-shadow: 0 2px 4px #121c23b8;
}
.family-map-pin[aria-pressed="true"] { z-index: 1; }
.family-map-pin[aria-pressed="true"]::before { width: 16px; height: 16px; background: #ffcc75; outline: 1px solid #f5d394; }
.family-map-pin span {
  position: absolute;
  z-index: 1;
  left: calc(50% + 12px);
  padding: 3px 6px;
  border-radius: 3px;
  background: #152735;
  color: #f9e5bb;
  font: 600 clamp(.6875rem, 1.3vw, .87rem)/1.2 var(--font-ui);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}
.family-map-pin:is([aria-pressed="true"], :hover, :focus-visible) span { opacity: 1; }
.family-map-pin[data-map-place="new-york"] span { left: auto; right: calc(50% + 12px); }
.family-map-pin:focus-visible { outline: 2px solid #ffdf9d; outline-offset: -4px; border-radius: 50%; }
.family-map-places { margin-top: 12px; }
.family-map-key, .family-map-credit { margin-top: 9px; color: var(--ink-2); font-size: .8rem; line-height: 1.5; }
.family-map-credit a { text-underline-offset: .18em; }
.family-map-details {
  min-width: 0;
  padding: clamp(17px, 2.8vw, 28px);
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: var(--surface);
}
.family-map-details h3, .family-research h3 {
  font: var(--display-weight) clamp(1.9rem, 3.6vw, 2.6rem)/1.08 var(--font-display);
}
.family-map-heading p { margin-top: 5px; color: var(--ink-2); font-size: .83rem; }
.family-map-note { margin-top: 13px; line-height: 1.55; }
.family-map-records { list-style: none; margin: 15px 0 0; padding: 0; }
.family-map-records li { display: grid; gap: 2px; padding: 7px 0; border-top: 1px solid var(--line); }
.family-map-records a { justify-self: start; font-weight: 600; }
.family-map-records span { color: var(--ink-2); font-size: .82rem; }
.family-map-source-details, .family-map-bibliography-wrap { margin-top: 14px; font-size: .83rem; }
.family-atlas summary { cursor: pointer; font-weight: 600; }
.family-map-sources { margin: 8px 0 0; padding-left: 16px; }
.family-map-sources li + li { margin-top: 4px; }
.family-research {
  scroll-margin-top: 74px;
  margin-top: clamp(45px, 9vw, 100px);
  padding-top: clamp(20px, 4vw, 40px);
  border-top: 1px solid var(--line-2);
}
.family-research header { max-width: 680px; }
.family-research-notes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(16px, 3vw, 32px); margin-top: 25px; }
.family-research-notes article { border-top: 1px solid var(--line-2); padding-top: 14px; }
.family-research-notes h4 { font: var(--display-weight) 1.55rem/1.13 var(--font-display); }
.family-research-notes p { margin: 8px 0; color: var(--ink-2); font-size: .94rem; line-height: 1.58; text-wrap: pretty; }
.family-research-notes a { display: table; margin-top: 8px; font-size: .8rem; }
.family-map-bibliography dt { margin-top: 14px; font-weight: 700; }
.family-map-bibliography dd { margin: 3px 0 0; color: var(--ink-2); }
.family-map-bibliography > div { scroll-margin-top: 80px; }
.family-map-bibliography > div:target { outline: 1px solid var(--accent); outline-offset: 5px; }
@media (max-width: 780px) {
  .family-map-layout, .family-research-notes { grid-template-columns: 1fr; }
  .family-map-key, .family-map-credit { font-size: .8rem; }
}
.family-film {
  width: min(100%, 1320px);
  margin-inline: auto;
  padding: 0 clamp(18px, 5vw, 76px) clamp(46px, 8vw, 100px);
  scroll-margin-top: 84px;
}
.family-film header {
  padding-top: clamp(26px, 5vw, 60px);
  border-top: 1px solid var(--line-2);
  margin-bottom: 20px;
}
.family-film h2 {
  font: var(--display-weight) clamp(2.35rem, 5.2vw, 4.1rem)/1.05 var(--font-display);
  letter-spacing: -.028em;
}
.family-film header p, .family-film-credits p {
  max-width: 680px;
  margin-top: 10px;
  color: var(--ink-2);
  line-height: 1.55;
}
.family-film video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  border: 1px solid #6b766a;
  background: #112331;
}
.family-film-access { margin-top: 10px; color: var(--ink-2); font-size: .84rem; }
.family-film-chapters { margin-block: 30px 24px; }
.family-film-chapters h3 {
  margin: 0 0 12px;
  font: var(--display-weight) clamp(1.25rem, 3vw, 1.55rem)/1.15 var(--font-display);
}
.family-film-chapters ol {
  display: grid;
  grid-template-columns: 1fr;
  column-gap: 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.family-film-chapters li { min-width: 0; }
.family-film-chapters button {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 9px 8px;
  border: 0;
  border-top: 1px solid var(--line-2);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
.family-film-chapters button:hover,
.family-film-chapters button[aria-current="true"] {
  background: color-mix(in srgb, var(--ink) 9%, transparent);
}
.family-film-chapters button:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
.family-film-chapters strong { font-weight: 600; line-height: 1.2; }
.family-film-chapters span, .family-film-chapters time {
  color: var(--ink-2);
  font-size: .79rem;
  font-variant-numeric: tabular-nums;
}
@media (min-width: 820px) {
  .family-film-chapters ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.family-film-credits { margin-top: 14px; font-size: .87rem; }
.family-film-credits summary { cursor: pointer; font-weight: 600; }
.family-film-credits ul { padding-inline-start: 19px; }
.family-film-credits li + li { margin-top: 5px; }
.family-film-credits a { color: inherit; text-underline-offset: .2em; }

/* Phone tap targets. Disclosure rows, stacked source links and record links reach 44px.
   The 3D exhibit and the chart bar are left as they are: both are sized to fit one pinned screen. */
@media (max-width: 820px) {
  .crest-history summary, .family-atlas summary, .family-film-credits summary { padding-block: 13px; }
  .family-research-notes a { display: flex; align-items: center; width: fit-content; min-height: 44px; margin-top: 0; }
  .family-map-records a { position: relative; }
  .family-map-records a::after { position: absolute; content: ""; inset: -11px 0; }
  .cover-light, .cover-language, .family-film-access .language-menu { min-height: 44px; }
  .panel :is(.rel, .link-btn, .src-btn), .descendant-family button { min-height: 44px; }
  .panel .rel { align-content: center; }
}

/* Phone cover: the picture starts about a quarter of the way down the screen. A strip of matching sky
   sits above it and the picture's top edge feathers into that strip, so no hard seam crosses the title. */
@media (max-width: 820px) {
  .cover-estate::before {
    position: absolute; content: ""; z-index: -1; left: 0; right: 0; bottom: 88%; height: 60cqh;
    background: linear-gradient(90deg, #162538, #314057 50%, #2b3d52);
  }
  :root[data-castle-lighting="day"] .cover-estate::before { background: linear-gradient(90deg, #e1f9ff, #dcfcff 50%, #c0d8e6); }
  .estate-facade > img { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 10%); mask-image: linear-gradient(to bottom, transparent, #000 10%); }
}
