/* Referent: Obsidian's graph view at the scale of a star atlas — black
   space, small glowing nodes, labels that come and go with the eye — dressed
   for the subject: the Fell types of the 1670s, burnished gold for marriages,
   a vellum leaf for the person you clicked. Houses wear their tinctures.
   Not here: white cards, soft shadows, rounded pills, Inter, gradient blobs. */

:root {
  --space: #04050d;
  --space-2: #0a0d22;
  --gold: #e9c46a;
  --gold-d: #a8832c;
  --gold-hi: #fff0c2;
  --vellum: #f2e6c8;
  --vellum-2: #e3cf9f;
  --ink: #2a1c0e;
  --ink-2: #5a4326;
  --rubric: #a3231f;
  --mist: rgba(242, 230, 200, .62);
  --display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --caps: "Source Serif 4", Georgia, serif;
  --text: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --ui: "Source Serif 4", Georgia, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--space); }
body { color: var(--vellum); font: 17px/1.45 var(--text); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
a { color: var(--gold); }

#scene, #map { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#scene:active, #map:active { cursor: grabbing; }

/* ------------------------------------------------------------ labels */
.labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.labels > div {
  position: absolute;
  left: 0; top: 0;
  white-space: nowrap;
  text-shadow: 0 0 3px var(--space), 0 0 7px var(--space);
}
.hl { font-family: var(--caps); letter-spacing: .04em; }
.pl { font-family: var(--display); color: rgba(242, 230, 200, .78); }
.pl.lit { color: var(--gold-hi); font-style: italic; }
.pl.sel { color: #fff; font-style: italic; }

/* ------------------------------------------------------------ title + find */
.title { position: fixed; left: 20px; top: 14px; pointer-events: none; max-width: 520px; }
.title h1 {
  margin: 0;
  font: 400 clamp(26px, 3.2vw, 40px)/1 var(--display);
  color: var(--gold);
  text-shadow: 0 0 18px rgba(233, 196, 106, .25);
}
.title p { margin: 4px 0 0; font: italic 16px var(--text); color: var(--mist); }

.find { position: fixed; left: 20px; top: 92px; width: min(380px, calc(100vw - 40px)); z-index: 20; }
.find input {
  width: 100%;
  padding: 9px 12px;
  font: 18px var(--display);
  color: var(--vellum);
  background: rgba(10, 13, 34, .85);
  border: 1px solid var(--gold-d);
  border-radius: 0;
}
.find input::placeholder { color: rgba(242, 230, 200, .45); font-style: italic; }
.find input:focus { outline: 1px solid var(--gold); border-color: var(--gold); }
.find-list {
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  background: var(--vellum);
  color: var(--ink);
  border: 1px solid var(--gold-d);
}
.find-list li { display: flex; align-items: baseline; gap: 10px; padding: 7px 12px; cursor: pointer; border-bottom: 1px solid var(--vellum-2); }
.find-list li:hover { background: var(--vellum-2); }
.find-name { flex: 1; font: 17px var(--display); }
.find-years { font-size: 14px; color: var(--ink-2); }
.swatch { display: inline-block; width: 10px; height: 10px; flex: 0 0 auto; border: 1px solid rgba(0, 0, 0, .3); }

.kinbar {
  display: flex; align-items: center; gap: 10px;
  margin-top: 6px; padding: 8px 10px 8px 14px;
  background: var(--gold); color: var(--space);
}
.kinbar p { margin: 0; flex: 1; font: italic 16px/1.3 var(--display); }
.kinbar button { padding: 4px 10px; background: transparent; border: 1px solid var(--space); cursor: pointer; }

/* ------------------------------------------------------------ start */
.start-label { margin: 8px 0 6px; font: 14px var(--caps); letter-spacing: .1em; color: var(--gold); text-shadow: 0 0 8px var(--space); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  padding: 4px 11px 5px;
  font: 16px var(--display);
  color: var(--vellum);
  background: rgba(10, 13, 34, .82);
  border: 1px solid rgba(233, 196, 106, .5);
  border-radius: 0;
  cursor: pointer;
}
.chip i { color: var(--gold); }
.chip:hover, .chip:focus-visible { background: var(--gold); color: var(--space); }
.chip:hover i { color: var(--rubric); }

/* ------------------------------------------------------------ tools */
.tools { position: fixed; right: 16px; top: 16px; display: flex; gap: 4px; z-index: 20; }
.tools button, .time button {
  padding: 6px 12px 7px;
  font: 16px var(--display);
  color: var(--gold);
  background: rgba(10, 13, 34, .85);
  border: 1px solid var(--gold-d);
  border-radius: 0;
  cursor: pointer;
}
.tools button:hover, .time button:hover, .tools button[aria-pressed="true"] { background: var(--gold); color: var(--space); }

.side {
  position: fixed;
  left: 20px; top: 146px; bottom: 90px;
  width: 300px;
  overflow-y: auto;
  z-index: 15;
}
.houses, .filters {
  padding: 6px 14px 14px;
  background: rgba(10, 13, 34, .92);
  border: 1px solid var(--gold-d);
}
.region { margin: 10px 0 4px; font: 14px var(--caps); letter-spacing: .1em; color: var(--gold); }
.hlist { display: flex; flex-direction: column; }
.house-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 4px;
  font: 16px var(--display);
  text-align: left;
  color: var(--vellum);
  background: none;
  border: 0;
  cursor: pointer;
}
.house-btn .n { margin-left: auto; font: 13px var(--text); color: var(--mist); }
.house-btn:hover, .house-btn[aria-pressed="true"] { background: rgba(233, 196, 106, .16); color: var(--gold-hi); }

/* ------------------------------------------------------------ time */
.time {
  position: fixed;
  left: 20px; right: 20px; bottom: 30px;
  display: flex; align-items: center; gap: 12px;
  z-index: 10;
}
.time .play { width: 40px; padding: 6px 0 7px; }
.time input[type=range] { flex: 1; accent-color: var(--gold); }
.time output { min-width: 150px; font: 15px var(--text); color: var(--mist); }
.time output b { font: 400 22px var(--display); color: var(--gold); margin-right: 6px; }

.time-ev {
  position: fixed;
  left: 50%; bottom: 74px;
  transform: translateX(-50%);
  width: min(620px, calc(100vw - 40px));
  text-align: center;
  pointer-events: none;
  z-index: 9;
}
.time-ev p { margin: 6px 0 0; font-size: 15px; line-height: 1.35; color: var(--vellum-2); text-shadow: 0 0 6px var(--space), 0 0 12px var(--space); }
.time-ev b { font: 400 19px var(--display); color: var(--gold-hi); }
.time-ev span { color: var(--gold); font-style: italic; }

.tip {
  position: fixed;
  left: 0; top: 0;
  z-index: 30;
  max-width: 300px;
  padding: 7px 11px 8px;
  pointer-events: none;
  background: rgba(10, 13, 34, .95);
  border: 1px solid var(--gold-d);
  font-size: 14px;
  line-height: 1.35;
}
.tip b { display: block; font: 400 18px/1.2 var(--display); color: var(--gold-hi); }
.tip span { display: block; color: var(--mist); }
.tip .tip-r { color: var(--gold); font-style: italic; }

.wait { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; font: italic 22px var(--display); color: var(--gold); }
.credit { position: fixed; left: 20px; bottom: 6px; margin: 0; font-size: 12px; color: rgba(242, 230, 200, .4); pointer-events: none; }

/* ------------------------------------------------------------ the leaf */
.leaf {
  position: fixed;
  z-index: 25;
  right: 16px; top: 58px; bottom: 80px;
  width: 380px;
  display: flex;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 250, 235, .7), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(196, 160, 96, .35), transparent 55%),
    var(--vellum);
  border: 1px solid var(--gold-d);
  outline: 3px solid var(--space);
  box-shadow: 0 0 0 4px var(--gold-d);
}
.leaf-close {
  position: absolute; right: 6px; top: 4px; z-index: 2;
  width: 36px; height: 36px;
  font: 30px/1 var(--display); color: var(--rubric);
  background: none; border: 0; cursor: pointer;
}
.leaf-body { flex: 1; overflow-y: auto; padding: 20px 20px 24px; font-size: 16.5px; line-height: 1.45; overscroll-behavior: contain; }
.leaf-head { display: flex; gap: 14px; align-items: center; margin: 0 28px 12px 0; }
.initial {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 60px; height: 60px;
  font: 48px/1 var(--display);
  color: var(--gold-hi);
  background: var(--tinct, #1f3296);
  border: 2px solid var(--gold);
  outline: 1px solid var(--ink);
  text-shadow: 0 1px 0 #6d5217;
}
.leaf h2 { margin: 0; font: 400 25px/1.08 var(--display); }
.leaf-dates { margin: 3px 0 0; font: italic 17px var(--text); color: var(--rubric); }
.portrait { margin: 0 0 12px; padding: 4px; background: var(--vellum-2); border: 1px solid var(--gold-d); }
.portrait img { display: block; width: 100%; max-height: 300px; object-fit: cover; object-position: 50% 20%; }
.leaf-desc { margin: 0 0 10px; }
.leaf-house { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font: 15px var(--caps); letter-spacing: .04em; color: var(--ink-2); }
.reigns { margin: 0 0 12px; padding: 0; list-style: none; border-top: 1px solid var(--gold-d); }
.reigns li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--vellum-2); }
.reigns li span:first-child { font-family: var(--display); }
.reigns li span:last-child { color: var(--gold-d); white-space: nowrap; }
.story { margin: 12px 0; padding: 10px 12px; background: rgba(163, 35, 31, .07); border-left: 3px solid var(--rubric); }
.story p { margin: 0; }
.story-head { font: 400 19px/1.2 var(--display); color: var(--rubric); margin-bottom: 4px !important; }
.fate { margin: 0 0 10px; font-style: italic; color: var(--rubric); }
.modes { display: flex; flex-wrap: wrap; align-items: center; gap: 0; margin: 14px 0 6px; }
.modes button {
  padding: 6px 11px 7px;
  font: 15px var(--display);
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink-2);
  margin-right: -1px;
  cursor: pointer;
}
.modes button[aria-pressed="true"] { background: var(--ink); color: var(--vellum); }
.modes .count { margin-left: 10px; font-style: italic; color: var(--ink-2); font-size: 15px; }
.collapse { margin: 8px 0; font-style: italic; color: var(--rubric); }
.family { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0; }
.family dt { font: 13px/1.9 var(--caps); letter-spacing: .05em; color: var(--ink-2); }
.family dd { margin: 0; }
.who {
  padding: 0;
  font-family: var(--display);
  color: var(--ink);
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--gold-d);
  cursor: pointer;
}
.who:hover { color: var(--rubric); border-color: var(--rubric); }
.who-x { color: var(--ink-2); font-size: 14px; }
.acts { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 8px; }
.act { padding: 7px 12px 8px; font: 15px var(--display); color: var(--vellum); background: var(--space-2); border: 1px solid var(--space-2); text-decoration: none; cursor: pointer; }
.act:hover { background: var(--rubric); border-color: var(--rubric); }
.act.ghost { color: var(--ink); background: transparent; border-color: var(--ink-2); }
.act.ghost:hover { background: var(--ink); color: var(--vellum); }
.extract { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--gold-d); font-size: 15.5px; color: var(--ink-2); }
.extract p { margin: 0 0 6px; }
.extract-head { font: 13px var(--caps); letter-spacing: .08em; color: var(--gold-d); }
.kin-pair { margin: 0; font: 400 23px/1.15 var(--display); }
.kin-pair span { color: var(--rubric); font-style: italic; }
.kin-verdict { font: 400 22px/1.25 var(--display); color: var(--rubric); margin: 4px 0 8px; }
.kin-via, .kin-ways { margin: 0 0 8px; }
.kin-ways { font-style: italic; color: var(--ink-2); }
.chain { margin: 12px 0; padding: 0; list-style: none; }
.chain li { position: relative; padding: 3px 0 3px 22px; }
.chain li::before { content: ""; position: absolute; left: 5px; top: 0; bottom: 0; width: 2px; background: var(--gold-d); }
.chain li::after { content: ""; position: absolute; left: 1px; top: 11px; width: 8px; height: 8px; background: var(--gold); border: 1px solid var(--ink); transform: rotate(45deg); }
.chain li:first-child::before { top: 12px; }
.chain li:last-child::before { bottom: calc(100% - 12px); }

:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }

/* ------------------------------------------------------------ small */
@media (max-width: 760px) {
  .title { left: 14px; top: 10px; right: 120px; }
  .title p { display: none; }
  .find { left: 14px; top: 50px; width: calc(100vw - 28px); }
  .tools { right: 10px; top: 10px; }
  .tools #b-reset { display: none; }
  .side { left: 10px; right: 10px; width: auto; top: 100px; bottom: 76px; z-index: 26; }
  .start { top: auto; bottom: 64px; max-height: 34vh; }
  .tools { flex-wrap: wrap; justify-content: flex-end; max-width: 60vw; }
  .trail { top: 96px; left: 10px; right: 10px; transform: none; max-width: none; }
  .chip { font-size: 14px; padding: 3px 8px 4px; }
  .start .chips:last-of-type .chip:nth-child(n+4) { display: none; }
  .time { left: 10px; right: 10px; bottom: 22px; gap: 8px; }
  .time output { min-width: 0; font-size: 12px; }
  .time output b { font-size: 18px; }
  .credit { left: 10px; font-size: 10px; }
  .leaf {
    left: 0; right: 0; bottom: 0; top: auto;
    width: auto; max-height: 58vh;
    outline: 0; box-shadow: none;
    border-width: 3px 0 0; border-style: double;
  }
}

