:root {
  --bg: #f4eee2;
  --paper: #fbf8f1;
  --ink: #2a241d;
  --ink-soft: #4a4136;
  --muted: #7a6e60;
  --line: #ddd1bc;
  --line-soft: #e9e0d0;
  --accent: #8a2c1f;
  --accent-soft: #f1ddd5;
  --link: #6d6255;
  --critique: #b0442c;
  --band-opacity: .55;
  --band-label: rgba(251, 248, 241, .86);
  --shadow: 0 10px 40px rgba(60, 40, 20, .16), 0 2px 8px rgba(60, 40, 20, .08);
  --panel-w: min(480px, 100vw);
  --display: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --serif: 'EB Garamond', 'Iowan Old Style', Georgia, serif;
  --ui: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #181512; --paper: #221e19; --ink: #ede5d7; --ink-soft: #d3c8b6; --muted: #a3957f;
    --line: #3b342b; --line-soft: #2c2721; --accent: #e5927a; --accent-soft: #3a2620;
    --link: #a49680; --critique: #e07a5f; --band-opacity: .085; --band-label: rgba(34, 30, 25, .86);
    --shadow: 0 10px 40px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #181512; --paper: #221e19; --ink: #ede5d7; --ink-soft: #d3c8b6; --muted: #a3957f;
  --line: #3b342b; --line-soft: #2c2721; --accent: #e5927a; --accent-soft: #3a2620;
  --link: #a49680; --critique: #e07a5f; --band-opacity: .085; --band-label: rgba(34, 30, 25, .86);
  --shadow: 0 10px 40px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 14px;
  display: grid; grid-template-rows: auto auto 1fr auto; grid-template-columns: minmax(0, 1fr); overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px; padding: 10px 18px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: var(--paper); border-bottom: 1px solid var(--line); z-index: 20; flex-wrap: wrap;
}
.brand-title { font-family: var(--display); font-weight: 700; font-size: 23px; letter-spacing: .01em; line-height: 1; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; letter-spacing: .02em; }
#whereami { color: var(--accent); font-weight: 500; }
.search { position: relative; }
#search {
  width: 250px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: inherit; outline: none;
}
#search:focus { border-color: var(--accent); }
#search-results {
  position: absolute; top: 38px; left: 0; width: 320px; list-style: none; margin: 0; padding: 6px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 50;
}
#search-results li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
#search-results li.active, #search-results li:hover { background: var(--accent-soft); }
#search-results img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; object-position: top; }
#search-results .sr-sub { color: var(--muted); font-size: 12px; }
.sr-period-dot { width: 28px; height: 28px; border-radius: 6px; flex: none; }

