/* Języki świata – style. Charakter: atlas na papierze – ciepłe tło, atrament, cynobrowy akcent, szeryfowa Literata
   w tytułach i IBM Plex Sans w treści. Ciemny motyw według systemu (prefers-color-scheme) albo wybrany przełącznikiem
   w nagłówku (<html data-theme>). Kolory map (statusy, liczba języków urzędowych, kolory kategorii regionów) są
   zmiennymi CSS – JS czyta je przy rysowaniu i przy zmianie motywu. */

:root {
  --bg: #f4efe4;
  --surface: #fbf8f1;
  --surface-2: #efe8da;
  --ink: #1f1b16;
  --ink-2: #4d463c;
  --muted: #7a7062;
  --line: #ddd3c0;
  --accent: #c4502f;
  --accent-ink: #a63f22;
  --indigo: #2d3a8c;
  --focus: #2d3a8c;

  --ocean: #e9e2d2;
  --land: #d8cfbc;
  --land-hover: #c9bea7;

  --st-official: #24307a;
  --st-co_official: #4a5cc4;
  --st-regional: #8f9be0;
  --st-widely: #d9925a;
  --st-minority: #ecc9a4;

  --count-0: #e3d9c6;
  --count-1: #f0c7a4;
  --count-2: #e3996c;
  --count-3: #cb6a44;
  --count-4: #a2432a;
  --count-5: #6e2a1c;

  --cat-0: #3f6fb5;
  --cat-1: #c4502f;
  --cat-2: #3f8f5a;
  --cat-3: #d9a32e;
  --cat-4: #8a5bb8;
  --cat-5: #1e9e9a;
  --cat-6: #cf5f98;
  --cat-7: #8a7550;
  --cat-8: #5b8a8f;
  --cat-9: #b5653a;
  --cat-10: #6c7fd6;
  --cat-11: #9aa33a;

  --serif: 'Literata', Georgia, 'Times New Roman', serif;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', 'Noto Sans', sans-serif;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(60 45 20 / 0.06), 0 6px 24px rgb(60 45 20 / 0.07);
  --wrap: 1240px;
  --header-h: 64px;
}

