/* Reels Studio — dark. Warm near-black, cream text, brass accent.
   Display face is a high-contrast Didone to echo the reference; everything else
   is the system sans so nothing is fetched from the network. */

:root {
  --bg:        #100e0b;
  --bg-2:      #17140f;
  --surface:   #1c1813;
  --surface-2: #221d17;
  --line:      rgba(238, 227, 205, 0.10);
  --line-2:    rgba(238, 227, 205, 0.18);
  --ink:       #f0e9db;
  --ink-2:     #c8bfae;
  --muted:     #8d8474;
  --brass:     #d9bc7e;
  --brass-dim: #97835a;
  --green:     #8fc98a;
  --red:       #e08a72;
  --blue:      #8fb4d9;
  --radius:    22px;
  --serif: "Bodoni 72", Didot, "Playfair Display", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 32px; }
.wrap-wide { max-width: 1320px; margin: 0 auto; padding: 0 32px; }
/* the lineage builder wants every pixel it can get: the canvas is the work */
.wrap-widest { max-width: 1920px; margin: 0 auto; padding: 0 24px; }

/* ---------- lineage builder: the canvas is the page ----------
   Both flanks are shut until something is selected, so the resting state is
   the map at full width. Opening one takes space rather than floating over the
   canvas — a panel covering the thing you just clicked is the one place it
   must not be. */

.build {
  display: flex; align-items: stretch; margin-top: 22px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
  padding: 16px; gap: 16px; min-height: 340px;
}
.build-canvas { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.build-canvas #graph { flex: 1 1 auto; display: flex; }
.build-canvas .mapwrap { flex: 1 1 auto; border: 0; background: none; padding: 0; }

/* the left flank: the editor for whatever you clicked */
.build-edit {
  flex: 0 0 356px; min-width: 0; overflow-y: auto; max-height: 84vh;
  border-right: 1px solid var(--line); padding-right: 16px;
}
.build-edit[hidden] { display: none; }
.build-edit-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.build-edit-head h3 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; min-width: 0; }
.build-edit-close {
  border: 1px solid var(--line-2); background: none; color: var(--muted);
  border-radius: 8px; cursor: pointer; font-size: 14px; line-height: 1;
  padding: 5px 8px; flex: none;
}
.build-edit-close:hover { color: var(--brass); border-color: var(--brass-dim); }

@media (max-width: 1180px) {
  .build { flex-direction: column; }
  .build-edit { flex: none; width: 100%; border-right: 0;
                border-bottom: 1px solid var(--line); padding: 0 0 16px; max-height: none; }
}


/* ---------- nav ---------- */

.nav {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 28px;
  padding: 16px 32px;
  background: rgba(16, 14, 11, 0.86);
  backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; font-family: var(--serif); font-size: 21px; letter-spacing: .2px; }