.layers { display: flex; gap: 5px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; font-size: 12px; color: var(--ink-soft);
  transition: background .15s, opacity .15s, border-color .15s; white-space: nowrap;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.chip.on { background: color-mix(in srgb, var(--c) 14%, transparent); border-color: color-mix(in srgb, var(--c) 55%, transparent); color: var(--ink); }
.chip:not(.on) { opacity: .55; }
.chip:not(.on) .dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--c); }
.chip.ghost { opacity: 1; color: var(--muted); border-style: dashed; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.progress { font-size: 12px; color: var(--muted); text-align: right; line-height: 1.35; }
.progress b { color: var(--ink); font-weight: 600; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: transparent;
  display: inline-grid; place-items: center; font-size: 15px; line-height: 1;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- stage / map ---------- */
#stage { position: relative; overflow: hidden; min-height: 0; }
#viewport { position: absolute; inset: 0; overflow: hidden; cursor: grab; user-select: none; touch-action: none; }
#viewport.dragging { cursor: grabbing; }
/* the world is panned with a compositor-only transform (see renderWorld/placeOverlay in app.js) */
#world { position: absolute; left: 0; top: 0; display: block; transform-origin: 0 0; will-change: transform; }
#overlay { position: absolute; left: 0; top: 0; pointer-events: none; }
#overlay .plabel { pointer-events: auto; }

.band { fill-opacity: var(--band-opacity); }
.band-edge { stroke: var(--line); stroke-width: 1; }
.grid line { stroke: var(--line-soft); stroke-width: 1; }
.axis-line { stroke: var(--line); }
.axis text { fill: var(--muted); font-size: calc(11px * var(--ts, 1)); font-family: var(--ui); }
.axis .tick line { stroke: var(--muted); }

.vol-line { stroke: var(--muted); stroke-width: 1; opacity: .6; }
.vol text { fill: var(--muted); font-family: var(--display); font-style: italic; font-size: calc(13.5px * var(--ts, 1)); font-weight: 600; letter-spacing: .02em; }
.plabel { cursor: pointer; }
.plabel rect { fill: var(--band-label); stroke: var(--line); }
.plabel text { fill: var(--ink); font-family: var(--display); font-size: calc(16px * var(--ts, 1)); font-weight: 700; letter-spacing: .01em; }
.plabel .pyears { fill: var(--muted); font-family: var(--ui); font-size: calc(10.5px * var(--ts, 1)); font-weight: 500; }
.plabel:hover rect, .plabel.sel rect { stroke: var(--accent); }
/* shorter periods (#38): shown only when zoomed in far enough for their labels */
#overlay .splabel { pointer-events: auto; cursor: pointer; }
.splabel rect { fill: var(--band-label); stroke: var(--line); fill-opacity: .92; }
.splabel text { fill: var(--ink-soft); font-family: var(--display); font-size: calc(13px * var(--ts, 1)); font-weight: 600; }
.splabel:hover rect, .splabel.sel rect { stroke: var(--accent); }
.sub-edge { stroke: var(--line); stroke-dasharray: 3 5; display: none; }
.bands.subs-shown .sub-edge { display: inline; }

.event { cursor: pointer; }
.event path { fill: var(--muted); }
.event:hover path { fill: var(--accent); }
.event text { fill: var(--muted); font-size: calc(10.5px * var(--ts, 1)); font-family: var(--ui); }
.event-stem { stroke: var(--line); stroke-dasharray: 2 3; }
.event-flash path { fill: var(--accent); }


.link path.vis { fill: none; stroke: var(--link); stroke-opacity: .5; }
.link.teacher path.vis { stroke: var(--ink); stroke-opacity: .55; }
.link.critique path.vis { stroke: var(--critique); stroke-dasharray: 6 4; stroke-opacity: .6; }
.link path.hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.link:hover path.vis, .link.hl path.vis { stroke-opacity: 1; }
.link.dim path.vis { stroke-opacity: .07; }
.link.faded { opacity: .12; }
.link.faded path.hit { pointer-events: none; }
.marker-teacher { fill: var(--ink); }
.marker-influence { fill: var(--link); }
.marker-critique { fill: var(--critique); }

.node { cursor: pointer; }
.node .halo { fill: var(--paper); }
.node .frame { fill: none; stroke: var(--ink); stroke-width: 1.4; }
.node.outsider .frame { stroke: #b08a2a; stroke-dasharray: 3 2.5; stroke-width: 1.8; }
.node .name { font-family: var(--display); font-weight: 700; font-size: calc(15px * var(--ts, 1)); fill: var(--ink); text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; }
.node .dates { font-size: calc(10.5px * var(--ts, 1)); fill: var(--muted); text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; }
.node .visited circle { fill: var(--accent); }
.node .visited path { stroke: #fff; stroke-width: 1.5; fill: none; }
.node:hover .frame, .node.sel .frame { stroke: var(--accent); stroke-width: 2.6; }
.node.sel .halo { fill: var(--accent); }
.node.dim { opacity: .2; }
.node.faded { opacity: .16; }
.node.far .name, .node.far .dates, .node.far .visited { display: none; }
.node.pulse .halo { animation: pulse 1.2s ease-out 2; }
@keyframes pulse { 0% { fill: var(--accent); } 100% { fill: var(--paper); } }

/* ---------- tooltip ---------- */
#tooltip {
  position: absolute; z-index: 40; max-width: 360px; padding: 12px 14px; pointer-events: none;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  font-size: 13px; line-height: 1.45; color: var(--ink-soft);
}
.tt-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.tt-head img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; object-position: top; flex: none; }
.tt-name { font-family: var(--display); font-weight: 700; font-size: 19px; color: var(--ink); line-height: 1.1; }
.tt-sub { font-size: 11.5px; color: var(--muted); }
.tt-tag { font-family: var(--serif); font-style: italic; font-size: 14.5px; color: var(--ink); margin: 6px 0; }
.tt-bio { margin: 6px 0; }
.tt-idea { margin: 5px 0; padding-left: 9px; border-left: 3px solid var(--c); }
.tt-idea b { color: var(--ink); font-weight: 600; }
.tt-hint { margin-top: 8px; font-size: 11px; color: var(--accent); letter-spacing: .02em; }
.tt-link-title { font-family: var(--display); font-weight: 700; font-size: 18px; color: var(--ink); }
.badge { display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; vertical-align: middle; }
.badge.teacher { color: var(--ink); border-color: var(--ink); }
.badge.critique { color: var(--critique); border-color: var(--critique); }

/* ---------- legend + zoom ---------- */
.legend {
  position: absolute; left: 14px; bottom: 14px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; font-size: 12px; color: var(--ink-soft); box-shadow: var(--shadow); z-index: 10;
}
.legend-toggle { border: 0; background: none; padding: 7px 12px; font-weight: 600; font-size: 12px; color: var(--muted); }
.legend-body { padding: 0 12px 10px; display: grid; gap: 4px; }
.legend.collapsed .legend-body { display: none; }
.lg-row { display: flex; align-items: center; gap: 8px; }
.lk { stroke-width: 2; }
.lk.teacher { stroke: var(--ink); stroke-width: 3; }
.lk.influence { stroke: var(--link); }
.lk.critique { stroke: var(--critique); stroke-dasharray: 6 4; }
.lg-node { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--ink); margin: 0 15px; }
.lg-node.outsider { border: 1.8px dashed #b08a2a; }

.zoomctl { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 10; transition: right .3s; }
.zoomctl button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); font-size: 18px; box-shadow: var(--shadow); }
.zoomctl button:hover { color: var(--accent); border-color: var(--accent); }
body.panel-open .zoomctl { right: calc(var(--panel-w) + 14px); }

