/* Dankstory — a storyteller's ledger.
   Warm laid paper and iron-gall ink by day, a walnut night ledger in dark mode;
   heraldic tinctures (gules, azure, vert, or, purpure, sable) mark the houses.
   Alegreya for names and headings, Source Sans 3 for the interface.
   Every page of the site uses this one stylesheet. */

@font-face {
  font-family: 'Alegreya';
  font-style: normal;
  font-display: swap;
  font-weight: 400 900;
  src: url(/fonts/alegreya-latin-wght-normal.woff2) format('woff2');
}
@font-face {
  font-family: 'Alegreya';
  font-style: italic;
  font-display: swap;
  font-weight: 400 900;
  src: url(/fonts/alegreya-latin-wght-italic.woff2) format('woff2');
}
@font-face {
  font-family: 'Source Sans 3';
  font-style: normal;
  font-display: swap;
  font-weight: 200 900;
  src: url(/fonts/source-sans-3-latin-wght-normal.woff2) format('woff2');
}

:root {
  color-scheme: light dark;
  --paper: #f5eedf;
  --paper-2: #fbf7ee;
  --paper-3: #ece2cc;
  --ink: #2a2016;
  --ink-2: #5b4b39;
  --rule: #d6c7a8;
  --rule-2: #b9a582;
  --accent: #8e2a22;        /* gules: the seal-wax red */
  --accent-ink: #fff8ec;
  --focus: #1f5f9e;
  --shadow: 0 1px 0 rgba(60, 40, 10, .08), 0 6px 18px -10px rgba(60, 40, 10, .35);
  /* heraldic tinctures for houses */
  --t-gules: #a3302a;
  --t-azure: #2c5a8f;
  --t-vert: #3d7149;
  --t-or: #b88a1c;
  --t-purpure: #74407a;
  --t-sable: #3b3631;
  --t-tenne: #b5621e;
  --t-sanguine: #7d2a3c;
  --serif: 'Alegreya', 'Iowan Old Style', Georgia, serif;
  --sans: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 10px;
}
/* screen only: paper is printed with the light ledger tokens */
@media screen and (prefers-color-scheme: dark) {
  :root {
    --paper: #1a1611;
    --paper-2: #241e17;
    --paper-3: #2e271e;
    --ink: #f0e6d2;
    --ink-2: #c3b498;
    --rule: #3d3428;
    --rule-2: #5a4d3b;
    --accent: #e0786a;
    --accent-ink: #1a1611;
    --focus: #8cc0ff;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 20px -12px rgba(0, 0, 0, .8);
    --t-gules: #e06d62;
    --t-azure: #79a8e0;
    --t-vert: #7dbb88;
    --t-or: #e2bb55;
    --t-purpure: #c191c8;
    --t-sable: #b5aa9b;
    --t-tenne: #e8955a;
    --t-sanguine: #d4788d;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.55 var(--sans);
  min-height: 100vh;
}
h1, h2, h3 { font-family: var(--serif); line-height: 1.15; margin: 0 0 .4em; }
h1 { font-weight: 800; font-size: clamp(1.55rem, 1.1rem + 2vw, 2.4rem); letter-spacing: -.01em; }
h2 { font-weight: 700; font-size: 1.3rem; }
h3 { font-weight: 700; font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 1440px; margin: 0 auto; padding: 0 16px; }

/* masthead */
.masthead { border-bottom: 1px solid var(--rule); background: var(--paper-2); }
.masthead .wrap { display: flex; align-items: baseline; gap: 12px; padding-top: 8px; padding-bottom: 8px; }
.brand { font: 800 1.35rem/1 var(--serif); color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand span { color: var(--accent); }
.masthead .tag { margin: 0; color: var(--ink-2); font-size: .9rem; }

/* buttons */
button, .btn {
  font: 600 .95rem/1.1 var(--sans);
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--rule-2);
  border-radius: 8px;
  padding: 9px 13px;
  min-height: 40px;
  cursor: pointer;
}
button:hover { border-color: var(--ink-2); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--t-gules); border-color: currentColor; background: transparent; }
button.link { background: none; border: 0; padding: 2px 0; min-height: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }
input[type=text], input[type=search], textarea, select {
  font: 400 1rem/1.3 var(--sans);
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--rule-2);
  border-radius: 7px;
  padding: 8px 10px;
  width: 100%;
  min-height: 40px;
}
textarea { resize: vertical; min-height: 64px; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
label > input, label > textarea, label > select { margin-top: 3px; }

/* footer */
.site-foot { border-top: 1px solid var(--rule); margin-top: 32px; padding: 18px 0 28px; color: var(--ink-2); font-size: .9rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------- family tree tool */
.tool-intro { padding: 12px 0 8px; }
.tool-intro .lede { color: var(--ink-2); margin: 0; max-width: 62ch; }
.tree-tool { position: relative; }
.tree-shell { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
.stage {
  position: relative;
  height: min(60vh, 640px);
  min-height: 360px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background-color: var(--paper-2);
  background-image: radial-gradient(circle at 1px 1px, var(--rule) 1px, transparent 0);
  background-size: 22px 22px;
  overflow: hidden;
  touch-action: none;
  box-shadow: var(--shadow);
}
.stage svg { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-select: none; cursor: grab; }
.stage svg:active { cursor: grabbing; }
.stage-tools { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; gap: 6px; pointer-events: none; }
.stage-tools[hidden] { display: none; }
.stage-tools .grp { display: flex; gap: 6px; pointer-events: auto; }
.stage-tools button { min-width: 44px; min-height: 40px; padding: 8px 10px; background: var(--paper-2); box-shadow: var(--shadow); }
.stage-tools .zoom button { font-size: 1.2rem; padding: 4px 10px; }
.stage-tools .zoom button.fit { font-size: .95rem; }

.empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 24px; text-align: center;
}
.empty[hidden] { display: none; }
.empty p { margin: 0; max-width: 30ch; color: var(--ink-2); font-family: var(--serif); font-size: 1.15rem; }
.empty .crest { width: 56px; height: 56px; color: var(--accent); }
.empty button { min-width: 230px; min-height: 48px; font-size: 1.02rem; }

.filebar { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-top: 10px; }
.filebar .name { flex: 1 1 220px; max-width: 360px; }
.storage-note { font-size: .88rem; color: var(--ink-2); margin: 8px 0 0; }
.msg { margin: 10px 0 0; padding: 10px 12px; border-left: 4px solid var(--t-gules); background: var(--paper-3); border-radius: 6px; }
.msg[hidden] { display: none; }

/* export menu and print dialog */
.filebar .export-btn[aria-expanded=true] { background: var(--paper-3); border-color: var(--ink-2); }
.export-menu {
  margin-top: 10px; padding: 12px 14px; display: grid; gap: 10px;
  background: var(--paper-2); border: 1px solid var(--rule-2); border-radius: var(--radius); box-shadow: var(--shadow);
  max-width: 640px;
}
.export-menu[hidden] { display: none; }
.export-menu fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.export-menu legend { float: left; margin-right: 6px; font-size: .8rem; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; }
.export-menu fieldset label { display: inline-flex; align-items: center; gap: 6px; font-size: .95rem; color: var(--ink); min-height: 32px; }
.export-menu input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.export-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.export-actions button { flex: 1 1 150px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
.export-actions small { font-weight: 400; font-size: .8rem; color: var(--ink-2); }
.export-help { margin: 0; font-size: .88rem; color: var(--ink-2); }
.export-note { margin: 0; padding: 8px 12px; border-left: 4px solid var(--t-or); background: var(--paper-3); border-radius: 6px; font-size: .92rem; }
.export-note[hidden] { display: none; }
.print-dialog {
  max-width: min(420px, calc(100vw - 24px)); padding: 18px; color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--rule-2); border-radius: var(--radius); box-shadow: var(--shadow);
}
.print-dialog::backdrop { background: rgba(20, 14, 6, .45); }
.print-dialog .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.print-dialog p { font-size: .92rem; color: var(--ink-2); }
.print-dialog .actions { display: flex; gap: 8px; }
.print-sheet { display: none; }

/* tree drawing */
.tree-lines path, .tree-lines line { fill: none; stroke: var(--ink-2); stroke-width: 2; }
.tree-lines .partners { stroke-dasharray: 2 5; stroke-linecap: round; }
.tree-lines .separated-mark { stroke: var(--ink-2); stroke-width: 2; }
.tree-lines .unknown { stroke-dasharray: 2 4; stroke-linecap: round; }
.tree-lines .adopted { stroke-dasharray: 7 5; }
.tree-lines .fostered { stroke-dasharray: 1 4; stroke-linecap: round; }
.tree-lines .join { fill: var(--ink-2); stroke: none; }
.person { cursor: pointer; outline: none; }
.person .card { fill: var(--paper-2); stroke: var(--rule-2); stroke-width: 1.5; }
.person:hover .card { stroke: var(--ink-2); }
.person.selected .card { stroke: var(--accent); stroke-width: 3; }
.person:focus-visible .card { stroke: var(--focus); stroke-width: 4; }
.person .nm { font: 700 15px var(--serif); fill: var(--ink); }
.person .sub { font: 400 12px var(--sans); fill: var(--ink-2); }
.person .stripe { fill: var(--t-sable); }
.person .ttl { font: 600 11px var(--sans); fill: var(--ink-2); }
.person.found .card { stroke: var(--accent); stroke-width: 3; }
.person .halo { fill: none; stroke: var(--accent); stroke-width: 3; stroke-dasharray: 7 5; }
.person .badge { cursor: pointer; }
.person .badge rect { fill: var(--accent); stroke: var(--paper-2); stroke-width: 2; }
.person .badge text { font: 700 12px var(--sans); fill: var(--accent-ink); text-anchor: middle; }
.person .heir rect { fill: var(--ink); stroke: var(--t-or); stroke-width: 2.5; }
.person .heir text { font: 700 12px var(--sans); fill: var(--paper-2); text-anchor: middle; }
.far .crest-mini { display: none; }
.unknown-box rect { fill: var(--paper-3); stroke: var(--rule-2); stroke-width: 1.5; stroke-dasharray: 3 3; }
.unknown-box text { font: 700 14px var(--serif); fill: var(--ink-2); text-anchor: middle; }
.h0 .stripe { fill: var(--t-gules); } .h1 .stripe { fill: var(--t-azure); } .h2 .stripe { fill: var(--t-vert); }
.h3 .stripe { fill: var(--t-or); } .h4 .stripe { fill: var(--t-purpure); } .h5 .stripe { fill: var(--t-tenne); }
.h6 .stripe { fill: var(--t-sanguine); } .h7 .stripe { fill: var(--t-sable); }

/* edit sheet: bottom sheet on a phone, side panel on a wide screen */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-height: 54vh; max-height: 54svh;
  overflow: auto; overscroll-behavior: contain;
  background: var(--paper-2);
  border-top: 1px solid var(--rule-2);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -10px 30px -12px rgba(0, 0, 0, .45);
  padding: 0 16px 20px;
}
.sheet[hidden] { display: none; }
.sheet-head { position: sticky; top: 0; background: var(--paper-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 0 8px; border-bottom: 1px solid var(--rule); z-index: 1; }
.sheet-head h2 { margin: 0; font-size: 1.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-head .close { min-width: 44px; font-size: 1.3rem; padding: 4px 10px; }
.sheet .fields { display: grid; gap: 10px; padding-top: 12px; }
.sheet .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sheet .fam { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--rule); display: grid; gap: 12px; }
.sheet .fam h3 { margin: 0 0 4px; }
.sheet .rel { display: grid; gap: 6px; }
.sheet .rel .who { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: .95rem; }
.sheet .rel .lbl { font-size: .8rem; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; }
.sheet .partner-row { display: grid; grid-template-columns: minmax(0, 1fr) 9.5rem; gap: 8px; align-items: center; }
.sheet .partner-row .link { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sheet .add-child { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.sheet [aria-pressed=true] { background: var(--paper-3); border-color: var(--ink-2); }
.sheet .danger { margin-top: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: var(--paper);
  padding: 8px 8px 8px 14px; border-radius: 10px; box-shadow: var(--shadow);
  max-width: calc(100vw - 24px);
}
.toast[hidden] { display: none; }
.toast button { background: transparent; color: var(--paper); border-color: var(--paper); }

/* search and houses bar above the chart */
.tree-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.tree-bar[hidden] { display: none; }
.find { position: relative; flex: 1 1 auto; max-width: 420px; }
.find input { margin: 0; }
.find-results {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0;
  list-style: none; margin: 0; padding: 4px; max-height: 320px; overflow: auto;
  background: var(--paper-2); border: 1px solid var(--rule-2); border-radius: 8px; box-shadow: var(--shadow);
}
.find-results[hidden] { display: none; }
.find-results .hit { display: flex; flex-direction: column; align-items: flex-start; width: 100%; border: 0; background: none; text-align: left; padding: 7px 10px; min-height: 44px; }
.find-results .hit:hover, .find-results .hit:focus-visible { background: var(--paper-3); }
.find-results .n { font: 700 1rem var(--serif); }
.find-results .t { font-size: .82rem; font-weight: 400; color: var(--ink-2); }
.find-results .none { padding: 8px 10px; color: var(--ink-2); font-size: .9rem; }
.houses-btn { flex: 0 0 auto; }

/* the legend over the chart (and, as SVG, in every export) */
.house-legend {
  position: absolute; left: 8px; bottom: 8px; z-index: 2; max-width: calc(100% - 16px); max-height: 46%;
  overflow: auto; background: var(--paper-2); border: 1px solid var(--rule-2); border-radius: 8px;
  box-shadow: var(--shadow); font-size: .88rem;
}
.house-legend[hidden] { display: none; }
.house-legend summary { cursor: pointer; padding: 8px 12px; font-weight: 700; min-height: 36px; }
.house-legend ul { list-style: none; margin: 0; padding: 0 12px 8px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.house-legend li { display: flex; align-items: center; gap: 6px; }
.house-legend .legend-houses svg { width: 20px; height: 24px; flex: 0 0 auto; cursor: default; }
.line-icon, .house-legend .line-icon { width: 36px; height: 14px; flex: 0 0 auto; cursor: default; }
.line-icon line { stroke: var(--ink-2); stroke-width: 2; }
.line-icon .border-icon { fill: none; stroke: var(--ink-2); stroke-width: 2; }

/* the Houses panel */
.houses-dialog {
  width: min(560px, calc(100vw - 16px)); max-height: calc(100vh - 32px); padding: 0 16px 16px;
  color: var(--ink); background: var(--paper-2); border: 1px solid var(--rule-2); border-radius: var(--radius); box-shadow: var(--shadow);
}
.houses-dialog::backdrop { background: rgba(20, 14, 6, .45); }
.houses-dialog .dlg-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 12px 0 8px; background: var(--paper-2); border-bottom: 1px solid var(--rule); }
.houses-dialog .dlg-head h2 { margin: 0; font-size: 1.25rem; }
.houses-dialog .close { min-width: 44px; font-size: 1.3rem; padding: 4px 10px; }
.houses-dialog .hint { font-size: .9rem; color: var(--ink-2); margin: 10px 0; }
.houses-dialog .none { color: var(--ink-2); }
.houses-dialog .actions { display: flex; gap: 8px; margin-top: 12px; }
/* the Check panel (continuity.js): the Houses dialog's frame, a list of tappable problems */
.check-opts { display: grid; gap: 10px; margin: 4px 0 12px; }
.check-opts .min-age { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check-opts .min-age input { width: 5.5em; flex: 0 0 auto; }
.check-opts .check-row { display: flex; align-items: flex-start; gap: 8px; font-size: .95rem; }
.check-opts .check-row input { margin-top: 3px; width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--accent); }
.check-summary { margin: 0 0 8px; font: 700 1.05rem/1.35 var(--serif); }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.check-hit {
  display: block; width: 100%; min-height: 44px; padding: 8px 12px; text-align: left; font: 400 .95rem/1.4 var(--sans);
  color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-left: 4px solid var(--accent); border-radius: 8px;
}
.check-hit:hover { background: var(--paper-3); }
.check-list.quiet .check-hit { border-left-color: var(--rule-2); color: var(--ink-2); font-size: .9rem; }
.check-more { margin-top: 12px; }
.check-more[hidden] { display: none; }
.check-more summary { cursor: pointer; min-height: 40px; padding: 8px 0; font-weight: 700; color: var(--ink-2); }
.houses-list { display: grid; gap: 8px; }
.house { border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); }
.house summary { display: flex; align-items: center; gap: 10px; padding: 8px 10px; cursor: pointer; min-height: 48px; }
.house summary svg { width: 28px; height: 34px; flex: 0 0 auto; }
.house .hn { font: 700 1.05rem var(--serif); }
.house .count { margin-left: auto; font-size: .82rem; color: var(--ink-2); }
.house-body { display: grid; gap: 10px; padding: 4px 10px 12px; }
.house fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.house legend { font-size: .85rem; font-weight: 600; color: var(--ink-2); padding: 0; margin-bottom: 4px; width: 100%; }
.house .swatch, .house .charge-pick { position: relative; cursor: pointer; }
.house .swatch input, .house .charge-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.house .chip { display: block; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--rule-2); }
.house .swatch input:checked + .chip { outline: 3px solid var(--ink); outline-offset: 2px; }
.house .swatch input:focus-visible + .chip, .house .charge-pick input:focus-visible + svg { outline: 3px solid var(--focus); outline-offset: 2px; }
.house .any { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-left: 4px; }
.house .any.on { color: var(--ink); }
.house .any input { width: 44px; height: 34px; padding: 0; border: 1px solid var(--rule-2); border-radius: 6px; background: none; }
.house .charge-pick svg { display: block; width: 36px; height: 44px; padding: 3px; border: 2px solid transparent; border-radius: 6px; }
.house .charge-pick input:checked + svg { border-color: var(--ink); background: var(--paper-3); }

/* the short block under the tool */
.about { margin-top: 26px; display: grid; gap: 18px; }
.about section { max-width: 68ch; }
.about p { margin: 0 0 .5em; }
.legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: .95rem; }
.legend svg { width: 44px; height: 14px; vertical-align: middle; margin-right: 8px; }
.legend line { stroke: var(--ink-2); stroke-width: 2; }

@media (min-width: 900px) {
  .tool-intro { display: flex; align-items: baseline; gap: 24px; flex-wrap: wrap; }
  .tool-intro h1 { margin: 0; }
  .stage { height: min(68vh, 760px); }
  .tree-shell.with-sheet { grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; }
  .sheet {
    position: static; max-height: min(68vh, 760px); border: 1px solid var(--rule); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 0 16px 16px;
  }
  .about { grid-template-columns: 1.2fr 1fr 1fr; }
}

/* ---------------------------------------------------------------- succession panel (royal-dynasty) */
.sheet .check { display: flex; align-items: center; gap: 8px; font-size: .95rem; color: var(--ink); min-height: 32px; }
.sheet .check input, .succession .check input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; flex: 0 0 auto; }
.succession {
  margin-top: 12px; padding: 12px 14px 14px; display: grid; gap: 12px;
  background: var(--paper-2); border: 1px solid var(--rule); border-left: 5px solid var(--t-or); border-radius: var(--radius); box-shadow: var(--shadow);
}
.succession[hidden] { display: none; }
.about .rules { margin: 0 0 .5em; padding-left: 1.1em; display: grid; gap: 6px; }
.succession h2 { margin: 0; font-size: 1.3rem; }
.succession .controls { display: grid; gap: 10px; align-content: start; }
.succession .check { display: flex; align-items: center; gap: 8px; font-size: .95rem; font-weight: 400; color: var(--ink); min-height: 32px; }
.succession .rule-def { margin: 0; font-size: .9rem; color: var(--ink-2); }
.succession .result { min-width: 0; }
.succession .result h3 { margin: 0 0 6px; font-size: 1.05rem; }
.heir-list { margin: 0; padding: 0 0 0 2.4em; display: grid; gap: 2px; }
.heir-list li { padding: 3px 0; break-inside: avoid; }
.heir-list li::marker { font: 700 1rem var(--serif); color: var(--accent); }
.heir-list button.link { font: 700 1rem var(--serif); text-align: left; color: var(--ink); text-decoration-color: var(--rule-2); }
.heir-list .t { display: block; font-size: .84rem; color: var(--ink-2); }
.succession .unplaced { margin-top: 10px; padding: 8px 12px; border-left: 4px solid var(--t-gules); background: var(--paper-3); border-radius: 6px; font-size: .92rem; }
.succession .unplaced ul { margin: 4px 0 0; padding-left: 1.2em; }
.succession .cannot { margin: 0; padding: 10px 12px; border-left: 4px solid var(--t-azure); background: var(--paper-3); border-radius: 6px; max-width: 62ch; }
@media (min-width: 900px) {
  .succession { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 14px 28px; }
  .succession h2 { grid-column: 1 / -1; }
  .heir-list { column-count: 2; column-gap: 32px; display: block; }
}
@media (min-width: 1200px) { .heir-list { column-count: 3; } }

