:root {
  --wall: #26241f;          /* a gallery wall: mid-dark warm grey, kind to paintings */
  --wall-deep: #1c1a17;
  --panel: #2f2c27;
  --line: #45413a;
  --ink: #ece6da;
  --ink-soft: #b5ad9e;
  --ink-faint: #9c9283;     /* ≥ 4.5:1 on wall and panel */
  --accent: #e0a84a;        /* current painting, active border */
  --preview: #8fb8d8;       /* preview state and its copies */
  --cell: 84px;             /* thumbnail cell */
  --label: 15px;            /* text line under a thumbnail */
  --head: 28px;             /* border header */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--wall-deep);
  color: var(--ink);
  font: 13px/1.4 var(--sans);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
a { color: var(--ink); }
button { font: inherit; color: inherit; }

/* ------------------------------------------------------------ top bar */
.bar {
  display: flex; align-items: center; gap: 20px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.brand { font: 600 15px var(--serif); letter-spacing: .02em; margin: 0; white-space: nowrap; }
.hint { margin: 0 0 0 auto; color: var(--ink-faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* ------------------------------------------------------------ layout */
/* Each side has a thumbnail size (--X-cell) and visibility (--X-vis, 0–1).
   The grid tracks are computed from them, so changing them moves everything
   together: a border growing, the opposite one sliding off, the centre
   shifting. */
@property --top-cell    { syntax: '<length>'; inherits: true; initial-value: 84px; }
@property --bottom-cell { syntax: '<length>'; inherits: true; initial-value: 84px; }
@property --left-cell   { syntax: '<length>'; inherits: true; initial-value: 84px; }
@property --right-cell  { syntax: '<length>'; inherits: true; initial-value: 84px; }
@property --top-vis     { syntax: '<number>'; inherits: true; initial-value: 1; }
@property --bottom-vis  { syntax: '<number>'; inherits: true; initial-value: 1; }
@property --left-vis    { syntax: '<number>'; inherits: true; initial-value: 1; }
@property --right-vis   { syntax: '<number>'; inherits: true; initial-value: 1; }

.space {
  --cell-big: calc(var(--cell) * 2);
  --side-pad: 40px;                         /* vertical border width = cell + this */
  --top-cell: var(--cell); --bottom-cell: var(--cell); --left-cell: var(--cell); --right-cell: var(--cell);
  --top-vis: 1; --bottom-vis: 1; --left-vis: 1; --right-vis: 1;
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns:
    calc((var(--left-cell) + var(--side-pad)) * var(--left-vis))
    minmax(0, 1fr)
    calc((var(--right-cell) + var(--side-pad)) * var(--right-vis));
  grid-template-rows:
    calc((var(--head) + var(--top-cell) + var(--label) + 12px) * var(--top-vis))
    minmax(0, 1fr)
    calc((var(--head) + var(--bottom-cell) + var(--label) + 12px) * var(--bottom-vis));
  /* Side borders run the full height (they own the corners), so an expanded
     side border is a long column; top and bottom sit between them. */
  grid-template-areas: "left top right" "left centre right" "left bottom right";
  gap: 1px;
  background: var(--line);
  overflow: hidden;                         /* a retracting border slides out of sight */
}
/* The expand / restore animation sets these per frame from js/app.js. */

/* Borders keep their full size and hug their inner edge, so when a track
   shrinks the border slides outward instead of being squashed. */
[data-side="top"]    { grid-area: top;    --cell: var(--top-cell);    align-self: end;
                       height: calc(var(--head) + var(--cell) + var(--label) + 12px); }
[data-side="bottom"] { grid-area: bottom; --cell: var(--bottom-cell); align-self: start;
                       height: calc(var(--head) + var(--cell) + var(--label) + 12px); }
[data-side="left"]   { grid-area: left;   --cell: var(--left-cell);   justify-self: end;
                       width: calc(var(--cell) + var(--side-pad)); }
[data-side="right"]  { grid-area: right;  --cell: var(--right-cell);  justify-self: start;
                       width: calc(var(--cell) + var(--side-pad)); }
.centre { grid-area: centre; }

/* Expanded cells have room for a title (or an artist's full name). */
.thumb .lbl .b { display: none; }
.sheet .thumb .lbl .a { display: none; }
.sheet .thumb .lbl .b { display: inline; }

/* ------------------------------------------------------------ borders */
.border {
  background: var(--wall);
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  position: relative;
}
.border.active { box-shadow: inset 0 0 0 2px var(--accent); }
.border-head {
  height: var(--head); flex: none;
  display: flex; align-items: center; gap: 6px;
  padding: 0 8px;
  color: var(--ink-soft); font-size: 12px;
  white-space: nowrap; overflow: hidden;
}
.border.active .border-head { color: var(--accent); }
.vertical .border-head {
  height: auto; flex-direction: column; align-items: stretch; gap: 3px;
  padding: 6px 6px 4px;
}
.border-head select {
  background: transparent; color: inherit; border: 1px solid transparent; border-radius: 4px;
  font: inherit; padding: 1px 2px; cursor: pointer; min-width: 0;
}
.border-head select:hover, .border-head select:focus { border-color: var(--line); outline: none; }
.border-head select.rel { font-weight: 600; color: var(--ink); }
.border.active .border-head select.rel { color: var(--accent); }
.border-head .list-title { font-weight: 600; color: var(--ink); }
.border-head .works-label {
  background: none; border: 1px solid transparent; border-radius: 4px; padding: 1px 4px;
  font: inherit; font-weight: 600; color: var(--ink); cursor: pointer;
  max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.border-head .works-label:hover { border-color: var(--line); }
.border.active .border-head .works-label { color: var(--accent); }
.works-label.flash { animation: label-flash 1.1s ease; }
@keyframes label-flash { 0%, 40% { background: color-mix(in srgb, var(--accent) 35%, transparent); } 100% { background: transparent; } }
.border-head .count { color: var(--ink-faint); margin-left: auto; }
.vertical .border-head .count { margin-left: 0; }
.vertical .border-head .list-title { padding: 0 2px; }

/* Category cells: name first, a cropped token of the best-known painting
   (round for artists), a count. Same footprint as a painting cell, but they
   must not read as paintings. */
.thumb.facet .frame {
  width: calc(var(--cell) * .62); height: calc(var(--cell) * .62);
  margin-top: calc(var(--cell) * .03);
  border-radius: 6px; overflow: hidden; background: var(--panel);
}
.thumb.facet.artists .frame { border-radius: 50%; }
.thumb.facet .frame img { width: 100%; height: 100%; max-width: none; max-height: none; object-fit: cover; }
.thumb.facet .lbl {
  height: calc(var(--cell) * .35 + var(--label));
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  white-space: normal; line-height: 1.2; padding-top: 3px;
}
.thumb.facet .nm {
  color: var(--ink); font-weight: 600; font-size: 11px;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  text-overflow: ellipsis; max-width: 100%;
}
.thumb.facet .n { color: var(--ink-faint); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sheet .thumb.facet .nm { font-size: 13px; -webkit-line-clamp: 3; }
.sheet .thumb.facet .n { font-size: 12px; }
.thumb.facet .n .b { display: none; }
.sheet .thumb.facet .n .a { display: none; }
.sheet .thumb.facet .n .b { display: inline; }
.thumb.facet.current .nm { color: var(--accent); }
.thumb.facet.current .frame { outline: 2px solid var(--accent); }
.thumb.flash .frame { animation: cell-flash 1.1s ease; }
@keyframes cell-flash { 0%, 35% { outline: 4px solid var(--accent); outline-offset: -4px; } 100% { outline-offset: -2px; } }

.track {
  flex: 1; min-height: 0; min-width: 0;
  display: flex; gap: 6px;
  padding: 2px 8px 8px;
  position: relative;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
  overflow-anchor: none;      /* we keep things in place ourselves (expanding borders) */
}
.horizontal .track { overflow-x: auto; overflow-y: hidden; }
.vertical .track { flex-direction: column; align-items: center; overflow-y: auto; overflow-x: hidden; padding: 2px 8px 8px; }
.track.stale .thumb { opacity: .35; }

.thumb {
  flex: none;
  width: var(--cell);
  padding: 0; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
}
.thumb .frame {
  width: var(--cell); height: var(--cell);
  display: flex; align-items: center; justify-content: center;
  background: var(--wall-deep);
  /* Outlines sit just inside the frame: cells clip their overflow (for
     speed), which would cut an outline drawn outside. */
  outline: 2px solid transparent; outline-offset: -2px;
  border-radius: 2px;
}
.thumb img { max-width: 100%; max-height: 100%; display: block; }
.thumb .lbl {
  height: var(--label); width: 100%;
  font-size: 11px; line-height: var(--label); color: var(--ink-faint);
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thumb:hover .frame { outline-color: var(--ink-faint); }
.thumb.current .frame { outline: 2px solid var(--accent); }
.thumb.current .lbl { color: var(--accent); }
.thumb.copy .frame { outline: 2px dashed var(--preview); }
.thumb.previewed .frame { outline: 2px solid var(--preview); }
.thumb:focus { outline: none; }
.thumb:focus-visible .frame { outline: 2px solid var(--ink); }

.message {
  margin: auto; padding: 0 12px;
  color: var(--ink-faint); font-style: italic; text-align: center;
}
.message button {
  margin-left: 6px; font-style: normal;
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  padding: 1px 8px; cursor: pointer;
}
.loading::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  background-size: 40% 100%; background-repeat: no-repeat;
  animation: sweep 1.1s linear infinite;
}
@keyframes sweep { from { background-position: -40% 0; } to { background-position: 140% 0; } }

/* ------------------------------------------------------------ centre */
.centre {
  background: var(--wall);
  display: flex; flex-direction: row;
  min-width: 0; min-height: 0;
}
.stage {
  flex: 1; min-height: 0;
  position: relative; overflow: hidden;
  background: rgb(16 15 13 / 0);
  transition: background .35s ease;      /* the comparison's backdrop fades in, as maximise's does */
}
.stage img {
  position: absolute; inset: 14px;
  width: calc(100% - 28px); height: calc(100% - 28px);
  object-fit: contain;
  transform-origin: center;
  user-select: none;
  filter: drop-shadow(0 4px 14px rgb(0 0 0 / .45));
}
.centre.previewing .stage { box-shadow: inset 0 0 0 2px var(--preview); }
.centre { position: relative; }
.badge {
  /* Sits at the top of the label column, never over the painting. */
  position: absolute; top: 10px; right: 20px; width: calc(clamp(250px, 21vw, 330px) - 40px);
  background: var(--preview); color: #10202c; text-align: center;
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 10px;
  pointer-events: none; z-index: 1;
}
.centre.previewing .caption { padding-top: 44px; }
.zoom-btn {
  position: absolute; z-index: 2;
  width: 32px; height: 32px; padding: 6px;
  border: 0; border-radius: 50%;
  background: rgb(20 18 16 / .62); color: var(--ink);
  cursor: pointer;
  opacity: 0; transition: opacity .2s, background .2s;
}
.zoom-btn svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.stage:hover .zoom-btn, .max .zoom-btn, .zoom-btn:focus-visible { opacity: .9; }
.zoom-btn:hover { background: rgb(20 18 16 / .85); opacity: 1; }
/* Only when it must sit on the painting: a ring so it can't vanish into it. */
.zoom-btn.inside { box-shadow: 0 0 0 1.5px rgb(236 230 218 / .55); }
.zoom-btn:disabled { cursor: default; color: var(--ink-faint); }
.stage:hover .zoom-btn:disabled, .max .zoom-btn:disabled { opacity: .45; }

.caption {
  /* A wall label beside the painting, so the painting gets the full height. */
  flex: none; width: clamp(250px, 21vw, 330px);
  overflow-y: auto;
  padding: 20px 20px 16px;
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 14px;
}
.caption h2 { font: 600 21px/1.25 var(--serif); margin: 0 0 6px; }
.caption .who { font: 16px/1.35 var(--serif); color: var(--ink); }
.caption .attr { color: var(--ink-soft); font-style: italic; margin-top: 2px; }
.caption .desc { color: var(--ink-soft); margin-top: 8px; }
.caption .note { color: var(--preview); margin-top: 8px; font-size: 12px; }
.caption .links { margin-top: auto; padding-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; }
.caption .links a { color: var(--ink-soft); }
.caption dl { margin: 0; display: flex; flex-direction: column; }
.caption dt {
  color: var(--ink-faint); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  margin-top: 10px;
}
.caption dt:first-child { margin-top: 0; }
.caption dd { margin: 2px 0 0; }
.caption .none { color: var(--ink-faint); font-style: italic; }
.caption .more { color: var(--ink-faint); }
.caption .pending { color: var(--ink-faint); font-style: italic; }
.caption .err { color: #e38b7a; }

/* ------------------------------------------------------------ maximise */
.stage.over-painting { cursor: zoom-in; }
.max { cursor: zoom-out; }
.max .zoom-btn { cursor: pointer; }
/* Disabled (no further detail): never the pointing hand, wherever it sits. */
.zoom-btn:disabled, .max .zoom-btn:disabled { cursor: default; }
.max-hint, .restore-hint {
  position: absolute; transform: translate(-50%, -100%);
  background: rgb(20 18 16 / .78); color: var(--ink);
  font-size: 12px; padding: 4px 12px; border-radius: 12px; white-space: nowrap;
  pointer-events: none; opacity: 0; transition: opacity .25s;
  z-index: 2;
}
.restore-hint { left: 50%; top: auto; bottom: 28px; transform: translateX(-50%); }
.max-hint.show, .restore-hint.show { opacity: 1; }
.max {
  position: fixed; inset: 0; z-index: 50;
  background: rgb(16 15 13 / 0);
  transition: background .35s ease;
}
.max.open { background: rgb(16 15 13 / .94); }
.max img {
  position: absolute;
  transform-origin: 0 0;
  transition: transform .38s cubic-bezier(.2, .7, .2, 1);
  will-change: transform;
  user-select: none;
  box-shadow: 0 10px 40px rgb(0 0 0 / .55);
}
@media (prefers-reduced-motion: reduce) {
  .max, .max img, .stage { transition: none; }
}

/* ------------------------------------------------------------ zoom mode */
.zoom {
  position: fixed; inset: 0; z-index: 60; overflow: hidden;
  background: rgb(12 11 10 / 0); transition: background .25s, opacity .25s;
  cursor: grab; touch-action: none; user-select: none;
}
.zoom.open { background: rgb(12 11 10 / 1); }
.zoom:not(.open) { opacity: 0; pointer-events: none; }   /* fading out: clicks go through */
.zoom.dragging { cursor: grabbing; }
.zoom-pane { position: absolute; inset: 0; overflow: hidden; }
.zoom-pane[hidden] { display: none; }
.zoom.double .zoom-pane:first-child { right: 50%; border-right: 2px solid rgb(0 0 0); }
.zoom.double .zoom-pane:nth-child(2) { left: 50%; }
.zoom.double .zoom-pane.active { box-shadow: inset 0 0 0 1px rgb(224 168 74 / .35); }
.zoom-img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; }
.zoom-img.anim { transition: transform .3s cubic-bezier(.2, .7, .2, 1); }
.zoom-exit {
  position: absolute; top: 14px; right: 14px;
  width: 40px; height: 40px; padding: 8px;
  border: 0; border-radius: 50%; cursor: pointer;
  background: rgb(20 18 16 / .7); color: var(--ink);
}
.zoom-exit:hover { background: rgb(20 18 16 / .92); }
.zoom-exit svg .x { stroke: var(--accent); stroke-width: 2.4; }
.zoom-exit svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.zoom-map {
  position: absolute; right: 14px; bottom: 14px;
  padding: 4px; background: rgb(20 18 16 / .75); border-radius: 4px;
  box-shadow: 0 4px 16px rgb(0 0 0 / .5);
  cursor: crosshair; line-height: 0;
  transition: opacity .2s;
}
.zoom-map.hidden { opacity: 0; pointer-events: none; }
.zoom-map img { display: block; opacity: .85; }
.zoom-rect {
  position: absolute; margin: 4px;
  outline: 2px solid var(--accent); box-shadow: 0 0 0 999px rgb(0 0 0 / .35);
  pointer-events: none;
}
.zoom-map { overflow: hidden; }
.zoom-hint {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: rgb(20 18 16 / .8); color: var(--ink-soft);
  font-size: 12px; padding: 5px 12px; border-radius: 12px;
  opacity: 0; transition: opacity .5s; pointer-events: none;
}
.zoom-hint.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .zoom, .zoom-img.anim { transition: none; }
}

/* ------------------------------------------------------------ file:// warning */
.file-warning {
  position: fixed; inset: 0; z-index: 100;
  background: var(--wall-deep); padding: 60px; font-size: 15px; line-height: 1.6;
}
.file-warning pre { background: var(--panel); padding: 12px 16px; border-radius: 6px; display: inline-block; }

/* Side borders are narrow: smaller menu text so relation names fit. */
.vertical .border-head select { font-size: 11.5px; width: 100%; padding: 1px 0; }


/* Performance: the category lists hold thousands of cells. Off-screen cells
   skip layout and paint (their size is declared, so scrolling and anchoring
   still measure correctly), and a border's insides are isolated from layout
   changes elsewhere (e.g. another border expanding). */
.thumb {
  /* Every cell is exactly this size, drawn or skipped, so positions along a
     strip are arithmetic (see anchorFor in app.js). */
  height: calc(var(--cell) + var(--label));
  overflow: hidden;
  content-visibility: auto;
  contain-intrinsic-size: var(--cell) calc(var(--cell) + var(--label));
}
.border { contain: layout paint; }

/* ------------------------------------------------------------ list search */
/* The search box appears in a border's header when the border expands. */
.lsearch {
  display: none;
  min-width: 0; width: 220px;
  padding: 3px 8px; border-radius: 5px;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  font: inherit; font-size: 12px;
}
.lsearch:focus { outline: none; border-color: var(--accent); }
.sheet-head .lsearch { display: block; }
.lsearch.filter { width: 170px; }
.vertical .lsearch { width: 100%; }

.ldrop {
  position: fixed; z-index: 47;          /* above the sheet (45), below maximise (50) */
  width: 340px; max-height: 60vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 10px 30px rgb(0 0 0 / .5);
  padding: 4px 0;
}
.ldrop .row {
  display: flex; flex-direction: column; align-items: flex-start; width: 100%;
  padding: 5px 12px; border: 0; background: none; text-align: left; cursor: pointer;
}
.ldrop .row .t { color: var(--ink); font-size: 13px; line-height: 1.3; }
.ldrop .row .m { color: var(--ink-faint); font-size: 11px; }
.ldrop .row.sel { background: var(--line); }
.ldrop .row.all { border-bottom: 1px solid var(--line); margin-bottom: 2px; padding-top: 7px; padding-bottom: 7px; }
.ldrop .row.all .t { color: var(--accent); }
.ldrop .also { padding: 7px 12px 5px; color: var(--ink-faint); font-size: 12px; border-top: 1px solid var(--line); margin-top: 2px; }
.ldrop .link { background: none; border: 0; padding: 0; color: var(--preview); cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 2px; }
.ldrop .note { padding: 8px 12px; color: var(--ink-faint); }

/* ------------------------------------------------------------ spread-out sheet */
.spread {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px 0 9px; margin-left: 4px;
  background: none; border: 1px solid var(--line); border-radius: 11px;
  color: var(--ink-soft); font: inherit; font-size: 11.5px; cursor: pointer;
}
.spread:hover { border-color: var(--ink-faint); color: var(--ink); background: var(--panel); }
.spread svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
/* Side lists are narrow: the button takes its own line under the title. */
.vertical .border-head .spread { align-self: flex-start; margin-left: 0; }

.sheet {
  position: fixed; inset: 0; z-index: 45;
  background: var(--wall-deep);
  display: flex; flex-direction: column;
  transform-origin: 0 0;
  --cell: 168px;
}
.sheet[hidden] { display: none; }     /* display: flex would override [hidden] */
.sheet-head {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  color: var(--ink-soft); font-size: 12px;
}
.sheet-title { font: 600 17px var(--serif); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.sheet-search { display: flex; gap: 8px; }
.sheet-head .order {
  background: transparent; color: inherit; border: 1px solid var(--line); border-radius: 4px; font: inherit; padding: 2px 4px;
}
.sheet-head .count { margin-left: auto; color: var(--ink-faint); }
.sheet-close {
  width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--panel); color: var(--ink); font-size: 14px;
}
.sheet-close:hover { background: var(--line); }
.sheet-grid {
  flex: 1; min-height: 0; overflow-y: auto; outline: none; position: relative;
  display: grid; grid-template-columns: repeat(auto-fill, var(--cell));
  justify-content: center; gap: 14px 12px; padding: 18px;
  align-content: start;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.sheet-grid .thumb .lbl { font-size: 12px; }
.sheet-grid .thumb.cursor .frame { outline: 2px solid var(--ink); }
.sheet-grid .thumb.current.cursor .frame { outline-color: var(--accent); box-shadow: 0 0 0 4px rgb(224 168 74 / .25); }
.sheet-foot {
  flex: none; min-height: 34px; padding: 8px 18px;
  border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sheet-foot b { color: var(--ink); font-weight: 600; }
.sheet .message { margin: 40px auto; }

/* ------------------------------------------------------------ about the data */
.about-link {
  margin-left: auto; flex: none;
  background: none; border: 0; padding: 2px 4px; cursor: pointer;
  color: var(--ink-soft); font: inherit; font-size: 12px;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line);
}
.about-link:hover { color: var(--ink); text-decoration-color: var(--ink-soft); }
.bar .hint { margin-left: 16px; }
.about {
  position: absolute; z-index: 3; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(440px, calc(100% - 48px));
  background: rgb(36 34 30 / .97); border: 1px solid var(--line); border-radius: 10px;
  padding: 22px 24px 18px; box-shadow: 0 18px 50px rgb(0 0 0 / .55);
  color: var(--ink); font-size: 14px; line-height: 1.55;
}
.about h2 { font: 600 18px var(--serif); margin: 0 0 8px; }
.about p { margin: 0 0 16px; color: var(--ink-soft); }
.about a { color: var(--ink); }
.about-ok {
  display: block; margin-left: auto;
  background: var(--accent); color: #241a08; border: 0; border-radius: 6px;
  padding: 6px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
.about-ok:hover { filter: brightness(1.08); }

/* ------------------------------------------------------------ narrow screens / touch */
.about .touch-note { color: var(--ink); border-top: 1px solid var(--line); padding-top: 12px; }
.narrow {
  position: fixed; inset: 0; z-index: 90;
  background: var(--wall-deep);
  display: flex; align-items: center; justify-content: center; padding: 24px 16px;
}
.narrow[hidden] { display: none; }
.narrow-card { max-width: 420px; color: var(--ink); font-size: 16px; line-height: 1.55; }
.narrow-card h2 { font: 600 22px var(--serif); margin: 0 0 10px; }
.narrow-card p { color: var(--ink-soft); margin: 0 0 20px; }
.narrow-card .about-ok { margin-left: 0; padding: 8px 18px; }

/* ------------------------------------------------------------ Wikipedia introduction */
.caption dd.wiki { color: var(--ink); line-height: 1.5; }
.caption dd.wiki p { margin: 0 0 8px; }
.caption .wiki-more { font-size: 12px; color: var(--ink-soft); }

/* ------------------------------------------------------------ comparison */
/* A painting set aside occupies the left pane; the current painting the
   right. --split is the left pane's share of the stage, 0–100. */
.stage { --split: 50; }
.stage.comparing #centre-img {
  left: calc(var(--split) * 1% + 12px);
  width: max(0px, calc((100 - var(--split)) * 1% - 26px));
}
.pin-pane {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: calc(var(--split) * 1%);
  overflow: hidden;
}
.pin-pane[hidden] { display: none; }
.stage .pin-pane img {
  inset: auto; left: 14px; top: 14px;
  width: max(0px, calc(100% - 26px)); height: calc(100% - 14px - 50px);
}
.pin-cap {
  position: absolute; left: 14px; right: 12px; bottom: 10px; height: 34px;
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden;
}
.pin-cap .t { color: var(--ink); font: 600 14px var(--serif); overflow: hidden; text-overflow: ellipsis; }
.pin-cap .m { overflow: hidden; text-overflow: ellipsis; }
.pin-cap .unpin {
  flex: none; margin-left: auto; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: var(--panel); color: var(--ink); cursor: pointer; font-size: 12px;
}
.pin-cap .unpin:hover { background: var(--line); }
.stage:not(.comparing) .pin-pane { display: none; }

.divider {
  position: absolute; top: 0; bottom: 0; z-index: 2;
  left: clamp(7px, calc(var(--split) * 1%), calc(100% - 7px));
  width: 14px; margin-left: -7px;
  cursor: col-resize; outline: none; touch-action: none;
}
.divider[hidden] { display: none; }
.divider span { position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.divider::after {
  content: ""; position: absolute; left: 2px; top: 50%; width: 10px; height: 44px; margin-top: -22px;
  border-radius: 5px; background: var(--ink-faint);
}
.divider:hover span, .divider:focus-visible span, .stage.dragging-split .divider span { background: var(--accent); }
.divider:hover::after, .stage.dragging-split .divider::after { background: var(--accent); }
.stage.dragging-split { cursor: col-resize; user-select: none; }

.pin-btn {
  position: absolute; z-index: 2;
  width: 32px; height: 32px; padding: 6px;
  border: 0; border-radius: 50%;
  background: rgb(20 18 16 / .62); color: var(--ink); cursor: pointer;
  opacity: 0; transition: opacity .2s, background .2s;
}
.pin-btn svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.stage:hover .pin-btn, .pin-btn:focus-visible { opacity: .9; }
.pin-btn:hover { background: rgb(20 18 16 / .85); opacity: 1; }
.pin-btn.on { color: var(--accent); opacity: .95; }
.pin-btn.on svg { fill: currentColor; }

/* The comparison maximised: the whole stage fills the window. */
.stage.cmp-max {
  position: fixed; inset: 0; z-index: 50;
  background: rgb(16 15 13 / 1);
  cursor: zoom-out;                      /* a click restores (the divider and buttons keep their own) */
}

/* Shrinking back from the maximised comparison: nothing cropped on the way. */
.stage.flipping, .stage.flipping .pin-pane { overflow: visible; }
.stage.flipping { z-index: 50; }

/* ------------------------------------------------------------ comparison captions */
/* The current painting's caption bar, only when the comparison is maximised
   (the label column is out of sight then). */
.cur-cap { display: none; }
.stage.cmp-max.comparing .cur-cap {
  display: flex; align-items: center; gap: 10px;
  position: absolute; bottom: 10px; height: 34px;
  left: calc(var(--split) * 1% + 12px); right: 12px;
  font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden;
}
.cur-cap .t { color: var(--ink); font: 600 14px var(--serif); overflow: hidden; text-overflow: ellipsis; flex: none; max-width: 60%; }
.cur-cap .m { overflow: hidden; text-overflow: ellipsis; }
.stage.cmp-max.comparing #centre-img { height: calc(100% - 14px - 50px); }
.stage.cmp-max.comparing[style*="--split: 100"] .cur-cap { display: none; }

/* Each half of the double zoom names its painting. */
.zoom-cap {
  position: absolute; left: 14px; bottom: 14px; z-index: 1;
  max-width: calc(100% - 28px - 150px);
  display: flex; flex-direction: column; gap: 1px;
  padding: 6px 10px; border-radius: 6px;
  background: rgb(16 15 13 / .78); color: var(--ink-soft); font-size: 12px;
  pointer-events: none;
}
.zoom-cap[hidden] { display: none; }
.zoom-cap .t { color: var(--ink); font: 600 14px var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zoom-cap .m { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* In the double zoom the captions sit at the bottom: the hint goes to the top. */
.zoom.double .zoom-hint { top: 18px; bottom: auto; }

/* ------------------------------------------------------------ back / forward */
.nav-buttons { display: flex; gap: 4px; margin-left: -6px; }
.nav-btn {
  width: 26px; height: 24px; padding: 0 0 2px;
  border: 1px solid var(--line); border-radius: 6px; background: none;
  color: var(--ink-soft); font-size: 18px; line-height: 1; cursor: pointer;
}
.nav-btn:hover:not(:disabled) { background: var(--panel); color: var(--ink); border-color: var(--ink-faint); }
.nav-btn:disabled { opacity: .35; cursor: default; }

/* ------------------------------------------------------------ copy link (maximise, zoom) */
.copy-link {
  position: fixed; z-index: 70; top: 14px; left: 14px;
  background: rgb(20 18 16 / .78); color: var(--ink); border: 1px solid var(--line); border-radius: 14px;
  padding: 5px 12px; font: inherit; font-size: 12px; cursor: pointer;
}
.copy-link:hover { background: rgb(20 18 16 / .95); border-color: var(--ink-faint); }
.copy-link[hidden] { display: none; }