/* ---------- panel ---------- */
#panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: var(--panel-w); background: var(--paper);
  border-left: 1px solid var(--line); box-shadow: var(--shadow); z-index: 30;
  transform: translateX(105%); transition: transform .32s cubic-bezier(.2, .8, .2, 1);
  display: flex; flex-direction: column;
}
body.panel-open #panel { transform: none; }
.panel-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.panel-kind { flex: 1; text-align: center; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.panel-body { overflow-y: auto; padding: 0 26px 40px; font-family: var(--serif); font-size: 17px; line-height: 1.6; color: var(--ink-soft); scroll-behavior: smooth; }
.panel-body p { margin: 0 0 .85em; }
.panel-body em { color: var(--ink); }

.hero { display: flex; gap: 18px; align-items: center; padding: 22px 0 12px; }
.hero img { width: 104px; height: 104px; border-radius: 50%; object-fit: cover; object-position: top; flex: none; box-shadow: 0 0 0 3px var(--paper), 0 0 0 4.5px var(--line); }
.hero h2 { font-family: var(--display); font-weight: 700; font-size: 34px; line-height: 1; margin: 0 0 6px; color: var(--ink); }
.hero .meta { font-family: var(--ui); font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.hero .meta .badge { margin-right: 4px; }
.tagline { font-style: italic; font-size: 19px; line-height: 1.45; color: var(--ink); margin: 6px 0 14px; padding-left: 14px; border-left: 3px solid var(--accent); }
.weights { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px 10px; margin: 6px 0 4px; font-family: var(--ui); font-size: 11px; color: var(--muted); }
.weights .w { cursor: pointer; }
.weights .bar { height: 4px; background: var(--line-soft); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.weights .bar i { display: block; height: 100%; background: var(--c); }

.secnav { position: sticky; top: 0; background: var(--paper); z-index: 2; display: flex; gap: 2px; padding: 10px 0 8px; margin-top: 10px; border-bottom: 1px solid var(--line-soft); font-family: var(--ui); overflow-x: auto; }
.secnav button { border: 0; background: none; font-size: 12px; padding: 4px 9px; border-radius: 999px; color: var(--muted); white-space: nowrap; }
.secnav button:hover { background: var(--accent-soft); color: var(--accent); }
.panel-body h3 { font-family: var(--display); font-size: 25px; font-weight: 700; color: var(--ink); margin: 28px 0 10px; scroll-margin-top: 50px; }
.panel-body h4 { font-family: var(--ui); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; margin: 20px 0 6px; color: var(--c, var(--muted)); display: flex; align-items: center; gap: 7px; }
.panel-body h4 .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.idea { padding-left: 14px; border-left: 2px solid color-mix(in srgb, var(--c) 45%, transparent); }
.idea.muted { opacity: .55; }
/* "Contributions" (#49): headline + one-line summary, tap to open before / move / influence */
.contrib { border-left: 3px solid var(--c); padding: 0 0 0 14px; margin: 14px 0; scroll-margin-top: 50px; }
.contrib.muted { opacity: .55; }
.contrib summary { cursor: pointer; list-style: none; padding: 4px 0; }
.contrib summary::-webkit-details-marker { display: none; }
.contrib .ct { font-family: var(--display); font-size: 19px; font-weight: 700; color: var(--ink); }
.contrib .ct::after { content: ' ▸'; font-size: 13px; color: var(--muted); }
.contrib[open] .ct::after { content: ' ▾'; }
.contrib .cl { display: inline-block; margin-left: 8px; font-family: var(--ui); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--c); vertical-align: 2px; }
.contrib .cs { display: block; color: var(--muted); font-size: 15.5px; margin-top: 2px; }
.contrib h5 { font-family: var(--ui); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--c); margin: 14px 0 4px; }
.contrib ul { padding-left: 18px; margin: 4px 0; }
.contrib li { margin: 5px 0; }
.contrib p { margin: 4px 0; }
.plink { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); text-underline-offset: 2px; cursor: pointer; }
.plink:hover { color: var(--accent); }
.curio { background: var(--accent-soft); border-radius: 12px; padding: 12px 16px; font-size: 16px; margin: 14px 0; }
.curio b { font-family: var(--ui); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); display: block; margin-bottom: 2px; }
.works { list-style: none; padding: 0; margin: 0; }
.works li { padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.works .wt { color: var(--ink); font-style: italic; }
.works .wy { font-family: var(--ui); font-size: 12px; color: var(--muted); margin-left: 6px; }
.works .wn { display: block; font-size: 15px; }
blockquote { margin: 14px 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--line); font-size: 19px; line-height: 1.45; color: var(--ink); font-style: italic; }
blockquote cite { display: block; font-style: normal; font-family: var(--ui); font-size: 12px; color: var(--muted); margin-top: 4px; }
.conn { display: flex; gap: 12px; padding: 10px; margin: 0 -10px; border-radius: 12px; cursor: pointer; align-items: flex-start; }
.conn:hover { background: var(--accent-soft); }
.conn img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; object-position: top; flex: none; }
.conn .cn { font-family: var(--display); font-weight: 700; font-size: 18px; color: var(--ink); }
.conn .cs { font-size: 15px; line-height: 1.45; }
.pn { display: flex; justify-content: space-between; gap: 10px; margin-top: 30px; font-family: var(--ui); }
.btn { border: 1px solid var(--line); background: var(--paper); padding: 8px 14px; border-radius: 999px; font-size: 13px; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.btn.primary:hover { filter: brightness(1.08); color: var(--paper); }

.pair { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 26px 0 10px; }
.pair .who { text-align: center; cursor: pointer; width: 130px; }
.pair img { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; object-position: top; box-shadow: 0 0 0 3px var(--paper), 0 0 0 4.5px var(--line); }
.pair .who div { font-family: var(--display); font-weight: 700; font-size: 19px; color: var(--ink); margin-top: 6px; line-height: 1.1; }
.pair .who:hover img { box-shadow: 0 0 0 3px var(--paper), 0 0 0 4.5px var(--accent); }
.pair .arrow { font-size: 28px; color: var(--muted); }
.pair .arrow.critique { color: var(--critique); }
.lead { font-size: 20px; line-height: 1.45; color: var(--ink); }
.chips-inline { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 4px 0 16px; font-family: var(--ui); }
.chips-inline .chip { opacity: 1; cursor: default; }

.period-hero { padding: 24px 0 6px; }
.period-hero .swatch { height: 6px; border-radius: 3px; margin-bottom: 14px; }
.period-hero h2 { font-family: var(--display); font-weight: 700; font-size: 32px; line-height: 1.05; margin: 0 0 6px; color: var(--ink); }
.ctx h4 { color: var(--accent); }
.evlist { list-style: none; padding: 0; margin: 0; }
.parts { list-style: none; padding: 0; margin: 0 0 8px; font-family: var(--ui); font-size: 13.5px; line-height: 1.9; }
.parts .pl-years, .small-meta .pl-years { color: var(--muted); font-size: 12px; }
.evlist li { display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; font-size: 15.5px; line-height: 1.4; }
.evlist li:hover { color: var(--accent); }
.evlist .ey { font-family: var(--ui); font-size: 12px; color: var(--muted); padding-top: 3px; }
.evlist b { color: var(--ink); font-weight: 500; }
.people-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pchip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; font-family: var(--ui); font-size: 13px; }
.pchip:hover { border-color: var(--accent); color: var(--accent); }
.pchip img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; object-position: top; }
.pending { font-family: var(--ui); font-size: 12px; color: var(--muted); font-style: italic; }

