:root {
    color-scheme: light dark;
    --canvas: light-dark(#fbf7f4, #191515);
    --paper: light-dark(#fffdfb, #241c1c);
    --ink: light-dark(#2d1d1a, #f8edeb);
    --muted: light-dark(#68544f, #ccb9b6);
    --accent: light-dark(#9f2018, #ffa79f);
    --fill: light-dark(#9f2018, #b33228);
    --fill-hover: light-dark(#76150f, #a1261e);
    --soft: light-dark(#f8e9e5, #402827);
    --line: light-dark(#e7d7d2, #4c3835);
    --hero-surface: light-dark(#f8ece6, #2c1c1c);
    --hero-fade: light-dark(#f8ece6a8, #2c1c1cac);
    --map-selection: light-dark(#ffa99d, #ffb6ad);
    --map-outline: #76150f;
    --serif: Georgia, "Times New Roman", serif;
    font: 16px/1.5 system-ui, -apple-system, sans-serif;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
[hidden] { display: none !important; }
img { display: block; max-width: 100%; }
svg { vertical-align: middle; }
p { margin: 0 0 .85rem; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.1; overflow-wrap: anywhere; }
h1, h2 { font-family: var(--serif); font-weight: 500; }
h1 { font-size: clamp(2.65rem, 6.2vw, 5.3rem); letter-spacing: -.055em; }
h2 { font-size: clamp(1.9rem, 3vw, 2.9rem); letter-spacing: -.035em; }
h3 { font-size: 1.12rem; }
ul { padding-left: 1.3rem; }
.wrap { width: min(1200px, calc(100% - 64px)); margin-inline: auto; }
.site-header { background: var(--paper); border-bottom: 1px solid var(--line); }
.header-inner { min-height: 73px; display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 1.35rem/1 var(--serif); color: var(--ink); text-decoration: none; }
.brand img { border-radius: 11px; }
.brand-sub { color: var(--accent); display: block; margin-top: 4px; font: 700 .59rem/1 system-ui; letter-spacing: .15em; }
nav { display: flex; gap: 4px; }
nav a, .app-link { padding: 9px 12px; color: var(--ink); text-decoration: none; font-size: .9rem; font-weight: 650; border-radius: 8px; white-space: nowrap; }
nav a:hover, nav a[aria-current], .app-link:hover { background: var(--soft); color: var(--accent); }
.app-link { border: 1px solid var(--line); }
.skip { position: fixed; top: 8px; left: 8px; padding: 10px; transform: translateY(-160%); background: var(--paper); z-index: 1; }
.skip:focus { transform: none; }
main { flex: 1; padding-block: 24px 65px; }
.hero {
    display: flex;
    align-items: center;
    min-height: 440px;
    border: 1px solid var(--line);
    border-radius: 20px;
    overflow: hidden;
    background:
        linear-gradient(90deg, var(--hero-surface) 43%, var(--hero-fade) 63%, transparent 85%),
        var(--hero-surface) url('/assets/countries-world-hero.png') right center / auto 125% no-repeat;
}
.hero-content { padding: clamp(25px, 5vw, 64px); width: min(100%, 750px); }
.hero h1 { max-width: 15ch; }
.hero p:not(.eyebrow) { max-width: 42ch; margin-block: 16px 22px; color: var(--muted); font-size: 1.08rem; }
.eyebrow { color: var(--accent); font-size: .74rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; margin: 0 0 10px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.section { margin-top: 35px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-head p { margin: 0; }
.page-head { margin-block: 16px 26px; max-width: 800px; }
.page-head h1 { font-size: clamp(2.7rem, 6vw, 4.8rem); }
.lead { color: var(--muted); font-size: 1.08rem; max-width: 66ch; }
.back { display: inline-block; margin-bottom: 14px; font-weight: 650; }
.muted, small, .meta { color: var(--muted); }
.meta { font-size: .9rem; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 15px; }
.tools { grid-template-columns: repeat(6, minmax(0,1fr)); gap: 12px; }
.tool, .card, .panel { background: var(--paper); border: 1px solid var(--line); border-radius: 15px; min-width: 0; }
.tool { position: relative; display: grid; align-content: start; gap: 8px; padding: 17px; color: var(--ink); text-decoration: none; }
.tool:hover, a.card:hover { border-color: var(--accent); }
.tool strong { font-size: .98rem; }
.tool small { line-height: 1.35; }
.tool-icon { width: 37px; height: 37px; display: grid; place-items: center; border-radius: 11px; background: var(--soft); color: var(--accent); }
.tool .arrow { position: absolute; top: 16px; right: 16px; color: var(--accent); }
.panel, .card-body { padding: clamp(15px, 2vw, 24px); }
.card { display: block; overflow: hidden; color: var(--ink); text-decoration: none; }
a.card h3 { margin-top: 4px; }
.cover { width: 100%; height: 175px; object-fit: cover; background: var(--soft); }
.cover-fallback { height: 175px; background: var(--soft); display: grid; place-items: center; font-size: 3rem; }
.cover-fallback .cover { grid-area: 1 / 1; z-index: 1; }
.cover-fallback span { grid-area: 1 / 1; }
.row, .actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.button, button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 15px; min-height: 42px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); color: var(--accent); text-decoration: none; font-weight: 700; font-size: .92rem; text-align: center; }
.button:hover, button:hover { border-color: var(--accent); }
.button.primary, button.primary, .hero .button:first-child { background: var(--fill); color: white; border-color: transparent; }
.button.primary:hover, button.primary:hover, .hero .button:first-child:hover { background: var(--fill-hover); }
button:disabled { opacity: .58; cursor: wait; }
.chip { border-radius: 100px; background: var(--soft); color: var(--ink); padding: 3px 9px; font-size: .78rem; font-weight: 700; display: inline-block; }
.notice { padding: 14px 16px; background: var(--soft); border-radius: 9px; color: var(--ink); }
.notice p:last-child, .panel p:last-child { margin-bottom: 0; }
.error { border-left: 3px solid var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 205px), 1fr)); gap: 14px; align-items: end; }
form .actions { margin-top: 15px; }
label { display: block; min-width: 0; font-weight: 650; font-size: .9rem; }
label > :is(input:not([type=checkbox]), select, textarea) { margin-top: 5px; }
label.check { display: flex; gap: 8px; align-items: center; min-height: 42px; }
input:not([type=checkbox]), select, textarea { min-height: 43px; width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--fill); }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 10px 14px; }
legend, summary { font-weight: 700; }
summary { cursor: pointer; }
details > :not(summary) { margin-top: 10px; }
.results { margin-top: 18px; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: none; }
.facts { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,155px),1fr)); gap: 12px; margin: 0; }
.facts div { border-bottom: 1px solid var(--line); padding-block: 8px; min-width: 0; }
.facts dt { color: var(--muted); font-size: .82rem; font-weight: 700; }
.facts dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.country-banner { height: clamp(210px, 38vw, 400px); width: 100%; object-fit: cover; border-radius: 16px; }
.tabs { display: flex; flex-wrap: wrap; gap: 7px; margin-block: 18px; }
.tabs [aria-current] { background: var(--soft); border-color: var(--accent); }
.map { background: var(--soft); border-radius: 12px; padding: 10px; }
.map svg, .map img { width: 100%; height: min(54vh, 460px); }
.map [role=button] { cursor: pointer; }
.map [role=button]:hover, .map [aria-pressed=true] { fill: var(--map-selection); stroke: var(--map-outline); stroke-width: 1.5; }
audio { width: 100%; }
.timeline { border-left: 2px solid var(--line); padding-left: 15px; }
.site-footer { border-top: 1px solid var(--line); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-block: 22px; color: var(--muted); font-size: .85rem; }
.footer-inner .brand { font-size: 1rem; }
dialog { width: min(690px, calc(100vw - 32px)); max-height: 88dvh; padding: 21px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: var(--paper); overflow: auto; }
dialog::backdrop { background: #210d0db8; }
.global-search { background: var(--paper); border-radius: 10px; display: flex; max-width: 510px; padding: 5px; border: 1px solid var(--line); }
.global-search input { border: 0; background: transparent; }
@media (max-width: 980px) { .tools { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 720px) {
    .wrap { width: calc(100% - 32px); }
    .header-inner { flex-wrap: wrap; gap: 8px; padding-block: 9px 6px; }
    nav { order: 3; width: 100%; justify-content: space-between; }
    nav a { padding: 8px 10px; }
    .app-link { font-size: .78rem; }
    main { padding-top: 15px; }
    .hero {
        min-height: 490px;
        align-items: end;
        background:
            linear-gradient(0deg, var(--hero-surface) 46%, var(--hero-fade) 68%, transparent 92%),
            var(--hero-surface) url('/assets/countries-world-hero.png') center top / auto 58% no-repeat;
    }
    .grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .split { grid-template-columns: 1fr; }
    .cover, .cover-fallback { height: 125px; }
}
@media (max-width: 370px) {
    .grid:not(.tools) { grid-template-columns: 1fr; }
    .wrap { width: calc(100% - 22px); }
    .tool { padding: 13px; }
}

.flag { max-height: 94px; width: auto; object-fit: contain; border-radius: 5px; }
figure.card { margin: 0; }
