:root { --bg: #131b21; --panel: rgba(20, 22, 24, 0.9); --line: rgba(255, 255, 255, 0.12); --text: #ece7dc; --dim: #a39d90; --accent: #f0c25a; --r: 10px;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); overscroll-behavior: none; }
#map, #overlay { position: fixed; inset: 0; display: block; }
#map { touch-action: none; cursor: grab; } #map.dragging { cursor: grabbing; } #overlay { pointer-events: none; }
button { font: inherit; color: var(--text); background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); border-radius: 7px; padding: 5px 10px; cursor: pointer; }
button:hover { background: rgba(255, 255, 255, 0.13); } button:disabled { opacity: .35; cursor: default; }
button.small { padding: 3px 8px; font-size: 13px; } button.icon { width: 34px; height: 34px; padding: 0; font-size: 22px; line-height: 1; border-radius: 50%; }
[hidden] { display: none !important; }

/* the header: one bar across the top, fixed height (as the 3D page's console bar): panel button and map title on the
   left, the family › region trail with counts in the middle, view controls on the right. Never wraps; the trail
   truncates in the middle (the family part gives way first). */
:root { --top: 52px; --side: 320px; }
#top { position: fixed; left: 0; right: 0; top: 0; height: var(--top); z-index: 5; display: flex; align-items: center; gap: 12px; padding: 0 12px;
  background: linear-gradient(rgba(18, 21, 23, .94), rgba(18, 21, 23, .86)); border-bottom: 1px solid rgba(236, 226, 198, .22);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35); backdrop-filter: blur(6px); white-space: nowrap; }
#top .tb { font-size: 13px; padding: 5px 10px; flex: none; }
#panel-btn { width: 36px; height: 34px; padding: 0; display: grid; place-items: center; flex: none; }
#panel-btn .burger, #panel-btn .burger::before, #panel-btn .burger::after { display: block; width: 16px; height: 2px; background: var(--text); border-radius: 1px; position: relative; content: ''; }
#panel-btn .burger::before { position: absolute; top: -5px; } #panel-btn .burger::after { position: absolute; top: 5px; }
#panel-btn[aria-expanded="true"] { background: rgba(240, 194, 90, .16); border-color: rgba(240, 194, 90, .55); }
.maptitle { font-weight: 600; font-size: 14.5px; flex: none; max-width: 24vw; overflow: hidden; text-overflow: ellipsis; }
#top .right { display: flex; gap: 6px; margin-left: auto; flex: none; align-items: center; }
#home .ico { display: none; }
.trail { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 8px; overflow: hidden; padding-left: 12px; border-left: 1px solid var(--line); }
.trail .part { min-width: 0; display: flex; align-items: baseline; gap: 8px; overflow: hidden; }
/* the family part gives way first but keeps a few letters, so the trail is cut in its middle */
.trail .part.fam { flex: 0 3 auto; min-width: 3.5em; max-width: 45%; } .trail .part.clu { flex: 0 1 auto; }
.trail button { background: none; border: 0; padding: 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.trail button:hover { text-decoration: underline; text-underline-offset: 3px; }
#h-fam { font: 600 13px/1.3 Georgia, serif; letter-spacing: .14em; text-transform: uppercase; color: #ece2c6; }
#h-clu { font-weight: 600; font-size: 14px; } #h-clu.weak { font-style: italic; }
.trail .sep { color: var(--dim); flex: none; }
.trail .n { font-size: 12px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; flex: 0 100000 auto; min-width: 0; }

/* the zoom ladder (optional: Zoom guide in the options) */
#ladder-box { position: fixed; right: 12px; top: 50%; transform: translateY(-50%); z-index: 3; width: 168px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 10px 10px 10px 26px; backdrop-filter: blur(6px); }
#ladder-track { position: absolute; left: 14px; top: 20px; bottom: 76px; width: 2px; background: rgba(255,255,255,.18); border-radius: 1px; }
#ladder-mark { position: absolute; left: -5px; top: calc(var(--p, 0) * 100% - 6px); width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(240,194,90,.25); }
#ladder { display: flex; flex-direction: column; gap: 2px; }
.rung { background: none; border: 0; text-align: left; padding: 3px 4px; display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; border-radius: 5px; }
.rung .d { display: none; } .rung.past { color: var(--dim); } .rung.here { color: var(--accent); font-weight: 600; }
#ladder-next { font-size: 11.5px; color: var(--dim); margin-top: 8px; height: 4.3em; overflow: hidden; }

/* the options panel: a sidebar under the header, collapsible */
#bar { position: fixed; top: var(--top); left: 0; bottom: 0; width: var(--side); overflow: auto; background: var(--panel); border-right: 1px solid var(--line);
  padding: 4px 14px 14px; backdrop-filter: blur(6px); z-index: 4; transition: transform .18s ease; }
