/* Colours are chosen for contrast: text ≥ 4.5:1, lines/borders that carry meaning ≥ 3:1. */
:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #1f2328;
  --muted: #62676f;
  --line: #d9d6cf;
  --edge: #8a857b;
  --accent: #2f6f5e;
  --accent-ink: #ffffff;
  --male: #4a7bb7;
  --female: #b7577e;
  --unknown: #9a9a9a;
  --selected: #a87b00;
  --selected-bg: #fff6d6;
  --new: #24855a;
  --new-bg: #e3f6ec;
  --copied-bg: #eef6f2;
  --danger: #b3261e;
  --danger-ink: #ffffff;
  --warn-ink: #8a5a00;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #17191c;
    --panel: #212428;
    --ink: #e7e5e0;
    --muted: #9aa0a8;
    --line: #363a40;
    --edge: #737881;
    --accent: #5fb39a;
    --accent-ink: #0f1a17;
    --selected: #f3c94c;
    --selected-bg: #3d3416;
    --new: #4cc38a;
    --new-bg: #173526;
    --copied-bg: #1d2b25;
    --danger: #ff8a80;
    --danger-ink: #2a0f0c;
    --warn-ink: #f3c94c;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
body.busy { cursor: progress; }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 15px; margin: 0; }
.muted { color: var(--muted); }
.warn { color: var(--danger); }
[hidden] { display: none !important; }

/* one clear, consistent focus ring for keyboard users */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 60; padding: 8px 12px; background: var(--panel); color: var(--ink); border: 2px solid var(--accent); border-radius: var(--radius); }
.skip-link:focus { top: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--ink); font: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-small { min-height: 28px; min-width: 28px; padding: 2px 8px; font-size: 12px; }
.btn-big { min-height: 44px; padding: 10px 18px; font-size: 16px; }
.btn-danger { color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); font-weight: 600; }
input, select { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; min-height: 32px; }
input:disabled { opacity: 0.55; }

/* ---- top bar: file, history, save ---- */
.topbar { display: flex; align-items: center; gap: 12px 16px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.history-btns { display: flex; gap: 6px; }
.topbar-save { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.unsaved { color: var(--warn-ink); font-weight: 600; font-size: 13px; text-decoration: none; white-space: nowrap; }
.unsaved:hover { text-decoration: underline; }

.trees-bar { display: flex; gap: 10px; align-items: center; padding: 10px 20px 0; flex-wrap: wrap; }
.tree-list { display: flex; gap: 8px; flex-wrap: wrap; }
.tree-chip { display: inline-flex; gap: 6px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 2px 4px 2px 12px; }
.tree-chip-close { width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; color: var(--muted); font: inherit; cursor: pointer; }
.tree-chip-close:hover { background: var(--bg); color: var(--ink); }

.hint { margin: 10px 20px; padding: 8px 12px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.hint summary { color: var(--ink); font-weight: 600; }
.hint p { margin: 6px 0 2px; }
.hint strong { color: var(--ink); }
.hint-zone { color: var(--accent); font-weight: 600; }

/* ---- the two trees ---- */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; padding: 0 20px; align-items: start; }
.workspace:focus { outline: none; }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; min-width: 0; }
/* colour-coded like their highlights: yellow = what is copied, green = where it lands */
.pane-source { border-top: 4px solid var(--selected); }
.pane-target { border-top: 4px solid var(--new); }
.pane-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flow-arrow { color: var(--new); }
.pane-tabs { display: none; }

.search { position: relative; }
.search input { width: 100%; }
.results { position: absolute; z-index: 5; left: 0; right: 0; margin: 2px 0 0; padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); max-height: 300px; overflow: auto; box-shadow: 0 6px 20px rgb(0 0 0 / 0.12); }
.results:empty { display: none; }
.results li > button { width: 100%; min-height: 32px; text-align: left; border: 0; background: none; color: inherit; font: inherit; padding: 5px 8px; border-radius: 5px; cursor: pointer; }
.results li > button:hover { background: var(--bg); }
.results li.muted { padding: 5px 8px; }

