:root {
  --paper: #f3efe7;
  --ink: #1f1c18;
  --muted: #6d665c;
  --card: rgba(253, 251, 247, 0.94);
  --line: rgba(31, 28, 24, 0.12);
  --accent: #c8102e;
  --gold: #f2c200;
  --shadow: 0 1px 2px rgba(31, 28, 24, .08), 0 6px 20px rgba(31, 28, 24, .10);
  --r: 12px;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); overflow: hidden; }
body { color: var(--ink); }
body.night { --paper: #121421; --card: rgba(28, 31, 46, .92); --ink: #ece8df; --muted: #a5a097; --line: rgba(236, 232, 223, .14); }
#map { position: fixed; inset: 0; background: var(--paper); }
.card { position: fixed; background: var(--card); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); z-index: 10; }

.brand { top: 14px; left: 14px; display: flex; align-items: center; gap: 10px; padding: 10px 16px 10px 12px; }
.brand h1 { margin: 0; font-size: 19px; line-height: 1.05; letter-spacing: -.01em; font-weight: 700; }
.brand p { margin: 1px 0 0; font-size: 12.5px; color: var(--muted); letter-spacing: .02em; }
.flag { display: grid; grid-template-rows: 1fr 1fr; width: 6px; height: 34px; border-radius: 3px; overflow: hidden; }
.flag i:first-child { background: var(--gold); } .flag i:last-child { background: var(--accent); }

.search { top: 14px; left: 50%; transform: translateX(-50%); width: min(420px, calc(100vw - 260px)); display: flex; align-items: center; gap: 8px; padding: 0 10px 0 12px; height: 44px; }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font: inherit; font-size: 15px; color: var(--ink); height: 100%; min-width: 0; }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd { font: 11px/1 ui-monospace, monospace; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; }
#results { position: absolute; top: 48px; left: 0; right: 0; margin: 0; padding: 4px; list-style: none; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); max-height: 60vh; overflow: auto; display: none; }
#results.open { display: block; }
#results li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
#results li span:last-child { color: var(--muted); font-size: 12px; white-space: nowrap; }
#results li.sel, #results li:hover { background: rgba(200, 16, 46, .08); }

.tools { top: 14px; right: 14px; display: flex; flex-direction: column; padding: 4px; gap: 2px; }
.tools button { width: 38px; height: 38px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.tools button:hover { background: rgba(31, 28, 24, .07); }
body.night .tools button:hover { background: rgba(236, 232, 223, .1); }
.tools button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tools button.on { color: var(--accent); }
.tools button[hidden] { display: none; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--paper);
  padding: 9px 14px; border-radius: 10px; font-size: 13.5px; opacity: 0; transition: .25s; pointer-events: none; z-index: 30; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.lbl { width: 0; height: 0; overflow: visible; pointer-events: none; transition: opacity .25s; }
.lbl > span { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); white-space: nowrap; pointer-events: auto; cursor: pointer; display: inline-block; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 9px; font-size: 12px; font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.lbl.loc span { background: transparent; border: 0; box-shadow: none; font-size: 15px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: rgba(31, 28, 24, .72); text-shadow: 0 0 3px var(--paper), 0 0 8px var(--paper), 0 0 2px var(--paper); }
body.night .lbl.loc span { color: rgba(236, 232, 223, .8); }
.lbl.pin span::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 1px; }
.lbl.hidden, .lbl.clash { opacity: 0; }
.lbl.hidden > span, .lbl.clash > span { pointer-events: none; }
.marker { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(200, 16, 46, .25); transform: translate(-50%, -50%); animation: pulse 1.6s ease-out 3; }
@keyframes pulse { from { box-shadow: 0 0 0 0 rgba(200,16,46,.45); } to { box-shadow: 0 0 0 22px rgba(200,16,46,0); } }

.attrib { position: fixed; right: 10px; bottom: 8px; font-size: 11px; color: var(--muted); z-index: 10; text-shadow: 0 0 4px var(--paper); }
.attrib a { color: inherit; }
.attrib .short { display: none; }

dialog#info { border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px 18px; max-width: 560px; width: calc(100vw - 32px);
  background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
dialog#info::backdrop { background: rgba(20, 18, 15, .28); }
dialog h2 { margin: 0 0 8px; font-size: 20px; }
dialog .lead { margin: 0 0 14px; line-height: 1.5; }
dialog details { border-top: 1px solid var(--line); padding: 10px 0; }
dialog summary { cursor: pointer; font-weight: 600; }
dialog details p, dialog li { font-size: 14px; line-height: 1.55; color: var(--ink); }
dialog .small { font-size: 12.5px; color: var(--muted); }
dialog a { color: var(--accent); }
.credits { padding-left: 18px; margin: 8px 0; }
.close { position: absolute; top: 10px; right: 12px; border: 0; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }

.openseadragon-container :focus { outline: none; }
@media (max-width: 700px) {
  .brand { top: calc(10px + env(safe-area-inset-top)); left: 10px; padding: 0 12px 0 10px; height: 44px; gap: 8px; }
  .brand h1 { font-size: 16px; } .brand p { display: none; } .flag { height: 24px; width: 5px; }
  .search { top: calc(10px + env(safe-area-inset-top)); left: 118px; right: 10px; width: auto; transform: none; height: 44px; }
  .search input { font-size: 16px; }              /* no iOS zoom-on-focus */
  .search kbd { display: none; }
  #results { top: 48px; max-height: 50vh; }
  .tools { top: auto; right: 50%; transform: translateX(50%); bottom: calc(12px + env(safe-area-inset-bottom)); flex-direction: row; padding: 3px; }
  .tools button { width: 44px; height: 44px; }
  .tools #zin, .tools #zout { display: none; }
  .attrib .long { display: none; } .attrib .short { display: inline; }
  .attrib { right: auto; left: 10px; bottom: calc(66px + env(safe-area-inset-bottom)); font-size: 9.5px; opacity: .75; }
  .lbl > span { font-size: 11px; padding: 2px 7px; }
  .lbl.loc > span { font-size: 11.5px; letter-spacing: .04em; }
  dialog#info { padding: 18px 18px 12px; max-height: 80vh; overflow: auto; }
  #toast { bottom: calc(70px + env(safe-area-inset-bottom)); }
}
}

#tip { position: fixed; z-index: 20; pointer-events: none; background: var(--ink); color: var(--paper); font-size: 12.5px; font-weight: 600;
  padding: 5px 9px; border-radius: 8px; opacity: 0; transition: opacity .12s; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
#tip.show { opacity: .94; }
