/* app.css — the house style of the family records: paper and ink, a serif to read, a narrow sans to label,
   a mono for numbers and sources, and one colour per provenance tier. */
@import url('../fonts/fonts.css');

:root {
  --paper: #E6E8E3; --paper2: #EFF0EC; --card: #FBFBF9;
  --ink: #1A211F; --ink2: #4A544F; --ink3: #6B746E; --ink4: #959D97;
  --rule: #C6CBC4; --rule2: #D8DCD6;
  --accent: #2E6A62; --accent2: #24524C; --danger: #A62B4C; --warn: #9C5B2E;
  --record: #2E6A62; --index: #3E6191; --chart: #8A7A4E; --inference: #818A84; --lore: #9C5B2E;
  --gap: #5F51A0; --conflict: #A62B4C; --superseded: #9A968E;
  --display: 'Archivo Narrow', ui-sans-serif, system-ui, sans-serif;
  --body: 'Spectral', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --r: 6px; --shadow: 0 1px 2px rgba(26,33,31,.08), 0 4px 16px rgba(26,33,31,.06);
  --cardw: 176px; --cardh: 62px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font: 16px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent2); }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; letter-spacing: .01em; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 30px; } h2 { font-size: 22px; } h3 { font-size: 17px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink2); }
h4 { font-size: 16px; }
p { margin: 0 0 .8em; }
.mono, code { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--ink3); } .small { font-size: 14px; } .tiny { font-size: 12.5px; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons ---------- */
button, .btn { background: var(--card); border: 1px solid var(--rule); border-radius: var(--r); padding: 7px 13px; cursor: pointer;
  font-family: var(--display); font-weight: 600; font-size: 15px; letter-spacing: .02em; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--ink3); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent2); }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--rule)); }