/* ---- chart ---- */
.chart-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12px; }
.zoom-level { min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }
.tools-sep { width: 1px; height: 18px; background: var(--line); margin: 0 6px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; margin-right: 8px; }
.stepper-value { min-width: 14px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); height: 60vh; min-height: 340px; cursor: grab; }
.chart-wrap.is-panning { cursor: grabbing; }
.chart-empty { padding: 60px 20px; text-align: center; color: var(--muted); cursor: default; }
.empty-start { max-width: 460px; margin: 0 auto; padding-top: 48px; }
.empty-start h3 { margin: 0 0 8px; font-size: 18px; color: var(--ink); }
.empty-start p { margin: 0 0 18px; }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.chart-sizer { position: relative; min-width: 100%; min-height: 100%; }
.chart {
  position: absolute; left: 0; top: 0; transform-origin: 0 0;
  display: flex; flex-direction: column; align-items: center; gap: 34px; padding: 22px; width: max-content;
}
.chart-edges { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.chart-edges path { fill: none; stroke: var(--edge); stroke-width: 1.5; }
.chart-edges path.edge-spouse { stroke-width: 2; }
.anc-parents { position: relative; z-index: 1; display: flex; gap: 14px; align-items: flex-end; }
.anc-node { display: flex; flex-direction: column; align-items: center; gap: 34px; }
.chart-note { font-size: 12px; }
.desc-node { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.couple { display: flex; gap: 22px; }
.desc-children { display: flex; gap: 24px; align-items: flex-start; }
.family-group { display: flex; flex-direction: column; align-items: center; gap: 0; }
.family-label { height: 14px; margin-bottom: 6px; font-size: 11px; line-height: 14px; color: var(--muted); background: var(--bg); padding: 0 6px; white-space: nowrap; }
.family-label:empty { background: none; padding: 0; }
.family-kids { display: flex; gap: 12px; align-items: flex-start; }

.card {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px;
  width: 150px; height: 60px; padding: 5px 9px; text-align: left;
  background: var(--panel); color: var(--ink); font: inherit;
  border: 1px solid var(--line); border-left: 4px solid var(--unknown); border-radius: 7px;
  cursor: pointer; transition: box-shadow 0.08s ease;
  -webkit-touch-callout: none; /* long-press opens our menu, not the browser's */
}
.card:hover { box-shadow: 0 3px 10px rgb(0 0 0 / 0.14); }
.card:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.card.sex-m { border-left-color: var(--male); }
.card.sex-f { border-left-color: var(--female); }
.card-name { font-weight: 600; font-size: 13px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.card-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.card-empty { cursor: default; color: var(--muted); font-style: italic; border-style: dashed; border-left-width: 1px; align-items: center; }
.card-empty:hover { box-shadow: none; }
.more { position: absolute; right: 4px; font-size: 10px; line-height: 1; padding: 2px 4px; border-radius: 4px; background: var(--bg); color: var(--muted); }
.more-up { top: 3px; }
.more-down { bottom: 3px; }

/* Card highlights, each with its own look (see the legends under the charts):
   centred = dark frame · selected = green outline · will be copied = yellow fill ·
   left out = crossed out and hatched · just added = green fill · added earlier = pale fill, dashed */
.card-focus { border-top: 2px solid var(--ink); border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.card.is-picked { outline: 3px solid var(--accent); outline-offset: 2px; }
.card.is-selected { background: var(--selected-bg); border-color: var(--selected); }
.card.is-excluded { opacity: 0.7; background: repeating-linear-gradient(-45deg, var(--panel) 0 6px, var(--bg) 6px 12px); }
.card.is-excluded .card-name { text-decoration: line-through; }
.card.is-new { background: var(--new-bg); border-color: var(--new); animation: card-pop 0.9s ease-out; }
.card.is-copied { background: var(--copied-bg); border-style: dashed; border-color: var(--new); }
@keyframes card-pop { from { box-shadow: 0 0 0 8px color-mix(in srgb, var(--new) 45%, transparent); } to { box-shadow: 0 0 0 0 transparent; } }
.chart-edges path.edge-new { stroke: var(--new); stroke-width: 2.5; }
.chart-edges path.edge-animate { stroke-dasharray: 1; stroke-dashoffset: 1; animation: edge-draw 0.7s 0.15s ease-out forwards; }
@keyframes edge-draw { to { stroke-dashoffset: 0; } }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.card.legend-swatch { display: inline-block; width: 22px; height: 14px; padding: 0; border-left-width: 1px; border-radius: 3px; cursor: default; animation: none; outline-offset: 1px; outline-width: 2px; }
.card.legend-swatch:hover { box-shadow: none; }
.card.legend-swatch.card-focus { border-left: 2px solid var(--ink); }

.status-line { margin: 0; min-height: 1.45em; font-size: 13px; }
.status-line .btn-small { margin-left: 4px; vertical-align: baseline; }

/* ---- drag and drop ---- */
#source-chart .card[data-id], #target-chart .card[data-id], #source-results button[data-id] { cursor: grab; touch-action: none; user-select: none; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }
.chart-wrap.drop-ready { outline: 2px dashed var(--accent); outline-offset: -2px; }
.chart-wrap.drop-loose { background: var(--new-bg); }
.card.is-drop-target { box-shadow: 0 0 0 3px var(--accent); }
.dnd-layer { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.dnd-zone {
  position: fixed; display: grid; place-items: center; text-align: center; padding: 2px 6px;
  font-size: 12px; font-weight: 600; color: var(--accent);
  background: color-mix(in srgb, var(--panel) 88%, var(--accent));
  border: 2px dashed var(--accent); border-radius: 7px;
  pointer-events: auto; /* found by elementFromPoint while dragging */
}
.dnd-zone.zone-same { background: color-mix(in srgb, var(--panel) 70%, var(--accent)); }
.dnd-zone.is-hot { background: var(--accent); color: var(--accent-ink); border-style: solid; }
.dnd-ghost {
  position: fixed; left: 0; top: 0; max-width: 280px; padding: 8px 12px; border-radius: var(--radius);
  background: var(--ink); color: var(--bg); box-shadow: 0 8px 24px rgb(0 0 0 / 0.25); opacity: 0.94;
}
.dnd-ghost.can-drop { background: var(--accent); color: var(--accent-ink); }
.dnd-ghost-title { font-weight: 600; }
.dnd-ghost-detail { font-size: 12px; opacity: 0.9; }

/* ---- changes, export check, messages ---- */
.help { margin: 0; color: var(--muted); }
summary { cursor: pointer; }
.issues { border-radius: var(--radius); padding: 8px 12px; font-size: 13px; margin-top: 6px; }
.issues.ok { background: var(--new-bg); }
.issues.has-issues { background: var(--selected-bg); }
.issues ul { margin: 4px 0 0; padding-left: 18px; }
.log-wrap { padding: 16px 20px 96px; }
.log-wrap:focus { outline: none; }
.log { margin: 6px 0 0; padding-left: 22px; display: grid; gap: 4px; }
.log .warn { font-size: 12px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); z-index: 20;
  display: flex; align-items: flex-start; gap: 10px; max-width: min(680px, 92vw);
  background: var(--ink); color: var(--bg); padding: 10px 10px 10px 16px; border-radius: var(--radius);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.error { background: #b3261e; color: #fff; }
.toast-msg { flex: 1; padding-top: 2px; }
.toast-close { flex: none; width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgb(255 255 255 / 0.15); color: inherit; font: inherit; cursor: pointer; }
.drop-overlay { position: fixed; inset: 0; display: grid; place-items: center; font-size: 22px; font-weight: 600; background: rgb(47 111 94 / 0.18); border: 4px dashed var(--accent); z-index: 30; pointer-events: none; }

/* ---- context menu, clipboard, dialogs ---- */
.ctx-menu {
  position: fixed; z-index: 50; min-width: 230px; max-width: min(360px, 94vw); max-height: 90vh; overflow: auto; padding: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.18);
}
.ctx-heading { padding: 6px 10px 4px; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 32px; padding: 6px 10px;
  border: 0; border-radius: 5px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.ctx-item:hover, .ctx-item:focus-visible { background: var(--bg); outline: none; }
.ctx-item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.ctx-item.danger { color: var(--danger); }
.ctx-hint { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ctx-sep { height: 1px; margin: 4px 6px; background: var(--line); }
.ctx-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 4px 10px 6px; }
.ctx-chips-label { font-size: 12px; color: var(--muted); margin-right: 4px; }
.ctx-chip { min-height: 26px; min-width: 26px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-size: 12px; padding: 1px 8px; border-radius: 999px; cursor: pointer; }
.ctx-chip:hover { border-color: var(--accent); }
.ctx-chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.clipboard-bar {
  position: fixed; left: 50%; bottom: 74px; transform: translateX(-50%); z-index: 15;
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; max-width: min(640px, 92vw);
  background: var(--panel); border: 1px solid var(--accent); border-radius: 999px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.12);
}
.person-dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; background: var(--panel); color: var(--ink); width: min(560px, 94vw); }
.person-dialog::backdrop { background: rgb(0 0 0 / 0.35); }
.person-dialog h3 { margin: 0 0 12px; font-size: 16px; }
.confirm-dialog { width: min(460px, 94vw); }
.confirm-message { margin: 0; white-space: pre-line; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form-grid label { display: grid; gap: 3px; font-size: 13px; color: var(--muted); }
.form-grid input, .form-grid select { color: var(--ink); }
.form-grid label.check { display: flex; align-items: center; gap: 6px; align-self: end; padding-bottom: 6px; color: var(--ink); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---- zoom hints ---- */
.zoom-tip { color: var(--muted); font-size: 12px; margin-left: 4px; white-space: nowrap; cursor: help; }
.zoom-hint {
  position: fixed; z-index: 45; transform: translate(-50%, -50%); pointer-events: none;
  padding: 8px 14px; border-radius: var(--radius); background: rgb(0 0 0 / 0.72); color: #fff; font-size: 13px;
  opacity: 0; transition: opacity 0.25s ease;
}
.zoom-hint.show { opacity: 1; }

/* ---- narrow screens: one tree at a time, as tabs ---- */
@media (max-width: 1100px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .pane-tabs { display: flex; gap: 6px; padding: 0 20px 10px; }
  .pane-tab {
    flex: 1; min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
    color: var(--muted); font: inherit; font-weight: 600; cursor: pointer;
  }
  #tab-source[aria-selected='true'] { color: var(--ink); border-color: var(--selected); box-shadow: inset 0 -4px 0 var(--selected); }
  #tab-target[aria-selected='true'] { color: var(--ink); border-color: var(--new); box-shadow: inset 0 -4px 0 var(--new); }
  .workspace[data-tab='source'] #pane-target, .workspace[data-tab='target'] #pane-source { display: none; }
  .pane-title { display: none; } /* the tab already names the tree */
}
@media (max-width: 600px) {
  .topbar, .trees-bar, .workspace, .log-wrap, .pane-tabs { padding-left: 16px; padding-right: 16px; }
  .hint { margin-left: 16px; margin-right: 16px; }
  /* keep the first screen for the tree: compact bar, icon-only undo/redo, short file chips */
  .topbar { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .topbar h1 { flex: 1; font-size: 16px; }
  .topbar-save { margin-left: auto; flex-wrap: nowrap; }
  .btn-label, .tree-chip-detail, .trees-bar > .muted { display: none; }
  .trees-bar { padding-top: 8px; }
  .hint { margin-top: 8px; margin-bottom: 8px; }
  .pane { padding: 10px; gap: 8px; }
  /* one row of zoom controls and one of generation steppers */
  .tools-reset, .tools-sep { display: none; }
  .chart-tools .btn-small { min-height: 36px; min-width: 36px; }
  .stepper { margin-right: 4px; }
  .zoom-tip { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .chart-wrap { height: 55vh; }
}

/* ---- touch screens: finger-sized targets ---- */
@media (pointer: coarse) {
  .btn, .btn-small, input, select, .results li > button, .ctx-item, .pane-tab { min-height: 44px; }
  .btn-small { min-width: 44px; }
  .ctx-chip, .tree-chip-close, .toast-close { min-height: 40px; min-width: 40px; }
}

/* ---- people who prefer less motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .chart-edges path.edge-animate { animation: none; stroke-dasharray: none; stroke-dashoffset: 0; }
}

/* ---- guided tour ---- */
.btn-link { margin-top: 14px; min-height: 32px; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.tour-shade { position: fixed; inset: 0; z-index: 70; }
.tour-shade.dim { background: rgb(0 0 0 / 0.45); }
.tour-spot {
  position: fixed; z-index: 71; border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgb(0 0 0 / 0.45); outline: 3px solid var(--accent); outline-offset: 0;
  transition: left 0.25s ease, top 0.25s ease, width 0.25s ease, height 0.25s ease;
}
.tour-card {
  position: fixed; z-index: 72; width: min(380px, 92vw); padding: 16px 16px 12px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 36px rgb(0 0 0 / 0.28); transition: opacity 0.15s;
}
.tour-card.busy { opacity: 0.6; }
.tour-card.centred { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.tour-card.sheet { left: 8px; right: 8px; bottom: 8px; width: auto; }
.tour-card.sheet.sheet-top { top: 8px; bottom: auto; }
.tour-card h3 { margin: 0 32px 6px 0; font-size: 16px; }
.tour-card p { margin: 0 0 12px; color: var(--muted); }
.tour-card p strong, .tour-card p em { color: var(--ink); }
.tour-actions { display: flex; align-items: center; gap: 8px; }
.tour-progress { margin-right: auto; font-size: 12px; color: var(--muted); }
.tour-close { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: var(--muted); font: inherit; cursor: pointer; }
.tour-close:hover { background: var(--bg); color: var(--ink); }
@media (pointer: coarse) { .btn-link, .tour-close { min-height: 44px; min-width: 44px; } }

/* ---- brand and welcome banner ---- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 32px; height: 32px; flex: none; }
#add-files-btn .btn-icon { display: none; } /* icon only on phones, see below */
/* A parchment card matching the painting's paper, so the art has no visible edge. It keeps
   its own light colours in dark mode (like a framed print), just dimmed a little. */
.hero {
  --panel: #ffffff; --ink: #2b2a26; --muted: #5c564b; --line: #dccfb6; --accent: #2f6f5e; --accent-ink: #ffffff;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  margin: 14px 20px; overflow: hidden; border: 1px solid #e6d9c1; border-radius: 12px;
  background: #f8eedf; color: var(--ink);
}
.hero-text { padding: 28px 8px 28px 32px; max-width: 620px; }
.hero h2 { margin: 0 0 10px; font-size: 28px; line-height: 1.2; font-family: Georgia, 'Times New Roman', serif; font-weight: 600; }
.hero p { margin: 0 0 18px; color: var(--muted); font-size: 15px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero .btn-link { margin-top: 12px; padding: 0; }
.hero-art img {
  display: block; height: clamp(260px, 30vw, 360px); width: auto;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16%); mask-image: linear-gradient(to right, transparent 0, #000 16%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .hero { filter: brightness(0.9); border-color: #4a4336; }
}
@media (max-width: 760px) {
  .hero { grid-template-columns: minmax(0, 1fr); margin: 10px 16px; }
  .hero-art { order: -1; }
  .hero-art img { width: 100%; height: auto; -webkit-mask-image: linear-gradient(to bottom, #000 82%, transparent); mask-image: linear-gradient(to bottom, #000 82%, transparent); }
  .hero-text { padding: 4px 18px 20px; }
  .hero h2 { font-size: 22px; }
  .hero-actions .btn-big { flex: 1 1 auto; }
}
@media (max-width: 600px) {
  .brand-logo { width: 28px; height: 28px; }
  .brand { white-space: nowrap; }
  #add-files-btn .btn-icon { display: inline; font-weight: 600; }
}

/* ---- links to the main site: a quiet credit line on top, the full list in the footer ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* every link that leaves the site (and opens a new tab) carries this marker */
.ext { margin-left: 3px; font-size: 0.85em; opacity: 0.75; }
/* neutral and small, so it never competes with the tool or its green action buttons */
.site-bar {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  padding: 3px 20px; font-size: 12px; color: var(--muted);
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.site-bar a { display: inline-flex; align-items: center; min-height: 24px; color: var(--ink); font-weight: 600; text-decoration: none; }
.site-bar a:hover { color: var(--accent); text-decoration: underline; }

.site-footer {
  display: grid; grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr); gap: 16px 40px; align-items: start;
  padding: 24px 20px 96px; border-top: 1px solid var(--line); background: var(--panel); font-size: 13px;
}
.footer-about p { margin: 0 0 6px; }
.footer-about a { color: var(--accent); }
.footer-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.footer-heading { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
/* navigation lists read as links from context: muted, underlined only on hover */
.footer-nav ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 20px; margin: 0; padding: 0; list-style: none; }
.footer-nav a { display: inline-flex; align-items: center; min-height: 28px; color: var(--ink); text-decoration: none; }
.footer-nav a:hover { color: var(--accent); text-decoration: underline; }
.footer-copy { grid-column: 1 / -1; margin: 0; color: var(--muted); }
.footer-copy a { color: inherit; }
.footer-copy a:hover { color: var(--accent); }
/* the changes list sits right above the footer, so it needs less room below it */
.log-wrap { padding-bottom: 24px; }

@media (max-width: 600px) {
  .site-bar { padding: 2px 16px; }
  .site-footer { grid-template-columns: 1fr; padding: 20px 16px 96px; }
}
@media (pointer: coarse) {
  .site-bar a, .footer-nav a, .footer-about a, .footer-copy a { min-height: 44px; }
}

/* ---- save dialog (browsers without a Save As window) ---- */
.save-field { display: grid; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.save-field input { width: 100%; color: var(--ink); }
.issues-note { margin: 6px 0 0; color: var(--muted); }