/* ---------- minimap ---------- */
#minimap-wrap { height: 58px; border-top: 1px solid var(--line); background: var(--paper); padding-bottom: env(safe-area-inset-bottom, 0px); }
#minimap { width: 100%; height: 58px; display: block; cursor: pointer; touch-action: none; }
.mm-band { fill-opacity: calc(var(--band-opacity) + .1); }
.mm-label { font-size: 10px; fill: var(--muted); font-family: var(--ui); pointer-events: none; }
.mm-dot { fill: var(--ink); opacity: .55; }
.mm-dot.outsider { fill: #b08a2a; }
.mm-dot.visited { fill: var(--accent); opacity: 1; }
.mm-view { fill: var(--accent); fill-opacity: .08; stroke: var(--accent); stroke-width: 1.5; rx: 4; }

/* ---------- enlarged portrait (#40) ---------- */
.hero img[data-zoom] { cursor: zoom-in; }
#lightbox { position: fixed; inset: 0; background: rgba(20, 15, 10, .72); backdrop-filter: blur(3px); z-index: 110; display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
#lightbox figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
#lightbox img { display: block; max-width: calc(100vw - 32px); max-height: calc(100vh - 90px); max-height: calc(100dvh - 90px); border-radius: 12px; box-shadow: var(--shadow); background: var(--paper); }
#lightbox img.small { height: min(300px, calc(100vh - 90px)); width: auto; }   /* no larger file: at most 1.5× so it stays sharp */
#lightbox figcaption { font-family: var(--display); font-size: 20px; color: #f6efe3; text-align: center; }
#lightbox figcaption span { display: block; font-family: var(--ui); font-size: 12.5px; opacity: .8; }

/* ---------- welcome ---------- */
#welcome { position: fixed; inset: 0; background: rgba(20, 15, 10, .45); backdrop-filter: blur(3px); z-index: 100; display: grid; place-items: center; padding: 16px; }
.welcome-card { background: var(--paper); border-radius: 20px; max-width: 720px; padding: 34px 38px; box-shadow: var(--shadow); max-height: 92vh; overflow: auto; }
.welcome-card h1 { font-family: var(--display); font-size: 42px; margin: 0 0 8px; line-height: 1; }
.welcome-card .lead { font-family: var(--serif); font-size: 19px; color: var(--ink-soft); }
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0; }
.how div { background: var(--bg); border-radius: 12px; padding: 12px; font-size: 12.5px; color: var(--ink-soft); line-height: 1.45; }
.how b { display: block; font-family: var(--display); font-size: 17px; color: var(--ink); margin-bottom: 2px; }
.keys { font-size: 12px; color: var(--muted); }
kbd { font-family: var(--ui); font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; margin: 0 1px; background: var(--bg); }
.welcome-actions { display: flex; gap: 10px; margin-top: 18px; }

