/*
  Whose Land? — digital atlas
  Visual language inherited from Libevra (index.css + S19): ink-tinted shadows in
  five elevation steps, 20px group radius, 14px field radius, 24px sheet radius,
  the green-grey neutral palette, system type roles and 220–260ms state
  transitions. Brand green is kept for controls and selection; the map's own
  colours belong to the six historical layers.
  Default material: S19 "B2 · Layered Glass" (see the B2 section near the end).
  The map sheet itself stays opaque paper; only the chrome around it is glass.
*/

:root {
  /* Libevra base palette */
  --canvas: #f2f4f2;
  --surface: #ffffff;
  --paper: #fcfcfa;
  --ink: #24312b;
  --muted: #60726a;
  --line: #e3ede7;
  --line-mid: #d3ddd8;
  --line-strong: #7f8f87;
  --brand: #55997a;
  --brand-dark: #447d63;
  --brand-soft: #edf5f0;
  --warn: #b07d2b;
  --overlay: rgb(36 49 43 / 0.35);

  /* Historical layers: low-saturation, each ≥ 5:1 on paper */
  --A: #9a5b36;
  --B: #3d6688;
  --C: #6c5b98;
  --D: #9a3c53;
  --E: #24312b;
  --F: #2a6e69;

  /* Libevra A elevation (s19-lab-tokens.css) */
  --ink-rgb: 36 49 43;
  --rim: inset 0 1px 0 rgb(255 255 255 / 0.9);
  --elev-0: inset 0 1px 2px rgb(var(--ink-rgb) / 0.07), inset 0 0 0 0.5px rgb(var(--ink-rgb) / 0.05);
  --elev-1-tight: 0 0 0 0.5px rgb(var(--ink-rgb) / 0.06), 0 1px 2px rgb(var(--ink-rgb) / 0.05);
  --elev-1: var(--elev-1-tight), 0 6px 14px -8px rgb(var(--ink-rgb) / 0.2);
  --elev-2: var(--rim), 0 0 0 0.5px rgb(var(--ink-rgb) / 0.07), 0 1px 2px rgb(var(--ink-rgb) / 0.08), 0 3px 8px -3px rgb(var(--ink-rgb) / 0.1), 0 8px 16px -7px rgb(var(--ink-rgb) / 0.16);
  --elev-3: var(--rim), 0 0 0 0.5px rgb(var(--ink-rgb) / 0.06), 0 2px 4px rgb(var(--ink-rgb) / 0.06), 0 14px 28px -10px rgb(var(--ink-rgb) / 0.22), 0 28px 52px -24px rgb(var(--ink-rgb) / 0.24);
  --elev-4: 0 0 0 0.5px rgb(var(--ink-rgb) / 0.06), 0 24px 48px -20px rgb(var(--ink-rgb) / 0.36);

  --r-group: 20px;
  --r-key: 24px;
  --r-field: 14px;
  --r-mini: 12px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);
  --t-fast: 180ms;
  --t: 220ms;
  --t-sheet: 260ms;

  --font: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --gap: 16px;
  --top-h: 68px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, output { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-dark); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--brand-dark); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- type roles */
.eyebrow {
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-dark);
}
.helper { font-size: 12px; line-height: 16px; color: var(--muted); }
.unit { font-size: 11px; letter-spacing: 0.04em; color: var(--muted); }

/* ---------------------------------------------------------------- app frame */
.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 var(--gap) var(--gap);
  padding-left: max(var(--gap), env(safe-area-inset-left));
  padding-right: max(var(--gap), env(safe-area-inset-right));
}
.topbar {
  flex: none;
  min-height: var(--top-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 6px;
}
.ident { display: grid; gap: 1px; min-width: 0; }
.ident h1 {
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  letter-spacing: -0.025em;
}
.ident .sub { font-size: 13px; line-height: 18px; color: var(--muted); }
.ident .eyebrow { display: none; }
.ident { grid-template-columns: auto 1fr; column-gap: 14px; align-items: baseline; }
.ident h1 { grid-column: 1; }
.ident .sub { grid-column: 2; }
.topnav { display: flex; gap: 4px; flex: none; }
.textbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  transition: background-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.textbtn:hover { background: var(--surface); box-shadow: var(--elev-1-tight); color: var(--ink); }
.textbtn:active { background: var(--brand-soft); }

.bench {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 312px minmax(0, 1fr) 320px;
  transition: grid-template-columns var(--t-sheet) var(--ease-sheet);
  grid-template-areas: "rail stage insp";
  gap: var(--gap);
}
.tabs { display: none; }

/* ---------------------------------------------------------------- rail */
.rail {
  grid-area: rail;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 4px 8px 2px;
  margin: -2px -4px 0 -2px;
  display: grid;
  align-content: start;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-mid) transparent;
}
.group { display: grid; gap: 10px; }
.ghead { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 0 6px; align-items: end; }
.ghead > :not(.gact) { grid-column: 1; }
.gact { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 2px; margin-right: -6px; }
.gact button { min-height: 32px; padding: 0 8px; border: 0; border-radius: 999px; background: transparent; font-size: 12px; font-weight: 500; color: var(--brand-dark); transition: background-color var(--t-fast) var(--ease); }
.gact button:hover { background: var(--surface); box-shadow: var(--elev-1-tight); }
.ghead h2, .insp h2.sect { font-size: 16px; line-height: 24px; font-weight: 600; }
.card {
  background: var(--surface);
  border-radius: var(--r-group);
  box-shadow: var(--elev-1);
}
.list { padding: 6px; display: grid; gap: 2px; }