/* ---------------------------------------------------------------- timeline tool */
.c-gules { --c: var(--t-gules); } .c-azure { --c: var(--t-azure); } .c-vert { --c: var(--t-vert); }
.c-or { --c: var(--t-or); } .c-purpure { --c: var(--t-purpure); } .c-tenne { --c: var(--t-tenne); }
.c-sanguine { --c: var(--t-sanguine); } .c-sable { --c: var(--t-sable); }
.tl-tool { position: relative; }
.tl-stage { height: min(70vh, 860px); height: min(70svh, 860px); background-image: none; }
.tl-scale[hidden] { display: none; }
.tl-scale { position: absolute; right: 8px; bottom: 50px; margin: 0; padding: 2px 8px; font-size: .78rem; color: var(--ink-2); background: var(--paper-2); border: 1px solid var(--rule); border-radius: 6px; pointer-events: none; }
.tl-stage.vert .tl-scale { bottom: 8px; }
#tl .band { fill: var(--paper-3); opacity: .7; }
#tl .track-bg { fill: var(--paper); opacity: .75; }
#tl .grid { stroke: var(--rule); stroke-width: 1; }
#tl .grid.era { stroke: var(--rule-2); stroke-width: 2; }
#tl .ruler-bg, #tl .head-bg { fill: var(--paper-2); }
#tl .ruler-bg { stroke: var(--rule); }
#tl .tick { font: 600 12px var(--sans); fill: var(--ink-2); }
#tl .tick.era { fill: var(--ink); font-weight: 700; }
#tl .era-name { font: italic 700 15px var(--serif); fill: var(--ink-2); }
#tl .head text { font: 700 14px var(--serif); fill: var(--ink); }
#tl .head .pill { fill: var(--paper-2); stroke: var(--rule-2); }
#tl .head .sw { fill: var(--c); }
.ev { cursor: pointer; outline: none; }
.ev .hit { fill: transparent; stroke: none; }
.ev:hover .hit { fill: var(--paper-3); }
.ev .mark { fill: var(--c); stroke: var(--paper-2); stroke-width: 1; }
.ev .t { font: 600 14px var(--sans); fill: var(--ink); }
.ev .y { font: 400 12px var(--sans); fill: var(--ink-2); }
.ev.selected .hit { fill: var(--paper-3); stroke: var(--accent); stroke-width: 2; }
.ev:focus-visible .hit { stroke: var(--focus); stroke-width: 3; }
.ev.dragging { cursor: grabbing; }
.ev.dragging .hit { fill: var(--paper-2); stroke: var(--accent); stroke-width: 2; stroke-dasharray: 5 3; }
.ev.dragging .y { fill: var(--accent); font-weight: 700; }
.sheet .hint, .setup-dialog .hint { font-size: .86rem; color: var(--ink-2); margin: 0; }
.sheet .two.one { grid-template-columns: 1fr; }
.sheet .two [hidden] { display: none; }
input[type=number] {
  font: 400 1rem/1.3 var(--sans); color: var(--ink); background: var(--paper-2);
  border: 1px solid var(--rule-2); border-radius: 7px; padding: 8px 10px; width: 100%; min-height: 40px;
}
.setup-dialog h3 { margin: 16px 0 4px; }
.setup-list { display: grid; gap: 8px; margin-top: 8px; }
.track-row, .era-row { display: grid; gap: 6px 8px; align-items: end; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); }
.track-row { grid-template-columns: 10px minmax(0, 1fr) minmax(0, 7.5rem); border-left: 0; position: relative; }
.track-row .swatch { align-self: stretch; background: var(--c); border-radius: 4px; grid-row: span 2; }
.track-row .btns { grid-column: 2 / -1; display: flex; gap: 6px; }
.track-row .btns button { min-width: 44px; }
.era-row { grid-template-columns: minmax(0, 1fr) minmax(0, 5rem); }
.era-row label:nth-child(3) { grid-column: 1; }
.era-row button { justify-self: end; }
.setup-dialog .check { display: flex; gap: 10px; align-items: center; margin-top: 10px; font-size: .95rem; color: var(--ink); font-weight: 400; }
.setup-dialog .check input { width: 20px; height: 20px; margin: 0; flex: 0 0 auto; accent-color: var(--accent); }
@media (min-width: 640px) {
  .era-row { grid-template-columns: minmax(0, 1fr) 5.5rem 8rem auto; }
  .era-row label:nth-child(3) { grid-column: auto; }
  .track-row { grid-template-columns: 10px minmax(0, 1fr) 8rem auto; }
  .track-row .swatch { grid-row: auto; }
  .track-row .btns { grid-column: auto; }
}
/* characters: lifelines, the ages row, the event sheet's list, the panel */
#tl .lives-bg { fill: var(--paper); opacity: .55; }
#tl .life .line { stroke: var(--ink-2); stroke-width: 2; }
#tl .life.on .line { stroke: var(--accent); }
#tl .life .born { fill: var(--paper-2); stroke: var(--ink); stroke-width: 2; }
#tl .life .died { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; }
#tl .life .ln { font: 600 12px var(--sans); fill: var(--ink-2); }
#tl .ages-row .age { font: 700 12px var(--sans); fill: var(--accent); }
#tl .ages-row .age-name { font: 700 12px var(--sans); fill: var(--ink); }
.tl-stage.vert #tl .ages-row .age-name { font-size: 11px; }
#tl .ages-row .age-bg { fill: var(--paper-2); }
#tl .ages-row .age-rule { stroke: var(--rule); stroke-width: 1; }
.stage-tools #ages-toggle[aria-pressed=true] { background: var(--ink); color: var(--paper-2); border-color: var(--ink); }
.sheet .alive { border-top: 1px solid var(--rule); padding-top: 8px; }
.sheet .alive h3 { margin: 0 0 4px; font-size: 1rem; }
.sheet .alive ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; }
.sheet .alive li { padding: 2px 9px; border: 1px solid var(--rule-2); border-radius: 999px; background: var(--paper); font-size: .92rem; }
.sheet .alive li.later { border-style: dashed; color: var(--ink-2); }
.sheet .alive [hidden] { display: none; }
.char-row { display: grid; gap: 6px 8px; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); grid-template-columns: 1fr 1fr; }
.char-row > label { grid-column: 1 / -1; }
.char-row .yp { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; align-content: end; }
.char-row .btns, .unusable .yp + button { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.char-row .btns { grid-column: 1 / -1; }
.chars-dialog .check { margin-top: 0; }
.chars-dialog code { font-size: .85em; }
.import-preview { margin-top: 10px; padding: 10px; border: 1px solid var(--rule-2); border-radius: 8px; background: var(--paper); }
.import-preview[hidden], .chars-dialog [hidden] { display: none; }
.import-preview p { margin: 0 0 8px; }
.import-preview h4 { margin: 12px 0 6px; }
.unusable { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.unusable li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 8px; align-items: end; padding: 8px 0; border-top: 1px solid var(--rule); }
.unusable li p { grid-column: 1 / -1; margin: 0; font-size: .92rem; }
.unusable .yp { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; align-items: end; }
@media (min-width: 640px) {
  .char-row { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); }
  .char-row > label { grid-column: auto; }
}
@media (min-width: 900px) {
  .tl-stage { height: min(68vh, 760px); }
}

