/* Panomatix — clean, minimal layout in United Nations colours.
   UN blue #009EDB (Pantone 2925 C) as the single accent, navy for headings, neutral greys,
   white surfaces, hairline borders, generous spacing. D-DIN (served locally), then Roboto and system fonts. */
[hidden] { display: none !important; }

/* D-DIN (local files, public/fonts/): regular covers weights up to 500, bold from 600. */
@font-face { font-family: "D-DIN"; src: url("../fonts/D-DIN.otf") format("opentype"); font-weight: 100 500; font-style: normal; font-display: swap; }
@font-face { font-family: "D-DIN"; src: url("../fonts/D-DIN-Bold.otf") format("opentype"); font-weight: 600 900; font-style: normal; font-display: swap; }
@font-face { font-family: "D-DIN"; src: url("../fonts/D-DIN-Italic.otf") format("opentype"); font-weight: 100 900; font-style: italic; font-display: swap; }

:root {
  --un-blue: #009edb;
  --un-blue-dark: #0077b8;
  --un-blue-soft: #e6f5fc;
  --navy: #1a2b49;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f9fa;
  /* Behind sign pictures (follows the theme: dark in dark mode). */
  --sign-bg: #f7f9fa;
  --text: #2b2f33;
  --heading: var(--navy);
  --muted: #6b737a;
  --line: #e4e8eb;
  --line-strong: #cfd6db;
  --accent: var(--un-blue);
  --accent-ink: var(--un-blue-dark); /* accessible on white for text and links */
  --danger: #c5283d;
  --ok: #2e8540;
  --warn: #f2a900;

  --font: "D-DIN", "Roboto", "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: "Roboto Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --radius: 6px;
  color-scheme: light dark;
}