.mark {
  width: 34px; height: 34px; border-radius: 9px; flex: none;
  background: linear-gradient(150deg, #f0dcae, #c9a765 60%, #8f7a44);
  display: grid; place-items: center;
  color: #22190c; font-size: 16px; font-weight: 700;
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
.nav-links { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav-links a {
  padding: 8px 16px; border-radius: 999px; font-size: 14.5px; color: var(--ink-2);
  transition: background .15s, color .15s;
}
.nav-links a:hover { background: var(--surface); color: var(--ink); }
.nav-links a.on { background: var(--surface-2); color: var(--ink); }

/* ---------- hero ---------- */

.hero { position: relative; text-align: center; padding: 92px 0 56px; overflow: hidden; }
.hero .display { margin: 0 auto; max-width: 15ch; }
.display {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(46px, 7.4vw, 92px);
  line-height: 1.02;
  letter-spacing: -0.5px;
  margin: 0 0 22px;
}
.lede { max-width: 60ch; margin: 0 auto; color: var(--ink-2); font-size: 17px; }
.hero-mark {
  width: 62px; height: 62px; border-radius: 16px; margin: 0 auto 34px;
  background: linear-gradient(150deg, #f4e3ba, #cba969 58%, #8a7440);
  display: grid; place-items: center; font-size: 27px;
  box-shadow: 0 10px 34px rgba(0,0,0,.55);
}

/* scattered coins, echoing the reference art — pure CSS, no assets */
.coin {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 34% 30%, #4a4238, #2a251e 62%, #191510);
  border: 1px solid rgba(238,227,205,.14);
  opacity: .55;
}
.coin::after {
  content: ""; position: absolute; inset: 16%; border-radius: 50%;
  border: 1px dashed rgba(238,227,205,.13);
}
/* namespaced: bare .c1-.c6 collided with other components' modifier classes */
.coin-1 { width: 54px; height: 54px; left: 6%;  top: 22%; }
.coin-2 { width: 82px; height: 82px; left: 2%;  top: 56%; opacity: .4; }
.coin-3 { width: 66px; height: 66px; right: 7%; top: 18%; }
.coin-4 { width: 44px; height: 44px; right: 3%; top: 50%; opacity: .45; }
.coin-5 { width: 30px; height: 30px; right: 13%; top: 74%; opacity: .3; }
.coin-6 { width: 36px; height: 36px; left: 13%; top: 78%; opacity: .32; }

/* ---------- surfaces ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}
.card-tan {
  background: linear-gradient(158deg, #d9c396, #bda36f);
  color: #241c0e; border: none;
}
.card-ink { background: #14181f; border-color: rgba(200,220,255,.09); }

.section-head {
  display: flex; align-items: baseline; gap: 14px; margin: 0 0 18px;
}
.section-head h2 {
  font-family: var(--serif); font-weight: 400; font-size: 30px; margin: 0;
  letter-spacing: -.2px;
}
.section-head .count { color: var(--muted); font-size: 14px; }

h3.sub { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 0 0 12px; }

/* ---------- form ---------- */

.form-grid { display: grid; gap: 20px; }
.row { display: grid; gap: 20px; grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .row { grid-template-columns: 1fr; } }

label.lbl {
  display: block; font-size: 12.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px; font-weight: 600;
}
input[type=text], input[type=number], input[type=url], input[type=date],
select, textarea {
  width: 100%; padding: 13px 15px;
  background: var(--bg-2); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 13px;
  font-family: var(--sans); font-size: 15.5px;
  transition: border-color .15s, box-shadow .15s;
}
/* a date input is a native control that ignores `color`, so its picker icon
   comes out near-black on a dark field and is invisible until you hit it */
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(.72); cursor: pointer; }
input[type=date]:not(:focus):invalid { color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(217,188,126,.15);
}
select { appearance: none; background-image:
  linear-gradient(45deg, transparent 50%, var(--muted) 50%),
  linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 22px, calc(100% - 15px) 22px;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.hint { color: var(--muted); font-size: 13px; margin-top: 7px; }

.drop {
  border: 1.5px dashed var(--line-2); border-radius: 16px;
  padding: 30px; text-align: center; cursor: pointer;
  background: var(--bg-2); transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--brass); background: #1e1a14; }
.drop .big { font-family: var(--serif); font-size: 20px; }
.drop .small { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.drop.has { border-style: solid; border-color: var(--brass-dim); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 14px 30px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--ink);
  font-family: var(--sans); font-size: 15px; font-weight: 600; cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s;
}
.btn:hover { background: #2a2419; border-color: var(--brass-dim); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(160deg, #f0dcae, #cdab6a);
  color: #201808; border: none; font-weight: 700;
}
.btn-primary:hover { background: linear-gradient(160deg, #f7e6bd, #d8b675); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-sm { padding: 9px 18px; font-size: 13.5px; }

details.adv { margin-top: 4px; }
details.adv > summary {
  cursor: pointer; color: var(--muted); font-size: 14px; list-style: none;
  padding: 9px 0; user-select: none;
}
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::before { content: "›"; display: inline-block; margin-right: 9px; }
details.adv[open] > summary::before { content: "⌄"; }
details.adv > summary:hover { color: var(--ink-2); }

/* ---------- progress ---------- */

.stages { display: grid; gap: 2px; margin: 4px 0 22px; }
.stage {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-radius: 12px; transition: background .2s;
}
.stage .dot {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--line-2); display: grid; place-items: center;
  font-size: 11px; color: var(--muted);
}
.stage .nm { font-size: 15px; color: var(--muted); }
.stage.done .dot { background: var(--brass); border-color: var(--brass); color: #201808; }
.stage.done .nm { color: var(--ink-2); }
.stage.active { background: var(--surface-2); }
.stage.active .dot { border-color: var(--brass); color: var(--brass); animation: pulse 1.6s ease-in-out infinite; }
.stage.active .nm { color: var(--ink); font-weight: 600; }
.stage.error .dot { border-color: var(--red); color: var(--red); }
.stage.error .nm { color: var(--red); }
.stage .side { margin-left: auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.bar { height: 7px; border-radius: 999px; background: var(--bg-2); overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #b7935120, var(--brass)); transition: width .5s ease; }
.bar-row { display: flex; align-items: center; gap: 16px; }
.bar-row .pct { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--ink-2); min-width: 46px; text-align: right; }

.logbox {
  margin-top: 18px; background: #0c0a08; border: 1px solid var(--line);
  border-radius: 13px; padding: 15px 17px; max-height: 220px; overflow: auto;
  font-family: var(--mono); font-size: 12.2px; line-height: 1.65; color: var(--muted);
  white-space: pre-wrap; word-break: break-word;
}

.note { border-radius: 14px; padding: 15px 18px; font-size: 14.5px; border: 1px solid; }
.note-warn { background: rgba(224,138,114,.07); border-color: rgba(224,138,114,.3); color: #f0b6a2; }
.note-err  { background: rgba(224,138,114,.11); border-color: rgba(224,138,114,.45); color: #f3ab93; }
.note-ok   { background: rgba(143,201,138,.07); border-color: rgba(143,201,138,.28); color: #a9d9a4; }
.note ul { margin: 8px 0 0; padding-left: 20px; }
.note li { margin: 3px 0; }

/* ---------- stats ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 17px; padding: 20px 22px; }
.stat .n { font-family: var(--serif); font-size: 34px; line-height: 1.1; }
.stat .k { color: var(--muted); font-size: 12.5px; letter-spacing: .07em; text-transform: uppercase; margin-top: 5px; }
.stat.gold { background: linear-gradient(158deg, #d9c396, #bda36f); border: none; color: #221a0c; }
.stat.gold .k { color: #5b4a24; }

/* ---------- run cards ---------- */

.run-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.run-card {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 24px; transition: transform .14s, border-color .14s, background .14s;
}
.run-card:hover { transform: translateY(-3px); border-color: var(--brass-dim); background: var(--surface-2); }
.run-card .rl { display: flex; align-items: baseline; gap: 12px; }
.run-card h3 { font-family: var(--serif); font-weight: 400; font-size: 25px; margin: 0;
               flex: 1; min-width: 0; }
.run-card .when { color: var(--muted); font-size: 13px; flex: none; white-space: nowrap; }
.run-card .niche { color: var(--brass); font-size: 14px; margin: 6px 0 16px; }
.run-card .facts { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: 12.5px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.chip.gold { background: rgba(217,188,126,.13); border-color: rgba(217,188,126,.32); color: var(--brass); }
.chip.dim { color: var(--muted); }
.chip.warn { background: rgba(224,138,114,.12); border-color: rgba(224,138,114,.38); color: var(--red); }

.badge {
  display: inline-block; padding: 4px 11px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
.b-valid { background: rgba(143,201,138,.15); color: var(--green); }
.b-excluded { background: rgba(224,138,114,.13); color: var(--red); }
.b-dead { background: rgba(224,138,114,.2); color: var(--red); }
.b-conditional { background: rgba(217,188,126,.15); color: var(--brass); }
.b-portable { background: rgba(143,180,217,.15); color: var(--blue); }
.b-other { background: var(--surface-2); color: var(--muted); }

/* ---------- tabs ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 30px 0 26px; flex-wrap: wrap; }
.tab {
  padding: 11px 18px; border-radius: 11px 11px 0 0; cursor: pointer;
  color: var(--muted); font-size: 14.5px; border-bottom: 2px solid transparent;
  margin-bottom: -1px; background: none; border-top: none; border-left: none; border-right: none;
  font-family: var(--sans);
}
.tab:hover { color: var(--ink-2); }
.tab.on { color: var(--ink); border-bottom-color: var(--brass); font-weight: 600; }
.pane { display: none; }
.pane.on { display: block; }

/* ---------- candidate / source blocks ---------- */

.cand {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px 28px; margin-bottom: 18px;
}
.cand.valid { border-left: 3px solid var(--green); }
.cand.dead, .cand.excluded { border-left: 3px solid rgba(224,138,114,.5); }
.cand.conditional { border-left: 3px solid var(--brass); }
.cand-top { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 6px; }
.cand-n {
  font-family: var(--serif); font-size: 30px; color: var(--brass-dim);
  line-height: 1; flex: none; min-width: 42px;
}
.cand h3 {
  font-family: var(--serif); font-weight: 400; font-size: 25px; line-height: 1.25;
  margin: 0; flex: 1; letter-spacing: -.1px;
}
.cand .meta { color: var(--muted); font-size: 13.5px; margin: 2px 0 18px 58px; }
@media (max-width: 700px) { .cand .meta { margin-left: 0; } }

.kv { display: grid; grid-template-columns: 190px 1fr; gap: 3px 22px; }
@media (max-width: 700px) { .kv { grid-template-columns: 1fr; gap: 1px; } }
.kv dt {
  color: var(--muted); font-size: 12.5px; letter-spacing: .06em;
  text-transform: uppercase; padding: 9px 0; font-weight: 600;
}
.kv dd { margin: 0; padding: 9px 0; font-size: 15px; color: var(--ink-2); border-bottom: 1px solid var(--line); }
.kv dd:last-child { border-bottom: none; }
.kv dd a { color: var(--brass); text-decoration: underline; text-underline-offset: 2px; }
.prose { color: var(--muted); font-size: 14.5px; margin-top: 14px; font-style: italic; }

/* ---------- verdict capture ---------- */

.judge { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.judge-bar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.judge-lbl {
  font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; margin-right: 5px;
}
.jbtn {
  padding: 7px 16px; border-radius: 999px; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--ink-2);
  font-family: var(--sans); font-size: 13.5px; transition: all .14s;
}
.jbtn:hover { border-color: var(--brass-dim); color: var(--ink); }
.j-clear { color: var(--muted); }
.judge[data-verdict="keep"] .j-keep {
  background: rgba(143,201,138,.16); border-color: rgba(143,201,138,.45); color: var(--green);
  font-weight: 700;
}
.judge[data-verdict="reject"] .j-reject {
  background: rgba(224,138,114,.16); border-color: rgba(224,138,114,.45); color: var(--red);
  font-weight: 700;
}
.judge-state { font-size: 13px; color: var(--muted); margin-left: auto; }
.judge-state.saved { color: var(--green); }
.judge-state.err { color: var(--red); }

.judge-form { display: none; margin-top: 16px; }
.judge-form.open { display: block; }
.judge-classes { display: grid; gap: 8px; margin-bottom: 14px; }
.jclass {
  display: flex; gap: 11px; align-items: flex-start; cursor: pointer;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 13px;
  background: var(--bg-2); transition: border-color .14s, background .14s;
}
.jclass:hover { border-color: var(--brass-dim); }
.jclass input { margin-top: 3px; accent-color: var(--brass); flex: none; }
.jclass span { display: block; font-size: 14px; }
.jclass strong { display: block; color: var(--ink); font-weight: 600; }
.jclass em { display: block; color: var(--muted); font-style: normal; font-size: 13px; margin-top: 3px; }
.jclass:has(input:checked) { border-color: var(--brass); background: var(--surface-2); }
.judge-reason { width: 100%; resize: vertical; font-size: 14.5px; }
.judge-actions { display: flex; gap: 10px; margin-top: 13px; }

.judged-note {
  display: block; width: 100%;
  margin-top: 12px; font-size: 14px; color: var(--ink-2);
  padding: 11px 15px; border-radius: 11px; background: var(--bg-2);
  border-left: 3px solid var(--line-2);
}
/* keyed off a data attribute, not a class, so no other component's
   modifier (.c1 …) can ever match it */
.judged-note[data-keep] { border-left-color: var(--green); }
.judged-note[data-class="1"] { border-left-color: var(--red); }
.judged-note[data-class="2"] { border-left-color: var(--brass); }
.judged-note[data-class="3"] { border-left-color: var(--blue); }
.judged-note .k { color: var(--muted); font-size: 12px; letter-spacing: .06em;
                  text-transform: uppercase; display: block; margin-bottom: 4px; }

/* ---------- lineage map ----------
   A bounded canvas. The pan/zoom transform lives on one <g> inside the svg, so
   nothing here knows the current view — this is only the frame around it. */

.mapwrap {
  position: relative; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); padding: 6px; overflow: hidden;
  display: flex; gap: 6px; align-items: stretch;
}
/* the canvas and its overlaid controls; the panel is its sibling, not on top */
.map-stage { position: relative; flex: 1 1 auto; min-width: 0; }
/* A DEFINITE HEIGHT, not one derived from the drawing. `height: auto` on an
   svg is computed from the viewBox aspect, so the frame's proportions were a
   function of the graph inside it — a wide lineage produced a short strip of a
   canvas. It also makes the viewBox unsyncable: set it from the measured box
   and the height recomputes from the new aspect, and round it goes. */
.mapwrap .linmap {
  display: block; height: 76vh; min-height: 400px; cursor: default;
  /* the drag is ours: without this a touch drag scrolls the page instead */
  touch-action: none; user-select: none;
}
/* only the HAND tool grabs. Select is an arrow, the way a pointer tool is
   everywhere else — you can still drag a node, but the canvas stops
   advertising itself as draggable when clicking is what you are there to do. */
.mapwrap.dragging .linmap { cursor: grabbing; }
.mapwrap:not(.panmode) .lin-node { cursor: default; }
.mapwrap:not(.panmode) .lin-node:active { cursor: grabbing; }
.mapwrap:not(.panmode) .lin-hull > rect { cursor: default; }
.mapwrap:not(.panmode) .lin-hit { cursor: pointer; }
/* Full screen is not decoration. Inline, a plain wheel has to keep scrolling
   the page or the map becomes a scroll trap; with no page behind it, the wheel
   is free to zoom. */
.mapwrap.full {
  position: fixed; inset: 0; z-index: 80; border-radius: 0; padding: 20px 20px 44px;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
}
/* Fill the screen rather than keeping the inline aspect: with height:auto the
   map was sized by its WIDTH alone and left two thirds of a 900px screen empty.
   preserveAspectRatio is `meet`, so filling the box fits the whole graph inside
   it — a taller lineage gets the height, and nothing is ever cropped. */
.mapwrap.full .map-stage {
  height: 100%; display: flex; flex-direction: column; justify-content: center;
}
.mapwrap.full .linmap {
  width: 100%; height: 100%; max-width: 100%; max-height: none;
}

/* ---------- the notes panel ----------
   Everything written about a video or a group lives here rather than on the
   map, which stopped being readable at about six videos once every note was
   printed next to its thumbnail. */

.map-side {
  flex: 0 0 258px; border-left: 1px solid var(--line); padding: 2px 4px 2px 16px;
  overflow-y: auto; max-height: 84vh;
}
.map-side[hidden] { display: none; }
.mapwrap.full .map-side { max-height: none; }
.map-card { display: none; }
.map-card.on { display: block; }
.map-card h4 {
  margin: 0 0 6px; font-size: 15px; font-weight: 600; color: var(--ink);
  line-height: 1.35;
}
.map-meta { margin: 0 0 2px; font-size: 12.5px; color: var(--muted); }
.map-note { margin: 4px 0 0; font-size: 14px; color: var(--ink-2); }
.map-note.gold { color: var(--brass); }
.map-watch { font-size: 13.5px; color: var(--brass); border-bottom: 1px solid var(--line-2); }
.map-watch:hover { border-color: var(--brass); }
.map-members { list-style: none; margin: 6px 0 0; padding: 0; }
.map-members button {
  background: none; border: 0; padding: 3px 0; text-align: left; cursor: pointer;
  color: var(--ink-2); font-size: 13px; font-family: inherit;
}
.map-members button:hover { color: var(--brass); }

/* selection, so you can see what the panel is describing */
.lin-node.sel rect[fill="none"] { stroke: var(--brass); stroke-width: 3; }
/* a disc is ringed by a circle, not a rect, so selecting a channel showed
   nothing at all — which is unreadable now that selecting one lights its videos */
.lin-node.sel circle[fill="none"] { stroke: var(--brass); stroke-width: 3.5; }
/* "this account made these" — a membership, so it reads as a different colour
   from every ancestry cue on the map. After .sel, because a selected video that
   happens to belong to the selected account is still the selected one.
   Deliberately heavy: nothing dims to make these stand out, so the border is
   the whole signal and 1px of blue among two dozen thumbnails is not one. */
.lin-node.by-account .lin-frame { stroke: var(--blue); stroke-width: 4; }
.lin-hull.sel > rect { stroke: var(--brass); fill: rgba(217,188,126,.07); }
.lin-hit { cursor: pointer; }
/* "there is something written on this arrow" — the words are in the panel */
.lin-dot { pointer-events: none; }
.lin-edge.sel .lin-dot, .lin-glink.sel .lin-dot { r: 6; }
.lin-edge.sel .lin-line { stroke: var(--brass); stroke-width: 3.4; opacity: 1; }
.lin-glink.sel .lin-gline { stroke-width: 5; opacity: 1; }
.lin-edge:hover .lin-line { stroke: var(--brass); }
.lin-glink:hover .lin-gline { stroke-width: 4.2; }
.lin-ctx .lin-gline { stroke: var(--blue); }
.lin-ctx:hover .lin-gline, .lin-ctx.sel .lin-gline { stroke-width: 3; opacity: 1; }

@media (max-width: 900px) {
  .mapwrap { flex-direction: column; }
  .map-side { flex: none; border-left: 0; border-top: 1px solid var(--line);
              padding: 14px 4px 4px; max-height: none; }
}

.map-tools { position: absolute; top: 12px; right: 12px; z-index: 2; display: flex; gap: 6px; }
.map-btn {
  min-width: 30px; height: 30px; padding: 0 9px; border-radius: 9px;
  border: 1px solid var(--line-2); background: rgba(16,14,11,.82); color: var(--ink-2);
  font-family: var(--mono); font-size: 13px; cursor: pointer; line-height: 1;
}
.map-btn:hover { border-color: var(--brass-dim); color: var(--brass); }
.map-hint { position: absolute; left: 14px; bottom: 8px; z-index: 2; margin: 0;
            font-size: 12px; color: var(--muted); pointer-events: none; }

.lin-node:hover .lin-play { opacity: 1; }
.lin-play { transition: opacity .12s; }
/* ---------- "came from": chosen ancestors, then a searchable picker ---------- */

/* one row per video, the editor only for the one you opened */
.pick-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 12px; margin-bottom: 6px; border-radius: 11px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink-2);
  font-family: inherit; font-size: 13.5px;
}
.pick-row:hover { border-color: var(--brass-dim); color: var(--ink); }
.pick-row.on {
  border-color: var(--brass); background: rgba(217,188,126,.09); color: var(--ink);
  margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0;
}
.pick-row-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
              white-space: nowrap; }
.pick-row-m { flex: none; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.pick-row.on + .node {
  border-top-left-radius: 0; border-top-right-radius: 0; border-top: 0;
  margin-bottom: 8px;
}

.anc {
  border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 12px;
  background: var(--surface); margin-bottom: 8px;
}
/* a group arrow reads red everywhere else, so it reads red here too */
.anc-red { border-color: rgba(224,138,114,.35); background: rgba(224,138,114,.05); }
.anc-red .anc-title { color: var(--red); }
/* a CONTEXT tie asserts nothing, so it reads as neither of the other two —
   blue, the colour an account's own videos already take on the map */
.anc-ctx { border-color: rgba(143,180,217,.32); background: rgba(143,180,217,.05); }
.anc-ctx .anc-title { color: var(--blue); }
.anc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.anc-title { font-size: 14px; color: var(--ink); flex: 1; min-width: 0; }
.anc-drop {
  flex: none; border: 0; background: none; color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 2px 4px;
}
.anc-drop:hover { color: var(--red); }
.anc .linkfield { margin-bottom: 6px; }
.anc .linkfield:last-child { margin-bottom: 0; }
/* the coded move: a read-out of what is set, and the way through to the arrow's
   own card where it is set. Quiet until it holds something. */
.anc-move {
  display: block; width: 100%; text-align: left; margin-top: 8px;
  border: 1px dashed var(--line-2); border-radius: 9px; background: none;
  color: var(--muted); cursor: pointer; padding: 6px 9px;
  font-family: var(--mono); font-size: 11.5px;
}
.anc-move:hover { color: var(--brass); border-color: rgba(217,188,126,.4); }
/* the one checkbox on the arrow card — a stitch/react/duet, where the source is
   physically inside the derivative */
.movecheck {
  display: flex; align-items: flex-start; gap: 9px; margin-top: 10px;
  font-size: 14px; color: var(--ink-2); cursor: pointer; line-height: 1.4;
}
.movecheck input { width: auto; flex: none; margin-top: 2px; accent-color: var(--brass); }
.anc-add { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }

/* The cross-canvas tally. An empty cell has to read as "never encoded" rather
   than as a zero, so it is left blank and unshaded — only cells with something
   in them get a surface. */
.tally { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
.tally th, .tally td {
  border: 1px solid var(--line); padding: 8px 10px; text-align: left;
  vertical-align: top;
}
.tally thead th {
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  font-weight: 600; white-space: nowrap;
}
.tally tbody th {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-2);
  font-weight: 600; white-space: nowrap;
}
.tally td.on { background: rgba(238,227,205,.03); }
.tally .n { font-size: 19px; color: var(--brass); line-height: 1.1; }
.tally .ch { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.tally .ch .chip { font-size: 10.5px; padding: 1px 6px; }
.tally .tot, .tally tr.tot td, .tally tr.tot th {
  background: rgba(238,227,205,.05); color: var(--ink);
}
.tally .dim { color: var(--muted); }
.tally td.bad { color: var(--red); font-weight: 600; }
.tally.slim { margin-top: 8px; }
.tally.slim th, .tally.slim td { border: 0; border-bottom: 1px solid var(--line); }
.tally.rows td { font-size: 13px; }
.tally .warnrow { color: var(--red); font-size: 12px; border-top: 0; }

/* ---------- lineage folders ----------
   One per group, so the picked column is filed rather than piled. */

.folder { border: 1px solid var(--line); border-radius: 16px; background: var(--bg-2);
          margin-bottom: 12px; overflow: hidden; }
.folder[open] { border-color: var(--line-2); }
.folder-head {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 12px 15px; list-style: none; user-select: none;
}
.folder-head::-webkit-details-marker { display: none; }
.folder-head::before {
  content: "▸"; color: var(--brass-dim); font-size: 12px; transition: transform .12s;
}
.folder[open] > .folder-head::before { transform: rotate(90deg); }
.folder-head:hover { background: var(--surface); }
/* the name takes the slack; the badges never squeeze into circles */
.folder-name { font-size: 15px; color: var(--ink); flex: 1 1 auto; min-width: 0; }
.folder-count, .folder-head .chip, .folder-head .btn { flex: none; white-space: nowrap; }
/* Autosave state. `err` is deliberately loud: a canvas that looks saved and is
   not is the one failure autosaving would make worse than no autosaving. */
.autosave {
  font-family: var(--mono); font-size: 11.5px; padding: 4px 9px;
  border-radius: 8px; white-space: nowrap;
}
.autosave.idle { color: var(--muted); }
.autosave.busy { color: var(--brass-dim); }
.autosave.ok   { color: var(--brass); background: rgba(217,188,126,.10); }
.autosave.err  { color: var(--red); background: rgba(224,138,114,.14); font-weight: 600; }

/* rename, right beside the name it renames. Quiet until you go near it. */
.folder-edit {
  flex: none; border: 0; background: none; cursor: pointer; padding: 2px 5px;
  color: var(--muted); font-size: 13px; line-height: 1; border-radius: 6px;
}
.folder-edit:hover { color: var(--brass); background: rgba(217,188,126,.12); }
.folder-count {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  border: 1px solid var(--line-2); border-radius: 20px; padding: 1px 9px;
}
.folder-body { padding: 0 12px 12px; }
.folder-body > .node { margin-bottom: 12px; }
.folder-body > .node:last-child { margin-bottom: 0; }

/* the hand tool: the whole surface becomes a pan, so nothing looks grabbable */
/* dragging a link in from another tab — the whole builder is the target, not
   just the svg, because aiming at a canvas you are also panning is fussy */
.build.dropping { outline: 2px dashed var(--brass); outline-offset: 6px; }
.build.dropping::after {
  content: "drop to add it to the canvas";
  position: absolute; inset: auto 0 12px 0; text-align: center;
  color: var(--brass); font-size: 13px; pointer-events: none;
}
.build { position: relative; }

.lin-grid { pointer-events: none; }

/* STEPPING THROUGH ONE NODE'S ANCESTORS. Two arrows into one video are two
   separate claims, and "which of these am I reading" is otherwise a question
   you answer by tracing lines with your eye. Dimming rather than hiding: the
   others stay as context, because the point of the comparison is that they
   share a target. */
.linmap.isolating .lin-edge { opacity: .13; transition: opacity .12s; }
.linmap.isolating .lin-edge.isolated { opacity: 1; }
.linmap.isolating .lin-edge.isolated .lin-line {
  stroke: var(--brass); stroke-width: 3.5;
}
.linmap.isolating .lin-node { opacity: .5; transition: opacity .12s; }
.linmap.isolating .lin-node.isolated { opacity: 1; }
.linmap.isolating .lin-node.isolated .lin-frame {
  stroke: var(--brass); stroke-width: 3;
}
.map-btn.on { color: var(--brass); border-color: var(--brass-dim); }

/* shift-drag to link. The source is held, everything else is offered, and the
   one under the cursor is the target — a claim about two videos should not
   come down to guessing which one you are over. */
.lin-node.linksrc .lin-frame { stroke: var(--brass); stroke-width: 3.5; }
.lin-node.linkable { opacity: .78; }
.lin-node.linkover { opacity: 1; }
.lin-node.linkover .lin-frame { stroke: var(--brass); stroke-width: 4; }
.lin-node.linkover circle[fill="none"] { stroke: var(--brass); stroke-width: 4; }
.mapwrap.linking .linmap { cursor: crosshair; }

.mapwrap.panmode .linmap { cursor: grab; }
.mapwrap.panmode .linmap:active { cursor: grabbing; }
.mapwrap.panmode .lin-node,
.mapwrap.panmode .lin-hull > rect,
.mapwrap.panmode .lin-hit { cursor: grab; }
.mapwrap.panmode .lin-play { display: none; }
.map-btn.on { color: var(--brass); border-color: var(--brass-dim); }
.map-sep { display: inline-block; width: 1px; height: 18px; margin: 0 4px;
           background: var(--line-2); vertical-align: middle; }

.lin-node { cursor: grab; }
.lin-node.grabbing { cursor: grabbing; }
.lin-node.grabbing .lin-play { opacity: 0; }
/* the empty space inside a group is the handle for the whole group */
.lin-hull > rect { cursor: grab; }
.lin-hull.grabbing > rect { cursor: grabbing; }
.lin-hull:hover > rect { stroke: var(--brass-dim); }
/* Hovering a video picks out its own arrows, so a node feeding three
   descendants reads as three arrows and not as noise.

   It did this by dimming everything else to 16%, and that was the wrong half
   to act on: the canvas went black on the way to every click, since you cannot
   click a thumbnail without first being over it. The arrows come up instead,
   and nothing has to go dark to produce it.

   WEIGHT ONLY, never colour. An arrow's colour is a ruling — red for one that
   runs backwards in time, grey-dashed for one the gate killed — so lighting a
   dead link brass would make a failed gate look like a passed one, which is
   the one inversion this map must never draw.

   The nodes at the far end are deliberately left ALONE. Restyling them fights
   the account highlight, which is a blue border on the same frame — and a
   hover erasing the answer to "which of these did that channel make" is worse
   than not marking the far end at all. The arrow points there anyway. */
.lin-edge.lit .lin-line { stroke-width: 4; }
.lin-edge.lit .lin-dot { r: 6; }

/* ---------- table ---------- */

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; padding: 13px 16px; color: var(--muted); font-weight: 600;
  font-size: 12px; letter-spacing: .07em; text-transform: uppercase;
  border-bottom: 1px solid var(--line-2); white-space: nowrap; position: sticky; top: 0;
  background: var(--surface-2);
}
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--surface-2); }
table.data td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.mult { color: var(--brass); font-weight: 700; font-variant-numeric: tabular-nums; }
.cell-clip { display: block; max-width: 380px; overflow: hidden; text-overflow: ellipsis;
             display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }

pre.md {
  background: #0c0a08; border: 1px solid var(--line); border-radius: 16px;
  padding: 24px; overflow: auto; font-family: var(--mono); font-size: 12.8px;
  line-height: 1.75; color: var(--ink-2); white-space: pre-wrap; word-break: break-word;
}

.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty .display { font-size: 34px; color: var(--ink-2); }

.filebar { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 8px; }
.filebar a {
  padding: 8px 15px; border-radius: 999px; background: var(--bg-2);
  border: 1px solid var(--line); font-size: 13px; color: var(--ink-2);
  font-family: var(--mono);
}
.filebar a:hover { border-color: var(--brass-dim); color: var(--brass); }

.pagehead { padding: 46px 0 8px; }
.pagehead .back { color: var(--muted); font-size: 14px; }
.pagehead .back:hover { color: var(--brass); }
.pagehead h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(38px, 5vw, 58px); margin: 12px 0 6px; letter-spacing: -.4px; }
.pagehead .sub { color: var(--muted); font-size: 15px; }

footer { margin: 90px 0 50px; color: var(--muted); font-size: 13px; text-align: center; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- lineage tree: the builder ---------- */

.node {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px 14px;
  margin-bottom: 12px;
}
.node-root { border-color: var(--brass-dim); }
/* ancestors nest inside their descendant, so the indent IS the claim */
.node-kids {
  margin: 12px 0 0 20px;
  padding-left: 18px;
  border-left: 2px solid var(--line-2);
}
.node-kids:empty { display: none; }
.node-foot { margin-top: 12px; }
.node .addparent { color: var(--brass); border-color: rgba(217,188,126,.3); }

.member-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.member-n { font-family: var(--serif); font-size: 17px; color: var(--brass); }
.node input[type=text], .node input[type=url] { background: var(--surface); }
.node .m-url { margin-bottom: 0; font-family: var(--mono); font-size: 14px; }
.node .m-manual { margin-top: 14px; }
.node .m-manual summary { font-size: 14px; }
.node input[type="file"] {
  width: 100%; font-size: 14px; color: var(--ink-2); font-family: var(--sans);
}
.node .node-drop { color: var(--muted); border-color: transparent; background: transparent; }
.node .node-drop:hover { color: var(--red); border-color: var(--line-2); }

/* ---------- lineage tree: the read-only page ---------- */

.tree-row { margin-bottom: 18px; }
.node-card { margin: 0; }
.node-main { border-color: var(--brass-dim); }

.edge {
  border-left: 2px solid var(--brass-dim);
  padding: 4px 0 18px 20px;
  margin-left: 22px;
}
.edge-dead { border-left-color: var(--line-2); opacity: .72; }
.edge-head {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.edge-arrow { color: var(--muted); font-size: 13px; font-family: var(--mono); }
.edge-cond {
  font-family: var(--serif); font-size: 18px; line-height: 1.5;
  color: var(--ink);
}

/* a jump target shouldn't hide under the sticky nav */
.node-card { scroll-margin-top: 84px; }
a.edge-arrow:hover { color: var(--brass); }

/* ---------- lineage builder ---------- */

.picklist {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 12px; max-height: 660px; overflow-y: auto; padding: 2px 6px 2px 2px;
}
.picklist > .hint { grid-column: 1 / -1; }

.pick {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px;
  overflow: hidden; transition: border-color .12s, background .12s;
}
.pick:hover { border-color: var(--brass-dim); }
.pick.on { border-color: var(--brass); background: rgba(217,188,126,.08); }

/* the thumbnail is a link out; everything else selects */
.pick-thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--bg-2); }
.pick-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick-thumb:hover .pick-open { opacity: 1; }
.pick-open {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(16,14,11,.55); color: var(--ink); font-size: 20px;
  opacity: 0; transition: opacity .12s;
}
.pick-mult {
  position: absolute; left: 7px; bottom: 7px;
  background: rgba(16,14,11,.82); color: var(--brass);
  font-family: var(--mono); font-size: 11.5px; font-weight: 700;
  padding: 2px 7px; border-radius: 999px; font-variant-numeric: tabular-nums;
}

.pick-body { display: flex; flex-direction: column; gap: 3px; padding: 10px 11px 8px; cursor: pointer; flex: 1; }
.pick-title {
  font-size: 13px; line-height: 1.35; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pick-meta { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pick-add {
  margin: 0 9px 9px; padding: 7px 0; border-radius: 9px; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--ink-2);
  font-family: var(--sans); font-size: 12.5px; font-weight: 600;
}
.pick-add:hover { border-color: var(--brass-dim); color: var(--ink); }
.pick.on .pick-add { background: rgba(217,188,126,.16); border-color: var(--brass); color: var(--brass); }

.cf-wrap { display: grid; gap: 4px; margin-top: 4px; }
.cf {
  display: flex; align-items: center; gap: 8px; font-size: 13.5px;
  color: var(--ink-2); cursor: pointer;
}
.cf input { accent-color: var(--brass); flex: none; }
/* a pulled or private video has no thumbnail — show the frame, not a broken icon */
.pick-thumb.no-thumb img { display: none; }
.pick-thumb.no-thumb::after {
  content: "no thumbnail"; position: absolute; inset: 0; display: grid;
  place-items: center; color: var(--muted); font-size: 11px; font-family: var(--mono);
}
.node textarea.origin {
  font-size: 13.5px; padding: 9px 11px; border-radius: 10px;
  background: var(--surface); resize: vertical;
}
.linknote { display: grid; gap: 6px; margin: 6px 0 10px 24px; }
.linknote .linkfield {
  font-size: 13px; padding: 8px 10px; border-radius: 9px; background: var(--surface);
}
.node textarea.nodefield {
  font-size: 13.5px; padding: 9px 11px; border-radius: 10px;
  background: var(--surface); resize: vertical;
}

/* The explanation of whichever vocabulary term is selected. Under the select,
   not inside the options: a dropdown you have to read rather than scan is a
   worse dropdown, and a native <option> truncates long text anyway. */
.termwhy {
  margin: 6px 0 0; padding-left: 10px; font-size: 12.5px; line-height: 1.5;
  color: var(--muted); border-left: 2px solid var(--line-2);
}