/* Ciemny motyw: według systemu (gdy nie wybrano jasnego przełącznikiem) albo wybrany przełącznikiem w nagłówku. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #14161d;
    --surface: #1b1e27;
    --surface-2: #232733;
    --ink: #ece5d8;
    --ink-2: #c6bdac;
    --muted: #928a7b;
    --line: #2f3442;
    --accent: #e2744f;
    --accent-ink: #f08c68;
    --indigo: #a3afff;
    --focus: #a3afff;

    --ocean: #10131a;
    --land: #2e3342;
    --land-hover: #3c4356;

    --st-official: #b4beff;
    --st-co_official: #7686ee;
    --st-regional: #45529f;
    --st-widely: #c9844e;
    --st-minority: #6e5340;

    --count-0: #262a35;
    --count-1: #4e3529;
    --count-2: #7d4630;
    --count-3: #ad5c3b;
    --count-4: #d9845a;
    --count-5: #f5b68b;

    --cat-0: #6f9be0;
    --cat-1: #e2744f;
    --cat-2: #62b57c;
    --cat-3: #e2b54e;
    --cat-4: #a985d6;
    --cat-5: #3cbfb9;
    --cat-6: #e382b3;
    --cat-7: #b09a72;
    --cat-8: #79b0b5;
    --cat-9: #d48a5c;
    --cat-10: #8e9cf0;
    --cat-11: #bcc45a;

    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 28px rgb(0 0 0 / 0.3);
  }
}
:root[data-theme='dark'] {
  --bg: #14161d;
  --surface: #1b1e27;
  --surface-2: #232733;
  --ink: #ece5d8;
  --ink-2: #c6bdac;
  --muted: #928a7b;
  --line: #2f3442;
  --accent: #e2744f;
  --accent-ink: #f08c68;
  --indigo: #a3afff;
  --focus: #a3afff;

  --ocean: #10131a;
  --land: #2e3342;
  --land-hover: #3c4356;

  --st-official: #b4beff;
  --st-co_official: #7686ee;
  --st-regional: #45529f;
  --st-widely: #c9844e;
  --st-minority: #6e5340;

  --count-0: #262a35;
  --count-1: #4e3529;
  --count-2: #7d4630;
  --count-3: #ad5c3b;
  --count-4: #d9845a;
  --count-5: #f5b68b;

  --cat-0: #6f9be0;
  --cat-1: #e2744f;
  --cat-2: #62b57c;
  --cat-3: #e2b54e;
  --cat-4: #a985d6;
  --cat-5: #3cbfb9;
  --cat-6: #e382b3;
  --cat-7: #b09a72;
  --cat-8: #79b0b5;
  --cat-9: #d48a5c;
  --cat-10: #8e9cf0;
  --cat-11: #bcc45a;

  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 28px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}
:root[data-theme='light'] { color-scheme: light; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  border-top: 4px solid var(--accent);
}
a { color: var(--indigo); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; margin: 0 0 0.4em; }
h1 { font-size: clamp(2rem, 4.2vw, 3.2rem); }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 0.9em; }
code { font-size: 0.9em; background: var(--surface-2); padding: 0.05em 0.35em; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--bg); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.kicker { font: 600 0.74rem/1.2 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: 0.6em; }
.kicker a { color: inherit; }
.lede { font-size: 1.12rem; color: var(--ink-2); max-width: 62ch; }
.note { border-left: 3px solid var(--accent); padding: 0.4em 0 0.4em 0.9em; color: var(--ink-2); max-width: 70ch; }
.endo { font-family: var(--serif); font-style: italic; color: var(--muted); font-weight: 400; margin-left: 0.25em; }
.dot { display: inline-block; width: 0.62em; height: 0.62em; border-radius: 50%; background: var(--c, var(--muted)); margin-right: 0.45em; vertical-align: 0.05em; }
.st { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 3px; margin-right: 0.45em; vertical-align: -0.05em; }
.st-official { background: var(--st-official); }
.st-co_official { background: var(--st-co_official); }
.st-regional { background: var(--st-regional); }
.st-widely { background: var(--st-widely); }
.st-minority { background: var(--st-minority); }
.btn, .btn-ghost {
  display: inline-block; font: 500 0.92rem/1 var(--sans); padding: 0.7em 1.05em; border-radius: 999px; text-decoration: none; cursor: pointer;
  border: 1px solid var(--ink); background: var(--ink); color: var(--bg);
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }

/* --- nagłówek ----------------------------------------------------------- */
.site-header {
  height: var(--header-h); padding: 0 clamp(16px, 2.5vw, 32px); display: flex; align-items: center; gap: 20px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: relative; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); margin-right: auto; }