@media (max-width: 900px) {
  .topbar { gap: 10px; padding: 8px 12px; }
  .toolbar { flex-wrap: nowrap; overflow-x: auto; }
  .layers { flex-wrap: nowrap; }
  .threads-btn { display: none; }
  #search { width: 170px; }
  .progress { display: none; }
  .how { grid-template-columns: 1fr 1fr; }
  .legend { display: none; }
}
@media (max-width: 560px) {
  .brand-sub { display: none; }
  .brand-title { font-size: 19px; }
  .search { flex: 1; }
  #search { width: 100%; }
  #search-results { width: calc(100vw - 24px); }
  .top-actions { gap: 4px; }
  .how { grid-template-columns: 1fr; }
  .welcome-card { padding: 24px 20px; }
  .panel-body { padding: 0 18px 40px; }
  body.panel-open .zoomctl { display: none; }
}

/* ---------- v3: toolbar, schools, tiers, threads ---------- */
.brand { flex: none; }
.search { flex: 1; max-width: 360px; }
#search { width: 100%; }
.top-actions { margin-left: auto; }
.threads-btn { font-family: var(--display); font-size: 16px; font-weight: 700; padding: 6px 14px; border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); }
.toolbar {
  display: flex; align-items: center; gap: 10px; padding: 6px 18px; background: var(--paper);
  border-bottom: 1px solid var(--line); z-index: 19; flex-wrap: wrap; min-width: 0;
}
.tb-group { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.tb-sep { width: 1px; align-self: stretch; background: var(--line); }
.tb-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-right: 2px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: none; font-size: 12px; padding: 4px 11px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--paper); }
.chip.mini { font-size: 11.5px; padding: 3px 9px; --c: var(--muted); }
.chip.mini.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--ink); opacity: 1; }
.chip.mini:not(.on) { opacity: .55; text-decoration: line-through; }
.chip.mini svg { margin-right: 2px; }
.layers.filtered .chip.on { box-shadow: 0 0 0 1.5px var(--c); }

