:root {
  --ink: #192823;
  --ink-soft: #52655e;
  --ink-faint: #7f8d87;
  --paper: #f7f4eb;
  --paper-deep: #eee8d9;
  --surface: rgba(255, 253, 247, .86);
  --surface-solid: #fffdf7;
  --jade: #2d5a4b;
  --jade-dark: #173c32;
  --jade-light: #dfe9e3;
  --cinnabar: #9c3f30;
  --gold: #aa8956;
  --line: rgba(40, 70, 61, .18);
  --line-strong: rgba(40, 70, 61, .36);
  --shadow-soft: 0 18px 55px rgba(24, 42, 36, .08);
  --header-height: 76px;
  color-scheme: light;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--paper); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -10%, rgba(170, 137, 86, .12), transparent 36rem),
    radial-gradient(circle at 90% 20%, rgba(45, 90, 75, .07), transparent 32rem),
    var(--paper);
}
button, input { font: inherit; }
button { color: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid rgba(156, 63, 48, .3);
  outline-offset: 3px;
}

.site-shell { min-height: 100vh; }
.site-header {
  position: sticky;
  z-index: 50;
  top: 0;
  height: var(--header-height);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 244, 235, .88);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  backdrop-filter: blur(18px) saturate(1.2);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  width: max-content;
  color: inherit;
  text-decoration: none;
}
.brand-seal {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--cinnabar);
  color: var(--cinnabar);
  font-size: 25px;
  font-weight: 700;
  line-height: 1;
  transform: rotate(-2deg);
  box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 3px rgba(156, 63, 48, .22);
}
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-size: 18px; letter-spacing: .18em; }
.brand-copy span { color: var(--ink-soft); font-size: 11px; letter-spacing: .12em; }
.header-context { display: grid; justify-items: center; gap: 2px; }
.context-kicker { color: var(--ink-faint); font-size: 10px; letter-spacing: .2em; }
.header-context strong { font-size: 15px; letter-spacing: .13em; }
.header-actions { display: flex; justify-content: flex-end; gap: 8px; }
.header-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease;
}
.header-action:hover { border-color: var(--line); background: rgba(255, 253, 247, .72); }
.header-action svg, .search-box svg, .detail-close svg, .dialog-close svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.header-action span { font-size: 13px; letter-spacing: .08em; }