body.panel-closed #bar { transform: translateX(-102%); visibility: hidden; transition: transform .18s ease, visibility 0s .18s; }
#controls .group { margin-top: 12px; } #controls .row { display: flex; gap: 6px; flex-wrap: wrap; }
.label { font-size: 12px; color: var(--dim); margin-bottom: 4px; } .label.sub { margin-top: 10px; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; } .seg button { flex: 1 1 auto; font-size: 13px; padding: 4px 8px; }
.seg button.on { background: rgba(240, 194, 90, 0.18); border-color: rgba(240, 194, 90, 0.6); color: #fff; }
#colls { list-style: none; margin: 0; padding: 0; }
#colls li { display: grid; grid-template-columns: 16px minmax(0, 1fr) 66px 40px; align-items: center; gap: 6px; padding: 2px 0; font-size: 13px; }
#colls li .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
#colls li .nm { overflow: hidden; text-overflow: ellipsis; } #colls li .n { color: var(--dim); text-align: right; font-variant-numeric: tabular-nums; }
#colls li button { font-size: 12px; padding: 2px 6px; } #colls li label { display: flex; align-items: center; gap: 6px; cursor: pointer; overflow: hidden; white-space: nowrap; }
.note { font-size: 12px; color: var(--dim); margin: 10px 0 0; }

#tag { position: fixed; left: 0; top: 0; z-index: 2; pointer-events: none; background: rgba(16,18,20,.92); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
#hint { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 1; font-size: 12px; color: var(--dim); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; transition: opacity .6s; white-space: nowrap; }
#hint.gone { opacity: 0; pointer-events: none; }
#toast { position: fixed; left: 50%; bottom: 50px; transform: translateX(-50%); z-index: 9; background: #222; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; opacity: 0; transition: opacity .3s; pointer-events: none; max-width: min(90vw, 560px); text-align: center; }
#toast.show { opacity: 1; }

/* the book */
#book { position: fixed; inset: 0; z-index: 7; background: rgba(6, 9, 11, .62); display: none; align-items: center; justify-content: center; }
#book.open { display: flex; }
#book .sheet { width: min(820px, 94vw); height: 88vh; background: #16191b; border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
#book header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); height: 64px; }
#book .where { flex: 1; min-width: 0; }
.b-path { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.b-path button { background: none; border: 0; padding: 0; font-weight: 600; } .b-path .fam { font: 600 12.5px Georgia, serif; letter-spacing: .14em; text-transform: uppercase; color: #ece2c6; }
.b-path .weak { font-style: italic; } .b-path button:hover { text-decoration: underline; }
.b-count { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-nav { display: flex; gap: 6px; align-items: center; } .b-nav button:not(.icon) { font-size: 13px; }
.b-grid { flex: 1; overflow-y: auto; padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 5px; align-content: start; overscroll-behavior: contain; }
.card { position: relative; height: 0; padding-top: 100%; background: #212528; border-radius: 4px; overflow: hidden; cursor: zoom-in; }
.card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s; }
.card.in img { opacity: 1; } .card.added { outline: 2px solid var(--c); outline-offset: -2px; }
#book .viewer { position: fixed; inset: 0; background: rgba(8, 8, 9, .96); display: flex; align-items: center; justify-content: center; z-index: 8; touch-action: none; }
#book .viewer figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
#book .viewer img { object-fit: contain; background: #111; }
#book .viewer figcaption { font-size: 13px; color: var(--dim); min-height: 1.4em; }
#book .v-x { position: absolute; top: 12px; right: 12px; } #book .nav { position: absolute; top: 50%; transform: translateY(-50%); font-size: 28px; }
#book .v-prev { left: 12px; } #book .v-next { right: 12px; }

#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 10; color: var(--dim); transition: opacity .4s; padding: 20px; text-align: center; }
#loading.gone { opacity: 0; pointer-events: none; }

@media (max-width: 760px), (pointer: coarse) and (max-width: 900px) {
  :root { --top: 48px; }
  /* one row; the map title takes the free room at the world and families rungs, the trail once inside a region;
     counts go first, then the family part of the trail, then the Whole map label (icon stays); 40 px touch targets */
  #top { gap: 6px; padding: 0 6px; } #top #copy { display: none; }
  #top .tb { padding: 0; min-width: 40px; height: 40px; display: grid; place-items: center; }
  #panel-btn { width: 40px; height: 40px; }
  #home .lbl { display: none; } #top #home .ico { display: block; }
  .maptitle { flex: 1 1 auto; max-width: none; min-width: 0; font-size: 15px; }
  .trail { padding-left: 0; border-left: 0; flex: 1 1 auto; } .trail .n { display: none; }
  body:not(.trail-wins) #top .trail { display: none; }
  body.trail-wins #top .maptitle { display: none; }
  /* no room for both parts on a phone: the region alone (the family is in the options and one tap up the trail) */
  body.trail-wins .trail .part.fam, body.trail-wins .trail .sep { display: none; }
  #bar { width: 100vw; border-right: 0; }
  #ladder-box { width: 112px; right: 6px; top: auto; bottom: 10px; transform: none; padding: 8px 6px 8px 22px; }
  #ladder-track { left: 11px; bottom: 62px; } .rung { font-size: 12px; padding: 2px; }
  #ladder-next { font-size: 10.5px; height: 4.6em; }
  #hint { bottom: 14px; white-space: normal; width: max-content; max-width: 90vw; text-align: center; }
  #book .sheet { width: 100vw; height: 100%; border-radius: 0; border: 0; }
  .b-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
}
@media (max-width: 760px) {
  #book header { height: 78px; padding: 10px; }
  .b-count { white-space: normal; line-height: 1.3; }
  .b-nav button:not(.icon) { padding: 4px 7px; }
  #ladder-box { width: 104px; } .rung { font-size: 11.5px; padding: 1px 2px; } #ladder-next { display: none; } #ladder-track { bottom: 14px; }
}

#freeze { position: fixed; inset: 0; pointer-events: none; z-index: 1; display: none; }
#freeze.on { display: block; opacity: 1; }
#freeze.fade { display: block; opacity: 0; transition: opacity .25s; }
.b-adds { font-size: 12px; color: var(--text); display: flex; gap: 8px; align-items: center; margin-top: 3px; white-space: nowrap; overflow: hidden; }
.b-adds[hidden] { display: none; } .b-adds-t { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.b-adds button { font-size: 11.5px; padding: 1px 7px; flex: none; } .b-adds button.on { background: rgba(240,194,90,.2); border-color: rgba(240,194,90,.6); }
.sheet.lit .card:not(.hit) img { filter: grayscale(.7) brightness(.32); }
.sheet.lit .card.offc img { filter: grayscale(.7) brightness(.25); }
.sheet.lit .card.added::after { content: ""; position: absolute; top: 4px; left: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1.5px rgba(0,0,0,.6); }
.card.added { outline: none; } .sheet.lit .card.added { outline: 2px solid var(--c); outline-offset: -2px; }
#book header { height: auto; min-height: 64px; }

/* picture information: height reserved per collection (--info-h, from its field table), never a scrollbar */
#book .viewer .info { position: relative; width: min(90vw, 460px); height: var(--info-h, 120px); overflow: hidden; font-size: 12.5px; line-height: 15px; color: var(--text); }
#book .viewer img { width: min(80vw, calc(100vh - var(--info-h, 120px) - 120px), var(--vmax, 440px)); height: min(80vw, calc(100vh - var(--info-h, 120px) - 120px), var(--vmax, 440px)); }   /* --vmax from the store's px (book.js) */
#book .viewer .info .src { display: flex; align-items: center; gap: 7px; font-weight: 600; height: 20px; margin-bottom: 4px; }
#book .viewer .info .src .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
#book .viewer .info .src .nc { font-weight: 400; font-size: 11px; color: var(--accent); border: 1px solid rgba(240,194,90,.5); border-radius: 4px; padding: 0 5px; }
#book .viewer .info.loading dl, #book .viewer .info.loading::after { opacity: .5; }
#book .viewer .info.loading::after { content: "…"; color: var(--dim); }
#book .viewer .info dl { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: 3px 10px; margin: 0; }
#book .viewer .info dt { color: var(--dim); max-width: 11em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } #book .viewer .info dd { margin: 0; min-width: 0; }
#book .viewer .info .v { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
#book .viewer .info .v.cut { cursor: pointer; text-decoration: underline dotted rgba(255,255,255,.35); text-underline-offset: 3px; }
#book .viewer .info a { color: #e8d4a0; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#book .viewer .info .pop { position: absolute; inset: 0; overflow: hidden; background: rgba(16,18,20,.97); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; line-height: 16px; cursor: pointer; }
#book .viewer figure { max-height: 100vh; }
/* about and credits */
#colls li { grid-template-columns: 16px minmax(0, 1fr) 66px 22px 40px; }
#colls li .about { font-size: 12px; padding: 0; width: 20px; height: 20px; border-radius: 50%; }
#colls li .about-box { grid-column: 1 / -1; font-size: 12px; color: var(--dim); padding: 3px 0 6px 22px; white-space: normal; }
#colls li .about-box a { color: #e8d4a0; }
#credits { font-size: 12px; color: var(--dim); margin-top: 6px; } #credits[hidden] { display: none; }
#credits p { margin: 4px 0; } #credits b { color: var(--text); font-weight: 600; } #credits a { color: #e8d4a0; }
.nc-tag { color: var(--accent); }
@media (max-width: 760px) { #book .viewer .info dt { max-width: 8.5em; } }
#to3d { color: #e0c38a; font-size: 14px; text-decoration: none; margin-top: 4px; } #to3d:hover { text-decoration: underline; }

/* facet filter: a two-handle range over the bins, the map-wide totals as a histogram behind it (fixed heights: no shift) */
.facet .fx-read { font-size: 13px; color: var(--text); height: 18px; line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.facet .fx-box { position: relative; height: 52px; margin: 4px 11px 0; touch-action: none; }
.facet .fx-hist { position: absolute; left: 0; right: 0; top: 0; width: 100%; height: 38px; }
.facet input[type=range] { position: absolute; left: -11px; right: -11px; width: calc(100% + 22px); bottom: 0; height: 22px; margin: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.facet input[type=range]::-webkit-slider-runnable-track { height: 3px; background: rgba(200,196,186,.25); border-radius: 2px; }
.facet input.fx-hi::-webkit-slider-runnable-track { background: none; }
.facet input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 22px; height: 22px; margin-top: -9.5px; border-radius: 50%; background: #f0c25a; border: 2px solid #1b1d1f; cursor: grab; }
.facet input[type=range]::-moz-range-track { height: 3px; background: rgba(200,196,186,.25); }
.facet input.fx-hi::-moz-range-track { background: none; }
.facet input[type=range]::-moz-range-thumb { pointer-events: auto; width: 18px; height: 18px; border-radius: 50%; background: #f0c25a; border: 2px solid #1b1d1f; cursor: grab; }
.facet input[type=range]:disabled::-webkit-slider-thumb { background: #666; cursor: default; }
.facet .fx-foot { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--dim); margin-top: 2px; }
.facet .fx-foot button { font-size: 12px; padding: 2px 10px; }
.facet .fx-foot button:disabled { opacity: .4; }
.facet .fx-why { margin: 4px 0 0; font-size: 12px; color: var(--dim); }