.row {
  position: relative;
  display: grid;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-field);
  background: transparent;
  text-align: left;
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease);
}
.row::after {
  /* selection outline, fades in */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 55%, transparent);
  opacity: 0;
  transition: opacity var(--t) var(--ease);
  pointer-events: none;
}
.row:hover { background: color-mix(in srgb, var(--brand-soft) 60%, transparent); }
.row[aria-pressed="true"], .row.is-current { background: var(--brand-soft); }
.row[aria-pressed="true"]::after, .row.is-current::after { opacity: 1; }
.row:active { background: color-mix(in srgb, var(--brand-soft) 100%, var(--brand) 8%); }

/* reading rows */
.rrow { grid-template-columns: 60px 1fr; gap: 8px; }
.rrow .stack { display: flex; align-items: center; gap: 0; }
.rrow .key {
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.rrow .title { font-size: 13.5px; line-height: 18px; font-weight: 500; }
.rrow[aria-pressed="true"] .key { color: #35664f; }
.stackmarks { display: flex; gap: 3px; margin-top: 4px; }
.stackmarks i { width: 12px; height: 3px; border-radius: 2px; background: var(--c); }

/* layer rows: a pressed row plus a sibling info button (never nested) */
.lrow-wrap { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; border-radius: var(--r-field); }
.lrow { grid-template-columns: 30px 1fr 18px; gap: 9px; padding: 7px 6px 7px 9px; min-height: 46px; }
.swatch { width: 30px; height: 24px; display: block; border-radius: 6px; overflow: hidden; background: var(--paper); box-shadow: inset 0 0 0 0.5px rgb(var(--ink-rgb) / 0.12); }
.swatch svg { width: 100%; height: 100%; display: block; }
.lrow .meta { min-width: 0; display: grid; }
.lrow .yr { font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: 0.04em; color: var(--muted); font-variant-numeric: tabular-nums; }
.lrow .yr b { color: var(--c); font-weight: 700; margin-right: 6px; }
.lrow .title { font-size: 13.5px; line-height: 18px; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.check { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; box-shadow: inset 0 0 0 1.25px var(--line-strong); transition: background-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease); }
.check svg { width: 12px; height: 12px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(0.6); transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.lrow[aria-pressed="true"] .check { background: var(--brand); box-shadow: none; }
.lrow[aria-pressed="true"] .check svg { opacity: 1; transform: none; }
.lrow:not([aria-pressed="true"]) .swatch { opacity: 0.55; filter: saturate(0.4); }
.swatch { transition: opacity var(--t) var(--ease), filter var(--t) var(--ease); }
.lrow[aria-pressed="true"] { background: var(--brand-soft); }
.lrow[aria-pressed="true"]::after { opacity: 0; }
.lrow-wrap { gap: 2px; }
.lrow-wrap.is-current .info { background: var(--ink); color: #fff; box-shadow: none; }
.info {
  width: 30px; height: 30px; margin-right: 3px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.info:hover { background: var(--surface); color: var(--ink); box-shadow: var(--elev-1-tight); }
.info svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }

.fillrow { padding: 10px 16px 8px; display: grid; gap: 4px; }
.fill-label { display: flex; justify-content: space-between; font-size: 12px; line-height: 16px; color: var(--muted); }
.fill-label output { font-variant-numeric: tabular-nums; color: var(--ink); }
input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 999px; background: linear-gradient(to right, var(--brand) 0 var(--v, 66%), #dfe5e1 var(--v, 66%)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; background: #dfe5e1; }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--brand); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 0.5px rgb(var(--ink-rgb) / 0.14), 0 1px 3px rgb(var(--ink-rgb) / 0.25);
}
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 0.5px rgb(var(--ink-rgb) / 0.14), 0 1px 3px rgb(var(--ink-rgb) / 0.25); }

.actions { display: flex; gap: 8px; padding: 0 2px; flex-wrap: wrap; }
.pill {
  min-height: 36px; padding: 0 14px; border: 0; border-radius: 999px;
  background: var(--surface); box-shadow: var(--elev-1-tight);
  font-size: 13px; font-weight: 500;
  transition: box-shadow var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.pill:hover { box-shadow: var(--elev-2); transform: translateY(-1px); }
.pill:active { transform: none; box-shadow: var(--elev-1-tight); background: var(--brand-soft); }

/* ---------------------------------------------------------------- stage / map */
.stage { grid-area: stage; min-height: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.mapcard {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: var(--r-key);
  background: #eef1ee;
  box-shadow: var(--elev-1);
  overflow: hidden;
  isolation: isolate;
}
.map {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.map.is-dragging { cursor: grabbing; }
.map.is-hot { cursor: pointer; }
.map:focus-visible { outline: none; }
.mapcard:has(.map:focus-visible) { box-shadow: var(--elev-1), inset 0 0 0 2px var(--brand-dark); }

.tools {
  position: absolute; top: 12px; right: 12px;
  display: grid; gap: 0;
  background: var(--surface); border-radius: var(--r-mini);
  box-shadow: var(--elev-2);
  overflow: hidden;
}
.tool {
  width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: transparent; color: var(--ink);
  transition: background-color var(--t-fast) var(--ease);
}
.tool + .tool { box-shadow: inset 0 0.5px 0 var(--line-mid); }
.tool:hover { background: var(--brand-soft); }
.tool.panel-tool { margin-top: 0; }
.tools .sep { height: 6px; background: var(--canvas); box-shadow: inset 0 0.5px 0 var(--line-mid), inset 0 -0.5px 0 var(--line-mid); }
.app.focus .bench { grid-template-columns: 312px minmax(0, 1fr) 0px; }
.app.focus .inspector { visibility: hidden; opacity: 0; }
.inspector { transition: opacity var(--t) var(--ease), visibility 0s linear 0s; }
.app.focus .inspector { transition: opacity var(--t-fast) var(--ease), visibility 0s linear var(--t-fast); }
.tool:disabled { color: #b3bdb8; cursor: default; background: transparent; }
.tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.foot {
  flex: none;
  margin: -2px 8px 0;
  font-size: 12px; line-height: 16px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: baseline;
}
.link {
  border: 0; background: none; padding: 0; color: var(--brand-dark); font-size: inherit; font-weight: 500;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px;
}
.link:hover { color: var(--ink); }

.tip {
  position: absolute; z-index: 3; left: 0; top: 0;
  max-width: 280px; padding: 8px 10px 9px;
  background: var(--surface); border-radius: var(--r-mini);
  box-shadow: var(--elev-3);
  font-size: 12px; line-height: 16px;
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease);
}
.tip ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.tip li { display: grid; grid-template-columns: 18px 1fr; gap: 6px; align-items: baseline; }
.tip .lt { font-weight: 700; color: var(--c); font-size: 11px; }
.tip .hint { margin-top: 6px; color: var(--muted); font-size: 11px; }

/* svg map styling */
.map text { font-family: var(--font); }
.paper { fill: var(--paper); }
.frame-line { fill: none; stroke: #b9c4be; stroke-width: 1; vector-effect: non-scaling-stroke; }
.grat { fill: none; stroke: #e1e7e3; stroke-width: 0.75; vector-effect: non-scaling-stroke; }
.lake { fill: #e2eae9; stroke: #9fb4b2; stroke-width: 0.8; vector-effect: non-scaling-stroke; }
.river { fill: none; stroke: #9db4b3; stroke-width: 1.1; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.ly { transition: opacity var(--t) var(--ease), visibility 0s linear var(--t); }
.ly.off { opacity: 0 !important; visibility: hidden; }
.ly.on { visibility: visible; transition: opacity var(--t) var(--ease), visibility 0s; }
.region { stroke: none; transition: opacity var(--t) var(--ease); }
.region.dim { opacity: 0.45; }
.bnd { fill: none; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: butt; vector-effect: non-scaling-stroke; }
.bnd-A { stroke: var(--A); stroke-dasharray: 7 4; }
.bnd-B { stroke: var(--B); }
.bnd-C { stroke: var(--C); stroke-width: 2.1; stroke-linecap: round; stroke-dasharray: 0.1 4.6; }
.bnd-D { stroke: var(--D); stroke-width: 1.9; }
.bnd.hl { stroke-width: 3; }
.bnd-C.hl { stroke-width: 3.2; }
.tick-B { fill: var(--paper); stroke: var(--B); stroke-width: 1.2; }
.tick-D { stroke: var(--D); stroke-width: 1.3; stroke-linecap: round; }
.halo { paint-order: stroke fill; stroke: var(--paper); stroke-width: 3px; stroke-linejoin: round; }
.lbl-lake { font-size: 11px; font-style: italic; letter-spacing: 0.08em; fill: #4c6563; }
.lbl-river { font-size: 10.5px; font-style: italic; letter-spacing: 0.04em; fill: #556e6b; }
.lbl-grat { font-size: 10px; fill: #5f716a; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.lbl-frame { font-size: 10px; fill: #5f716a; letter-spacing: 0.02em; }
.cross { stroke: #8a9a93; stroke-width: 1; }
.place-dot { fill: #60726a; }
.lbl-place { font-size: 11.5px; fill: #4f6159; transition: fill var(--t) var(--ease); }
.lbl-place.strong { fill: var(--ink); font-weight: 600; }
.lbl-place.ref { fill: #5f716a; font-style: italic; font-size: 11px; }
.sym-E { fill: none; stroke: var(--E); stroke-width: 1.6; }
.sym-E-x { stroke: var(--E); stroke-width: 1.5; stroke-linecap: round; }
.sym-F-disk { fill: color-mix(in srgb, var(--F) 14%, transparent); }
.sym-F { fill: none; stroke: var(--F); stroke-width: 2; stroke-dasharray: 5 3; stroke-linecap: butt; }
.sym-F-dot { fill: var(--F); }
.sym-hit { fill: transparent; stroke: none; }
.selring { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 2 3; opacity: 0.9; }
.ovl-sym { cursor: pointer; }
.ovl-sym:focus, .ovl-sym:focus-visible { outline: none; }
.ovl-sym:focus-visible .selfocus { opacity: 1; }
.selfocus { fill: none; stroke: var(--brand-dark); stroke-width: 2; opacity: 0; }

/* chips (mobile quick toggles) */
.chips { display: none; }

/* ---------------------------------------------------------------- inspector */
.inspector {
  grid-area: insp;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: var(--r-group);
  box-shadow: var(--elev-1);
  scrollbar-width: thin;
  scrollbar-color: var(--line-mid) transparent;
}
.inspector:focus { outline: none; }
.insp { padding: 20px 22px 24px; display: grid; gap: 18px; }
.insp.enter { animation: insp-in var(--t) var(--ease); }
@keyframes insp-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.ihead { display: grid; gap: 6px; }
.ihead h2 { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.02em; }
.ihead .lede { font-size: 14px; line-height: 22px; color: var(--muted); }
.crumb {
  justify-self: start;
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 32px; margin: -6px 0 -2px -8px; padding: 0 10px 0 6px;
  border: 0; border-radius: 999px; background: transparent;
  font-size: 12px; font-weight: 500; color: var(--brand-dark);
  transition: background-color var(--t-fast) var(--ease);
}
.crumb:hover { background: var(--brand-soft); }
.crumb svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.stackline { display: flex; flex-wrap: wrap; gap: 6px; }
.lchip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 0 10px 0 6px;
  border: 0; border-radius: 999px;
  background: var(--canvas);
  box-shadow: inset 0 0 0 0.5px rgb(var(--ink-rgb) / 0.1);
  font-size: 12px; line-height: 16px; font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: background-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
button.lchip:hover { background: var(--surface); box-shadow: var(--elev-1-tight); }
.lchip .dot { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; font-size: 10px; font-weight: 700; }
.lchip .dot.e { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }

.qa { display: grid; gap: 14px; }
.qa dt { font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.qa dd { margin: 0; font-size: 14px; line-height: 24px; }
.qa dd.q { font-size: 16px; line-height: 24px; font-weight: 600; }
.qa .rich p + p { margin-top: 8px; }
.qa .rich a { word-break: break-word; }

.note {
  padding: 12px 14px;
  border-radius: var(--r-field);
  background: var(--canvas);
  box-shadow: var(--elev-0);
  font-size: 13px; line-height: 20px;
}
.note b { display: block; font-size: 11px; line-height: 16px; letter-spacing: 0.08em; text-transform: uppercase; color: #8f6420; font-weight: 700; margin-bottom: 2px; }

.srcs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.src {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: start;
  padding: 10px 10px 10px 10px; border-radius: var(--r-field);
  background: var(--canvas);
}
.sid {
  font-size: 11px; line-height: 20px; font-weight: 700; letter-spacing: 0.03em; text-align: center;
  border-radius: 6px; background: var(--surface); box-shadow: var(--elev-1-tight); color: var(--ink);
}
.src .st { font-size: 13px; line-height: 18px; font-weight: 500; }
.src .sm { font-size: 12px; line-height: 16px; color: var(--muted); margin-top: 2px; }
.src .go {
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: var(--brand-dark);
  transition: background-color var(--t-fast) var(--ease);
}
.src .go:hover { background: var(--surface); box-shadow: var(--elev-1-tight); }
.src .go svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.src.feat { background: var(--brand-soft); }

.hits { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.hit {
  width: 100%; display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center;
  min-height: 48px; padding: 8px 10px; border: 0; border-radius: var(--r-field); text-align: left; background: var(--canvas);
  transition: background-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.hit:hover { background: var(--surface); box-shadow: var(--elev-1); }
.hit .lt { font-weight: 700; font-size: 12px; color: var(--c); text-align: center; }
.hit .ht { font-size: 14px; line-height: 20px; font-weight: 500; }
.hit .hk { font-size: 12px; line-height: 16px; color: var(--muted); }
.hit .chev { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.sitelist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sitelist button {
  width: 100%; display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  min-height: 40px; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; text-align: left;
  transition: background-color var(--t-fast) var(--ease);
}
.sitelist button:hover { background: var(--canvas); }
.sitelist .art { font-size: 12px; color: var(--muted); white-space: nowrap; }

.legend { display: grid; gap: 8px; }
.legend li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: center; font-size: 13px; line-height: 18px; }
.legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.ctrlrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ctrlrow .grow { flex: 1; min-width: 140px; display: grid; gap: 4px; }
.coord { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pager { display: flex; justify-content: space-between; gap: 8px; padding-top: 4px; border-top: 1px solid var(--line); }
.pager button { min-height: 40px; border: 0; background: transparent; border-radius: 999px; padding: 0 10px; font-size: 13px; font-weight: 500; color: var(--brand-dark); }
.pager button:hover { background: var(--brand-soft); }
.pager button:disabled { visibility: hidden; }

/* ---------------------------------------------------------------- sheets */
.sheet {
  border: 0; padding: 0; margin: auto;
  width: min(720px, calc(100vw - 48px));
  max-height: min(860px, calc(100dvh - 64px));
  border-radius: var(--r-key);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--elev-4);
  overflow: hidden;
}
.sheet.wide { width: min(880px, calc(100vw - 48px)); }
.sheet[open] { display: flex; animation: sheet-in var(--t-sheet) var(--ease-sheet); }
.sheet.closing { animation: sheet-out 200ms var(--ease-exit) forwards; }
.sheet::backdrop { background: var(--overlay); animation: fade-in var(--t-sheet) var(--ease); }
.sheet.closing::backdrop { animation: fade-out 200ms var(--ease-exit) forwards; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes sheet-out { to { opacity: 0; transform: translateY(10px) scale(0.99); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.sheet-inner { display: flex; flex-direction: column; min-height: 0; width: 100%; }
.sheet-head, .sheet-nav { flex: none; }
.sheet-body { flex: 1; min-height: 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 22px 24px 14px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 20px; line-height: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; }
.close { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--canvas); margin: -4px -8px 0 0; transition: background-color var(--t-fast) var(--ease); }
.close:hover { background: var(--brand-soft); }
.close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.sheet-nav { display: flex; gap: 4px; padding: 10px 20px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.sheet-nav a { flex: none; min-height: 32px; display: inline-flex; align-items: center; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--ink); text-decoration: none; transition: background-color var(--t-fast) var(--ease); }
.sheet-nav a:hover { background: var(--brand-soft); }
.sheet-body { overflow-y: auto; padding: 8px 24px 28px; overscroll-behavior: contain; }
.sheet-body section { padding-top: 22px; scroll-margin-top: 8px; }
.sheet-body h3 { font-size: 16px; line-height: 24px; font-weight: 600; margin-bottom: 4px; }
.sheet-body .helper { margin-bottom: 12px; font-size: 12px; line-height: 20px; }
.prose p { font-size: 14px; line-height: 24px; }
.prose p + p { margin-top: 10px; }
.prose ul { margin: 8px 0 0; padding-left: 18px; font-size: 14px; line-height: 24px; }
.prose li + li { margin-top: 4px; }

.scard {
  display: grid; grid-template-columns: 40px 1fr; gap: 4px 14px;
  padding: 16px; border-radius: var(--r-group); background: var(--surface); box-shadow: var(--elev-1);
}
.scard + .scard { margin-top: 10px; }
.scard .sid { line-height: 24px; font-size: 12px; grid-row: span 3; align-self: start; }
.scard h4 { margin: 0; font-size: 14px; line-height: 20px; font-weight: 600; }
.scard .type { font-size: 11px; line-height: 16px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.scard dl { margin: 6px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; font-size: 12px; line-height: 18px; }
.scard dt { color: var(--muted); }
.scard dd { margin: 0; }
.scard .open { margin-top: 10px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.scard .open svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.scard.feat { background: linear-gradient(var(--brand-soft), var(--brand-soft)) padding-box; box-shadow: var(--elev-1), inset 0 0 0 1px color-mix(in srgb, var(--brand) 40%, transparent); }
.scard .access { grid-column: 2; margin-top: 8px; padding-top: 8px; border-top: 1px solid color-mix(in srgb, var(--brand) 22%, transparent); font-size: 12px; line-height: 18px; color: var(--ink); }
.scard .body { grid-column: 2; min-width: 0; }
.scard .used { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }

.mtable { display: grid; gap: 10px; }
.mrow { display: grid; grid-template-columns: 40px 1fr; gap: 4px 14px; padding: 14px 16px; border-radius: var(--r-group); background: var(--canvas); }
.mrow .sid { grid-row: span 2; align-self: start; line-height: 24px; color: #fff; background: var(--c); box-shadow: none; }
.mrow .sid.e { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.mrow p { font-size: 13px; line-height: 21px; }
.mrow .ev { color: var(--muted); }
.helper.after { margin-top: 12px; }
.downloads { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.downloads a { text-decoration: none; }

.noscript { padding: 24px; }

/* ---------------------------------------------------------------- medium: rail + stage, reading below */
@media (max-width: 1239px) {
  .app { height: auto; min-height: 100%; }
  .bench {
    grid-template-columns: 280px minmax(0, 1fr);
    grid-template-areas: "rail stage" "rail insp";
    grid-template-rows: min(72vh, 760px) auto;
  }
  .rail { overflow: visible; margin: 0; padding: 0; }
  .panel-tool, .tools .sep { display: none; }
  .app.focus .bench { grid-template-columns: 280px minmax(0, 1fr); }
  .app.focus .inspector { visibility: visible; opacity: 1; }
  .inspector { overflow: visible; }
}

/* ---------------------------------------------------------------- phone */
@media (max-width: 759px) {
  :root { --gap: 12px; }
  .app { padding: 0 0 calc(24px + env(safe-area-inset-bottom)); }
  .topbar { min-height: 0; padding: 10px 14px 8px; align-items: center; gap: 8px; }
  .ident { grid-template-columns: 1fr; }
  .ident h1 { font-size: 18px; line-height: 24px; }
  .ident .sub { grid-column: 1; font-size: 12px; line-height: 16px; }
  .ident .sub .sep, .ident .sub .scope { display: none; }
  .topnav { gap: 0; margin-right: -6px; }
  .textbtn { padding: 0 10px; font-size: 13px; }
  .hide-sm { display: none; }

  .bench { display: block; }
  .stage {
    position: sticky; top: 0; z-index: 5;
    padding: 0 10px 8px;
    background: var(--canvas);
    gap: 8px;
  }
  .mapcard { flex: none; height: min(76vw, 48vh); border-radius: var(--r-group); }
  .tools { top: 8px; right: 8px; grid-auto-flow: row; }
  .tool { width: 34px; height: 34px; }
  .foot { margin: -2px 4px 0; font-size: 11px; line-height: 14px; gap: 2px 8px; }
  .foot > span:nth-child(2) { display: none; }
  .lbl-lake { font-size: 10px; letter-spacing: 0.05em; }
  .lbl-river { font-size: 9.5px; }
  .lbl-place { font-size: 10.5px; }
  .lbl-place.ref { font-size: 10px; }
  .lbl-grat { font-size: 9px; }
  .chips { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
  .chip {
    position: relative;
    min-height: 40px; border: 0; border-radius: var(--r-mini);
    display: grid; justify-items: center; align-content: center; gap: 0;
    background: var(--surface); box-shadow: var(--elev-1-tight);
    font-size: 13px; line-height: 16px; font-weight: 700; color: var(--muted);
    transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  }
  .chip small { font-size: 10px; line-height: 12px; font-weight: 500; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
  .chip::before { content: ""; position: absolute; left: 10px; right: 10px; bottom: 4px; height: 2px; border-radius: 2px; background: var(--c); opacity: 0; transition: opacity var(--t-fast) var(--ease); }
  .chip[aria-pressed="true"] { color: var(--c); background: var(--surface); box-shadow: var(--elev-2), inset 0 0 0 1px color-mix(in srgb, var(--c) 45%, transparent); }
  .chip[aria-pressed="true"]::before { opacity: 1; }

  .tabs {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 0;
    margin: 6px 12px 12px; padding: 3px; border-radius: 999px; background: #e7ebe8; box-shadow: var(--elev-0);
    position: relative;
  }
  .tabs button {
    position: relative; z-index: 1; min-height: 36px; border: 0; border-radius: 999px; background: transparent;
    font-size: 13px; font-weight: 500; color: var(--muted);
    transition: color var(--t) var(--ease), background-color var(--t) var(--ease), box-shadow var(--t) var(--ease);
  }
  .tabs button[aria-selected="true"] { color: var(--ink); background: var(--surface); box-shadow: var(--elev-2); }

  .rail, .inspector { display: none; margin: 0 12px; padding: 0; overflow: visible; }
  .app[data-tab="reading"] .inspector { display: block; }
  .app[data-tab="stacks"] .rail, .app[data-tab="layers"] .rail { display: grid; }
  .app[data-tab="stacks"] #layers, .app[data-tab="layers"] #readings { display: none; }
  .app[data-tab="stacks"] .ghead, .app[data-tab="layers"] .ghead { padding-top: 2px; }
  .insp { padding: 18px 16px 22px; }
  .ihead h2 { font-size: 18px; line-height: 26px; }
  .row { min-height: 48px; }

  .sheet, .sheet.wide {
    width: 100vw; max-width: 100vw; max-height: 92dvh;
    margin: auto 0 0; border-radius: var(--r-key) var(--r-key) 0 0;
  }
  @keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
  @keyframes sheet-out { to { transform: translateY(100%); } }
  .sheet-head { padding: 18px 18px 12px; }
  .sheet-body { padding: 4px 16px calc(24px + env(safe-area-inset-bottom)); }
  .sheet-nav { padding: 8px 12px; }
  .scard, .mrow { grid-template-columns: 34px 1fr; padding: 14px; gap: 4px 10px; }
}

/* ================= B2 · Layered Glass (default material) =================
   Ported from Libevra index.css `html:root[data-visual-style="b2"]` (balanced
   preset: blur 9.1px, white rim + hairline + soft ink shadow) and the light
   wallpaper recipe in s19/wallpaper.css (spread 1.9 × .82). Tuned for a reading
   site, accessibility first: the wallpaper is at 55% strength (Libevra 85%),
   glass fills are thicker (content .42, chrome .5, reading panel .55) and grey
   text is one step darker, so every text colour measures ≥ 4.5:1 against the
   actual pixels behind it. Layer colours used as text are darkened slightly;
   on the map they are unchanged. The map paper itself is never translucent. */
:root {
  --wp-spread: 1.558;
  --wp-strength: 55%;
  --wp-base: color-mix(in srgb, var(--brand) 3%, #fafcfb);
  --wp-primary: color-mix(in srgb, var(--brand) 62%, #fff);
  --wp-warm: color-mix(in srgb, var(--brand) 8%, #f2c7a1);
  --wp-cool: color-mix(in srgb, var(--brand) 12%, #b4cde4);
  --wp-highlight: color-mix(in srgb, #fff var(--wp-strength), transparent);
  --wp-main: color-mix(in srgb, var(--wp-primary) var(--wp-strength), transparent);
  --wp-warm-l: color-mix(in srgb, var(--wp-warm) var(--wp-strength), transparent);
  --wp-cool-l: color-mix(in srgb, var(--wp-cool) var(--wp-strength), transparent);
  --wp-edge-top: color-mix(in srgb, var(--wp-primary) calc(var(--wp-strength) * .12), var(--wp-base));
  --wp-edge-bottom: color-mix(in srgb, var(--wp-cool) calc(var(--wp-strength) * .38), var(--wp-base));
  --wallpaper:
    linear-gradient(to bottom, var(--wp-edge-top), transparent 7%, transparent 92%, var(--wp-edge-bottom)),
    radial-gradient(ellipse calc(10% * var(--wp-spread)) calc(6% * var(--wp-spread)) at 75% 17%, var(--wp-highlight), transparent),
    radial-gradient(ellipse calc(38% * var(--wp-spread)) calc(22% * var(--wp-spread)) at 83% 21%, var(--wp-main) 12%, transparent 100%),
    radial-gradient(ellipse calc(24% * var(--wp-spread)) calc(14% * var(--wp-spread)) at 12% 85%, var(--wp-main), transparent),
    radial-gradient(ellipse calc(38% * var(--wp-spread)) calc(18% * var(--wp-spread)) at 10% 30%, var(--wp-warm-l) 12%, transparent 100%),
    radial-gradient(ellipse calc(50% * var(--wp-spread)) calc(29% * var(--wp-spread)) at 90% 92%, var(--wp-cool-l) 12%, transparent 100%),
    var(--wp-base);

  --glass-rgb: 250 251 249;
  --content-fill: .42;
  --chrome-fill: .5;
  --reading-fill: .55;
  --muted: #53655d;
  --brand-dark: #376a52;
  --glass-blur: 9.1px;
  --glass-filter: blur(var(--glass-blur)) saturate(1.5);
  --tool-filter: blur(calc(var(--glass-blur) * .6)) saturate(1.6);
  --glass-card: linear-gradient(160deg, rgb(255 255 255 / calc(.12 * var(--content-fill))), transparent 38%), rgb(var(--glass-rgb) / var(--content-fill));
  --glass-reading: linear-gradient(160deg, rgb(255 255 255 / calc(.12 * var(--content-fill))), transparent 38%), rgb(var(--glass-rgb) / var(--reading-fill));
  --glass-card-sh: inset 0 1px 0 #fff, inset 0 0 0 .5px rgb(255 255 255 / .48), 0 0 0 .5px rgb(40 52 46 / .07), 0 12px 28px -20px rgb(40 52 46 / .34);
  --glass-tool: rgb(var(--glass-rgb) / var(--chrome-fill));
  --glass-tool-sh: inset 0 1px 0 #fff, inset 0 0 0 .5px rgb(255 255 255 / .55), 0 0 0 .5px rgb(40 52 46 / .07), 0 6px 16px -8px rgb(40 52 46 / .24);
  --glass-pill: linear-gradient(180deg, rgb(255 255 255 / .92), rgb(255 255 255 / .72));
  --glass-pill-sh: inset 0 1px 0 #fff, 0 0 0 .5px rgb(40 52 46 / .08), 0 3px 9px -3px rgb(40 52 46 / .22);
  --glass-tile: rgb(255 255 255 / .5);
  --glass-sheet: linear-gradient(180deg, rgb(251 252 250 / .96), rgb(248 249 247 / .93));
  --glass-sheet-sh: inset 0 1px 0 #fff, 0 0 0 .5px rgb(40 52 46 / .08), 0 24px 52px -24px rgb(40 52 46 / .4);
  --overlay: rgb(36 44 40 / .32);
}
html { background: var(--wp-edge-top) linear-gradient(var(--wp-edge-top), var(--wp-edge-bottom)) fixed; }
/* body must stay transparent: the fixed ::before paints beneath it (Libevra wallpaper.css note). */
body { background: transparent; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--wallpaper); }

.card, .inspector {
  background: var(--glass-card);
  box-shadow: var(--glass-card-sh);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
}
.inspector { background: var(--glass-reading); --canvas: var(--glass-tile); }
.mapcard {
  background: var(--glass-card);
  box-shadow: var(--glass-card-sh);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
}
.mapcard:has(.map:focus-visible) { box-shadow: var(--glass-card-sh), inset 0 0 0 2px var(--brand-dark); }
.tools {
  background: var(--glass-tool);
  box-shadow: var(--glass-tool-sh);
  -webkit-backdrop-filter: var(--tool-filter);
  backdrop-filter: var(--tool-filter);
  --canvas: rgb(var(--ink-rgb) / .04);
}
.tool:hover { background: rgb(255 255 255 / .55); }
.tip {
  background: rgb(var(--glass-rgb) / .86);
  box-shadow: var(--glass-tool-sh), 0 14px 28px -12px rgb(40 52 46 / .3);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
}
.textbtn:hover, .gact button:hover, .info:hover { background: rgb(255 255 255 / .6); box-shadow: var(--glass-pill-sh); }
/* Selection = Libevra B2 "select glass": an untinted glass pill with the
   tab-glass rim, no green outline (the tick and bold label carry state). */
.row:hover { background: rgb(255 255 255 / .4); }
.row[aria-pressed="true"], .row.is-current, .lrow[aria-pressed="true"] {
  background: linear-gradient(180deg, rgb(255 255 255 / .82), rgb(255 255 255 / .6));
  box-shadow: inset 0 1px 0 #fff, inset 0 0 0 .5px rgb(255 255 255 / .7), inset 0 -1px 1px rgb(255 255 255 / .45), 0 0 0 .5px rgb(40 52 46 / .11), 0 4px 12px -5px rgb(40 52 46 / .2);
}
.row[aria-pressed="true"]::after, .row.is-current::after { opacity: 0; }
.row:active { background: rgb(255 255 255 / .7); }
.pill { background: var(--glass-pill); box-shadow: var(--glass-pill-sh); }
.lrow .yr b, .tip .lt, .hit .lt { color: color-mix(in srgb, var(--c) 78%, #000); }
input[type="range"]::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--brand) 0 var(--v, 66%), rgb(var(--ink-rgb) / .12) var(--v, 66%)); }
input[type="range"]::-moz-range-track { background: rgb(var(--ink-rgb) / .12); }
.sheet {
  background: var(--glass-sheet);
  box-shadow: var(--glass-sheet-sh);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  --canvas: rgb(var(--ink-rgb) / .045);
  --surface: rgb(255 255 255 / .75);
}
.sheet::backdrop { -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }

@media (max-width: 759px) {
  .stage {
    background: rgb(var(--glass-rgb) / .72);
    -webkit-backdrop-filter: blur(14px) saturate(1.5);
    backdrop-filter: blur(14px) saturate(1.5);
    box-shadow: inset 0 -1px 0 rgb(255 255 255 / .6), inset 0 -1.5px 0 rgb(40 52 46 / .07);
  }
  .chip { background: rgb(var(--glass-rgb) / .62); box-shadow: var(--glass-tool-sh); }
  .chip[aria-pressed="true"] { background: var(--glass-pill); box-shadow: var(--glass-pill-sh), inset 0 0 0 1px color-mix(in srgb, var(--c) 45%, transparent); }
  .tabs { background: rgb(110 108 96 / .08); box-shadow: inset 0 0 0 .5px rgb(255 255 255 / .55); }
  .tabs button[aria-selected="true"] { background: var(--glass-pill); box-shadow: var(--glass-pill-sh); }
  .sheet, .sheet.wide { box-shadow: var(--glass-sheet-sh); }
}

/* Where the reader asks for less transparency or more contrast, or the
   browser cannot blur, the same surfaces become solid. */
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  :root { --content-fill: .94; --chrome-fill: .96; --reading-fill: .96; --glass-tile: #f2f4f2; }
  .tip { background: #fafbf9; }
}
@media (max-width: 759px) and (prefers-reduced-transparency: reduce), (max-width: 759px) and (prefers-contrast: more) {
  .stage { background: #f2f4f2; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --content-fill: .9; --chrome-fill: .92; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, .sheet::backdrop {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    transition-delay: 0ms !important;
  }
}
@media (prefers-contrast: more) {
  :root { --muted: #45554e; --line-mid: #a8b5ae; }
  .grat { stroke: #c8d1cc; }
}
@media print {
  .tools, .tabs, .chips, .topnav, .foot .link { display: none !important; }
}