.genealogy-app {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 350px;
  min-height: calc(100vh - var(--header-height));
}
.control-rail, .detail-panel {
  position: relative;
  z-index: 20;
  min-height: calc(100vh - var(--header-height));
  background: rgba(250, 248, 241, .82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.control-rail {
  padding: 24px 20px 20px;
  border-right: 1px solid var(--line);
  overflow: visible;
}
.rail-section {
  padding: 0 2px 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.rail-section h2, .legend-section h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .16em;
}
.search-label {
  display: block;
  margin-bottom: 9px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .15em;
}
.search-box {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 253, 247, .76);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.search-box:focus-within {
  border-color: var(--jade);
  background: var(--surface-solid);
  box-shadow: 0 0 0 4px rgba(45, 90, 75, .08);
}
.search-box svg { color: var(--ink-soft); }
.search-box input {
  min-width: 0;
  padding: 0;
  border: 0;
  outline: none;
  color: var(--ink);
  background: transparent;
  font-family: inherit;
  font-size: 14px;
}
.search-box input::placeholder { color: var(--ink-faint); }
.search-box kbd {
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--ink-faint);
  background: var(--paper);
  font-family: ui-monospace, monospace;
  font-size: 9px;
}
.search-results {
  position: absolute;
  z-index: 80;
  width: calc(100% - 40px);
  max-height: 340px;
  margin-top: 8px;
  padding: 6px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 253, 247, .98);
  box-shadow: var(--shadow-soft);
}
.search-result {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.search-result:hover, .search-result[aria-selected="true"] { background: var(--jade-light); }
.search-result strong { font-size: 15px; letter-spacing: .08em; }
.search-result span { color: var(--ink-soft); font-size: 11px; }
.search-empty { padding: 18px 12px; color: var(--ink-faint); font-size: 13px; text-align: center; }
.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-heading > span { color: var(--ink-faint); font-size: 11px; }
.text-action {
  padding: 0;
  border: 0;
  color: var(--cinnabar);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
}
.branch-list { display: grid; gap: 7px; }
.branch-button {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.branch-button:hover { border-color: var(--line); background: rgba(255, 253, 247, .65); }
.branch-button[aria-pressed="true"] { color: var(--jade-dark); background: var(--jade-light); }
.branch-index {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-size: 10px;
}
.branch-button[aria-pressed="true"] .branch-index { border-color: var(--jade); color: var(--paper); background: var(--jade); }
.branch-label { font-size: 14px; font-weight: 700; letter-spacing: .1em; }
.branch-count { color: var(--ink-faint); font-size: 10px; }
.generation-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.generation-button {
  min-height: 35px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-soft);
  background: rgba(255, 253, 247, .55);
  cursor: pointer;
}
.generation-button:hover { border-color: var(--jade); color: var(--jade); }
.generation-button[aria-pressed="true"] { border-color: var(--jade); color: var(--paper); background: var(--jade); }
.legend-section { display: grid; gap: 11px; }
.legend-row { display: grid; grid-template-columns: 40px 1fr; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 12px; }
.legend-line { display: block; height: 0; border-top: 2px solid var(--jade-dark); }
.legend-line.dashed { border-top-style: dashed; border-color: var(--ink-faint); }
.legend-node {
  display: block;
  width: 27px;
  height: 18px;
  margin-left: 6px;
  border: 1px solid var(--jade);
  background: var(--surface-solid);
}
.legend-node.evidence::after {
  content: "";
  display: block;
  width: 5px;
  height: 5px;
  margin: 2px 0 0 17px;
  border-radius: 50%;
  background: var(--cinnabar);
}
.legend-section p { margin: 4px 0 0; color: var(--ink-faint); font-size: 11px; line-height: 1.8; }
.rail-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.rail-summary span {
  display: grid;
  justify-items: center;
  gap: 2px;
  color: var(--ink-faint);
  font-size: 9px;
  letter-spacing: .08em;
}
.rail-summary strong { color: var(--jade-dark); font-size: 18px; font-weight: 700; }

.tree-workspace { min-width: 0; display: grid; grid-template-rows: 58px minmax(620px, calc(100vh - var(--header-height) - 58px)); background: rgba(255, 253, 247, .34); }
.workspace-bar {
  position: relative;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 18px 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 247, .7);
}
.selection-path { display: grid; gap: 1px; min-width: 0; }
.selection-path .eyebrow { color: var(--ink-faint); font-size: 9px; letter-spacing: .18em; }
.selection-path strong { overflow: hidden; font-size: 13px; letter-spacing: .1em; text-overflow: ellipsis; white-space: nowrap; }
.workspace-tools { display: flex; align-items: center; gap: 5px; }
.workspace-tools button, .workspace-tools output {
  display: grid;
  min-width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, .84);
}
.workspace-tools button { cursor: pointer; }
.workspace-tools button:hover { border-color: var(--jade); color: var(--jade); }
.workspace-tools output { min-width: 52px; color: var(--ink-soft); font-family: ui-sans-serif, system-ui, sans-serif; font-size: 10px; }
.workspace-tools .fit-button { min-width: auto; padding: 0 11px; font-size: 11px; letter-spacing: .08em; }
.tree-canvas {
  position: relative;
  min-width: 0;
  min-height: 620px;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background:
    linear-gradient(90deg, transparent 49.8%, rgba(45, 90, 75, .025) 50%, transparent 50.2%),
    linear-gradient(0deg, transparent 49.8%, rgba(45, 90, 75, .025) 50%, transparent 50.2%),
    #f8f5ed;
}
.tree-canvas.is-dragging { cursor: grabbing; }
#treeSvg { display: block; width: 100%; height: 100%; color: var(--ink); user-select: none; }
#canvasPaper { fill: #f8f5ed; }
#canvasGrain { color: var(--jade-dark); pointer-events: none; }
.generation-guide { stroke: rgba(45, 90, 75, .15); stroke-width: 3; stroke-dasharray: 10 22; pointer-events: none; }
.generation-label {
  fill: var(--ink-faint);
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 8px;
  writing-mode: vertical-rl;
  text-anchor: middle;
  pointer-events: none;
}
.edge-group { transition: opacity .22s ease; }
.edge-path {
  fill: none;
  stroke: var(--jade-dark);
  stroke-width: 8;
  stroke-linecap: square;
  stroke-linejoin: miter;
  vector-effect: non-scaling-stroke;
  transition: stroke .2s ease, opacity .2s ease, stroke-width .2s ease;
}
.adoption-path {
  fill: none;
  stroke: var(--ink-faint);
  stroke-width: 7;
  stroke-dasharray: 22 16;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.adoption-label rect { fill: rgba(248, 245, 237, .96); stroke: rgba(82, 101, 94, .4); stroke-width: 3; }
.adoption-label text { fill: var(--ink-soft); font-size: 30px; text-anchor: middle; dominant-baseline: middle; }
.edge-group.is-dim, .adoption-group.is-dim { opacity: .08; }
.edge-group.is-related .edge-path, .adoption-group.is-related .adoption-path { stroke: var(--cinnabar); stroke-width: 11; }
.gene-node { cursor: pointer; transition: opacity .22s ease; outline: none; }
.gene-node .node-card {
  fill: rgba(255, 253, 247, .97);
  stroke: var(--jade-dark);
  stroke-width: 5;
  rx: 13;
  transition: fill .2s ease, stroke .2s ease, stroke-width .2s ease;
}
.gene-node.is-unresolved .node-card { fill: #f2f1eb; stroke: var(--ink-faint); }
.gene-node.is-adoption-node .node-card { fill: #f3f4ef; stroke: var(--ink-faint); stroke-dasharray: 17 12; }
.gene-node .node-name { fill: var(--ink); font-size: 70px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.gene-node .node-name.vertical,
.gene-node .vertical-meta {
  writing-mode: vertical-rl;
  text-orientation: upright;
  glyph-orientation-vertical: 0deg;
}
.gene-node .node-name.vertical { font-size: 82px; }
.gene-node .node-meta { fill: var(--ink-soft); font-size: 30px; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.gene-node .vertical-meta { dominant-baseline: middle; text-anchor: middle; }
.gene-node .node-generation { fill: var(--ink-faint); font-size: 24px; text-anchor: middle; pointer-events: none; }
.evidence-mark { fill: var(--cinnabar); stroke: var(--surface-solid); stroke-width: 4; }
.gene-node:hover .node-card { fill: #fff; stroke: var(--cinnabar); stroke-width: 7; }
.gene-node.is-dim { opacity: .12; }
.gene-node.is-related .node-card { stroke: var(--gold); stroke-width: 8; }
.gene-node.is-selected { filter: url(#selectedGlow); }
.gene-node.is-selected .node-card { fill: #fff9ef; stroke: var(--cinnabar); stroke-width: 11; }
.gene-node.is-selected .node-name { fill: var(--cinnabar); }
.gene-node:focus-visible .node-card { stroke: var(--cinnabar); stroke-width: 10; }
.canvas-hint {
  position: absolute;
  z-index: 8;
  bottom: 18px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(255, 253, 247, .86);
  box-shadow: 0 8px 28px rgba(24, 42, 36, .07);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 10px;
  transform: translateX(-50%);
  transition: opacity .25s ease;
  pointer-events: none;
}
.canvas-hint.is-hidden { opacity: 0; }
.mouse-glyph { width: 13px; height: 18px; border: 1.5px solid currentColor; border-radius: 8px; }
.mouse-glyph::before { content: ""; display: block; width: 1px; height: 4px; margin: 3px auto 0; background: currentColor; }
.canvas-watermark {
  position: absolute;
  right: 24px;
  bottom: 10px;
  color: rgba(156, 63, 48, .06);
  font-size: clamp(110px, 12vw, 190px);
  line-height: 1;
  pointer-events: none;
}

.detail-panel {
  padding: 26px 24px 28px;
  border-left: 1px solid var(--line);
  overflow: auto;
}
.detail-close {
  position: absolute;
  z-index: 3;
  top: 18px;
  right: 18px;
  display: none;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 253, 247, .75);
  cursor: pointer;
}
.detail-empty {
  display: grid;
  min-height: 55vh;
  place-content: center;
  justify-items: center;
  text-align: center;
}
.empty-seal {
  display: grid;
  width: 62px;
  height: 62px;
  margin-bottom: 18px;
  place-items: center;
  border: 2px solid rgba(156, 63, 48, .55);
  color: rgba(156, 63, 48, .75);
  font-size: 30px;
}
.detail-empty h2 { margin: 0 0 8px; font-size: 18px; letter-spacing: .12em; }
.detail-empty p { max-width: 220px; margin: 0; color: var(--ink-faint); font-size: 12px; line-height: 1.8; }
.detail-content { animation: detail-enter .26s ease both; }
@keyframes detail-enter { from { opacity: 0; transform: translateY(8px); } }
.detail-heading { padding: 10px 0 22px; border-bottom: 1px solid var(--line); }
.detail-generation {
  display: inline-block;
  margin-bottom: 9px;
  padding: 4px 8px;
  border: 1px solid rgba(45, 90, 75, .22);
  border-radius: 999px;
  color: var(--jade);
  background: var(--jade-light);
  font-size: 10px;
  letter-spacing: .1em;
}
.detail-heading h2 { margin: 0; color: var(--jade-dark); font-size: 34px; letter-spacing: .12em; }
.detail-heading p { margin: 8px 0 0; color: var(--ink-soft); font-size: 12px; }
.fact-list { margin: 0; padding: 18px 0 4px; }
.fact-list > div {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.fact-list dt { color: var(--ink-faint); font-size: 11px; letter-spacing: .12em; }
.fact-list dd { margin: 0; font-size: 13px; line-height: 1.65; }
.fact-link { padding: 0; border: 0; border-bottom: 1px solid currentColor; color: var(--cinnabar); background: transparent; cursor: pointer; }
.detail-note { margin-top: 18px; padding: 14px 15px; border-left: 3px solid var(--gold); background: rgba(170, 137, 86, .08); }
.detail-note h3, .children-section h3, .evidence-section h3 { margin: 0; font-size: 12px; letter-spacing: .13em; }
.detail-note p { margin: 8px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.8; }
.children-section, .evidence-section { margin-top: 24px; }
.detail-section-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.detail-section-heading span { color: var(--ink-faint); font-size: 10px; }
.relative-list { display: flex; flex-wrap: wrap; gap: 7px; }
.relative-button {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--jade-dark);
  background: rgba(255, 253, 247, .7);
  font-size: 12px;
  cursor: pointer;
}
.relative-button:hover { border-color: var(--cinnabar); color: var(--cinnabar); }
.evidence-list { display: grid; gap: 10px; }
.evidence-thumb {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 253, 247, .72);
  text-align: left;
  cursor: zoom-in;
}
.evidence-thumb:hover { border-color: var(--cinnabar); }
.evidence-thumb img { width: 92px; height: 72px; object-fit: contain; }
.evidence-thumb span { color: var(--ink-soft); font-size: 11px; line-height: 1.65; }
.detail-actions { display: grid; gap: 8px; margin-top: 28px; }
.detail-actions button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--jade);
  border-radius: 9px;
  color: var(--paper);
  background: var(--jade);
  font-size: 12px;
  letter-spacing: .08em;
  cursor: pointer;
}
.detail-actions button:hover { background: var(--jade-dark); }
.detail-actions .secondary-action { color: var(--jade); background: transparent; }
.detail-actions .secondary-action:hover { color: var(--paper); background: var(--jade); }
.detail-actions button:disabled { opacity: .38; cursor: default; }

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  background: var(--paper-deep);
  font-size: 10px;
  letter-spacing: .09em;
}

.panel-scrim {
  position: fixed;
  z-index: 60;
  inset: var(--header-height) 0 0;
  display: none;
  width: 100%;
  border: 0;
  background: rgba(17, 35, 29, .2);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  cursor: pointer;
}
.panel-scrim.is-visible { display: block; }

.evidence-dialog {
  width: min(900px, calc(100vw - 34px));
  max-height: calc(100vh - 34px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(45, 90, 75, .28);
  border-radius: 18px;
  color: var(--ink);
  background: var(--surface-solid);
  box-shadow: 0 30px 100px rgba(16, 31, 26, .25);
}
.evidence-dialog::backdrop { background: rgba(13, 25, 21, .58); backdrop-filter: blur(6px); }
.evidence-dialog figure { margin: 0; padding: 32px; }
.evidence-dialog img { display: block; width: 100%; max-height: calc(100vh - 160px); object-fit: contain; }
.evidence-dialog figcaption { padding-top: 14px; color: var(--ink-soft); font-size: 12px; text-align: center; letter-spacing: .08em; }
.dialog-close {
  position: absolute;
  z-index: 2;
  top: 14px;
  right: 14px;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 253, 247, .92);
  cursor: pointer;
}
noscript { display: block; padding: 20px; color: var(--cinnabar); text-align: center; }

@media (max-width: 1380px) {
  .genealogy-app { grid-template-columns: 270px minmax(0, 1fr); }
  .detail-panel {
    position: fixed;
    z-index: 70;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    width: min(390px, 92vw);
    min-height: 0;
    box-shadow: -24px 0 70px rgba(19, 39, 32, .14);
    transform: translateX(104%);
    transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  }
  .detail-panel.is-open { transform: translateX(0); }
  .detail-close { display: grid; }
}

@media (max-width: 820px) {
  :root { --header-height: 66px; }
  .site-header { grid-template-columns: 1fr auto; padding: 0 14px; }
  .brand-seal { width: 38px; height: 38px; font-size: 22px; }
  .brand-copy strong { font-size: 16px; }
  .brand-copy span { display: none; }
  .header-context { display: none; }
  .header-action { padding: 8px; }
  .header-action span { display: none; }
  .genealogy-app { display: block; }
  .control-rail {
    position: fixed;
    z-index: 75;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: min(330px, 92vw);
    min-height: 0;
    overflow: auto;
    box-shadow: 24px 0 70px rgba(19, 39, 32, .15);
    transform: translateX(-104%);
    transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  }
  .control-rail.is-open { transform: translateX(0); }
  .tree-workspace { grid-template-rows: 54px minmax(570px, calc(100vh - var(--header-height) - 54px)); }
  .workspace-bar { padding: 0 10px 0 14px; }
  .selection-path .eyebrow { display: none; }
  .workspace-tools output { display: none; }
  .workspace-tools .fit-button { padding: 0 8px; }
  .tree-canvas { min-height: 570px; }
  .canvas-hint { bottom: 12px; max-width: calc(100% - 24px); text-align: center; white-space: nowrap; }
  .detail-panel {
    top: auto;
    left: 0;
    width: 100%;
    max-height: 82vh;
    padding: 26px 20px calc(26px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    border-left: 0;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -24px 70px rgba(19, 39, 32, .16);
    transform: translateY(104%);
  }
  .detail-panel.is-open { transform: translateY(0); }
  .detail-empty { display: none; }
  .site-footer { display: none; }
  .evidence-dialog figure { padding: 24px 15px 18px; }
}

@media (max-width: 460px) {
  .site-header { gap: 8px; }
  .header-actions { gap: 1px; }
  .workspace-tools { gap: 3px; }
  .workspace-tools button { min-width: 32px; }
  .workspace-tools .fit-button { font-size: 10px; }
  .canvas-hint { font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