.brand-mark { width: 30px; height: 30px; color: var(--accent); }
.brand-name { font: 600 1.28rem/1 var(--serif); letter-spacing: -0.01em; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; align-items: center; }
.site-nav a, .more-menu summary { display: block; padding: 7px 11px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-size: 0.95rem; cursor: pointer; }
.site-nav a:hover, .more-menu summary:hover { background: var(--surface-2); color: var(--ink); }
.site-nav a[aria-current] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px; color: var(--ink); }
.nav-toggle svg { width: 20px; height: 20px; display: block; }
.more-menu { position: relative; }
.more-menu summary { list-style: none; }
.more-menu summary::-webkit-details-marker { display: none; }
.more-menu summary::after { content: '▾'; font-size: 0.75em; margin-left: 0.35em; color: var(--muted); }
.more-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px !important; min-width: 230px; display: block !important; z-index: 30; }
.more-home { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.more-home a { color: var(--accent-ink); font-weight: 500; }
.more-lang { font-size: 0.7rem; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.lang-switch { display: flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--surface); }
.lang-switch a { font: 600 0.78rem/1 var(--sans); letter-spacing: 0.06em; padding: 7px 10px; border-radius: 999px; color: var(--muted); text-decoration: none; }
.lang-switch a[aria-current] { background: var(--ink); color: var(--bg); }
/* Przełącznik motywu: słońce / auto / księżyc – pigułka jak przełącznik języków */
/* Przełącznik motywu: moduł theme (assets/theme/theme.css) – wygląd serwisu przez zmienne --theme-switch-*: wybrany tryb
   odwrócony (ciemna pigułka z jasną ikoną), odstęp od sąsiadów daje gap nagłówka. */
.site-header {
  --theme-switch-size: 27px; --theme-switch-border: var(--line); --theme-switch-gap-left: 0; --theme-switch-gap-left-compact: 0;
  --theme-switch-active: var(--ink); --theme-switch-fg-active: var(--bg);
}
.theme-switch button[aria-pressed='false']:hover { color: var(--ink); }
/* Menu formatów eksportu PNG: moduł export (assets/export/export.css) na zmiennych serwisu */
:root { --export-font: var(--sans); --export-radius: 8px; --export-line: var(--line); --export-hover: var(--surface-2); }

/* --- strona główna: mapa na cały ekran, panel po lewej -------------------- */
main { display: block; }
.atlas {
  display: grid; grid-template-columns: 380px minmax(0, 1fr);
  height: calc(100dvh - var(--header-h) - 4px); min-height: 600px;
}
.codex {
  order: -1; position: relative; z-index: 2; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--line); box-shadow: 6px 0 24px -18px rgb(60 45 20 / 0.5);
}
.codex-intro { padding: 22px 22px 4px; }
.codex.is-detail .codex-intro { display: none; }
.codex-intro h1 { font-size: 1.85rem; }
.codex-intro .lede { font-size: 1rem; }
.stats { display: flex; gap: 24px; margin: 0 0 16px; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dd { margin: 0; font: 600 1.55rem/1 var(--serif); color: var(--accent-ink); }
.stats dt { font-size: 0.82rem; color: var(--muted); margin-top: 3px; }
.codex .finder { padding: 0 22px 14px; border-bottom: 1px solid var(--line); }
.codex.is-detail .finder { padding-top: 16px; }
.codex .finder-list { left: 22px; right: 22px; top: calc(100% - 8px); }
.codex-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 22px 22px; scrollbar-width: thin; }
.codex-body h2 { font-size: 1.5rem; }
.atlas .atlas-map { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--ocean); }
.atlas .map-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.atlas .map-frame { flex: 1; min-height: 0; position: relative; border: 0; border-radius: 0; }
.map-tools {
  position: absolute; z-index: 4; top: 14px; left: 14px; right: 64px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; pointer-events: none;
}
.map-tools > * { pointer-events: auto; }
/* Zakładki i opcje aktywnej zakładki w jednej karcie: zakładki u góry, pod kreską – to, co dotyczy wybranej. */
.mode-card {
  max-width: 100%; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px);
}
.mode-card .modes { background: none; border-radius: 0; padding: 0 6px; gap: 0; border-bottom: 1px solid var(--line); flex-wrap: nowrap; }
.mode-card .modes button { border-radius: 0; padding: 12px 12px 10px; margin-bottom: -1px; border-bottom: 2px solid transparent; flex: none; }
.mode-card .modes button:hover { color: var(--ink); }
.mode-card .modes button[aria-selected='true'] { background: none; box-shadow: none; color: var(--ink); border-bottom-color: var(--accent); }
.mode-card .atlas-sub { margin: 0; padding: 8px 12px; min-height: 46px; }
.count-scale { list-style: none; display: flex; gap: 10px; margin: 0; padding: 0; font-weight: 600; color: var(--ink); }
.count-scale li { display: flex; align-items: center; gap: 4px; }
/* Wybór języka w trybie „gdzie mówi się…”: pole z bieżącym językiem i popularne języki. */
.langpick .finder { display: flex; align-items: center; gap: 8px; }
.langpick label { font-weight: 600; color: var(--ink); }
.langpick .finder input {
  width: 210px; padding: 7px 32px 7px 12px; font-size: 0.92rem; font-weight: 500; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%238a8f99' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center / 11px 8px;
}
.langpick .finder input:focus { cursor: text; }
.langpick .finder input::-webkit-search-cancel-button { display: none; }
.langpick .finder-list { right: auto; min-width: 300px; }
.langpick .finder-list li { grid-template-columns: 1fr auto; align-items: baseline; }
.quick { display: flex; flex-wrap: wrap; gap: 4px; }
.quick button { font: 0.84rem/1 var(--sans); padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-2); cursor: pointer; }
.quick button:hover { border-color: var(--indigo); color: var(--ink); }
.quick button[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.atlas .legend { margin: 0; padding: 10px 18px 12px; background: var(--surface); border-top: 1px solid var(--line); max-height: min(30%, 140px); overflow-y: auto; scrollbar-width: thin; }
.reel { overflow: hidden; border-bottom: 1px solid var(--line); background: var(--surface); mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent); }
.reel-track { list-style: none; margin: 0; padding: 12px 0; display: flex; gap: 34px; width: max-content; animation: reel 120s linear infinite; }
.reel:hover .reel-track, .reel:focus-within .reel-track { animation-play-state: paused; }
.reel a { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.reel-word { font: 500 1.35rem/1.2 var(--serif); }
.reel-lang { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.reel a:hover .reel-word { color: var(--accent-ink); }
@keyframes reel { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .reel-track { animation: none; } .reel { overflow-x: auto; } }

.modes { display: flex; gap: 2px; background: var(--surface-2); border-radius: 999px; padding: 3px; flex-wrap: wrap; }
.modes button { font: 500 0.92rem/1 var(--sans); color: var(--ink-2); background: none; border: 0; border-radius: 999px; padding: 9px 15px; cursor: pointer; }
.modes button[aria-selected='true'] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.finder { position: relative; }
.finder input, .filters input[type='search'], .filters select {
  width: 100%; font: 0.95rem/1.2 var(--sans); padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink);
}
.finder input:focus, .filters input:focus, .filters select:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px color-mix(in srgb, var(--indigo) 20%, transparent); }
.finder-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); list-style: none; margin: 0; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 20; max-height: 360px; overflow: auto; }
.finder-list li { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; padding: 7px 9px; border-radius: 7px; cursor: pointer; }
.finder-list li[aria-selected='true'], .finder-list li:hover { background: var(--surface-2); }
.hit-type { grid-row: span 2; align-self: center; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; padding: 3px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); }
.hit-lang { color: var(--indigo); }
.hit-country { color: var(--accent-ink); }
.hit-label { font-weight: 500; }
.hit-sub { font-size: 0.8rem; color: var(--muted); }
.atlas-sub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 0; font-size: 0.9rem; color: var(--ink-2); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { font: 0.86rem/1 var(--sans); padding: 7px 12px; border: 0; background: var(--surface); color: var(--ink-2); cursor: pointer; }
.seg button[aria-checked='true'] { background: var(--ink); color: var(--bg); }
/* Mapa z przyciskiem eksportu PNG w prawym dolnym rogu (menu formatów otwiera się w górę, do prawej). */
.map-stage { position: relative; }
.map-export-wrap { position: absolute; z-index: 5; right: 12px; bottom: 12px; }
.map-export-wrap[hidden] { display: none; }
.map-frame { background: var(--ocean); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); min-height: 200px; }
.map-frame[aria-busy='true'] { min-height: 380px; background: linear-gradient(100deg, var(--ocean) 30%, var(--surface-2) 50%, var(--ocean) 70%) 0 0 / 300% 100%; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }
.legend { margin-top: 10px; font-size: 0.86rem; }
.legend-title { font-weight: 600; margin-bottom: 4px; }
.legend ul, .legend-inline { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.legend li, .legend-inline li { display: flex; align-items: center; gap: 6px; }
.legend a { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); text-decoration: none; }
.legend a:hover { text-decoration: underline; }
/* Gałęzie: nazwa rodziny i jej gałęzie płyną w jednym wierszu z resztą legendy. */
.legend .legend-group, .legend .legend-group > ul { display: contents; }
.legend .legend-fam { font-weight: 600; margin-left: 10px; }
.legend > ul > :first-child > .legend-fam { margin-left: 0; }
.sw { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.status-key { list-style: none; padding: 0; margin: 12px 0 0; font-size: 0.9rem; }
.status-key li { margin: 4px 0; }
.lrows { list-style: none; margin: 10px 0; padding: 0; }
.lrow-main { width: 100%; display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: 'st name pct' 'st status status' 'bar bar bar'; column-gap: 8px; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--line); padding: 8px 2px; cursor: pointer; color: var(--ink); font: inherit; }
.lrow-main:hover, .lrow.is-active .lrow-main { background: var(--surface-2); }
.lrow-main .st { grid-area: st; margin-top: 0.3em; }
.lrow-name { grid-area: name; font-weight: 500; }
.lrow-status { grid-area: status; font-size: 0.78rem; color: var(--muted); }
.lrow-pct { grid-area: pct; font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.lrow-bar { grid-area: bar; height: 3px; background: var(--surface-2); margin-top: 5px; border-radius: 2px; }
.lrow-bar span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.mode-fact { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.mode-fact .sw { flex: none; width: 18px; height: 18px; margin-top: 2px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.15); }
.mode-fact strong { display: block; font-weight: 600; }
.mode-fact strong a { color: inherit; }
.mode-fact span:not(.sw) { display: block; font-size: 0.84rem; color: var(--muted); margin-top: 2px; }
.panel-card h3 { font-size: 0.95rem; font-family: var(--sans); font-weight: 600; margin: 14px 0 4px; }
.clist { font-size: 0.9rem; line-height: 1.7; margin: 0; }
.clist button { background: none; border: 0; padding: 0; color: var(--indigo); font: inherit; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line); }
.clist button:hover { color: var(--accent-ink); }
.facts a { color: var(--ink); text-decoration: none; }
.wm { --wm-ocean: var(--ocean); --wm-land: var(--land); --wm-land-hover: var(--land-hover); --wm-border: var(--bg); --wm-sphere-stroke: var(--line);
  --wm-selected: var(--accent); --wm-selected-outline: var(--ink); --wm-hover-outline: var(--ink); --wm-font: var(--sans);
  --wm-tooltip-bg: var(--ink); --wm-tooltip-fg: var(--bg); --wm-control-bg: var(--surface); --wm-control-fg: var(--ink); --wm-control-border: var(--line); }