/* Dark colours: when the system asks for them (unless the visitor chose light), or when the visitor
   chose dark with the button in the header (data-theme on <html>, see js/theme.js). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161c;
    --surface: #161c23;
    --surface-2: #1c232b;
    --sign-bg: #1c232b;
    --text: #dfe5ea;
    --heading: #f2f6f9;
    --muted: #8f99a3;
    --line: #26303a;
    --line-strong: #34404c;
    --accent-ink: #4cc3f0;
    --un-blue-soft: #0f2a38;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11161c;
  --surface: #161c23;
  --surface-2: #1c232b;
  --sign-bg: #1c232b;
  --text: #dfe5ea;
  --heading: #f2f6f9;
  --muted: #8f99a3;
  --line: #26303a;
  --line-strong: #34404c;
  --accent-ink: #4cc3f0;
  --un-blue-soft: #0f2a38;
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.6 var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 40px 24px 80px; outline: none; }
h1, h2, h3, h4, h5 { color: var(--heading); line-height: 1.25; margin: 1.6em 0 .6em; font-weight: 500; }
h1 { font-size: clamp(1.7rem, 3vw, 2.3rem); font-weight: 300; margin-top: 0; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }
h4 { font-size: 1rem; margin: 0; }
h5 { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 500; margin: 1.6em 0 .5em; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code, .mono { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pad { padding: 24px; }
.error { color: var(--danger); }
.warning { margin: 0; padding: 10px 12px; border-left: 4px solid #d97706; background: color-mix(in srgb, #d97706 10%, transparent); border-radius: var(--radius); }
.box.danger-zone { border-color: var(--danger); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.ok { color: var(--ok); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #fff; padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }

/* --- header ---------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 32px;
  padding: 0 max(24px, calc((100% - 1152px) / 2)); min-height: 64px;
  background: var(--surface);
  border-top: 4px solid var(--un-blue);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--heading); font-weight: 500; font-size: 1.15rem; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.mainnav { display: flex; gap: 28px; align-self: stretch; }
.mainnav a { display: flex; align-items: center; color: var(--muted); font-size: .95rem; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.mainnav a:hover { color: var(--heading); text-decoration: none; }
.mainnav a.active { color: var(--heading); border-bottom-color: var(--un-blue); }
.account { margin-left: auto; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; padding: 10px 0; }
.account .btn:not(.primary) { border-color: transparent; color: var(--muted); }
.account .btn:not(.primary):hover { color: var(--heading); border-color: var(--line); }
.account .btn.primary { margin-right: 8px; }
@media (min-width: 1000px) { .topbar { flex-wrap: nowrap; } .mainnav, .account { flex-wrap: nowrap; white-space: nowrap; } }
.account .btn.user { color: var(--heading); }
.btn.user .role { display: none; }
select.lang { width: auto; padding: 5px 26px 5px 8px; font-size: .85rem; color: var(--muted); border-color: transparent; background-color: transparent; }
select.lang:hover { border-color: var(--line); }

/* --- buttons & inputs ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 1rem; line-height: 1.4; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent-ink); text-decoration: none; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--un-blue); border-color: var(--un-blue); color: #fff; }
.btn.primary:hover { background: var(--un-blue-dark); border-color: var(--un-blue-dark); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: var(--danger); color: #fff; }
.btn.small { padding: 3px 10px; font-size: .88rem; }
.btn.add { margin-top: 10px; border-style: dashed; color: var(--muted); }
.linklike { background: none; border: 0; padding: 0; color: var(--accent-ink); cursor: pointer; font: inherit; }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], select, textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px;
}
input:focus, select:focus, textarea:focus { border-color: var(--un-blue); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--un-blue) 18%, transparent); }
input.narrow { width: 6em; }
input[type="checkbox"] { accent-color: var(--un-blue); width: 16px; height: 16px; }
textarea { resize: vertical; }
.invalid, .invalid input, .invalid select { border-color: var(--danger) !important; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field.endalign { justify-content: flex-end; align-items: flex-start; }
.field .label { font-size: .75rem; color: var(--muted); letter-spacing: .02em; }
.field .help { font-size: .78rem; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.grid2, .grid3, .grid4 { display: grid; gap: 16px 20px; }
.grid2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.checks { display: flex; gap: 18px; flex-wrap: wrap; padding: 6px 0; }
.check { display: inline-flex; gap: 6px; align-items: center; }

/* --- surfaces ---------------------------------------------------------------------------- */
.page { animation: fade .2s ease-out; }
.page.narrow { max-width: 480px; margin: 0 auto; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.box { padding: 28px 0; margin: 0; border-top: 1px solid var(--line); }
.box > h2:first-child { margin-top: 0; }
.page.narrow .box { padding: 24px 0; }
.banner { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 24px; }
.banner.readonly { background: color-mix(in srgb, var(--accent, #009EDB) 8%, var(--surface)); border-left: 3px solid var(--accent, #009EDB); font-size: .92rem; }
.banner.warn { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border-left: 3px solid var(--warn); }
.crumbs { color: var(--muted); font-size: .85rem; margin: 0 0 8px; }

/* --- home / list ---------------------------------------------------------------------------- */
.hero { padding: 16px 0 8px; max-width: 760px; }
.hero h1 { font-size: clamp(2rem, 4vw, 2.8rem); margin-bottom: .3em; }
.hero p { color: var(--muted); font-size: 1.05rem; margin: 0; }
.filters { display: grid; grid-template-columns: minmax(240px, 2fr) repeat(3, minmax(150px, 1fr)); gap: 10px; margin: 32px 0 12px; }
@media (max-width: 860px) { .filters { grid-template-columns: 1fr 1fr; } .filters input { grid-column: 1 / -1; } }
.filters input[type="search"] { padding-left: 14px; }
.results.loading { opacity: .5; transition: opacity .2s; }
.cards { list-style: none; padding: 0; margin: 8px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
.card a {
  display: flex; flex-direction: column; height: 100%; color: inherit;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.card a:hover { text-decoration: none; border-color: var(--un-blue); box-shadow: 0 6px 24px rgb(0 60 100 / .08); }
.thumb { height: 150px; display: grid; place-items: center; background: var(--sign-bg); }
.thumb img { max-width: 70%; max-height: 110px; object-fit: contain; }
.noimg { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
.card-body { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px 16px; }
.card-body strong { color: var(--heading); font-weight: 500; line-height: 1.35; margin-bottom: 4px; }
.ref { font-size: .78rem; color: var(--accent-ink); letter-spacing: .02em; }
.ref.big { font-size: .95rem; }
.empty { padding: 60px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: center; align-items: center; gap: 20px; margin: 40px 0 0; color: var(--muted); font-size: .9rem; }

/* --- sign page -------------------------------------------------------------------------------- */
.sign-head { display: flex; gap: 40px; align-items: center; padding: 8px 0 32px; }
.hero-img { width: 140px; height: 140px; object-fit: contain; flex: none; padding: 16px; background: var(--sign-bg); border-radius: var(--radius); box-sizing: content-box; }
@media (max-width: 640px) { .sign-head { flex-direction: column; align-items: flex-start; gap: 16px; } }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.kvs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 24px; margin-top: 20px; }
.kv { display: flex; flex-direction: column; }
.kv .k { font-size: .72rem; color: var(--muted); letter-spacing: .02em; }
.i18n { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.i18n dt { font-family: var(--mono); font-size: .75rem; color: var(--muted); padding-top: 3px; }
.i18n dd { margin: 0; }
.design { padding: 24px 0; border-top: 1px solid var(--line); }
.design header { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: .8rem; margin: 2px 4px 2px 0; }
code.chip { font-size: .78rem; }
img.mini { width: 20px; height: 20px; object-fit: contain; }
.badge { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: .7rem; letter-spacing: .04em; background: var(--surface-2); color: var(--muted); margin-left: 6px; }
.notes { margin: 8px 0; padding-left: 20px; color: var(--muted); font-size: .9rem; }
.jurs { display: flex; flex-direction: column; margin-top: 16px; border-top: 1px solid var(--line); }
.jur { border-bottom: 1px solid var(--line); }
.jur > summary { padding: 10px 4px; cursor: pointer; list-style: none; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.jur > summary::-webkit-details-marker { display: none; }
.jur > summary::before, .item > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; flex: none; margin-right: 4px; align-self: center; }
.jur[open] > summary::before, .item[open] > summary::before { transform: rotate(45deg); }
.jur > summary strong { color: var(--heading); font-weight: 500; text-transform: capitalize; }
.jur-body { padding: 4px 4px 20px 18px; }
.cc { color: var(--accent-ink); background: var(--un-blue-soft); padding: 0 6px; border-radius: 4px; font-size: .72rem; }
.imgs { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 12px; }
.imgs img { width: 72px; height: 72px; object-fit: contain; background: var(--sign-bg); border-radius: var(--radius); padding: 6px; }
table { border-collapse: collapse; width: 100%; }
table.compact th, table.compact td { padding: 6px 10px 6px 0; text-align: left; border-bottom: 1px solid var(--line); font-size: .88rem; vertical-align: top; }
table.compact th { font-weight: 400; color: var(--muted); font-size: .75rem; }
table.list th, table.list td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: .92rem; }
table.list th { font-weight: 400; color: var(--muted); font-size: .75rem; letter-spacing: .02em; }
tr.inactive { opacity: .5; }
ul.plain { list-style: none; padding: 0; margin: 4px 0; }
ul.plain li { padding: 3px 0; }
.sources summary { cursor: pointer; color: var(--muted); font-size: .82rem; margin-top: 12px; }

/* --- editor ----------------------------------------------------------------------------------- */
.toolbar {
  position: sticky; top: 68px; z-index: 10;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 12px 0; margin: 16px 0 8px;
  background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.toolbar .comment { flex: 1; min-width: 200px; }
.tabs { display: inline-flex; gap: 2px; background: var(--surface-2); border-radius: var(--radius); padding: 3px; }
.tabs button { border: 0; background: transparent; padding: 5px 14px; font: inherit; font-size: .88rem; cursor: pointer; color: var(--muted); border-radius: 4px; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--heading); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
textarea.json { width: 100%; min-height: 70vh; font-family: var(--mono); font-size: .82rem; line-height: 1.5; white-space: pre; background: var(--surface-2); }
.errors { border-left: 3px solid var(--danger); padding: 10px 16px; background: color-mix(in srgb, var(--danger) 5%, var(--surface)); margin: 12px 0; font-size: .9rem; }
.errors ul { margin: 4px 0; padding-left: 18px; max-height: 240px; overflow: auto; }
.listed, .mapped { display: flex; flex-direction: column; }
.item { border-bottom: 1px solid var(--line); }
.listed > .item:first-child, .mapped > .item:first-child { border-top: 1px solid var(--line); }
.item > summary { display: flex; align-items: center; gap: 10px; padding: 10px 4px; cursor: pointer; list-style: none; }
.item > summary::-webkit-details-marker { display: none; }
.item-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--heading); }
.tools { display: inline-flex; gap: 4px; margin-left: auto; opacity: .55; transition: opacity .15s; }
summary:hover .tools, .maprow:hover .tools, .tools:focus-within { opacity: 1; }
.tools .btn.small { padding: 1px 7px; border-color: transparent; }
.tools .btn.small:hover { border-color: var(--line-strong); }
.item-body { padding: 8px 4px 24px 18px; }
.item-body h4 { margin: 28px 0 8px; font-weight: 500; }
.item-body > div > .field.wide, .item-body .grid2 + div { margin-top: 12px; }
.item .item-body .item > summary { padding: 8px 4px; }
.mapkey { font-family: var(--mono); font-size: .82rem; color: var(--accent-ink); }
.maprow { display: grid; grid-template-columns: minmax(40px, max-content) 1fr auto; gap: 10px; align-items: start; margin: 6px 0; }
.maprow .mapkey { padding-top: 9px; }
.addrow { display: flex; gap: 6px; margin-top: 8px; max-width: 460px; }
.addrow input { flex: 1; }
.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; }
.tag { display: inline-flex; align-items: center; gap: 2px; padding: 1px 2px 1px 10px; background: var(--un-blue-soft); color: var(--heading); border-radius: 999px; font-size: .85rem; }
.tag .x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; padding: 2px 6px; border-radius: 50%; }
.tag .x:hover { color: var(--danger); }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; align-items: start; }
.panel-pos { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 14px; }
.panel-pos h5 { margin: 2px 0 8px; display: flex; justify-content: space-between; }
.panel-pos.absent { border-style: dashed; display: grid; place-items: center; min-height: 60px; }
.panel-pos.absent .btn { border: 0; color: var(--muted); }
.panel-pos.absent .btn:hover { color: var(--accent-ink); }
.slot { border-top: 1px solid var(--line); padding: 10px 0 4px; }
.slot-head { display: flex; justify-content: space-between; align-items: flex-start; }
.images-edit { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }
.imgcell { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; width: 112px; border-radius: var(--radius); background: var(--sign-bg); }
.imgcell img { width: 72px; height: 72px; object-fit: contain; }
.imgcell figcaption { font-size: .72rem; word-break: break-all; text-align: center; color: var(--muted); }
.imgcell .noimg { height: 72px; display: grid; place-items: center; }
.imgcell .btn.small { border: 0; background: none; color: var(--accent-ink); }

/* --- history & diff ------------------------------------------------------------------------- */
.diff td { padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: .8rem; vertical-align: top; word-break: break-word; }
.diff tr.added .after, .diff tr.changed .after { color: var(--ok); }
.diff tr.removed .before, .diff tr.changed .before { color: var(--danger); text-decoration: line-through; }
.action-create, .action-restore { color: var(--ok); }
.action-delete { color: var(--danger); }
.action-revert, .action-update { color: var(--accent-ink); }

/* --- API page ------------------------------------------------------------------------------------ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 24px; margin: 24px 0 32px; }
.stat { display: flex; flex-direction: column; border-left: 2px solid var(--un-blue); padding-left: 14px; }
.stat strong { font-size: 1.9rem; font-weight: 300; color: var(--heading); }
.stat span { color: var(--muted); font-size: .82rem; }
pre.code { background: var(--surface-2); color: var(--text); padding: 16px 18px; border-radius: var(--radius); overflow: auto; font-family: var(--mono); font-size: .82rem; }
.method { display: inline-block; min-width: 56px; font-family: var(--mono); font-size: .72rem; font-weight: 500; color: var(--muted); }
.m-get { color: var(--ok); }
.m-post { color: var(--accent-ink); }
.m-put, .m-patch { color: #b26b00; }
.m-delete { color: var(--danger); }

/* --- overlays --------------------------------------------------------------------------------- */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--navy); color: #fff; padding: 10px 18px; border-radius: var(--radius); box-shadow: 0 8px 28px rgb(0 0 0 / .18); max-width: 420px; font-size: .9rem; transition: opacity .4s; }
.toast-error { background: var(--danger); }
.toast.hide { opacity: 0; }
.dialog { border: 1px solid var(--line); border-radius: 8px; padding: 24px; min-width: min(420px, 90vw); background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgb(0 0 0 / .2); }
.dialog::backdrop { background: rgb(26 43 73 / .35); }
.dialog p { margin-top: 0; }
.dialog input { margin-bottom: 16px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print { .topbar, .toolbar, .actions, .toasts { display: none; } }

/* --- country comparison ------------------------------------------------------------------ */
.compare-filters { display: grid; grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr) minmax(180px, 1.4fr) auto auto; gap: 10px; margin: 24px 0 10px; align-items: start; }
@media (max-width: 960px) { .compare-filters { grid-template-columns: 1fr 1fr; } }
.row.between { justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.picker { position: relative; }
.picker > summary { list-style: none; white-space: nowrap; width: 100%; justify-content: space-between; padding: 8px 12px; }
.picker > summary::-webkit-details-marker { display: none; }
.picker > summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); margin: 0 2px 3px 10px; }
.picker-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 320px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 16px 40px rgb(0 40 70 / .14); display: flex; flex-direction: column; gap: 8px; }
.country-list { max-height: 340px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.country-list .check { padding: 3px 4px; border-radius: 4px; font-size: .9rem; }
.country-list .check:hover { background: var(--surface-2); }
.matrix-wrap { overflow: auto; max-height: calc(100vh - 150px); border: 1px solid var(--line); border-radius: var(--radius); }
.matrix-wrap.loading { opacity: .5; }
table.matrix { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-size: .78rem; }
.matrix th, .matrix td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--surface); }
.matrix thead th { position: sticky; top: 0; z-index: 2; vertical-align: bottom; padding: 8px 6px; font-weight: 400; }
.matrix .rowhead { position: sticky; left: 0; z-index: 1; text-align: left; padding: 6px 12px; min-width: 210px; max-width: 260px; font-weight: 400; }
.matrix .corner { left: 0; z-index: 3; text-align: left; padding: 8px 12px; color: var(--muted); }
.matrix .rowhead a { display: flex; flex-direction: column; color: var(--heading); }
.matrix .rowhead .rname { font-size: .82rem; line-height: 1.3; }
.colhead { width: 76px; min-width: 76px; }
.colhead .cname { display: block; font-size: .74rem; color: var(--heading); line-height: 1.2; margin-bottom: 4px; white-space: normal; }
.colhead .coverage { display: block; color: var(--muted); font-size: .68rem; margin-top: 3px; font-variant-numeric: tabular-nums; }
.matrix td { text-align: center; padding: 4px; vertical-align: middle; height: 72px; }
.matrix td a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text); position: relative; }
.matrix td a:hover { text-decoration: none; }
.matrix td:hover { background: var(--un-blue-soft); }
.matrix td img { width: 40px; height: 40px; object-fit: contain; }
.matrix td .code { font-family: var(--mono); font-size: .68rem; color: var(--muted); max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.matrix td .more { font-size: .62rem; color: var(--accent-ink); }
.matrix td .dnum { position: absolute; top: -2px; right: 0; font-size: .6rem; color: var(--muted); }
.matrix td.none { color: var(--line-strong); background: var(--surface-2); }
.noimg-dot { font-size: 1.6rem; color: var(--line-strong); line-height: 40px; height: 40px; }

/* --- country side panel ------------------------------------------------------------------ */
.matrix td.addable { padding: 0; }
.addcell { width: 100%; height: 100%; min-height: 64px; border: 0; background: transparent; color: transparent; font-size: 1.4rem; cursor: pointer; }
.addcell:hover, .addcell:focus-visible { color: var(--un-blue); background: var(--un-blue-soft); }
.edit-country { margin-left: auto; }
.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0; height: 100vh; max-height: 100vh; width: min(680px, 100vw); max-width: 100vw;
  border: 0; border-left: 1px solid var(--line); padding: 0; background: var(--surface); color: var(--text);
  display: flex; flex-direction: column; box-shadow: -24px 0 64px rgb(0 30 60 / .16);
  animation: slidein .22s ease-out;
}
.drawer:not([open]) { display: none; }
.drawer::backdrop { background: rgb(26 43 73 / .25); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 20px 28px 12px; border-top: 4px solid var(--un-blue); }
.drawer-head h2 { margin: 2px 0 0; font-weight: 400; font-size: 1.5rem; }
.drawer-head .crumbs { margin: 0; }
.btn.close { border: 0; font-size: 1.6rem; line-height: 1; padding: 2px 10px; color: var(--muted); }
.drawer .banner.info { margin: 0 28px 8px; background: var(--un-blue-soft); border-left: 3px solid var(--un-blue); }
.drawer-body { flex: 1; overflow: auto; padding: 4px 28px 24px; }
.drawer-foot { border-top: 1px solid var(--line); padding: 12px 28px 14px; background: var(--surface); }
.drawer-foot .row { gap: 8px; }
.drawer-foot .comment { flex: 1; }
.drawer-foot p { margin: 6px 0 0; }
.variant { padding: 16px 0 24px; border-bottom: 1px solid var(--line); }
.variant:last-of-type { border-bottom: 0; }
.variant-head { display: flex; justify-content: space-between; align-items: center; }
.variant-head h3 { margin: 0; font-size: 1rem; font-weight: 500; }
.variant-main { display: grid; grid-template-columns: 150px 1fr; gap: 20px; align-items: start; margin-top: 12px; }
@media (max-width: 560px) { .variant-main { grid-template-columns: 1fr; } }
.dropzone {
  width: 150px; height: 150px; border: 1.5px dashed var(--line-strong); border-radius: 8px; background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; cursor: pointer; position: relative; overflow: hidden;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--un-blue); background: var(--un-blue-soft); }
