:root {
  --bg: #f7f6f3;
  --panel: #ffffff;
  --text: #1f2328;
  --muted: #646b73;
  --line: #dcdad4;
  --accent: #8a3b12;
  --accent-soft: #f3e3d8;
  --sel: #1f6feb;
  --radius: 8px;
  --player-h: 230px;
  /* one colour per version of a recording (player badges, list, map) */
  --v-original: #6e7781; --v-entrauscht: #0072b2; --v-stimme: #c4520a; --v-begleitung: #00875f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b; --panel: #1f2226; --text: #e6e6e3; --muted: #9aa0a6;
    --line: #34383d; --accent: #e08a5a; --accent-soft: #3a2a20; --sel: #58a6ff;
    --v-original: #a2a9b1; --v-entrauscht: #56b4e9; --v-stimme: #f08a4b; --v-begleitung: #3ccf9e;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }
button, select, input[type=text], input[type=number], input[type=search] {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

.topbar { display: flex; align-items: baseline; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; text-decoration: none; letter-spacing: .04em; }
.brand-sub { color: var(--muted); font-size: 12px; }
.archive-name { font-weight: 600; }
.topnav { margin-left: auto; }

/* Archive picker */
.picker { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.picker h1 { margin: 0 0 4px; }
.lead { color: var(--muted); margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { display: block; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--text); }
.card:hover { border-color: var(--accent); }
.card h2 { font-size: 16px; margin: 0 0 4px; }
.card .meta { color: var(--muted); margin: 0 0 8px; font-size: 13px; }
.card .desc { margin: 0; font-size: 13px; }

/* Analysis page: SOM top left, player bottom left, list right */
.analysis-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.tabs { display: none; }
.analysis { flex: 1; min-height: 0; display: grid; gap: 12px; padding: 12px;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) var(--player-h);
  grid-template-areas: "som list" "player list"; }
.pane { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  min-height: 0; min-width: 0; }
.pane-som { grid-area: som; display: flex; flex-direction: column; padding: 8px; }
.pane-player { grid-area: player; padding: 10px 12px; overflow: auto; }
.pane-list { grid-area: list; display: flex; flex-direction: column; }

.toolbar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 13px; }
.toolbar label { display: inline-flex; gap: 4px; align-items: center; color: var(--muted); }
.toolbar select { max-width: 220px; color: var(--text); }
.msg { color: var(--muted); font-size: 12px; min-height: 0; }
#cv-msg:not(:empty) { margin-top: 4px; }
#cv-msg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.train-panel { border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin-top: 6px;
  font-size: 13px; max-height: 45%; overflow: auto; }