.school-hull { fill-opacity: .045; stroke-opacity: .3; stroke-width: 1.2; stroke-dasharray: 4 4; pointer-events: none; transition: fill-opacity .2s; }
.school-hull.hover, .school-hull.sel { fill-opacity: .16; stroke-opacity: .8; }
.school-label { font-family: var(--display); font-style: italic; font-weight: 700; font-size: calc(14px * var(--ts, 1)); text-anchor: start; cursor: pointer; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; stroke-linejoin: round; letter-spacing: .02em; }
.school-label:hover { text-decoration: underline; }
.node[data-level="far"] ~ * .school-label { font-size: calc(12px * var(--ts, 1)); }

.node.hidden, .link.hidden { display: none; }
.node.nolabel:not(:hover):not(.sel) .name, .node.nolabel:not(:hover):not(.sel) .dates { display: none; }
.node.tier2 .name { font-size: calc(12.5px * var(--ts, 1)); font-weight: 600; }
.node.tier2 .dates { font-size: calc(9.5px * var(--ts, 1)); }
.node[data-level="mid"] .dates, .node[data-level="far"] .dates, .node[data-level="far"] .name, .node[data-level="far"] .visited { display: none; }
.node[data-level="far"].tier1:not(.nolabel) .name { display: block; font-size: calc(12px * var(--ts, 1)); }
.node .mono-bg { fill-opacity: .85; }
.node .mono { fill: #fff; font-family: var(--display); font-weight: 700; text-anchor: middle; pointer-events: none; }
.node.tier2 .frame { stroke-width: 1; }
.node[data-level="far"] .frame { stroke-width: .8; }
.node .tstep rect { fill: var(--paper); stroke: #c08a1a; stroke-width: 1.4; }
.node .tstep text { fill: #a0700f; font-size: 10px; font-weight: 700; font-family: var(--ui); }
.node .tstep .cur rect { fill: #c08a1a; }
.node .tstep .cur text { fill: #fff; }
.thread-seg { fill: none; stroke: #c08a1a; stroke-width: 3; stroke-linecap: round; opacity: .9; }
.thread-seg.done { stroke-dasharray: 2 6; opacity: .6; }
.marker-thread { fill: #c08a1a; }

.mono-html { display: inline-grid; place-items: center; border-radius: 50%; background: var(--c); color: #fff; font-family: var(--display); font-weight: 700; flex: none; width: 40px; height: 40px; font-size: 16px; }
.tt-head .mono-html { width: 46px; height: 46px; font-size: 19px; }
.hero .mono-html.big { width: 104px; height: 104px; font-size: 42px; box-shadow: 0 0 0 3px var(--paper), 0 0 0 4.5px var(--line); }
.pair .mono-html.big { width: 84px; height: 84px; font-size: 32px; }
.pchip .mono-html, #search-results .mono-html { width: 28px; height: 28px; font-size: 12px; }
.pchip.major { font-weight: 600; border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.minor-off .pchip.minor { opacity: .55; }   /* hidden on the map while minor thinkers are off (#48) */
.badge.major { color: var(--accent); border-color: var(--accent); }
.small-meta { font-family: var(--ui); font-size: 12.5px; color: var(--muted); }
.panel-body a { color: var(--accent); }
.sr-period-dot.thread { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.ideas-list { padding-left: 20px; margin: 0 0 14px; }
.ideas-list li { margin: 4px 0; }
.period-hero .meta { font-family: var(--ui); font-size: 12.5px; color: var(--muted); margin-top: 4px; }

.thread-list { display: grid; gap: 12px; margin-top: 10px; }
.thread-card { border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 12px; padding: 12px 14px; cursor: pointer; transition: background .15s; }
.thread-card:hover { background: var(--accent-soft); }
.tc-layer { font-family: var(--ui); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.tc-title { font-family: var(--display); font-weight: 700; font-size: 22px; color: var(--ink); line-height: 1.15; margin: 2px 0; }
.tc-q { font-size: 15.5px; line-height: 1.4; }
.tc-faces { display: flex; margin-top: 8px; }
.tc-faces img, .tc-faces .mono-html { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; object-position: top; margin-right: -6px; box-shadow: 0 0 0 2px var(--paper); font-size: 11px; }
.thread-chips { display: flex; flex-wrap: wrap; gap: 6px; font-family: var(--ui); }
.tchip { font-size: 12.5px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--c); color: var(--ink); cursor: pointer; }
.tchip:hover { background: var(--accent-soft); }
.tour-bar { position: sticky; top: 0; z-index: 2; background: var(--paper); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-family: var(--ui); font-size: 12.5px; color: var(--muted); }
.steps { list-style: none; padding: 0; margin: 10px 0; }
.step { padding: 12px 14px; margin: 0 -14px; border-radius: 12px; cursor: pointer; transition: background .2s; scroll-margin-top: 60px; }
.step:hover { background: color-mix(in srgb, var(--accent-soft) 50%, transparent); }
.step.cur { background: var(--accent-soft); }
.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.step-head img, .step-head .mono-html { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; object-position: top; font-size: 15px; }
.step-head b { font-family: var(--display); font-size: 19px; color: var(--ink); }
.step-n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #c08a1a; color: #fff; font-family: var(--ui); font-size: 11px; font-weight: 700; }
.step-d { font-family: var(--ui); font-size: 11.5px; color: var(--muted); margin-left: 4px; }
.step p { margin: 4px 0; }
.linkish { border: 0; background: none; padding: 0; font-family: var(--ui); font-size: 12.5px; color: var(--accent); }
.lg-node.small { width: 10px; height: 10px; margin: 0 18px; }
.lg-school { width: 30px; height: 14px; border-radius: 8px; border: 1.2px dashed #7b4fb0; background: rgba(123, 79, 176, .08); margin: 0 8px; }

/* ---------- phones: one-row scrollable toolbar, panel as bottom sheet ---------- */
@media (max-width: 900px) {
  .toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 6px 12px; }
  .toolbar::-webkit-scrollbar { display: none; }
  .tb-group, .layers { flex-wrap: nowrap; flex: none; }
  .chip { flex: none; }
}
@media (max-width: 560px) {
  .brand-title { font-size: 17px; }
  .search { min-width: 110px; }
  .topbar { flex-wrap: nowrap; }
  .brand-title { white-space: nowrap; }
  body.panel-open #viewport { bottom: 62%; }
  body.panel-open .legend, body.panel-open .zoomctl { display: none; }
  #panel { top: auto; height: 62%; width: 100%; border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; transform: translateY(105%); }
  body.panel-open #panel { transform: none; }
  .hero img, .hero .mono-html.big { width: 76px; height: 76px; }
  .hero h2 { font-size: 28px; }
}

.link.s1 path.vis { stroke-opacity: .32; }
.link.transit:not(.hl) path.vis { stroke-opacity: .07; }
.link.transit:not(.hl) path.hit { pointer-events: none; }
.link.long:not(.hl) path.vis { stroke-opacity: .16; }
@media (max-width: 560px) {
  #theme-btn, #random-btn { display: none; }
  .topbar { gap: 8px; }
  .brand-title { font-size: 16px; }
}
@media (max-width: 560px) {
  .welcome-card { display: flex; flex-direction: column; }
  .welcome-card .welcome-actions { order: 1; flex-wrap: wrap; margin: 4px 0 14px; }
  .welcome-card .how { order: 2; }
  .welcome-card .keys { display: none; }
}
.lang-btn { font-size: 11px; font-weight: 600; letter-spacing: .04em; }

/* timeline spacing switch (#19): sits by the zoom buttons, just above the time axis */
.timectl { position: absolute; right: 64px; bottom: 14px; z-index: 10; display: flex; align-items: center; gap: 6px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 3px 4px 3px 12px; box-shadow: var(--shadow); transition: right .3s; }
body.panel-open .timectl { right: calc(var(--panel-w) + 64px); }
@media (max-width: 560px) { body.panel-open .timectl { display: none; } .timectl .tb-label { display: none; } .timectl { padding-left: 4px; } }

/* stage build (apps.lisitsin.com/philosophy-stage/): a small badge so it is never mistaken for the live site */
body.is-stage::after { content: 'STAGE'; position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 2px); transform: translateX(-50%);
  z-index: 1000; pointer-events: none; padding: 1px 8px; border-radius: 0 0 6px 6px; background: #c2410c; color: #fff;
  font: 700 10px/1.6 system-ui, sans-serif; letter-spacing: .12em; }

/* ---------- phone settings sheet (#33) ---------- */
/* explicit rows, so the page keeps its shape when the toolbar moves into the sheet */
.topbar { grid-row: 1; } #stage { grid-row: 3; } #minimap-wrap { grid-row: 4; }
#settings-btn, #settings, #settings-backdrop { display: none; }
#settings-btn { position: relative; font-size: 17px; }
#settings-btn.dot::after { content: ''; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--paper); }
@media (max-width: 700px), (max-height: 500px) {
  #settings-btn { display: inline-grid; }
  .brand { display: none; }
  .topbar { gap: 8px; }
  .search { flex: 1; min-width: 0; }
  #search { width: 100%; }
  #search-results { width: calc(100vw - 24px); }
  .threads-btn { display: inline-flex; font-size: 0; padding: 0; width: 34px; height: 34px; justify-content: center; align-items: center; flex: none; }
  .threads-btn::before { content: '✦'; font-size: 16px; }
  .progress { display: none; }
  .timectl, #zoom-in, #zoom-out { display: none; }
  #settings-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 60; }
  #settings:not([hidden]) { display: flex; }
  #settings { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 55%; flex-direction: column;
    background: var(--paper); border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.25);
    padding-bottom: env(safe-area-inset-bottom, 0px); transform: translateY(105%); transition: transform .25s ease; }
  body.settings-open #settings { transform: none; }
  .set-grab { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 8px auto 2px; flex: none; }
  .set-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 10px 4px 18px; flex: none;
    font-family: var(--display); font-weight: 700; font-size: 18px; }
  .set-body { overflow-y: auto; padding: 0 18px 18px; overscroll-behavior: contain; }
  .set-body h4 { margin: 14px 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .set-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
  .set-row:last-child { border-bottom: 0; }
  /* the toolbar, laid out as wrapping groups instead of one scrolling row */
  #settings .toolbar { display: flex; flex-direction: column; align-items: stretch; gap: 10px; padding: 0; border: 0; background: none;
    overflow: visible; flex-wrap: nowrap; position: static; }
  #settings .tb-group, #settings .layers { flex-wrap: wrap; gap: 6px; flex: none; }
  #settings .tb-sep { display: none; }
  #settings #time-mode { display: inline-flex; }
}
@media (max-width: 700px), (max-height: 500px) { #settings #theme-btn, #settings #random-btn, #settings #help-btn { display: inline-grid; } }
@media (max-height: 500px) { #settings { max-height: 85%; } }

/* ---------- text size (#30) ---------- */
/* --ts (0.9 … 1.3) is set on <html> by js/app.js. Interface parts are zoomed; map labels use calc() above. */
.topbar, .toolbar, #panel, #tooltip, .welcome-card, #settings, .legend { zoom: var(--ts, 1); }
#settings .toolbar { zoom: 1; }                     /* already inside the zoomed sheet */
@media (min-width: 561px) { #panel { width: calc(var(--panel-w) / var(--ts, 1)); } }   /* side panel keeps its width; text grows */
.textsize-wrap { position: relative; display: inline-flex; }
#textsize-btn { font-family: var(--display); font-weight: 700; font-size: 15px; }
#textsize-pop { position: absolute; top: calc(100% + 6px); right: 0; z-index: 70; background: var(--paper);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px; box-shadow: var(--shadow); }
#text-size button { min-width: 34px; line-height: 1.4; font-family: var(--display); font-weight: 700; }
@media (max-width: 700px), (max-height: 500px) { .textsize-wrap { display: none; } }
/* larger text: the reading-progress counts give way so search keeps a usable width */
.search { min-width: 150px; }
@media (max-width: 1500px) { html.ts-big .progress { display: none; } }
@media (max-width: 700px), (max-height: 500px) { .search { min-width: 0; } }