.dropzone img { max-width: 110px; max-height: 105px; object-fit: contain; }
.dz-empty { font-size: 1.8rem; color: var(--line-strong); line-height: 1; }
.dz-hint { font-size: .72rem; color: var(--muted); text-align: center; padding: 0 8px; }
.prefixed { display: flex; align-items: stretch; }
.prefixed .prefix { display: flex; align-items: center; padding: 0 10px; font-family: var(--mono); font-size: .9rem; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line-strong); border-right: 0; border-radius: var(--radius) 0 0 var(--radius); }
.prefixed input { border-radius: 0 var(--radius) var(--radius) 0; font-size: 1.05rem; }
.texts { display: flex; flex-direction: column; gap: 10px; }
.design-picker { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; }
.dchoice {
  flex: none; width: 108px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px 8px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; font: inherit; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.dchoice:hover { border-color: var(--un-blue); }
.dchoice.on { border-color: var(--un-blue); box-shadow: 0 0 0 2px var(--un-blue); background: var(--un-blue-soft); }
.dchoice:disabled { opacity: .35; cursor: not-allowed; }
.dchoice img { width: 44px; height: 44px; object-fit: contain; }
.dchoice .dlabel { font-size: .68rem; line-height: 1.25; text-align: center; color: var(--heading); }
.dchoice .dcount { font-size: .64rem; color: var(--muted); }
.dchoice.new { border-style: dashed; justify-content: center; }
.newdesign { margin: 8px 0 4px; padding: 12px; background: var(--surface-2); border-radius: var(--radius); }
.more { margin-top: 18px; }
.more > summary { cursor: pointer; color: var(--accent-ink); font-size: .9rem; }
.more > .stack { padding-top: 12px; }
.removed { padding: 20px; margin: 16px 0; background: color-mix(in srgb, var(--danger) 6%, var(--surface)); border-radius: var(--radius); }
::placeholder { color: var(--muted); opacity: .55; }
.row.between > h2 { margin: 0; } section > .row.between { margin: 40px 0 8px; }

/* --- official Vienna Convention models ------------------------------------------------------- */
.official { display: flex; flex-wrap: wrap; gap: 16px; }
.official figure { margin: 0; width: 132px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.official img { width: 112px; height: 112px; object-fit: contain; padding: 8px; background: var(--sign-bg); border-radius: var(--radius); }
.official figcaption { display: flex; flex-direction: column; align-items: center; font-size: .8rem; text-align: center; gap: 1px; }
.matrix .rowhead a { flex-direction: row; align-items: center; gap: 10px; }
.matrix .rowhead .rtext { display: flex; flex-direction: column; }
.official-mini { width: 40px; height: 40px; object-fit: contain; flex: none; }
.official figure { width: 150px; }
.official figcaption a { color: var(--accent-ink); }
.design-official { display: flex; gap: 6px; }
.design-official img { width: 56px; height: 56px; object-fit: contain; padding: 4px; background: var(--sign-bg); border-radius: var(--radius); }
.design { scroll-margin-top: 80px; }
.badge.warn { background: color-mix(in srgb, var(--warn) 22%, var(--surface)); color: var(--text); margin-left: 0; }


/* --- sign page: hero, tabs, national sign tiles ------------------------------------------------ */
.sign-hero { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px 0 36px; text-align: center; }
.sign-hero .hero-img { width: min(360px, 70vw); height: min(360px, 70vw); padding: 28px; }
.official-strip { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.official-strip figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; max-width: 110px; }
.official-thumb { padding: 6px; background: var(--sign-bg); border: 2px solid transparent; border-radius: var(--radius); cursor: pointer; }
.official-thumb[aria-pressed="true"] { border-color: var(--accent); }
.official-thumb img { width: 72px; height: 72px; object-fit: contain; display: block; }
.sign-hero .ref.big { font-size: 1.6rem; letter-spacing: .04em; }
.hero-id { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.sign-section { border-top: 1px solid var(--line); padding: 28px 0 8px; }
.sign-section > h2 { margin: 0 0 6px; }

.tabstrip { display: flex; gap: 8px; overflow-x: auto; padding: 8px 2px 10px; scroll-snap-type: x proximity; }
.tabthumb { flex: none; scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 112px; padding: 10px 6px 8px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.tabthumb:hover { border-color: var(--line-strong); }
.tabthumb[aria-selected="true"] { border-color: var(--un-blue); box-shadow: 0 0 0 2px var(--un-blue-soft), inset 0 -3px 0 var(--un-blue); }
.tabthumb:focus-visible { outline: 2px solid var(--un-blue); outline-offset: 2px; }
.tt-img { width: 64px; height: 64px; display: grid; place-items: center; }
.tt-img:empty { height: 0; }
.tt-img img { max-width: 64px; max-height: 64px; object-fit: contain; }
.tt-label { font-size: .82rem; font-weight: 500; color: var(--heading); text-align: center; line-height: 1.2; max-height: 2.4em; overflow: hidden; }
.tt-count { font-size: .72rem; color: var(--muted); }
.tabpanel { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px 24px; background: var(--surface); }
.tabpanel-head { display: flex; gap: 24px; align-items: flex-start; padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabpanel-head h3 { margin: 0 0 8px; font-weight: 400; font-size: 1.3rem; }
.tab-models { display: flex; gap: 8px; flex: none; }
.tab-models img { width: 88px; height: 88px; object-fit: contain; padding: 6px; background: var(--sign-bg); border-radius: var(--radius); }
@media (max-width: 640px) { .tabpanel-head { flex-direction: column; } }

.tiles-head { margin: 4px 0 10px; gap: 12px; }
.tiles-head h4 { margin: 0; }
.tile-filter { max-width: 260px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(216px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.tile[hidden] { display: none; }
.tile:hover { border-color: var(--line-strong); box-shadow: 0 2px 8px rgb(0 0 0 / .06); }
.tile-img { height: 112px; display: grid; place-items: center; background: var(--sign-bg); padding: 10px; }
.tile-img img { max-width: 100%; max-height: 92px; object-fit: contain; }
.tile-id { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 4px; min-height: 58px; }
.tile-id code { font-size: .92rem; color: var(--heading); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-country { font-size: .76rem; color: var(--muted); }
.tile-country .cc { font-family: var(--mono); text-transform: uppercase; }
.tile-badges .badge { margin: 0 4px 0 0; }
.tile-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 6px 8px 10px; }
.tile-actions .btn { flex: 1 1 auto; min-width: 0; justify-content: center; gap: 3px; padding: 5px 6px; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-actions .btn[disabled] { opacity: .45; cursor: not-allowed; }
.tile-add { align-items: center; justify-content: center; gap: 6px; min-height: 230px; border-style: dashed; color: var(--accent-ink); font: inherit; cursor: pointer; }
.tile-add .plus { font-size: 2rem; line-height: 1; }

/* --- dialogs: info, move, panel picker --------------------------------------------------------- */
.dialog.wide { width: min(900px, 94vw); max-height: 88vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 8px; }
.modal-head h2 { margin: 0; font-weight: 400; }
.modal-foot { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); gap: 8px; }
.modal-foot input { margin: 0; flex: 1; }
.dialog .actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.dialog .box { padding: 18px 0; }
.dialog .box h3 { margin: 0 0 10px; }
.linkish { border: 0; background: none; padding: 0 2px; color: var(--accent-ink); font: inherit; cursor: pointer; text-decoration: underline; }
.badge.ok { background: color-mix(in srgb, var(--ok) 16%, var(--surface)); color: var(--text); }
.unit-pics { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 14px; }
.unit-pics img { width: 96px; height: 96px; object-fit: contain; padding: 6px; background: var(--sign-bg); border-radius: var(--radius); }
.kv-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0 0 14px; }
.kv-list dt { color: var(--muted); font-size: .82rem; }
.kv-list dd { margin: 0; }
.loc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 10px; }
.loc-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-align: center; }
.loc-card:hover:not([disabled]) { border-color: var(--un-blue); }
.loc-card[disabled] { opacity: .5; cursor: not-allowed; }
.loc-card.current { border-color: var(--un-blue); opacity: .8; }
.loc-card img { width: 64px; height: 64px; object-fit: contain; }
.loc-label { font-weight: 500; font-size: .85rem; color: var(--heading); }
.loc-props, .loc-count { font-size: .72rem; color: var(--muted); }
.ptiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin-bottom: 12px; }
.ptile { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-align: center; }
.ptile:hover { border-color: var(--un-blue); }
.ptile img { width: 72px; height: 48px; object-fit: contain; }
.ptile .noimg { width: 72px; height: 48px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.ptile .small { color: var(--muted); max-height: 2.6em; overflow: hidden; }

/* --- additional panels: chips, stacked preview, editor ---------------------------------------- */
.pchip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .8rem; margin: 2px 4px 2px 0; }
.pchip .lvl { font-weight: 700; }
.pchip.lvl-ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); } .pchip.lvl-ok .lvl { color: var(--ok); }
.pchip.lvl-warning { border-color: var(--warn); } .pchip.lvl-warning .lvl { color: #9a6b00; }
.pchip.lvl-error { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); } .pchip.lvl-error .lvl { color: var(--danger); }
.pchip .x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 1rem; line-height: 1; }
.pstack { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 16px; background: var(--surface-2); border-radius: var(--radius); }
.pstack-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pstack-mid { display: flex; align-items: center; gap: 8px; }
.pstack-sign { width: 72px; height: 72px; object-fit: contain; }
.pstack-sign.blank { display: block; border: 2px dashed var(--line-strong); border-radius: 50%; }
.pstack-slot { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; }
.panels-edit { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 24px; align-items: start; }
@media (max-width: 720px) { .panels-edit { grid-template-columns: 1fr; } }
.panels-preview { position: sticky; top: 0; }
.ppos { padding: 4px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.ppos h5 { display: flex; align-items: center; gap: 8px; }
.pslot { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.pslot-n { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--un-blue-soft); color: var(--accent-ink); font-size: .78rem; font-weight: 600; }
.pslot-refs { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.pcheck-status { margin-top: 10px; font-size: .9rem; }
.pc-ok { color: var(--ok); } .pc-warn { color: #9a6b00; } .pc-err { color: var(--danger); font-weight: 500; }
.pcheck-list { margin: 6px 0 0; padding-left: 18px; font-size: .82rem; }
.pcheck-list .lvl-error { color: var(--danger); } .pcheck-list .lvl-warning { color: #9a6b00; }

/* --- comparison: every national sign of one country ------------------------------------------ */
.cs-unit { border-top: 1px solid var(--line); padding: 14px 0 6px; }
.cs-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.cs-head h3 { margin: 0 0 2px; font-size: 1.05rem; }
.cs-head p { margin: 0; }
.cs-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.cs-code { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.cs-code img, .cs-noimg { width: 100px; height: 100px; object-fit: contain; padding: 6px; box-sizing: border-box; background: var(--sign-bg); border-radius: var(--radius); }
.cs-noimg { display: block; }
.cs-code figcaption { display: flex; flex-direction: column; gap: 1px; font-size: .85rem; }
.add-country { border-top: 1px solid var(--line); padding-top: 8px; }
.add-country h5 { margin: 4px 0 6px; }
.add-country .row { gap: 6px; flex-wrap: nowrap; }
.add-country input { min-width: 0; }
.add-country input.mono { width: 70px; flex: none; }
.colhead .badge { margin: 2px 0 0; }

/* Wikidata ID: link + inline editor */
.wd, .wd-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .9rem; }
.wd-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.wd-link { text-decoration: none; }
.wd-link code { font-size: .9rem; }
.wd-form .wd-input { width: 26ch; max-width: 100%; flex: 0 1 auto; }
.wd-status { flex-basis: 100%; }
.hero-id .wd-status { text-align: center; }
.tabpanel-head .wd { margin-top: 6px; }

/* Sign pictures shown without a framed box (tables, chips, small icons) get the light plate too. */
img[src^="/media/"], img[src^="/vienna-media/"] { background-color: var(--sign-bg); }
.theme-toggle { min-width: 2.4em; font-size: 1.05rem; line-height: 1; }