/* ---------------------------------------------------------------- front page */
.home .hero { display: grid; gap: 14px; padding: 16px 0 6px; align-items: center; }
.home .hero h1 { margin-bottom: .3em; }
.home .lede { color: var(--ink-2); max-width: 46ch; margin-bottom: 14px; }
.cta {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 12px 26px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent);
  font: 700 1.12rem/1.1 var(--sans); text-decoration: none; box-shadow: var(--shadow);
}
.cta:hover { filter: brightness(1.08); }
.hero-figure { margin: 0; }
.hero-figure img {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--paper-2);
}
.hero-figure figcaption { margin-top: 6px; font-size: .85rem; color: var(--ink-2); }
.points { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 12px; }
.points li { padding: 12px 14px 12px 16px; background: var(--paper-2); border: 1px solid var(--rule); border-left: 5px solid var(--t-gules); border-radius: 8px; max-width: 68ch; }
.points li:nth-child(2) { border-left-color: var(--t-azure); }
.points li:nth-child(3) { border-left-color: var(--t-vert); }
.points strong { display: block; font-family: var(--serif); font-size: 1.08rem; }
.made-for { margin-top: 24px; max-width: 68ch; }
.tool-card {
  display: grid; gap: 4px; margin-top: 16px; padding: 14px 16px 14px 18px; max-width: 68ch;
  background: var(--paper-2); border: 1px solid var(--rule); border-left: 5px solid var(--t-or); border-radius: 8px;
  color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
}
.tool-card:hover { border-color: var(--ink-2); border-left-color: var(--t-or); }
.tool-card strong { font: 700 1.2rem/1.2 var(--serif); }
.tool-card .go { color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
@media (min-width: 900px) {
  .home .hero { grid-template-columns: minmax(300px, 2fr) 3fr; gap: 36px; padding: 36px 0 10px; }
  .points { grid-template-columns: repeat(3, 1fr); }
}

/* ---------------------------------------------------------------- OC page
   Portraits and signature colours on the chart (drawn wherever a tree has
   them), and the portrait picker and character fields in the edit sheet. */
.person .portrait-ring { fill: none; stroke: var(--rule-2); stroke-width: 2; }
.person .oc-chip { stroke: var(--paper-2); stroke-width: 1.5; }
.sheet .portrait-field { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 12px; align-items: start; }
.sheet .portrait-frame {
  width: 88px; height: 88px; border-radius: 50%; overflow: hidden;
  background: var(--paper-3); border: 2px dashed var(--rule-2); display: grid; place-items: center; color: var(--ink-2);
}
.sheet .portrait-frame.has { border-style: solid; }
.sheet .portrait-frame.square { border-radius: 9px; }
.sheet .portrait-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.sheet .portrait-frame img[hidden] { display: none; }
.sheet .portrait-ctl { display: grid; gap: 8px; }
.sheet .portrait-ctl .actions { align-items: center; }
.pick-btn { position: relative; display: inline-flex; align-items: center; font: 600 .95rem/1.1 var(--sans); color: var(--accent-ink); background: var(--accent); border: 1px solid var(--accent); border-radius: 8px; padding: 9px 13px; min-height: 40px; cursor: pointer; }
.pick-btn input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.pick-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.sheet .shape { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.sheet .shape[hidden] { display: none; }
.sheet .shape legend { float: left; margin-right: 4px; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.sheet .shape label { display: inline-flex; align-items: center; gap: 6px; font-size: .95rem; color: var(--ink); min-height: 32px; }
.sheet .shape input, .sheet .pan input { accent-color: var(--accent); }
.sheet .pan[hidden] { display: none; }
.sheet .pan input { width: 100%; margin-top: 3px; }
.sheet .colour-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sheet .colour-row input[type=color] { width: 52px; height: 40px; padding: 2px; border: 1px solid var(--rule-2); border-radius: 7px; background: var(--paper-2); }
.sheet .colour-row .state { font: 400 .95rem var(--sans); color: var(--ink); }
.msg.storage-warn { border-left-color: var(--t-or); }
.oc-chars { display: grid; gap: 8px; }
.oc-chars dt { font: 700 1.05rem var(--serif); }
.oc-chars dd { margin: 0 0 6px; }

/* ---------------------------------------------------------------- print
   Only the print copy of the tree (built by tree-export.js) is printed: its
   name as the title, then the whole tree scaled to fit one page. */
@media print {
  body { background: #fff; min-height: 0; }
  body > :not(.print-sheet) { display: none !important; }
  .print-sheet { display: block; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-title { margin: 0 0 4mm; font-size: 20pt; }
  .print-sheet svg { display: block; width: 100%; height: auto; max-height: var(--print-h, calc(100vh - 4rem)); break-inside: avoid; }
}