.wm[data-wm-theme] { --wm-ocean: var(--ocean); --wm-land: var(--land); --wm-land-hover: var(--land-hover); --wm-border: var(--bg); --wm-sphere-stroke: var(--line);
  --wm-selected: var(--accent); --wm-selected-outline: var(--ink); --wm-hover-outline: var(--ink);
  --wm-tooltip-bg: var(--ink); --wm-tooltip-fg: var(--bg); --wm-control-bg: var(--surface); --wm-control-fg: var(--ink); --wm-control-border: var(--line); }
.rm, .rm[data-rm-theme] { --rm-land: var(--land); --rm-land-hover: var(--land-hover); --rm-land-inactive: var(--land); --rm-border: var(--bg); --rm-outline: var(--ink-2);
  --rm-hover-outline: var(--ink); --rm-frame: var(--line); --rm-font: var(--sans); --rm-tooltip-bg: var(--ink); --rm-tooltip-fg: var(--bg);
  --rm-control-bg: var(--surface); --rm-control-fg: var(--ink); --rm-control-border: var(--line); }
.map-regions { background: var(--surface); }
.map-regions.is-focus .rm-region:not(.is-hl) { opacity: 0.25; }
.map-regions .rm-region { transition: opacity 0.15s ease; }

/* --- pasma pod mapą ------------------------------------------------------ */
.band { max-width: var(--wrap); margin: 36px auto 0; padding: 0 20px; display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; }
.bars { list-style: none; margin: 12px 0; padding: 0; counter-reset: n; }
.bars li a { display: grid; grid-template-columns: minmax(130px, 1.1fr) 2fr 90px; gap: 12px; align-items: center; padding: 6px 0; color: var(--ink); text-decoration: none; border-bottom: 1px dashed var(--line); }
.bars li a:hover .bar-name { color: var(--accent-ink); }
.bar-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--c); border-radius: 5px; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; font-size: 0.9rem; color: var(--ink-2); }
.bars.compact li a { padding: 4px 0; }
.chips { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips a { display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 0.92rem; }
.chips a:hover { border-color: var(--c); }
.chips .muted { margin-left: 0.3em; }
.legend .muted { margin-left: 0.15em; }
.more { font-weight: 500; }

/* --- podstrony ----------------------------------------------------------- */
.page { max-width: var(--wrap); margin: 0 auto; padding: 16px 20px 20px; }
.crumbs { font-size: 0.85rem; color: var(--muted); margin-bottom: 18px; }
.crumbs a { color: var(--muted); }
.page-head { margin-bottom: 22px; }
.language-head { display: grid; grid-template-columns: 1fr auto; gap: 30px; align-items: start; }
.endonym { font: 400 1.6rem/1.3 var(--serif); font-style: italic; margin: -0.1em 0 0.6em; }
.fam { color: inherit; text-decoration: none; }
.greet { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; min-width: 240px; box-shadow: var(--shadow); position: relative; }
.greet::before { content: '“'; position: absolute; right: 14px; top: -6px; font: 600 4rem/1 var(--serif); color: var(--accent); opacity: 0.5; }
.greet-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin: 0; }
.greet-word { font: 600 1.7rem/1.25 var(--serif); margin: 2px 0 0; }
.greet-latin { font-style: italic; color: var(--ink-2); margin: 0 0 12px; }
.greet-word + .greet-label { margin-top: 12px; }
.facts-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 0 0 30px; }
.facts-grid > div { background: var(--surface); padding: 14px 16px; }
.facts-grid dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.facts-grid dd { margin: 4px 0 0; font-weight: 500; }
.facts-grid dd.muted, .facts-grid dd.small { font-weight: 400; }
/* Bez min-height z ładowania: przy aspect-ratio przeniósłby się na min. szerokość (760 px) i mapa wychodziła za ekran. */
.map-frame.map-wide { aspect-ratio: 2 / 1; min-height: 0; }
.lang-map, .lang-countries, .relatives { margin-bottom: 28px; }
.legend-inline { margin-top: 10px; font-size: 0.88rem; }
.lang-countries { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px 36px; }
.status-group h3 { font-family: var(--sans); font-size: 1rem; border-bottom: 2px solid var(--ink); padding-bottom: 4px; }
.clist-rows { list-style: none; margin: 0; padding: 0; }
.clist-rows li { display: grid; grid-template-columns: 1fr 70px 52px auto; gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 0.93rem; }
.clist-rows .row-note { grid-column: 1 / -1; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pbar { display: inline-block; width: 70px; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; vertical-align: middle; }
.pbar span { display: block; height: 100%; background: var(--accent); }
.row-note { font-size: 0.82rem; color: var(--muted); margin: 3px 0 0; }
.country-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.country-map { position: sticky; top: 12px; }
.ltable { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
/* Tabele w przewijanym kontenerze – na wąskim ekranie przewija się tabela, nie cała strona. */
.table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.ltable th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--ink); padding: 6px 8px; }
.ltable td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; }
.ltable th.num { text-align: right; }
.ltable tbody tr:hover { background: var(--surface); }
.ltable .num .pbar { margin-right: 6px; }
.lname { font-weight: 500; color: var(--ink); text-decoration: none; }
.lname:hover { color: var(--accent-ink); text-decoration: underline; }
.badge { display: inline-block; font-size: 0.76rem; padding: 3px 8px; border-radius: 999px; white-space: nowrap; color: #fff; }
.badge.st-regional, .badge.st-widely, .badge.st-minority { color: var(--ink); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .badge.st-official, :root:not([data-theme='light']) .badge.st-co_official { color: #111; }
  :root:not([data-theme='light']) .badge.st-regional, :root:not([data-theme='light']) .badge.st-minority { color: var(--ink); }
}
:root[data-theme='dark'] .badge.st-official, :root[data-theme='dark'] .badge.st-co_official { color: #111; }
:root[data-theme='dark'] .badge.st-regional, :root[data-theme='dark'] .badge.st-minority { color: var(--ink); }
.back { margin-top: 26px; }
.family-branches { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 10px 40px; margin-top: 26px; }
.family-page .page-head h1 { color: var(--ink); text-decoration: underline; text-decoration-color: var(--fam); text-decoration-thickness: 6px; text-underline-offset: 0.12em; }
.filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters label { flex: 0 1 280px; }
.filters label.check { flex: 0 0 auto; font-size: 0.9rem; }
.catalog td { padding: 6px 8px; }
.prose { max-width: 860px; }
.prose h2 { margin-top: 1.6em; }
.prose li { margin-bottom: 0.4em; }
.defs dt { font-weight: 600; margin-top: 8px; }
.defs dd { margin: 0 0 0 1.3em; color: var(--ink-2); }
.error-page { text-align: center; padding: 70px 20px; }
.error-glyphs { font: 600 3rem/1 var(--serif); color: var(--accent); letter-spacing: 0.1em; }
.error-page .lede { margin-inline: auto; }

/* --- kontakt ------------------------------------------------------------- */
.contact-form { max-width: 640px; margin: 22px 0 18px; }
.contact-form .field { margin-bottom: 16px; }
.contact-form label { display: block; font-weight: 500; margin-bottom: 5px; }
.contact-form input[type='text'], .contact-form input[type='email'], .contact-form textarea {
  width: 100%; font: 0.98rem/1.45 var(--sans); padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
}
.contact-form textarea { resize: vertical; min-height: 160px; }
.contact-form input:focus, .contact-form textarea:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px color-mix(in srgb, var(--indigo) 20%, transparent); }
.contact-form [aria-invalid='true'] { border-color: var(--accent); }
.contact-form .field-check label { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; font-weight: 400; font-size: 0.93rem; color: var(--ink-2); }
.contact-form .field-check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); }
.contact-form .btn { font-size: 1rem; }
.req { color: var(--accent-ink); }
.field-error { color: var(--accent-ink); font-size: 0.88rem; margin: 5px 0 0; }
.form-alert, .form-success { border-left: 3px solid var(--accent); background: var(--surface); padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0; max-width: 640px; }
.form-success { border-left-color: var(--st-official); font-size: 1.08rem; }
.form-clause { max-width: 640px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* --- stopka -------------------------------------------------------------- */
.site-footer { max-width: var(--wrap); margin: 50px auto 0; padding: 22px 20px 40px; border-top: 1px solid var(--line); font-size: 0.85rem; color: var(--muted); }
.site-footer a { color: var(--ink-2); }
.site-footer .copyright { margin-top: 6px; }
/* Ikonki kanałów marki w stopce (Series::socialLinks, moduł series): kolor tekstu stopki, przy najechaniu i fokusie jaśniej */
.series-social-link { transition: opacity .15s; }
.series-social-link:hover, .series-social-link:focus-visible { opacity: .7; }

/* --- telefon ------------------------------------------------------------- */
@media (max-width: 980px) {
  .country-grid, .band { grid-template-columns: 1fr; }
  .country-map { position: static; }
  .facts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .atlas { display: flex; flex-direction: column; height: auto; min-height: 0; overflow-x: clip; }
  .atlas > * { min-width: 0; max-width: 100%; }
  .atlas .atlas-map { order: 1; }
  .codex { order: 2; }
  .atlas .map-stage { flex: none; }
  .atlas .map-frame { flex: none; height: max(260px, 62vw); max-height: 70vh; }
  .map-tools { position: static; order: -1; padding: 12px; gap: 8px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .mode-card { box-shadow: none; backdrop-filter: none; }
  .mode-card .modes { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .langpick .finder { flex: 1 1 100%; }
  .langpick .finder input { width: auto; flex: 1; min-width: 0; }
  .langpick .finder-list { right: 0; min-width: 0; }
  .langpick .quick { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .quick button { flex: none; }
  .atlas .legend { max-height: none; }
  .codex { border-right: 0; border-top: 1px solid var(--line); box-shadow: none; }
  .codex-body { overflow: visible; }
}
@media (max-width: 720px) {
  .site-header { gap: 10px; padding: 0 16px; }
  .brand-name { font-size: 1.1rem; }
  .nav-toggle { display: block; }
  .site-nav > ul {
    display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; align-items: stretch;
    padding: 8px 16px 12px !important; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
  }
  .site-nav.is-open > ul { display: flex; }
  .more-list { position: static; box-shadow: none; }
  .band, .page, .site-footer { padding-left: 16px; padding-right: 16px; }
  .codex-intro, .codex-body { padding-left: 16px; padding-right: 16px; }
  .codex .finder { padding-left: 16px; padding-right: 16px; }
  .codex .finder-list { left: 16px; right: 16px; }
  .language-head { grid-template-columns: 1fr; }
  .bars li a { grid-template-columns: 1fr 1fr 74px; }
  .clist-rows li { grid-template-columns: 1fr 52px auto; }
  .clist-rows .pbar { display: none; }
  .ltable .pbar { display: none; }
  .catalog th:nth-child(3), .catalog td:nth-child(3) { display: none; }
  .family-branches, .lang-countries { grid-template-columns: 1fr; }
}
/* Na wąskim ekranie jeden przycisk z bieżącym trybem – dotknięcie przełącza auto → jasny → ciemny (moduł theme) */
@media (max-width: 480px) {
  /* Nazwa serwisu w jednej linii obok menu, języków i motywu: mniejsze odstępy i logo */
  .site-header { gap: 6px; padding: 0 12px; }
  .brand { gap: 6px; min-width: 0; }
  .brand-mark { width: 24px; height: 24px; flex: none; }
  .brand-name { font-size: 0.95rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .lang-switch a { padding: 7px 8px; }
  .theme-switch button[aria-pressed='true'] { color: var(--ink); }
}
@media (max-width: 380px) {
  .brand-mark { display: none; }
}

/* ---------- Quiz (/quiz – moduł quiz z assets) ---------- */
.quiz-stage { margin: 0 0 28px; }
.quiz-stage .quiz { --quiz-accent: var(--accent); --quiz-radius: var(--radius); }
.quiz-map {
  --wm-ocean: var(--ocean); --wm-land: var(--land); --wm-land-hover: var(--land-hover); --wm-dot: var(--land); --wm-border: var(--bg);
  --wm-sphere-stroke: var(--line); --wm-border-width: .6px; --wm-font: var(--sans);
  position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden;
}
.quiz-about { max-width: 46rem; color: var(--ink-2); }