.train-row { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.quick button { padding: 2px 6px; font-size: 12px; }
.train-features { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 2px 12px; margin: 8px 0; }
.train-features .feat { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.train-features .feat span { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.train-features .feat-group { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px 10px;
  align-items: baseline; margin-top: 6px; padding-top: 4px; border-top: 1px solid var(--line); }
.train-features .feat-group:first-child { border-top: 0; margin-top: 0; }
.an-sources { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 6px; }
.an-sources label { display: flex; gap: 6px; align-items: center; }
.acc-list { margin: 6px 0; padding-left: 18px; }
.acc-list li { margin: 2px 0; }
.acc-dl { margin: 0 6px; font-size: .92em; white-space: nowrap; }
#access-panel input[type=text] { min-width: 220px; }
.an-kinds { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; margin-bottom: 6px; }
.an-kinds label { display: flex; gap: 4px; align-items: center; }
.an-kinds[hidden] { display: none; }
.viz-src { font-size: 12px; margin-top: 2px; }

.som-wrap { position: relative; flex: 1; min-height: 0; margin-top: 6px; }
/* The map always keeps its size and stays fully visible (size measured with all panels
   closed, see analysis.html). An open panel (Analyse, Neue SOM, ...) gets its own scroll
   bar; the map moves down and the whole page scrolls, not the map pane. */
.pane-som.som-fixed .som-wrap { flex: 0 0 var(--som-h); }
.pane-som.som-fixed .train-panel { flex: 0 0 auto; max-height: 40vh; }
.pane-som #cv-msg { min-height: 1.4em; }
@media (min-width: 901px) {
  body.analysis-page:has(.pane-som.som-fixed) { height: auto; min-height: 100vh; overflow: visible; }
  body.analysis-page:has(.pane-som.som-fixed) .analysis { flex: 1 0 auto;
    grid-template-rows: auto var(--player-h); }
  /* the list fills the rows' height but does not stretch them */
  body.analysis-page:has(.pane-som.som-fixed) .pane-list { contain: size; }
}
@media (max-width: 900px) { .pane-som.som-fixed { overflow-y: auto; } }
body.som-max .pane-som.som-fixed .som-wrap { flex: 1 1 auto; }
#som { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; }
#som .cell { stroke: var(--line); stroke-width: .5; }
#som .cell.unit-sel { stroke: var(--sel); stroke-width: 2.5; }
#som .dot { stroke: rgba(0,0,0,.55); cursor: pointer; }
#som .dot.sel { stroke: var(--sel); stroke-width: 3; }
#som .dot.dim { opacity: .15; }
#som .pie { cursor: pointer; }
#som .pie path { stroke: var(--panel); }
#som .pie-count { font-size: 10px; text-anchor: middle; dominant-baseline: central;
  pointer-events: none; fill: #111; font-weight: 600; paint-order: stroke; stroke: #fff; stroke-width: 2.5px; }
.tooltip { position: absolute; pointer-events: none; z-index: 5; background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px;
  max-width: 320px; box-shadow: 0 4px 14px rgba(0,0,0,.15); }
.tooltip ul { margin: 4px 0 0; padding-left: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; padding-top: 6px; }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 4px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.3); }
.legend .bar { display: inline-block; width: 120px; height: 10px; vertical-align: -1px;
  margin: 0 4px; border: 1px solid var(--line); }

.list-head { display: flex; gap: 8px; align-items: center; padding: 8px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap; }
#search { flex: 1; min-width: 160px; }
.count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.chip { background: var(--accent-soft); border-color: var(--accent); font-size: 12px; }
.table-wrap { flex: 1; overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th { position: sticky; top: 0; background: var(--panel); text-align: left; font-weight: 600;
  padding: 6px 8px; border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap; }
tbody td.nowrap { white-space: nowrap; }
tbody td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--accent-soft); }
tbody tr.noaudio td { color: var(--muted); }
tbody tr.sel { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
td .sw { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

.player-empty { color: var(--muted); }
.player h3 { margin: 0 0 2px; font-size: 15px; }
.player .sub { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.player audio, .player video { width: 100%; }
.player video, .player iframe { max-height: calc(var(--player-h) - 80px); }
.player iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; }
.player .meta-grid { display: grid; grid-template-columns: max-content 1fr; gap: 0 10px;
  font-size: 12px; margin-top: 8px; }
.player .meta-grid dt { color: var(--muted); }
.player .meta-grid dd { margin: 0; }
.player .nomedia { color: var(--muted); font-size: 12px; font-style: italic; }

.mini { position: fixed; z-index: 20; width: 300px; max-width: calc(100vw - 16px);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px; box-shadow: 0 8px 28px rgba(0,0,0,.25); font-size: 13px; }
.mini .mini-head { display: flex; gap: 8px; align-items: start; }
.mini .mini-head strong { flex: 1; }
.mini audio { width: 100%; margin-top: 6px; }
.variant-switch { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.variant-switch button { font: inherit; font-size: 12px; padding: 3px 9px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--panel); color: var(--text); cursor: pointer; }
.variant-switch button:hover { border-color: var(--accent); }
.variant-switch .variant-dl { font-size: 12px; align-self: center; margin-left: 4px; color: var(--accent); }
.variant-switch .variant-dl[hidden] { display: none; }
.variant-switch button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }
.mini .close { border: 0; padding: 0 4px; font-size: 16px; line-height: 1; }
/* version per piece: player row, list column, table before training, ring on the map */
.version-row { margin: 2px 0 4px; font-size: 12px; }
.version-row .msg { font-size: 12px; }
.version-btns { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin-top: 2px; }
.version-btns button { font-size: 12px; padding: 2px 8px; }
button.link:disabled { color: var(--muted); cursor: default; text-decoration: none; }
tbody td.vcell { color: var(--muted); }
tbody td.vcell.own { color: var(--text); font-weight: 600; }
.train-versions { margin: 6px 0; }
.train-versions summary { cursor: pointer; font-weight: 600; }
.tv-wrap { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.tv-table { width: 100%; border-collapse: collapse; }
.tv-table th { position: sticky; top: 0; background: var(--panel); text-align: left; padding: 3px 6px; }
.tv-table td { padding: 2px 6px; vertical-align: middle; }
.tv-table td.num { text-align: right; white-space: nowrap; }
.tv-table select { font-size: 12px; max-width: 170px; }
#som .dot.own-src { stroke: var(--text); }
/* version badges: colour plus text, a dashed outline for an open suggestion */
.vb { display: inline-block; font-size: 12px; line-height: 1.35; padding: 0 7px; border-radius: 999px;
  border: 1px solid var(--vc); color: var(--vc); background: color-mix(in srgb, var(--vc) 13%, transparent);
  font-weight: 600; white-space: nowrap; }
.vb.open { border-style: dashed; background: none; font-weight: 400; }
.vb-original { --vc: var(--v-original); }
.vb-entrauscht { --vc: var(--v-entrauscht); }
.vb-stimme { --vc: var(--v-stimme); }
.vb-begleitung { --vc: var(--v-begleitung); }
.vt { color: var(--vc); font-weight: 600; }
/* the player's switch in the same colours: outline and text, the chosen one filled */
.variant-switch button[class*="vb-"] { border-color: var(--vc); color: var(--vc); }
.variant-switch button[class*="vb-"]:hover { background: color-mix(in srgb, var(--vc) 10%, var(--panel)); }
.variant-switch button[class*="vb-"][aria-pressed="true"] { background: var(--vc); border-color: var(--vc); color: #fff; }
@media (prefers-color-scheme: dark) { .variant-switch button[class*="vb-"][aria-pressed="true"] { color: #111; } }
tbody td.vcell .vt { font-weight: 400; }
tbody td.vcell.own .vt.own { font-weight: 700; }
.player-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.player-head > div:first-child { min-width: 0; }
.vbox { display: grid; grid-template-columns: max-content max-content; gap: 2px 6px; align-items: center;
  font-size: 12px; flex: none; }
.vbox .vbox-k { color: var(--muted); text-align: right; }
.vbox .vbox-v { display: flex; gap: 4px; flex-wrap: wrap; }
@media (max-width: 480px) { .player-head { flex-direction: column; } .vbox .vbox-k { text-align: left; } }

/* Phones and narrow tablets: tabs for map and list, player as a bar at the bottom */
@media (max-width: 900px) {
  :root { --player-h: auto; }
  .brand-sub { display: none; }
  .tabs { display: flex; gap: 4px; padding: 6px 12px 0; }
  .tab { flex: 1; border-radius: 6px 6px 0 0; }
  .tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
  .analysis { display: flex; flex-direction: column; padding: 0 8px 8px; gap: 8px; }
  .pane-som, .pane-list { display: none; flex: 1; }
  .pane-som.active, .pane-list.active { display: flex; }
  .pane-player { flex: 0 0 auto; max-height: 40vh; }
  .player .meta-grid { display: none; }
  .toolbar select { max-width: 150px; }
  .train-panel { max-height: 55%; }
}

/* Accounts and private collections */
.muted { color: var(--muted); }
form.inline { display: inline; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }
.topnav { display: flex; gap: 12px; align-items: baseline; }
.picker h1.section { margin-top: 32px; }
.card.mine { border-style: dashed; }
.card.new-collection { display: flex; flex-direction: column; gap: 8px; }
.card.new-collection label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.form-page { max-width: 460px; margin: 0 auto; padding: 24px 16px; }
.form-page form { display: flex; flex-direction: column; gap: 10px; }
.form-page label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.form-page label.check { flex-direction: row; gap: 8px; align-items: flex-start; color: var(--text); }
.form-page input[type=text], .form-page input[type=password], .form-page input[type=email] {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; color: var(--text); }
.form-page .helptext, .form-page ul { font-size: 12px; color: var(--muted); }
.form-errors { color: #b42318; font-size: 13px; }
.prose li { margin-bottom: 8px; }
th.check, td.check { width: 28px; padding-right: 0; cursor: default; }
.selection-bar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 6px 8px;
  border-bottom: 1px solid var(--line); background: var(--accent-soft); font-size: 13px; }
.selection-bar select { max-width: 220px; }

/* Analysis panel and expert menu */
.an-status { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.an-row { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.an-row strong { min-width: 90px; }
.progress { display: inline-block; width: 140px; height: 8px; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); }
.expert { margin-top: 6px; }
.expert summary { cursor: pointer; color: var(--muted); }
.an-params fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 6px 0; padding: 6px 8px; }
.an-params legend { font-weight: 600; padding: 0 4px; }
.param-group { font-size: 12px; color: var(--muted); margin: 6px 0 2px; }
.param-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 12px; }
.param-grid label { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 12px; }
.param-grid label.changed span { color: var(--accent); font-weight: 600; }
.param-grid input[type=number] { width: 90px; }
.search-row { margin-top: 6px; }
.search-result { border-left: 3px solid var(--accent); padding: 4px 8px; margin: 6px 0; font-size: 12px; }
.search-result ol { margin: 4px 0; padding-left: 18px; }
.mini-table td { padding: 1px 8px 1px 0; border: 0; }

/* Timbre and pitch players */
.analysis.viz-on { --player-h: 470px; }
.viz-toggles { display: flex; gap: 14px; margin-top: 8px; font-size: 13px; }
.viz { margin-top: 8px; }
.viz-head { font-size: 13px; margin-bottom: 2px; }
.viz-plot { position: relative; cursor: crosshair; border: 1px solid var(--line); border-radius: 4px; background: var(--bg); }
.viz-plot canvas { display: block; width: 100%; }
.viz-cursor { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); opacity: .5; pointer-events: none; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 4px 0; font-size: 12px; align-items: center; }
.viz-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 3px; vertical-align: -1px; }
.viz-legend .sw.dash { background: repeating-linear-gradient(90deg, var(--muted) 0 3px, transparent 3px 6px); height: 2px; }
.viz-chip { font-size: 11px; padding: 1px 6px; }
.viz-chip.off { opacity: .45; }
.viz-values { min-height: 1.2em; }
.viz-zoom { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin: 4px 0; font-size: 12px; }
.viz-zoom button { font-size: 12px; padding: 2px 8px; }
.viz-phrase { font-size: 16px; line-height: 1.4; min-height: 1.4em; margin: 4px 0; }
.viz-phrase strong { color: #c0392b; }
.viz-full .viz-phrase { font-size: 20px; }
.viz-caption { margin: 2px 0 8px; }
.viz-subhead { font-size: 13px; margin: 6px 0 2px; }
.lg-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: -1px; }
.lg-dot.measured { background: #1f5fa8; }
.lg-dot.estimated { border: 1.5px solid #888; box-sizing: border-box; }
.lg-line { display: inline-block; width: 2px; height: 11px; background: #c0392b; vertical-align: -1px; }
@media (max-width: 900px) {
  .analysis.viz-on .pane-player { max-height: 45vh; }
  .pane-som.active { min-height: 240px; }
}

/* Full-screen map */
body.som-max .pane-som { position: fixed; inset: 0; z-index: 15; display: flex; margin: 0;
  border-radius: 0; border: 0; padding: 10px 14px; background: var(--panel); }
body.som-max #btn-cv, body.som-max #btn-analysis, body.som-max #btn-train,
body.som-max #analysis-panel, body.som-max #train-panel, body.som-max #cv-msg { display: none !important; }
body.som-max #btn-max { font-weight: 600; }
.mini.hovercard { width: 380px; max-height: min(80vh, 640px); overflow: auto; }
.mini.hovercard video, .mini.hovercard iframe { width: 100%; margin-top: 6px; border: 0; }
.mini.hovercard iframe { aspect-ratio: 16 / 9; height: auto; }
.mini.hovercard .meta-grid { display: grid; grid-template-columns: max-content 1fr; gap: 0 10px;
  margin: 8px 0 0; font-size: 13px; }
.mini.hovercard .meta-grid dt { color: var(--muted); }
.mini.hovercard .meta-grid dd { margin: 0; overflow-wrap: anywhere; }
.mini .pin { display: none; font-size: 12px; }
.mini.hovercard.pinned .pin { display: inline; }
@media (max-width: 900px) {
  body.som-max .pane-som { padding: 6px 8px; }
  .mini.hovercard { left: 8px !important; right: 8px; top: auto !important; bottom: 8px; width: auto; max-height: 55vh; }
}

/* Archive picker in the top bar */
.archive-switch select { font-weight: 600; max-width: min(46vw, 360px); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Overview: map top left plus component planes, all tiles the same size */
body.som-planes #som { position: absolute; left: 0; top: 18px; }
body.som-planes #btn-planes { font-weight: 600; }
.planes { position: absolute; inset: 0; pointer-events: none; }
.planes .plane { position: absolute; pointer-events: auto; }
.planes canvas { display: block; cursor: crosshair; border: 1px solid var(--line); box-sizing: content-box; }
.plane-head { display: flex; gap: 6px; align-items: baseline; height: 18px; font-size: 12px; overflow: hidden; }
.plane-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.plane-range { color: var(--muted); white-space: nowrap; }
.plane-x { border: 0; padding: 0 3px; font-size: 14px; line-height: 1; background: none; }
.plane-note { position: absolute; right: 0; top: 0; max-width: 40%; pointer-events: auto; }
#som .cell.unit-hover { stroke: var(--sel); stroke-width: 2.5; }
.plane-picker { max-height: 50vh; }
.plane-picker input[type=search] { width: 100%; max-width: 320px; margin: 6px 0; }
.plane-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 12px; }
.plane-picker .close { margin-left: auto; border: 0; font-size: 16px; padding: 0 4px; }
body.som-planes .plane-picker { position: absolute; z-index: 8; top: 52px; right: 14px; width: min(640px, calc(100% - 28px));
  margin: 0; background: var(--panel); box-shadow: 0 8px 28px rgba(0,0,0,.25); }
#cv-msg.long { white-space: normal; }
/* Language switch, far right in the top bar */
.lang-switch label { display: inline-flex; gap: 4px; align-items: center; }
.lang-switch select { max-width: 9.5em; font-size: 13px; padding: 2px 4px; }
@media (max-width: 900px) { .lang-switch select { max-width: 5.5em; } }
/* Ten best-matching tonal systems (player) */
.scales-pop { position: relative; }
.scales-list { position: fixed; z-index: 25; width: min(860px, calc(100vw - 16px)); max-height: 70vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.25); font-size: 12px; }
.scales-list th { text-align: left; font-weight: 600; padding-right: 8px; }
.scales-list td { padding: 1px 8px 1px 0; vertical-align: top; }
.scales-list .close { margin-left: auto; border: 0; padding: 0 4px; font-size: 16px; background: none; }
.scales-list td.msg { white-space: nowrap; font-size: 11px; }
.train-kind { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.train-kind legend { float: left; padding: 0; margin-right: 6px; }
.train-kind label { display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; }
.cb-zoom { margin-left: auto; display: inline-flex; gap: 2px; }
.cb-zoom button { padding: 0 6px; font-size: 12px; line-height: 18px; min-width: 22px; }
.cb-canvas { cursor: grab; touch-action: none; }
.cb-canvas:active { cursor: grabbing; }
.page-dialog { border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; max-width: min(460px, calc(100vw - 32px)); background: var(--panel); color: var(--text); box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.page-dialog::backdrop { background: rgba(0,0,0,.3); }
.page-dialog p { margin: 0 0 14px; white-space: pre-line; line-height: 1.4; }
.page-dialog-btns { display: flex; justify-content: flex-end; gap: 8px; }
.viz-toggles { align-items: center; }
.viz-full-btn { margin-left: auto; font-size: 12px; padding: 1px 8px; }
.viz-full { position: fixed; inset: 0; z-index: 60; background: var(--panel); color: var(--text); display: flex; flex-direction: column; padding: 10px 16px 12px; overflow: auto; }
.viz-full-head { display: flex; gap: 10px; align-items: baseline; }
.viz-full-head .msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz-full-head .close { font-size: 20px; line-height: 1; padding: 0 8px; }
.viz-full-audio audio { width: 100%; margin: 6px 0 2px; }
.viz-full .viz-head { font-size: 14px; }
.viz-full .viz-legend { font-size: 13px; }
body.viz-full-open { overflow: hidden; }
@media (max-width: 700px) { .viz-full { padding: 8px; } }
.kultur-switch { font-size: 12px; white-space: nowrap; display: inline-flex; gap: 4px; align-items: center; }

/* Documentation (/doku/) */
.doku-index { max-width: 900px; margin: 0 auto; padding: 24px 16px; }
.doku-index .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.doku-index .card strong { display: block; margin-top: 4px; }
.doku-num { color: var(--accent); font-weight: 600; }
.doku { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; max-width: 1180px; margin: 0 auto; padding: 16px; }
.doku-nav { position: sticky; top: 12px; align-self: start; max-height: calc(100vh - 24px); overflow: auto; font-size: 14px; }
.doku-nav ol { list-style: none; padding-left: 0; margin: 8px 0; }
.doku-nav ol ol { padding-left: 14px; font-size: 13px; }
.doku-nav li { margin: 4px 0; }
.doku-nav li.active > a { font-weight: 600; }
.doku-nav a { text-decoration: none; }
.doku-home { font-weight: 600; color: var(--text); }
.doku-body { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 28px; line-height: 1.6; min-width: 0; }
.doku-body h1 { margin-top: 0; }
.doku-body h2 { margin-top: 32px; border-bottom: 1px solid var(--line); padding-bottom: 4px; scroll-margin-top: 12px; }
.doku-body h3 { margin-top: 22px; }
.doku-body img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; }
.doku-body figure { margin: 16px 0; }
.doku-body details.beispiel { border: 1px solid var(--line); border-radius: 6px; background: var(--bg);
  padding: 6px 14px; margin: 12px 0; }
.doku-body details.beispiel > summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.doku-body details.beispiel[open] > summary { margin-bottom: 8px; }
.doku-body figcaption { font-size: 13px; color: var(--muted); }
.doku-body table { border-collapse: collapse; margin: 12px 0; font-size: 14px; display: block; overflow-x: auto; }
.doku-body th, .doku-body td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.doku-body code { font-size: 13px; background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.doku-body .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.doku-body .refs li { margin-bottom: 6px; padding-left: 2em; text-indent: -2em; list-style: none; }
.doku-body .refs { padding-left: 0; }
.doku-note { background: var(--accent-soft); padding: 8px 12px; border-radius: 6px; }
.doku-body .hinweis { background: var(--bg); border-left: 3px solid var(--accent); padding: 8px 12px; }
.doku-stand { margin-top: 32px; font-size: 13px; }
.doku-pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
@media (max-width: 800px) {
  .doku { grid-template-columns: 1fr; padding: 8px 16px; }
  .doku-nav { position: static; max-height: none; }
  .doku-body { padding: 16px; }
}
@media (max-width: 600px) { .topnav { flex-wrap: wrap; gap: 6px 12px; } }

/* Welcome page: intro text with field research photos */
.welcome { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start;
  margin: 8px 0 32px; }
.welcome.with-photos { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.welcome-text { font-size: 15px; line-height: 1.6; max-width: 68ch; }
.welcome-text p { margin: 0 0 12px; }
.welcome .kicker { color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; margin-bottom: 6px; }
.picker .welcome h1 { font-size: clamp(24px, 3.2vw, 34px); line-height: 1.15; margin: 0 0 14px; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px !important; }
a.button { display: inline-block; padding: 8px 16px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel); color: var(--text); text-decoration: none; font-weight: 500; }
a.button:hover { border-color: var(--accent); }
a.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.welcome-photos { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; grid-auto-rows: 150px; }
.welcome-photos figure { position: relative; margin: 0; overflow: hidden; border-radius: var(--radius);
  background: var(--accent-soft); }
.welcome-photos figure:first-child { grid-column: 1 / -1; grid-row: span 2; }
.welcome-photos.n1 figure:first-child { grid-row: span 3; }
.welcome-photos.n2 figure { grid-column: 1 / -1; grid-row: span 2; }
.welcome-photos.n4 figure:last-child { grid-column: 1 / -1; }
.welcome-photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.welcome-photos figcaption { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 6px;
  color: #fff; font-size: 12px; line-height: 1.3; background: linear-gradient(transparent, rgba(0,0,0,.65)); }
#archive { scroll-margin-top: 12px; }

/* Phones: photos as a swipeable strip above the text */
@media (max-width: 900px) {
  .welcome.with-photos { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .welcome-photos { order: -1; display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
    margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .welcome-photos::-webkit-scrollbar { display: none; }
  .welcome-photos figure { flex: 0 0 85%; height: 56vw; max-height: 320px; scroll-snap-align: center; }
  .welcome-photos.n1 figure { flex-basis: 100%; }
  .welcome-text { font-size: 15px; }
}

/* Public video library (/videos/, /video/<slug>/) */
.videothek h1 { margin: 0 0 4px; }
.vt-filter { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 12px 0 16px; }
.vt-filter input[type=search] { flex: 1 1 220px; max-width: 360px; padding: 6px 10px; }
.vt-kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.vt-kinds button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.vt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.vt-card { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.vt-card:hover { border-color: var(--accent); }
.vt-thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: #000; }
.vt-thumb { overflow: hidden; }
.vt-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.vt-dur { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.75); color: #fff;
  font-size: 12px; padding: 1px 6px; border-radius: 4px; }
.vt-title { font-weight: 600; padding: 4px 10px 0; }
.vt-meta { color: var(--muted); font-size: 13px; padding: 0 10px 10px; }
.vt-page .vt-back { margin: 0 0 10px; }
.vt-stage { background: #000; border-radius: var(--radius); overflow: hidden; }
.vt-stage .vt-video { display: block; width: 100%; max-height: 75vh; background: #000; }
.vt-stage .nomedia { color: #ccc; padding: 40px 16px; text-align: center; }
.vt-info { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 320px); gap: 16px 24px; margin-top: 14px; }
.vt-info h1 { font-size: 22px; line-height: 1.25; }
.vt-info .vt-meta { padding: 0; margin: 2px 0 10px; }
.vt-desc { max-width: 70ch; font-size: 15px; line-height: 1.55; }
.vt-share { display: flex; flex-direction: column; gap: 10px; font-size: 13px; color: var(--muted); }
.vt-share p { margin: 0; }
.vt-share label { display: flex; flex-direction: column; gap: 4px; }
.vt-copy { display: flex; gap: 6px; align-items: flex-start; }
.vt-copy input, .vt-copy textarea { flex: 1; min-width: 0; font: 12px/1.4 ui-monospace, monospace; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; resize: vertical; }
.videothek h2.section { font-size: 17px; margin: 28px 0 10px; }
/* overview grouped by region and theme, metadata under each video */
.vt-toc { font-size: 14px; line-height: 1.7; margin: 0 0 8px; }
.vt-toc p { margin: 0 0 4px; }
.vt-toc a { white-space: nowrap; }
.videothek .vt-region > h2.section { font-size: 20px; margin: 32px 0 4px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.vt-theme { scroll-margin-top: 70px; }
.vt-theme h3 { font-size: 16px; margin: 20px 0 10px; }
.vt-card-meta { padding-bottom: 10px; }
.vt-card-meta:hover { border-color: var(--line); }
.vt-link { display: flex; flex-direction: column; gap: 4px; color: var(--text); text-decoration: none; }
.vt-link:hover .vt-title { color: var(--accent); }
.vt-dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1px 10px; margin: 4px 10px 0;
  font-size: 12.5px; line-height: 1.4; }
.vt-dl dt { color: var(--muted); }
.vt-dl dd { margin: 0; overflow-wrap: anywhere; }
.vt-info .vt-dl { margin: 0 0 12px; font-size: 14px; max-width: 60ch; }
.vt-entry { margin: 6px 10px 0; font-size: 12.5px; }
.vt-lock { font-size: 11px; }
.vt-signup { margin-top: 28px; }
.vt-themes { margin-bottom: 8px; }
.vt-open { display: inline-block; font-size: 12px; margin-top: 4px; }
.pane-player video + .vt-open { display: block; }
@media (max-width: 700px) {
  .vt-info { grid-template-columns: minmax(0, 1fr); }
  .vt-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .vt-page { padding-left: 0; padding-right: 0; padding-top: 0; }
  .vt-page .vt-back, .vt-page .vt-info, .vt-page h2.section, .vt-page .vt-grid { padding-left: 16px; padding-right: 16px; }
  .vt-page .vt-back { padding-top: 12px; }
  .vt-stage { border-radius: 0; }
}

/* World map of the places of origin (alternative view of the list, analysis.js "world map") */
.view-switch { display: inline-flex; }
.view-switch button { border-radius: 0; }
.view-switch button:first-child { border-radius: 6px 0 0 6px; }
.view-switch button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.view-switch button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.world-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#world { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; cursor: grab; }
#world .sphere { fill: var(--w-sea); stroke: var(--line); }
#world .country { fill: var(--w-land); stroke: var(--panel); cursor: default; }
#world .country.has { fill: var(--accent); cursor: pointer; }
#world .country.has:hover { fill-opacity: .85; }
#world .wm { cursor: pointer; }
#world .wm circle { stroke: rgba(0,0,0,.6); stroke-width: 1; }
#world .wm circle.rough { stroke-dasharray: 2 1.5; stroke-width: 1.4; }
#world .wm path { stroke: var(--panel); stroke-width: .8; }
#world .wm .wm-hole { fill: var(--panel); stroke: none; }
#world .wm-land rect { fill: var(--panel); stroke: var(--accent); stroke-width: 1.6; }
#world .wm-count { font-size: 10px; font-weight: 600; text-anchor: middle; dominant-baseline: central;
  fill: var(--text); pointer-events: none; }
#world .wm.sel circle, #world .wm.sel rect { stroke: var(--sel); stroke-width: 3; }
.world-tools { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; }
.world-tools button { width: 32px; height: 32px; padding: 0; font-size: 16px; line-height: 1; }
.world-pop { position: absolute; z-index: 6; width: min(340px, calc(100% - 8px)); max-height: 60%;
  overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18); font-size: 13px; }
.world-pop-head { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.world-pop-head button { border: 0; background: none; padding: 2px 6px; font-size: 14px; }
.world-pop ul { list-style: none; margin: 0; padding: 0; }
.world-pop li { display: flex; gap: 6px; align-items: baseline; padding: 6px 8px; cursor: pointer;
  border-bottom: 1px solid var(--line); }
.world-pop li:last-child { border-bottom: 0; }
.world-pop li > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.world-pop li:hover, .world-pop li.sel { background: var(--accent-soft); }
.world-pop li.noaudio strong { color: var(--muted); font-weight: 500; }
.world-pop .sw { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; border: 1px solid rgba(0,0,0,.3); }
.world-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: 12px;
  padding: 6px 8px; border-top: 1px solid var(--line); }
.world-legend .wl-dot, .world-legend .wl-sq { display: inline-block; width: 10px; height: 10px;
  margin-right: 4px; vertical-align: -1px; }
.world-legend .wl-dot { border-radius: 50%; background: var(--muted); border: 1px solid rgba(0,0,0,.5); }
.world-legend .wl-dot.rough { background: transparent; border: 1.4px dashed var(--text); }
.world-legend .wl-sq { border-radius: 2px; border: 1.6px solid var(--accent); background: var(--panel); }
:root { --w-sea: #eef2f4; --w-land: #dedbd3; }
@media (prefers-color-scheme: dark) { :root { --w-sea: #1a1e22; --w-land: #34383d; } }
@media (max-width: 900px) {
  .world-wrap { min-height: 260px; }
  .world-tools button { width: 38px; height: 38px; }
  .world-pop { max-height: 70%; }
}