/* ------------------------------------------------------------ added: views, trail, tree, filters */
.tools .seg { display: inline-flex; margin-right: 6px; }
.tools .seg button + button { margin-left: -1px; }
.tools .seg button[aria-pressed="true"] { background: var(--gold); color: var(--space); }

.pl .role { font-family: var(--text); font-style: italic; font-size: .82em; color: rgba(233, 196, 106, .9); }
.pl.faint { opacity: .55; }

.trail {
  position: fixed;
  left: 50%; top: 16px;
  transform: translateX(-50%);
  max-width: calc(100vw - 900px);
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px;
  padding: 4px 8px;
  background: rgba(10, 13, 34, .9);
  border: 1px solid var(--gold-d);
  z-index: 20;
}
.trail .step { padding: 2px 4px; font: 15px var(--display); color: var(--mist); background: none; border: 0; cursor: pointer; }
.trail .step:hover { color: var(--gold-hi); }
.trail .step.now { color: var(--gold-hi); font-style: italic; }
.trail .sep { color: var(--gold-d); }
.trail-clear { margin-left: 6px; padding: 1px 7px; font: 13px var(--caps); letter-spacing: .05em; color: var(--gold); background: none; border: 1px solid var(--gold-d); cursor: pointer; }

.tree {
  position: fixed;
  left: 20px; bottom: 82px;
  max-width: min(700px, calc(100vw - 460px));
  max-height: 46vh;
  padding: 8px 10px 10px;
  overflow: hidden;
  display: flex; flex-direction: column;
  background: rgba(10, 13, 34, .9);
  border: 1px solid var(--gold-d);
  z-index: 12;
}
.tree-head { margin: 0 0 6px; font: 13px var(--caps); letter-spacing: .1em; color: var(--gold); }
.tree-scroll { overflow: auto; }
.tree svg { display: block; }
.tree .bl { stroke: rgba(242, 230, 200, .45); stroke-width: 1.2; }
.tree .tie { stroke: var(--gold); stroke-width: 1.6; }
.tree .tb { cursor: pointer; }
.tree .tb rect:first-of-type { fill: #141a3c; stroke: rgba(233, 196, 106, .35); }
.tree .tb.self rect:first-of-type { fill: #2a2410; stroke: var(--gold); stroke-width: 2; }
.tree .tb.crowned rect:first-of-type { stroke: var(--gold); }
.tree .tb:hover rect:first-of-type, .tree .tb:focus rect:first-of-type { fill: #232a55; }
.tree .tb.more { cursor: default; }
.tree .tb.more rect { fill: none; stroke-dasharray: 3 3; stroke: rgba(233, 196, 106, .35); }
.tree .tb.more text { fill: var(--mist); font: italic 12px var(--text); }
.tree .tn { fill: var(--vellum); font: 12.5px var(--display); }
.tree .tb.self .tn { fill: var(--gold-hi); }
.tree .ty { fill: rgba(242, 230, 200, .55); font: 11px var(--text); }
.tree-in-leaf { position: static; max-width: none; max-height: none; margin: 10px 0; background: var(--space-2); }

.modes { gap: 8px; }
.modes .seg { display: inline-flex; }
.modes .seg button + button { margin-left: -1px; }
.modes .seg button { margin-right: 0; }
.leaf-where { margin: 0 0 10px; font-size: 15px; color: var(--ink-2); font-style: italic; }
.leaf-fiefs { margin: 0 0 12px; font-size: 15px; color: var(--ink-2); }
.leaf-fiefs span { font: 13px var(--caps); letter-spacing: .05em; margin-right: 4px; }

.f-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 6px 0 4px; }
.f-title { margin: 0; font: 400 20px var(--display); color: var(--gold); }
.f-count { margin: 0; font: italic 15px var(--text); color: var(--mist); }
.f-clear { margin-left: auto; padding: 2px 8px; font: 13px var(--caps); color: var(--gold); background: none; border: 1px solid var(--gold-d); cursor: pointer; }
.f-label { margin: 12px 0 5px; font: 13px var(--caps); letter-spacing: .08em; color: var(--gold); }
.f-label span { font: italic 12px var(--text); letter-spacing: 0; color: var(--mist); text-transform: none; }
.fchips { display: flex; flex-wrap: wrap; gap: 4px; }
.fchip { padding: 2px 8px 3px; font: 14px var(--display); color: var(--vellum); background: transparent; border: 1px solid rgba(233, 196, 106, .4); cursor: pointer; }
.fchip:hover { border-color: var(--gold); }
.fchip[aria-pressed="true"] { background: var(--gold); color: var(--space); border-color: var(--gold); }
.f-input { width: 100%; margin-bottom: 5px; padding: 5px 8px; font: 15px var(--display); color: var(--vellum); background: var(--space); border: 1px solid var(--gold-d); }
.f-check { display: flex; gap: 8px; align-items: center; margin: 14px 0 4px; font-size: 15px; color: var(--vellum-2); cursor: pointer; }

.time-ev { pointer-events: none; }
.time-ev .ev { pointer-events: auto; }
.time-ev .ev { padding: 0; font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.time-ev .ev:hover b { text-decoration: underline; }

/* ------------------------------------------------------------ boards: thrones, marriages */
.board {
  position: fixed;
  left: 330px; right: 16px; top: 140px; bottom: 76px;
  overflow: auto;
  background: var(--space);
  z-index: 5;
}
.board[data-view="marriages"] { overflow: hidden; }
.board svg { display: block; }

.thrones .grid { stroke: rgba(233, 196, 106, .08); }
.thrones .grid.c { stroke: rgba(233, 196, 106, .2); }
.thrones .gy { fill: rgba(242, 230, 200, .55); font: 12px var(--text); }
.thrones .rn { fill: var(--vellum-2); font: 14px var(--display); }
.thrones .rl { stroke: rgba(233, 196, 106, .1); }
.thrones .seg { stroke: rgba(4, 5, 13, .7); stroke-width: .5; cursor: pointer; opacity: .9; }
.thrones .seg:hover { stroke: var(--gold-hi); stroke-width: 1.5; opacity: 1; }
.thrones .seg.off { opacity: .14; }
.thrones .seg.me { stroke: #fff; stroke-width: 2; opacity: 1; }
.thrones .sn { fill: #0a0d22; font: 10.5px var(--display); pointer-events: none; }
.thrones .sn.off { display: none; }
.thrones .swap { stroke: var(--gold); stroke-width: 1.5; }
.thrones .union { stroke: rgba(233, 196, 106, .28); stroke-width: 1; stroke-dasharray: 2 2; }
.thrones .union.on { stroke: var(--gold-hi); stroke-width: 2; stroke-dasharray: none; }
.thrones .now { stroke: var(--gold-hi); stroke-width: 1.5; }

.chord .rib { opacity: .5; stroke: rgba(4, 5, 13, .4); stroke-width: .5; transition: opacity .15s; cursor: default; }
.chord .rib.hot { opacity: .85; }
.chord .rib.off { opacity: .05; }
.chord .grp { cursor: pointer; stroke: rgba(4, 5, 13, .6); }
.chord .grp.off { opacity: .3; }
.chord .gn { fill: var(--vellum); font: 14px var(--display); cursor: pointer; }
.chord .gn.off { opacity: .35; }
.chord .gc { fill: var(--gold); font: italic 12px var(--text); }
.chord-sum { fill: var(--gold); font: italic 15px var(--text); opacity: .7; pointer-events: none; }

/* ------------------------------------------------------------ the family panel's tabs */
.ptabs { display: flex; gap: 0; margin: 0 0 6px; align-items: center; }
.ptabs button {
  padding: 3px 10px 4px;
  font: 13px var(--caps);
  letter-spacing: .06em;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--gold-d);
  margin-right: -1px;
  cursor: pointer;
}
.ptabs button[aria-pressed="true"] { background: var(--gold); color: var(--space); }
.ptabs .pbig { margin-left: auto; margin-right: 0; font: italic 13px var(--text); letter-spacing: 0; }
.tree .pbody { overflow: auto; }
.tree.big { max-width: calc(100vw - 460px); width: calc(100vw - 460px); max-height: calc(100vh - 230px); height: calc(100vh - 230px); }
.tree-in-leaf .ptabs button { color: var(--gold); }

.life .lg { stroke: rgba(233, 196, 106, .08); }
.life .ly { fill: rgba(242, 230, 200, .5); font: 11px var(--text); }
.life .lnow { stroke: var(--gold-hi); stroke-width: 1.2; }
.life .lhit { fill: transparent; cursor: pointer; }
.life .lrow:hover .lhit { fill: rgba(233, 196, 106, .07); }
.life .lrow.me .lhit { fill: rgba(233, 196, 106, .12); }
.life .lname { fill: var(--vellum); font: 12.5px var(--display); }
.life .lrow.far .lname { fill: rgba(242, 230, 200, .65); }
.life .lrole { fill: var(--gold); font: italic 11px var(--text); }
.life .lbar { opacity: .75; }
.life .lreign { fill: var(--gold); opacity: .85; }
.life .lyears { fill: rgba(242, 230, 200, .45); font: 10.5px var(--text); }
.life .lbirth { stroke-width: 1; opacity: .45; }
.life .lwed { stroke: var(--gold); stroke-width: 1.2; opacity: .8; }
.life .lwedm { fill: var(--gold); }

.hour .hlabel { fill: var(--gold); font: 12px var(--caps); letter-spacing: .1em; }
.hour .hl { fill: none; stroke: rgba(242, 230, 200, .35); stroke-width: 1.1; }
.hour .hb { cursor: pointer; }
.hour .hb rect:first-of-type { fill: #141a3c; stroke: rgba(233, 196, 106, .3); }
.hour .hb.self rect:first-of-type { fill: #2a2410; stroke: var(--gold); stroke-width: 2; }
.hour .hb.crowned rect:first-of-type { stroke: var(--gold); }
.hour .hb.rep rect:first-of-type { fill: #3a1418; stroke: #e2584a; }
.hour .hb.same rect:first-of-type { fill: #5a1c22; stroke: #ffb4a8; stroke-width: 2; }
.hour .hb:hover rect:first-of-type { fill: #232a55; }
.hour .hb.more { cursor: default; }
.hour .hb.more rect { fill: none; stroke-dasharray: 3 3; stroke: rgba(233, 196, 106, .35); }
.hour .hb.more text { fill: var(--mist); font: italic 12px var(--text); }
.hour .tn { fill: var(--vellum); font: 12px var(--display); }
.hour .hb.self .tn { fill: var(--gold-hi); }
.hour .ty { fill: rgba(242, 230, 200, .55); font: 10.5px var(--text); }
.hour .badge { fill: #e2584a; stroke: var(--space); }
.hour .badget { fill: #fff; font: 600 10px var(--text); }

@media (max-width: 760px) {
  .board { left: 0; right: 0 !important; top: 96px; bottom: 64px; }
  .tools .seg button { padding: 5px 7px 6px; font-size: 14px; }
}

.thrones .hn { font: 11px var(--caps); letter-spacing: .05em; }
.thrones .hn.off { opacity: .25; }
.board { overflow-x: hidden; }

@media (max-width: 760px) {
  .tools { left: 10px; right: 10px; top: auto; bottom: 108px; max-width: none; justify-content: center; }
  .tools button { padding: 4px 7px 5px; font-size: 13.5px; }
  .tools .seg { margin-right: 4px; }
  .title { right: 10px; }
  .board { top: 100px; bottom: 150px; }
  .time-ev { bottom: 150px; }
}

/* ------------------------------------------------------------ the filter column */
/* Always there on a wide screen: under the search, down the left edge.
   Start and Houses open beside it rather than over it. */
@media (min-width: 761px) {
  .filters {
    position: fixed;
    left: 20px; top: 146px; bottom: 90px;
    width: 300px;
    overflow-y: auto;
    z-index: 14;
  }
  #b-filters { display: none; }
  .side { left: 330px; }
  .tree { left: 330px; max-width: min(700px, calc(100vw - 770px)); }
  .tree.big { max-width: calc(100vw - 770px); width: calc(100vw - 770px); }
  .start { padding: 8px 12px 12px; background: rgba(10, 13, 34, .92); border: 1px solid var(--gold-d); }
}
@media (max-width: 760px) {
  .filters {
    position: fixed;
    left: 10px; right: 10px; top: 100px; bottom: 150px;
    overflow-y: auto;
    z-index: 26;
  }
}


/* ================================================================ type and UI pass
   Cormorant Garamond (600) for the title and big names, where its contrast
   is a pleasure; Source Serif 4 for everything read small, which is most
   of the page, with real small caps for labels. Written last so it wins over
   the font shorthands above. */
body { font-family: var(--text); font-size: 16px; font-optical-sizing: auto; }
.title h1, .leaf h2, .kin-pair, .kin-verdict, .f-title, .story-head, .more-text b,
.tip b, .time-ev b, .time output b, .initial {
  font-family: var(--display);
  font-weight: 600;
}
.title h1 { letter-spacing: .005em; }
.leaf h2 { font-size: 27px; line-height: 1.05; }
.kin-verdict { font-size: 23px; }
.tip b { font-size: 19px; }

/* Everything that is a control or a list reads in the text face. */
button, input, select, .chip, .fchip, .act, .who, .house-btn, .find-name, .find input,
.tools button, .time button, .modes button, .trail .step, .reigns li span:first-child,
.tree .tn, .hour .tn, .life .lname, .thrones .rn, .thrones .sn, .chord .gn, .pl {
  font-family: var(--ui);
}
.chip, .fchip, .act, .tools button, .time button, .modes button { font-weight: 500; }
.find input { font-size: 16px; }
.chip { font-size: 15px; }
.fchip { font-size: 13.5px; }
.house-btn { font-size: 15px; }
.who { font-weight: 500; }
.reigns li span:first-child { font-weight: 500; }

/* Small caps: section labels, house names on the sphere, tabs. */
.hl, .start-label, .region, .f-label, .f-clear, .leaf-house, .family dt, .extract-head,
.trail-clear, .ptabs button, .thrones .hn, .hour .hlabel, .deep-eyebrow {
  font-family: var(--caps);
  font-variant-caps: all-small-caps;
  font-weight: 600;
  letter-spacing: .07em;
}
.hl { font-weight: 700; letter-spacing: .09em; }
.ptabs button { font-size: 14px; }
.family dt { font-size: 14px; line-height: 1.7; }

/* Labels on the sphere: heavier, so they stay sharp over the points. */
.pl { font-weight: 600; letter-spacing: .005em; }
.pl.lit, .pl.sel { font-style: normal; }
.pl.sel { font-weight: 700; }
.pl .role { font-weight: 400; font-style: italic; }

/* SVG text in the boards and panels. */
.tree .tn, .hour .tn { font-size: 12px; font-weight: 600; }
.tree .ty, .hour .ty, .life .lyears { font-family: var(--ui); }
.life .lname { font-size: 12px; font-weight: 500; }
.thrones .rn { font-size: 13.5px; font-weight: 600; }
.thrones .sn { font-size: 10px; font-weight: 600; }
.chord .gn { font-size: 13px; font-weight: 600; }

/* ---------------------------------------------------------------- scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(233, 196, 106, .4) transparent; }
.leaf, .leaf * { scrollbar-color: rgba(90, 67, 38, .45) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(233, 196, 106, .35);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(233, 196, 106, .6); }
::-webkit-scrollbar-corner { background: transparent; }
.leaf ::-webkit-scrollbar-thumb { background-color: rgba(90, 67, 38, .4); }

/* ---------------------------------------------------------------- the year slider */
.time input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
.time input[type=range]::-webkit-slider-runnable-track {
  height: 3px;
  background: linear-gradient(90deg, rgba(233, 196, 106, .25), rgba(233, 196, 106, .7));
}
.time input[type=range]::-moz-range-track { height: 3px; background: rgba(233, 196, 106, .45); }
.time input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  margin-top: -6.5px;
  background: var(--gold);
  border: 2px solid var(--space);
  outline: 1px solid var(--gold);
  transform: rotate(45deg);
  transition: transform .15s;
}
.time input[type=range]:hover::-webkit-slider-thumb { transform: rotate(45deg) scale(1.15); }
.time input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px;
  background: var(--gold);
  border: 2px solid var(--space);
  border-radius: 0;
  transform: rotate(45deg);
}
.time input[type=range]:focus-visible { outline: none; }
.time input[type=range]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--gold-hi); outline-offset: 2px; }

/* ---------------------------------------------------------------- controls */
button, .act, .chip, .fchip, .house-btn, .tools button { transition: background-color .12s, color .12s, border-color .12s; }
.f-check input, input[type=checkbox] { accent-color: var(--gold); width: 15px; height: 15px; }
.find input, .f-input { transition: border-color .12s, box-shadow .12s; }
.find input:focus, .f-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.f-input { font-family: var(--ui); font-size: 14px; }
.find input::placeholder, .f-input::placeholder { font-family: var(--ui); font-style: italic; }
.find-name { font-size: 15px; font-weight: 500; }
.leaf-close { font-family: var(--ui); font-weight: 400; }
.time .play { font-family: var(--ui); }
.time output { font-family: var(--ui); }
.time output b { font-size: 24px; }

/* Small caps sit at x-height, so the labels that use them need the size
   back. */
.f-label, .start-label, .region { font-size: 15.5px; }
.leaf-house, .extract-head { font-size: 15px; }
.f-clear, .trail-clear { font-size: 14px; }

.thrones .hn { font-size: 13px; }


/* ================================================================ phones: the drawer
   Everything below 761px. Top: title, search, the views. Bottom: the year,
   then the drawer with the panels behind tabs. The drawer's height is in
   --sheet-h, so whatever sits on it moves with it. */
.sheet { display: none; }
@media (max-width: 760px) {
  .title { left: 12px; top: 8px; right: 12px; }
  .title h1 { font-size: 21px; }
  .title p { display: none; }
  .find { left: 12px; right: 12px; top: 38px; width: auto; }
  .find input { padding: 7px 10px; font-size: 16px; }   /* 16px: iOS zooms smaller inputs */
  .tools { left: 12px; right: 12px; top: 84px; bottom: auto; max-width: none; display: flex; gap: 6px; justify-content: stretch; }
  .tools .seg { flex: 1; display: flex; margin: 0; }
  .tools .seg button { flex: 1; padding: 6px 2px 7px; font-size: 13.5px; }
  #b-start, #b-houses, #b-filters { display: none; }
  #b-reset { padding: 6px 8px 7px; font-size: 13.5px; }
  .trail { top: 122px; left: 12px; right: 12px; max-width: none; transform: none; font-size: 14px; }
  .credit { display: none; }

  .time { left: 10px; right: 10px; bottom: calc(var(--sheet-h, 88px) + 6px); transition: bottom .22s; }
  .time-ev { bottom: calc(var(--sheet-h, 88px) + 50px); width: calc(100vw - 24px); transition: bottom .22s; }
  .time-ev p { font-size: 13px; }
  .time-ev p:nth-child(2) { display: none; }
  .board { top: 122px; bottom: calc(var(--sheet-h, 88px) + 50px); left: 0 !important; right: 0 !important; }
  .kinbar { margin-top: 4px; }
  .tree { display: none !important; }

  .sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: 88px;
    z-index: 30;
    background: rgba(9, 12, 32, .97);
    border-top: 1px solid var(--gold-d);
    box-shadow: 0 -1px 0 var(--space), 0 -2px 0 rgba(233, 196, 106, .25);
    transition: height .22s ease-out;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sheet[hidden] { display: none !important; }
  .sheet.dragging, .sheet.dragging ~ .time { transition: none; }
  .sheet-grip { flex: 0 0 auto; height: 22px; display: grid; place-items: center; touch-action: none; cursor: grab; }
  .sheet-grip span { width: 44px; height: 4px; border-radius: 2px; background: var(--gold-d); }
  .sheet-tabs { flex: 0 0 auto; display: flex; padding: 0 10px 8px; gap: 0; }
  .sheet-tabs button {
    flex: 1;
    min-width: 0;
    padding: 8px 4px 9px;
    font: 600 14px var(--ui);
    color: var(--gold);
    background: transparent;
    border: 1px solid var(--gold-d);
    margin-right: -1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .sheet-tabs button[data-sheet="person"] { flex: 1.6; }
  .sheet-tabs button[aria-pressed="true"] { background: var(--gold); color: var(--space); }
  .sheet[data-size="peek"] .sheet-tabs button[aria-pressed="true"] { background: rgba(233, 196, 106, .18); color: var(--gold-hi); }
  .sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .sheet[data-size="peek"] .sheet-body { visibility: hidden; }
  .sheet-empty { margin: 18px 16px; font-style: italic; color: var(--mist); }

  /* Panels inside the drawer: no floating, no frames of their own; only the
     chosen tab shows. */
  .sheet-body > .leaf, .sheet-body > .filters, .sheet-body > .houses, .sheet-body > .start {
    position: static !important;
    inset: auto !important;
    width: auto !important;
    max-height: none !important;
    margin: 0;
    outline: 0;
    box-shadow: none;
    border: 0;
    display: none !important;
  }
  .sheet-body > .in-sheet-on { display: block !important; }
  .sheet-body > .start, .sheet-body > .houses, .sheet-body > .filters { padding: 4px 14px 16px; background: none; }
  .sheet-body > .leaf { background: var(--vellum); }
  .sheet-body > .leaf .leaf-body { overflow: visible; padding: 16px 16px 24px; }
  .sheet-body > .leaf .leaf-close { position: absolute; right: 8px; top: 6px; }
  .sheet-body > .leaf { position: relative !important; }
  .portrait img { max-height: 220px; }

  /* Bigger targets for fingers. */
  .chip { padding: 7px 11px 8px; font-size: 15px; }
  .fchip { padding: 6px 10px 7px; font-size: 14px; }
  .house-btn { padding: 8px 4px; font-size: 16px; }
  .who { padding: 3px 0; }
  .modes button { padding: 8px 12px 9px; }
  .act { padding: 9px 13px 10px; }
  .time .play { width: 44px; height: 38px; }
  .time input[type=range] { height: 32px; }
  .time input[type=range]::-webkit-slider-thumb { width: 20px; height: 20px; margin-top: -8.5px; }
  .tree-in-leaf { margin: 12px -6px; }
  .tree-in-leaf .pbody { max-height: 60vh; overflow: auto; }
}

@media (max-width: 760px) {
  .tools #b-reset { display: block; flex: 0 0 auto; }
}

/* Phones: one cheap shadow on the names, which repaint as the sphere turns. */
@media (pointer: coarse), (max-width: 760px) {
  .labels > div { text-shadow: 0 0 4px var(--space); }
}
.labels.moving .pl { visibility: hidden; }