button.link { background: none; border: none; padding: 0; color: var(--accent2); text-decoration: underline; font-family: var(--body); font-weight: 400; font-size: inherit; }
button.icon { background: none; border: none; font-size: 22px; line-height: 1; padding: 4px 8px; color: var(--ink3); }
button.small, .btn.small { padding: 3px 9px; font-size: 13.5px; }
button:disabled { opacity: .5; cursor: default; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- form fields ---------- */
input[type=text], input[type=search], input[type=password], input[type=number], input[type=url], input[type=date], select, textarea {
  background: #fff; border: 1px solid var(--rule); border-radius: 5px; padding: 7px 9px; width: 100%; font-size: 15.5px; }
textarea { min-height: 80px; resize: vertical; font-family: var(--body); }
/* dropdowns draw their own caret, inset from the edge (the browser's sits against the border) */
select:not([multiple]) { -webkit-appearance: none; appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%234A544F' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px; }
select:disabled { cursor: default; opacity: .6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.field { display: block; margin-bottom: 12px; }
.flabel { display: block; font-family: var(--display); font-weight: 600; font-size: 13.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink2); margin-bottom: 4px; }
.fhint { display: block; font-size: 13px; color: var(--ink3); margin-top: 3px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* ---------- shell ---------- */
.top { position: sticky; top: 0; z-index: 30; background: var(--ink); color: #E8ECE8; display: flex; align-items: center; gap: 18px; padding: 0 18px; height: 52px; }
.brand { font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; cursor: pointer; }
.brand small { font-weight: 500; opacity: .6; margin-left: 8px; text-transform: none; letter-spacing: 0; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.nav a { color: #C9D1CC; text-decoration: none; font-family: var(--display); font-weight: 600; font-size: 15px; padding: 15px 10px 13px; border-bottom: 3px solid transparent; white-space: nowrap; }
.nav a:hover { color: #fff; }
.nav a.on { color: #fff; border-bottom-color: #7FC1B5; }
.nav .badge, .navbtn .badge { background: #C26A1E; color: #fff; border-radius: 9px; font-size: 11.5px; padding: 1px 6px; margin-left: 4px; font-family: var(--mono); }
.navbtn { display: none; align-items: center; gap: 8px; flex: 1; min-width: 0; justify-content: flex-start; background: transparent; border: 1px solid #4A544F; color: #fff; font-family: var(--display); font-weight: 600; font-size: 15px; padding: 6px 12px; white-space: nowrap; }
.navbtn .caret { width: 8px; height: 8px; border-right: 2px solid #C9D1CC; border-bottom: 2px solid #C9D1CC; transform: rotate(45deg) translateY(-2px); margin-left: auto; transition: transform .15s; }
.top.open .navbtn .caret { transform: rotate(-135deg) translateY(-2px); }
.top.folded .navbtn { display: flex; }
.top.folded .nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; background: var(--ink); padding: 4px 0 10px; box-shadow: 0 10px 24px rgba(0,0,0,.25); max-height: calc(100vh - 52px); overflow-y: auto; }
.top.folded.open .nav { display: flex; }
.top.folded .nav a { padding: 12px 22px; border-bottom: none; border-left: 3px solid transparent; font-size: 17px; }
.top.folded .nav a.on { border-left-color: #7FC1B5; background: rgba(255,255,255,.05); }
.tmenu { position: relative; }
.tmbtn { display: inline-flex; align-items: center; gap: 8px; background: transparent; color: #C9D1CC; border-color: #4A544F; padding: 5px 11px; font-size: 14px; }
.tmbtn .caret { width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); }
.tmenu.open .tmbtn .caret { transform: rotate(-135deg) translateY(-1px); }
.tmlist { display: none; position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--card); border: 1px solid var(--rule2); border-radius: 8px; box-shadow: 0 10px 28px rgba(0,0,0,.22); padding: 6px 0; z-index: 35; }
.tmenu.open .tmlist { display: block; }
.tmlist button { display: block; width: 100%; text-align: left; border: none; border-radius: 0; background: none; padding: 10px 16px; color: var(--ink); font-size: 15px; }
.tmlist button:hover { background: var(--paper2); }
.importhelp { margin: -14px 0 26px; color: var(--ink2); }
.importhelp summary { cursor: pointer; }
.savestate { font-family: var(--mono); font-size: 12px; color: #9AA59F; white-space: nowrap; }
.savestate.error { color: #FF9C9C; }
main { max-width: 1240px; margin: 0 auto; padding: 26px 22px 80px; }
main.full { max-width: none; padding: 0; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.pagehead h1 { margin: 0; }
.pagehead p { margin: 4px 0 0; color: var(--ink2); max-width: 70ch; }

/* ---------- panels and cards ---------- */
.panel { background: var(--card); border: 1px solid var(--rule2); border-radius: 10px; padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.panel > h3:first-child { margin-top: 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; align-items: start; }
.cols > .panel { margin-bottom: 0; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--rule2); border-radius: 10px; padding: 12px 14px; }
.stat b { display: block; font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1.1; }
.stat span { font-family: var(--display); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink3); }
.empty { text-align: center; padding: 40px 20px; color: var(--ink2); }
.empty h2 { color: var(--ink); }

/* provenance pill */
.pv { display: inline-block; font-family: var(--display); font-weight: 600; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase;
  color: #fff; background: var(--tc, var(--ink3)); border-radius: 3px; padding: 1px 6px; vertical-align: 1px; white-space: nowrap; }
.pv.record { --tc: var(--record); } .pv.index { --tc: var(--index); } .pv.chart { --tc: var(--chart); } .pv.inference { --tc: var(--inference); }
.pv.lore { --tc: var(--lore); } .pv.gap { --tc: var(--gap); } .pv.conflict { --tc: var(--conflict); } .pv.superseded { --tc: var(--superseded); }
.srcref { font-family: var(--mono); font-size: 12.5px; color: var(--ink2); background: var(--paper2); border: 1px solid var(--rule2); border-radius: 3px; padding: 0 4px; cursor: pointer; }
.srcref:hover { border-color: var(--ink3); }
.speculative { background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(156,91,46,.05) 6px 12px); }

/* ---------- home ---------- */
.hero { padding: 40px 0 26px; }
.hero h1 { font-size: 44px; margin-bottom: 8px; }
.hero p { font-size: 19px; color: var(--ink2); }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 22px 0 30px; }
.choice { text-align: left; display: flex; flex-direction: column; justify-content: flex-start; align-items: flex-start; padding: 18px; border-radius: 10px; background: var(--card); border: 1px solid var(--rule2); box-shadow: var(--shadow); font-family: var(--body); font-weight: 400; }
.choice b { display: block; font-family: var(--display); font-size: 19px; margin-bottom: 4px; }
.choice span { color: var(--ink2); font-size: 15px; }
.choice:hover { border-color: var(--accent); }
.projlist { display: grid; gap: 10px; }
.proj { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--rule2); border-radius: 10px; padding: 12px 16px; }
.proj .grow { flex: 1; cursor: pointer; margin-right: 8px; }
.proj b { font-family: var(--display); font-size: 18px; }

/* ---------- people list ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 320px; }
.toolbar select { width: auto; }
table.list { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; border: 1px solid var(--rule2); }
table.list th { text-align: left; font-family: var(--display); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink3); padding: 9px 12px; border-bottom: 1px solid var(--rule); background: var(--paper2); cursor: pointer; white-space: nowrap; }
table.list td { padding: 8px 12px; border-bottom: 1px solid var(--rule2); vertical-align: top; }
table.list tr:hover td { background: #F4F5F1; cursor: pointer; }
table.list tr:last-child td { border-bottom: none; }
.meter { display: inline-block; width: 60px; height: 6px; border-radius: 3px; background: var(--rule2); overflow: hidden; vertical-align: middle; }
.meter i { display: block; height: 100%; background: var(--accent); }
.av { width: 34px; height: 34px; border-radius: 50%; background: var(--paper2); border: 1px solid var(--rule); display: inline-flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 700; font-size: 13px; color: var(--ink2); overflow: hidden; flex: none; background-size: cover; background-position: center; }
.av.lg { width: 92px; height: 92px; font-size: 30px; }
.namecell { display: flex; align-items: center; gap: 10px; }

/* ---------- drawer (person) ---------- */
.drawer-back { position: fixed; inset: 0; background: rgba(26,33,31,.28); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); background: var(--paper2); z-index: 41; overflow-y: auto; box-shadow: -10px 0 40px rgba(0,0,0,.18); animation: slidein .18s ease-out; }
@keyframes slidein { from { transform: translateX(40px); opacity: .6; } }
.drawer-head { position: sticky; top: 0; z-index: 2; background: var(--card); border-bottom: 1px solid var(--rule2); padding: 16px 20px 0; border-top: 5px solid var(--tc, var(--ink3)); }
.drawer-head .who { display: flex; gap: 16px; align-items: center; }
.drawer-head h2 { margin: 0; font-size: 26px; }
.drawer-head .sub { color: var(--ink2); }
.tabs { display: flex; gap: 2px; margin-top: 12px; overflow-x: auto; }
.tabs button { background: none; border: none; border-bottom: 3px solid transparent; border-radius: 0; padding: 8px 12px; color: var(--ink3); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.drawer-body { padding: 18px 20px 60px; }
.closex { position: absolute; top: 10px; right: 10px; }

/* facts */
.facts { display: grid; gap: 8px; }
.fact { background: var(--card); border: 1px solid var(--rule2); border-left: 4px solid var(--tc, var(--ink3)); border-radius: 6px; padding: 9px 12px; display: grid; grid-template-columns: 74px 1fr auto; gap: 4px 12px; align-items: start; }
.fact.speculative { background-color: var(--card); }
.fact .yr { font-family: var(--mono); font-size: 13px; color: var(--ink2); padding-top: 2px; }
.fact .lab { font-family: var(--display); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink3); }
.fact .val { font-size: 16px; }
.fact .meta { grid-column: 2 / 4; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--ink3); }
.fact .acts { display: flex; gap: 2px; }
.fact.superseded { opacity: .6; } .fact.superseded .val { text-decoration: line-through; }
.fact.fromfamily { border-left-style: dashed; }
.warnline { color: var(--danger); font-size: 14px; }

/* prompts inside the drawer and on the missing page */
.prompt { background: var(--card); border: 1px solid var(--rule2); border-left: 4px solid #C26A1E; border-radius: 6px; padding: 12px 14px; margin-bottom: 10px; }
.prompt.parents { border-left-color: #4157C9; } .prompt.conflict, .prompt.check { border-left-color: var(--conflict); }
.prompt.unsourced { border-left-color: var(--chart); } .prompt.map { border-left-color: var(--gap); } .prompt.photo { border-left-color: var(--ink4); }
.prompt .q { font-family: var(--display); font-size: 17.5px; font-weight: 600; margin-bottom: 2px; }
.prompt .why { color: var(--ink3); font-size: 14px; margin-bottom: 8px; }
.prompt .who { font-size: 13px; color: var(--ink3); font-family: var(--display); text-transform: uppercase; letter-spacing: .05em; }
.prompt form { margin-top: 8px; }
.howknown { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.howknown label { border: 1px solid var(--rule); border-radius: 18px; padding: 4px 11px; cursor: pointer; font-size: 14.5px; background: #fff; display: inline-flex; gap: 6px; align-items: center; }
.howknown input { margin: 0; }
.howknown label:has(input:checked) { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 10%, #fff); box-shadow: inset 0 0 0 1px var(--tc); }
.groupnav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.groupnav button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* interview card */
.interview { max-width: 640px; margin: 20px auto; }
.interview .prompt { padding: 26px 28px; border-left-width: 6px; }
.interview .prompt .q { font-size: 24px; }
.progressbar { height: 6px; background: var(--rule2); border-radius: 3px; overflow: hidden; margin: 8px 0 18px; }
.progressbar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

/* ---------- tree ---------- */
.treewrap { position: relative; height: calc(100vh - 52px); overflow: hidden; background: var(--paper); cursor: grab; touch-action: none; }
.treewrap.dragging { cursor: grabbing; }
.treecanvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.treebar { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 5; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; pointer-events: none; }
.treebar > * { pointer-events: auto; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; background: var(--card); }
.seg button { border: none; border-radius: 0; border-right: 1px solid var(--rule2); }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--ink); color: #fff; }
.tcard { position: absolute; width: var(--cardw); height: var(--cardh); background: var(--card); border: 1px solid var(--rule); border-top: 4px solid var(--tc, var(--ink3)); border-radius: 6px;
  padding: 6px 8px 5px 50px; text-align: left; font-family: var(--body); font-weight: 400; display: block; box-shadow: 0 1px 2px rgba(0,0,0,.06); overflow: hidden; }
.tcard .av { position: absolute; left: 7px; top: 9px; width: 36px; height: 36px; font-size: 12px; }
.tcard .tn { display: block; font-family: var(--display); font-weight: 600; font-size: 14.5px; line-height: 1.15; max-height: 2.3em; overflow: hidden; }
.tcard .ty { display: block; font-family: var(--mono); font-size: 11.5px; color: var(--ink3); margin-top: 2px; white-space: nowrap; }
.tcard.subject { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 40%, transparent); }
.tcard.ghost { background: transparent; border: 1.5px dashed var(--ink4); border-top: 1.5px dashed var(--ink4); color: var(--ink3); padding-left: 10px; display: flex; align-items: center; justify-content: center; text-align: center; }
.tcard.ghost:hover { border-color: var(--accent); color: var(--accent2); background: color-mix(in srgb, var(--card) 70%, transparent); }
.tcard.ghost .tn { font-weight: 500; font-size: 14px; }
.tcard .tnum { position: absolute; right: 6px; bottom: 3px; font-family: var(--mono); font-size: 10.5px; color: var(--ink4); }
.tcard .tflag { position: absolute; right: 5px; top: 3px; width: 9px; height: 9px; border-radius: 50%; background: #C26A1E; }
.tcard:hover { border-color: var(--ink3); }
.tree-svg { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.tree-svg path { fill: none; stroke: var(--ink4); stroke-width: 1.5; }
.genlabel { position: absolute; font-family: var(--display); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink3); white-space: nowrap; }
.zoomctl { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 4px; z-index: 5; }
.zoomctl button { width: 36px; height: 36px; justify-content: center; padding: 0; font-size: 18px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--ink2); align-items: center; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.treelegend { position: absolute; left: 14px; bottom: 14px; z-index: 5; background: color-mix(in srgb, var(--card) 92%, transparent); border: 1px solid var(--rule2); border-radius: 8px; padding: 8px 10px; max-width: 520px; }

/* ---------- media ---------- */
.dropzone { border: 2px dashed var(--rule); border-radius: 12px; padding: 26px; text-align: center; color: var(--ink2); background: var(--paper2); margin-bottom: 18px; transition: background .15s; }
.dropzone.over { background: color-mix(in srgb, var(--accent) 10%, var(--paper2)); border-color: var(--accent); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.thumb { background: var(--card); border: 1px solid var(--rule2); border-radius: 8px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; text-align: left; padding: 0; font-family: var(--body); font-weight: 400; }
.thumb .img { align-self: stretch; aspect-ratio: 4 / 3; background: var(--paper2) center / cover no-repeat; display: flex; align-items: center; justify-content: center; color: var(--ink3); font-family: var(--mono); font-size: 13px; }
.thumb .cap { align-self: stretch; padding: 6px 9px; font-size: 13.5px; line-height: 1.3; }
.thumb .cap small { display: block; color: var(--ink3); font-family: var(--mono); font-size: 11.5px; }
.thumb.document .img { background-size: contain; background-color: #EDEEE9; }
.viewer { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 18px; }
.viewer .big { background: #2B302E; border-radius: 8px; min-height: 300px; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.viewer .big img { max-width: 100%; max-height: 72vh; display: block; }
.viewer .big .focus { position: absolute; width: 22px; height: 22px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px rgba(0,0,0,.5); transform: translate(-50%,-50%); pointer-events: none; }
@media (max-width: 860px) { .viewer { grid-template-columns: 1fr; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--paper2); border: 1px solid var(--rule); border-radius: 14px; padding: 2px 10px; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.chip button { border: none; background: none; padding: 0; font-size: 15px; color: var(--ink3); }

/* ---------- sources / log ---------- */
.item { background: var(--card); border: 1px solid var(--rule2); border-left: 4px solid var(--tc, var(--ink3)); border-radius: 6px; padding: 12px 14px; margin-bottom: 10px; }
.item .tag { font-family: var(--mono); font-size: 12px; color: var(--ink3); margin-bottom: 2px; }
.item h4 { margin-bottom: 4px; }
.item .body { font-size: 15.5px; }
.item .body p:last-child { margin-bottom: 0; }

/* ---------- charts ---------- */
.vchart { width: 100%; overflow-x: auto; }
.vchart svg { display: block; font-family: var(--display); }
/* chart text takes its size and colour from SVG attributes; CSS here would override them */
.vchart .hit { fill: transparent; cursor: pointer; }
.charttitle { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.vztip { position: fixed; z-index: 90; pointer-events: none; background: var(--ink); color: #F1F3EF; border-radius: 6px; padding: 7px 10px; font-size: 13.5px; line-height: 1.35; max-width: 320px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.vztip b { font-family: var(--display); }
.vizgrid { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: start; }
.viznav { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 2px; }
.viznav button { justify-content: flex-start; background: none; border: none; text-align: left; padding: 8px 10px; color: var(--ink2); }
.viznav button.on { background: var(--card); color: var(--ink); box-shadow: inset 3px 0 0 var(--accent); }
@media (max-width: 860px) { .vizgrid { grid-template-columns: 1fr; } .viznav { position: static; flex-direction: row; flex-wrap: wrap; } }
details.tableview { margin-top: 10px; font-size: 14px; }
details.tableview table { border-collapse: collapse; width: 100%; }
details.tableview td, details.tableview th { border-bottom: 1px solid var(--rule2); padding: 3px 8px; text-align: left; }

/* map */
.mapbox { position: relative; background: #DCE3E2; border-radius: 8px; overflow: hidden; border: 1px solid var(--rule2); height: 560px; touch-action: none; cursor: grab; }
.mapbox svg { width: 100%; height: 100%; display: block; }
.mapbox .land { fill: #F3F1EA; stroke: #CBC8BC; stroke-width: .5; vector-effect: non-scaling-stroke; }
.mapbox .pin { stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: pointer; }
.mapbox .route { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; opacity: .75; }
/* size and halo are set per zoom level in map.js — a CSS font-size here would be in map units */
.mapbox .plabel { font-family: var(--display); fill: var(--ink); paint-order: stroke; stroke: #F3F1EA; pointer-events: none; }

/* ---------- file viewer (as in the records) ---------- */
#fviewer { position: fixed; inset: 0; z-index: 90; display: none; flex-direction: column; background: rgba(26,33,31,.93); }
#fviewer.on { display: flex; }
#fviewer .vbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; background: var(--paper2); border-bottom: 2px solid var(--ink); }
#fviewer .vcap { flex: 1 1 220px; min-width: 0; font-family: var(--mono); font-size: 12px; line-height: 1.4; color: var(--ink2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#fviewer .vcap b { color: var(--ink); font-weight: 600; }
#fviewer button, #fviewer .vnew { font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; padding: 9px 12px; min-height: 38px; border: 1px solid var(--ink); border-radius: 3px; background: var(--card); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
#fviewer button:hover:not(:disabled), #fviewer .vnew:hover { background: var(--ink); color: var(--card); }
#fviewer button:disabled { opacity: .35; cursor: default; }
#fviewer .vclose { font-weight: 600; }
#fviewer .vstage { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; padding: 12px; }
#fviewer .vstage img { margin: auto; max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; cursor: zoom-in; }
#fviewer.zoom .vstage img { max-width: none; max-height: none; cursor: zoom-out; }
#fviewer .vstage iframe { flex: 1 1 auto; width: 100%; border: 0; background: #fff; }
@media (max-width: 640px) { #fviewer .vcap { flex-basis: 100%; order: 5; } }
@media print { #fviewer { display: none !important; } }

/* ---------- research (AI) ---------- */
.ai-out { background: var(--card); border: 1px solid var(--rule2); border-radius: 8px; padding: 14px 16px; white-space: pre-wrap; font-size: 15.5px; min-height: 40px; }
.ai-status { font-family: var(--mono); font-size: 12.5px; color: var(--ink3); margin: 6px 0; }
.suggestion { display: grid; grid-template-columns: 34px 1fr auto; gap: 4px 12px; align-items: start; }
.rank { font-family: var(--display); font-weight: 700; font-size: 18px; width: 30px; height: 30px; border-radius: 50%; background: var(--paper2); border: 1px solid var(--rule); display: flex; align-items: center; justify-content: center; }
.rank.A { background: var(--accent); color: #fff; border-color: var(--accent); }
.proposal { display: grid; grid-template-columns: 26px 1fr; gap: 4px 10px; padding: 8px 0; border-bottom: 1px solid var(--rule2); }
.callout { background: color-mix(in srgb, #C26A1E 9%, var(--card)); border: 1px solid color-mix(in srgb, #C26A1E 35%, var(--rule2)); border-radius: 8px; padding: 10px 14px; font-size: 15px; margin-bottom: 14px; }
.callout.ok { background: color-mix(in srgb, var(--accent) 8%, var(--card)); border-color: color-mix(in srgb, var(--accent) 35%, var(--rule2)); }

/* ---------- modal & toast ---------- */
dialog.modal { border: none; border-radius: 12px; padding: 0; width: min(560px, 94vw); max-height: 90vh; background: var(--paper2); box-shadow: 0 20px 70px rgba(0,0,0,.35); color: var(--ink); }
dialog.modal.wide { width: min(940px, 96vw); }
dialog.modal::backdrop { background: rgba(26,33,31,.4); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 8px; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 4px 18px 10px; overflow-y: auto; max-height: calc(90vh - 130px); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--rule2); }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: #F1F3EF; padding: 9px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); display: flex; gap: 14px; align-items: center; transition: opacity .4s; font-size: 15px; }
.toast.error { background: var(--danger); } .toast.ok { background: var(--accent2); }
.toast.out { opacity: 0; }
.toast .link { color: #BFE3DA; }

.picklist { max-height: 300px; overflow-y: auto; border: 1px solid var(--rule2); border-radius: 6px; background: #fff; }
.picklist button { display: flex; width: 100%; justify-content: space-between; border: none; border-bottom: 1px solid var(--rule2); border-radius: 0; background: none; font-family: var(--body); font-weight: 400; text-align: left; }
.picklist button:hover { background: var(--paper2); }
.steps { display: flex; gap: 6px; margin-bottom: 16px; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--rule2); }
.steps span.on { background: var(--accent); }

/* ---------- phones ---------- */
@media (max-width: 700px) {
  .top { gap: 10px; padding: 0 10px; }
  .brand small, .savestate { display: none; }
  main { padding: 18px 12px 60px; }
  h1, .hero h1 { font-size: 28px; }
  .hero p { font-size: 17px; }
  .drawer-head { padding: 12px 14px 0; }
  .drawer-head h2 { font-size: 21px; }
  .drawer-body { padding: 14px 12px 60px; }
  .av.lg { width: 60px; height: 60px; font-size: 20px; }
  .fact { grid-template-columns: 46px 1fr; }
  .fact .acts { grid-column: 2; }
  .fact .meta { grid-column: 1 / 3; }
  .treebar .small.muted { display: none; }
  .treelegend { display: none; }
  .mapbox { height: 420px !important; }
  .stat b { font-size: 24px; }
  .panel { padding: 14px; }
}

@media print { .top, .treebar, .zoomctl, .toolbar, button { display: none !important; } body { background: #fff; } .panel { box-shadow: none; } }
