/* Ierbarul risipit · v2 */

:root {
  color-scheme: light dark;

  --bg: light-dark(#e8ebe3, #0d1210);
  --bg-2: light-dark(#dfe3d8, #121915);
  --bg-3: light-dark(#d4d9cc, #18211c);
  --ink: light-dark(#17201a, #e7e9e0);
  --ink-2: light-dark(#3d4840, #c3c9bd);
  --muted: light-dark(#5b665d, #94a095);
  --rule: light-dark(rgba(23, 32, 26, 0.16), rgba(231, 233, 224, 0.14));
  --rule-soft: light-dark(rgba(23, 32, 26, 0.08), rgba(231, 233, 224, 0.07));

  --accent: light-dark(#a3301d, #ef7f63);
  --accent-ink: light-dark(#ffffff, #1a0d08);
  --accent-soft: light-dark(rgba(163, 48, 29, 0.1), rgba(239, 127, 99, 0.14));
  --green: light-dark(#2f5a3c, #8fc39b);

  --paper: light-dark(#f7f4ea, #ece6d6);
  --paper-ink: #1d211b;
  --paper-edge: light-dark(#d8d2c0, #bfb7a2);

  --wood-1: light-dark(#4a2f1d, #2c1c12);
  --wood-2: light-dark(#5c3b25, #3a2618);
  --wood-3: light-dark(#6e4a2f, #4a3220);
  --wood-hi: light-dark(rgba(255, 228, 190, 0.18), rgba(255, 220, 170, 0.1));
  --brass-1: light-dark(#e2c27a, #e8c985);
  --brass-2: light-dark(#a9823a, #b38b42);
  --brass-3: light-dark(#6f521d, #6d521f);
  --brass-ink: #2a1d07;

  --tray: light-dark(#cfd5c7, #1b241f);
  --table-glow: light-dark(#f3f5ee, #1a221d);
  --table-grid: light-dark(rgba(47, 90, 60, 0.09), rgba(143, 195, 155, 0.07));

  --map-sea: light-dark(#dde2d6, #0f1613);
  --map-sea-2: light-dark(#e9ece3, #131c17);
  --map-land: light-dark(#c3cab9, #27322b);
  --map-border: light-dark(rgba(23, 32, 26, 0.22), rgba(231, 233, 224, 0.16));
  --map-ring: light-dark(rgba(23, 32, 26, 0.2), rgba(231, 233, 224, 0.16));
  --map-romania: light-dark(#f2f0e6, #34433a);
  --map-thread: light-dark(rgba(163, 48, 29, 0.16), rgba(239, 127, 99, 0.13));
  --map-thread-hi: light-dark(rgba(163, 48, 29, 0.85), rgba(255, 170, 140, 0.9));
  --map-coast: light-dark(rgba(47, 70, 52, 0.35), rgba(170, 200, 175, 0.18));
  --map-rim: light-dark(rgba(23, 32, 26, 0.10), rgba(0, 0, 0, 0.45));
  --map-node: light-dark(#a3301d, #ef7f63);
  --map-node-ring: light-dark(#f7f4ea, #0d1210);
  --map-home: light-dark(#17201a, #e7e9e0);
  --map-point: light-dark(rgba(47, 90, 60, 0.75), rgba(160, 220, 170, 0.7));
  --map-label: light-dark(#17201a, #e7e9e0);
  --map-halo: light-dark(rgba(232, 235, 227, 0.92), rgba(13, 18, 16, 0.9));

  --to-top-bg: light-dark(#f7f4ea, #18211c);
  --to-top-fg: light-dark(#17201a, #e7e9e0);

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Courier Prime", ui-monospace, SFMono-Regular, Menlo, monospace;
  --hand: "Newsreader", Georgia, serif;

  --measure: 64ch;
  --wide: 80rem;
  --topbar: 52px;
  --shadow-sheet: 0 1px 1px rgba(0, 0, 0, 0.08), 0 6px 14px -4px rgba(20, 24, 18, 0.28), 0 22px 40px -18px rgba(20, 24, 18, 0.35);
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) { color-scheme: dark; }
:root:has(> head > meta[name="color-scheme"][content="light"]) { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar) + 12px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background:
    radial-gradient(120% 60% at 70% -10%, light-dark(rgba(255, 255, 250, 0.7), rgba(60, 90, 70, 0.18)), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent); text-underline-offset: 0.18em; }
a:hover { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--rule-soft); padding: 0.05em 0.3em; border-radius: 3px; }

.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 100; background: var(--ink); color: var(--bg); padding: 0.5rem 0.9rem; font-family: var(--sans); font-size: 0.9rem; border-radius: 4px; }
.skip-link:focus { top: 0.6rem; }

.wrap { width: min(100% - 2.5rem, var(--measure)); margin-inline: auto; }
.wrap-wide { width: min(100% - 2.5rem, var(--wide)); margin-inline: auto; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: saturate(1.3) blur(10px); -webkit-backdrop-filter: saturate(1.3) blur(10px); border-bottom: 1px solid var(--rule-soft); }
.topbar-inner { height: var(--topbar); width: min(100% - 1.5rem, var(--wide)); margin-inline: auto; display: flex; align-items: center; gap: 1rem; font-family: var(--sans); font-size: 0.82rem; }
.topbar-home { display: inline-flex; align-items: center; gap: 0.45rem; text-decoration: none; font-family: var(--serif); font-size: 1.02rem; font-weight: 500; white-space: nowrap; }
.topbar-home svg { width: 20px; height: 20px; color: var(--green); }
.topbar-nav { display: flex; gap: 1.1rem; margin-left: auto; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.topbar-nav::-webkit-scrollbar { display: none; }
.topbar-nav a { text-decoration: none; color: var(--ink-2); padding: 0.3rem 0; border-bottom: 1.5px solid transparent; }
.topbar-nav a:hover, .topbar-nav a[aria-current="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.topbar-actions { display: flex; align-items: center; gap: 0.4rem; }
.lang-switch { text-decoration: none; font-weight: 600; letter-spacing: 0.04em; font-size: 0.75rem; border: 1px solid var(--rule); border-radius: 999px; padding: 0.22rem 0.6rem; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 999px; border: 1px solid var(--rule); background: transparent; color: var(--ink); line-height: 1; font-family: var(--sans); font-size: 1.15rem; }
.icon-btn:hover { border-color: var(--ink-2); }
.icon-btn svg { width: 17px; height: 17px; display: block; }
.icon-btn svg[hidden] { display: none; }
#theme-toggle .icon-sun { display: none; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) #theme-toggle .icon-sun { display: block; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) #theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:has(> head > meta[name="color-scheme"][content="light dark"]) #theme-toggle .icon-sun { display: block; }
  :root:has(> head > meta[name="color-scheme"][content="light dark"]) #theme-toggle .icon-moon { display: none; }
}
.scroll-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.scroll-progress-bar { height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }

/* Reading rail */
.reading-rail { position: fixed; right: 18px; top: 50%; transform: translateY(-50%); z-index: 40; display: none; flex-direction: column; gap: 12px; }
@media (min-width: 1180px) { .reading-rail { display: flex; } }
.reading-rail a { position: relative; display: block; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--muted); text-decoration: none; }
.reading-rail a[aria-current="true"] { background: var(--accent); border-color: var(--accent); }
.reading-rail a span { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); white-space: nowrap; font-family: var(--sans); font-size: 0.75rem; background: var(--bg); padding: 0.1rem 0.45rem; border-radius: 4px; border: 1px solid var(--rule); opacity: 0; pointer-events: none; transition: opacity 0.15s; }
.reading-rail a:hover span, .reading-rail a:focus-visible span { opacity: 1; }

/* Typography */
h1, h2, h3 { font-weight: 500; letter-spacing: -0.012em; line-height: 1.12; margin: 0; }
h1 { font-size: clamp(2.1rem, 1.3rem + 3.1vw, 3.9rem); }
h2 { font-size: clamp(1.6rem, 1.15rem + 1.6vw, 2.45rem); }
h3 { font-size: 1.25rem; }
.anchor { text-decoration: none; }
.anchor:hover { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; }
.kicker, .sec-num { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.78rem; color: var(--accent); margin: 0 0 0.9rem; }
.sec-num { letter-spacing: 0.2em; }
.section-head { max-width: 52rem; margin-bottom: 2rem; }
.section-head h2 { margin-bottom: 0.9rem; }
.section-sub { color: var(--ink-2); margin: 0; font-size: 1.06rem; }
.chapter { padding: clamp(3.5rem, 7vw, 6.5rem) 0; border-top: 1px solid var(--rule-soft); scroll-margin-top: var(--topbar); }
.prose p { margin: 0 0 1.1rem; }
.prose h2 { margin-bottom: 1.2rem; }

/* Share row */
.share-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem; margin-top: 1.4rem; font-family: var(--sans); font-size: 0.8rem; color: var(--muted); }
.share-label { margin-right: 0.25rem; }
.share-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--rule); background: transparent; color: var(--ink-2); text-decoration: none; }
.share-btn:hover { color: var(--accent); border-color: var(--accent); }
.share-btn svg { width: 15px; height: 15px; }
.share-btn[hidden] { display: none; }
.share-status { margin-left: 0.4rem; color: var(--green); }

/* Hero */
.hero { padding: clamp(2rem, 4vw, 3.5rem) 0 0; }
.hero-grid { width: min(100% - 2.5rem, var(--wide)); margin-inline: auto; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(1.5rem, 4vw, 4rem); align-items: center; min-height: min(78svh, 760px); }
.hero-copy h1 { margin-bottom: 1.2rem; text-wrap: balance; }
.deck { font-size: clamp(1.08rem, 1rem + 0.35vw, 1.28rem); color: var(--ink-2); margin: 0; max-width: 38rem; }

.lighttable { margin: 0; }
.lt-surface {
  position: relative; aspect-ratio: 1.32 / 1; border-radius: 14px; overflow: hidden;
  background:
    linear-gradient(var(--table-grid) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, var(--table-grid) 1px, transparent 1px) 0 0 / 28px 28px,
    radial-gradient(90% 80% at 50% 45%, light-dark(#ffffff, #223029), var(--table-glow) 70%);
  box-shadow: inset 0 0 0 1px var(--rule), inset 0 -40px 80px -40px light-dark(rgba(47, 90, 60, 0.18), rgba(0, 0, 0, 0.5));
}
.lt-glow { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(40% 35% at 50% 50%, light-dark(rgba(255, 255, 255, 0.0), rgba(239, 127, 99, 0.06)), transparent); }
.lt-sheet {
  position: absolute; left: var(--x); top: var(--y); width: var(--w); z-index: var(--z);
  padding: 0; border: 0; background: var(--paper); border-radius: 2px;
  transform: rotate(var(--r)); box-shadow: var(--shadow-sheet);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.35s;
}
.lt-sheet img { width: 100%; aspect-ratio: 420 / 629; object-fit: cover; border-radius: 2px; }
.lt-sheet:hover, .lt-sheet:focus-visible { transform: rotate(0deg) translateY(-6px) scale(1.04); z-index: 20; box-shadow: 0 2px 2px rgba(0,0,0,.08), 0 18px 40px -10px rgba(20, 24, 18, 0.45); }
.lt-stamp {
  position: absolute; left: 8%; bottom: 7%; transform: rotate(-7deg);
  font-family: var(--mono); font-size: clamp(0.5rem, 0.36rem + 0.4vw, 0.72rem); text-transform: uppercase; letter-spacing: 0.06em;
  color: #9d2b18; border: 1.5px solid currentColor; border-radius: 40% / 60%; padding: 0.25em 0.7em; background: rgba(247, 244, 234, 0.82); line-height: 1.2; white-space: nowrap;
}
.lt-stamp b { font-weight: 700; }
.lt-year { position: absolute; top: -0.6em; right: 10%; font-family: var(--hand); font-style: italic; font-size: clamp(0.78rem, 0.5rem + 0.7vw, 1.1rem); color: var(--paper-ink); background: #efe6c9; padding: 0 0.45em; border-radius: 2px; box-shadow: 0 2px 4px rgba(0,0,0,.2); transform: rotate(3deg); }
.lighttable figcaption { font-family: var(--sans); font-size: 0.8rem; color: var(--muted); margin-top: 0.7rem; }
@media (prefers-reduced-motion: no-preference) {
  .lt-sheet { animation: scatter 1.1s cubic-bezier(0.16, 0.84, 0.24, 1) backwards; animation-delay: calc(var(--z) * 70ms); }
  @keyframes scatter { from { left: 40%; top: 30%; transform: rotate(0deg) scale(0.55); opacity: 0; } 40% { opacity: 1; } }
}

.hero-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: clamp(2rem, 4vw, 3.5rem) 0 0; border-top: 1px solid var(--rule); }
.stat { padding: 1.25rem 1.25rem 1.6rem 0; margin: 0; }
.stat + .stat { padding-left: 1.25rem; border-left: 1px solid var(--rule-soft); }
.stat-num { font-size: clamp(1.9rem, 1.3rem + 1.8vw, 2.9rem); line-height: 1; font-weight: 500; font-variant-numeric: lining-nums tabular-nums; margin-bottom: 0.5rem; }
.stat-label { margin: 0; font-family: var(--sans); font-size: 0.82rem; line-height: 1.45; color: var(--ink-2); }
.stat.is-zero .stat-num { color: var(--accent); }
.stat.is-home .stat-num { color: var(--green); }

/* Cabinet */
.cabinet {
  position: relative; border-radius: 10px; padding: clamp(0.8rem, 1.6vw, 1.4rem);
  background:
    repeating-linear-gradient(92deg, transparent 0 7px, rgba(0, 0, 0, 0.05) 7px 8px, transparent 8px 19px, rgba(255, 220, 180, 0.035) 19px 20px),
    linear-gradient(180deg, var(--wood-2), var(--wood-1));
  box-shadow: 0 30px 60px -30px rgba(20, 14, 8, 0.6), inset 0 1px 0 var(--wood-hi), inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.cabinet-crown { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.16em; color: var(--brass-1); padding: 0.2rem 0.3rem 0.9rem; border-bottom: 1px solid rgba(0, 0, 0, 0.35); box-shadow: 0 1px 0 var(--wood-hi); margin-bottom: 0.9rem; }
.drawer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 178px), 1fr)); gap: 10px; }
.cabinet-plinth { height: 10px; margin: 0.9rem -0.4rem -0.4rem; border-radius: 0 0 6px 6px; background: linear-gradient(180deg, rgba(0,0,0,.35), rgba(0,0,0,.1)); }
.drawer { padding: 0; border: 0; background: none; text-align: center; perspective: 600px; }
.drawer-face {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 118px; padding: 12px 10px 10px; border-radius: 4px;
  background:
    repeating-linear-gradient(88deg, transparent 0 11px, rgba(0, 0, 0, 0.045) 11px 12px, transparent 12px 23px),
    linear-gradient(180deg, var(--wood-3), var(--wood-2));
  box-shadow: inset 0 1px 0 var(--wood-hi), inset 0 -2px 0 rgba(0, 0, 0, 0.3), 0 1px 0 rgba(0, 0, 0, 0.4), 0 3px 6px -2px rgba(0, 0, 0, 0.5);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.28s, filter 0.2s;
}
.drawer:hover .drawer-face { filter: brightness(1.08); }
.drawer[aria-expanded="true"] .drawer-face { transform: translateY(-3px) translateZ(14px); filter: brightness(1.14); box-shadow: inset 0 1px 0 var(--wood-hi), 0 0 0 2px var(--brass-1), 0 14px 22px -8px rgba(0, 0, 0, 0.7); }
.label-frame { display: block; width: 100%; padding: 4px; border-radius: 3px; background: linear-gradient(145deg, var(--brass-1), var(--brass-2) 55%, var(--brass-3)); box-shadow: 0 1px 2px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.4); }
.label-card { display: grid; gap: 1px; padding: 6px 6px 5px; border-radius: 1px; background: #f4eedd; color: var(--paper-ink); box-shadow: inset 0 0 6px rgba(120, 90, 40, 0.25); }
.label-latin { font-family: var(--serif); font-size: 0.98rem; font-variant: small-caps; letter-spacing: 0.03em; line-height: 1.1; }
.label-vern { font-family: var(--sans); font-size: 0.66rem; line-height: 1.25; color: #4b4a40; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.label-count { font-family: var(--mono); font-size: 0.68rem; color: #8e2a17; }
.drawer-pull { width: 46px; height: 12px; border-radius: 0 0 24px 24px / 0 0 12px 12px; background: linear-gradient(180deg, var(--brass-1), var(--brass-3)); box-shadow: 0 2px 3px rgba(0, 0, 0, 0.55), inset 0 -2px 2px rgba(0, 0, 0, 0.25); }
.drawer[data-type-drawer="true"] .label-card { background: #f6e6dc; }
.drawer[data-type-drawer="true"] .label-latin { color: #8e2a17; }

.tray {
  position: relative; margin-top: -4px; border-radius: 0 0 10px 10px; padding: clamp(1rem, 2vw, 1.6rem);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.16), transparent 26px), var(--tray);
  border: 1px solid var(--rule); border-top: 0;
  box-shadow: inset 0 10px 18px -12px rgba(0, 0, 0, 0.45);
}
.tray:focus { outline: none; }
.tray-bar { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem 1.5rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.tray-title-wrap h3 { font-size: 1.45rem; }
.tray-meta { margin: 0.25rem 0 0; font-family: var(--sans); font-size: 0.82rem; color: var(--muted); }
.tray-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; font-family: var(--sans); font-size: 0.82rem; }
.tray-controls input[type="search"], .tray-controls select { height: 36px; border-radius: 8px; border: 1px solid var(--rule); background: var(--bg); padding: 0 0.7rem; font-size: 0.85rem; }
.tray-controls input[type="search"] { width: min(100%, 15rem); }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 2px; background: color-mix(in srgb, var(--bg) 85%, transparent); }
.seg-btn { border: 0; background: transparent; border-radius: 999px; padding: 0.35rem 0.8rem; font-family: var(--sans); font-size: 0.8rem; color: var(--ink-2); white-space: nowrap; }
.seg-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.reset-btn { border: 1px solid var(--accent); color: var(--accent); background: var(--bg); border-radius: 999px; padding: 0.35rem 0.85rem; font-family: var(--sans); font-size: 0.8rem; }
.reset-btn:hover { background: var(--accent); color: var(--accent-ink); }
.reset-btn[hidden] { display: none; }

.sheets-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(46%, 168px), 1fr)); gap: clamp(0.8rem, 1.6vw, 1.3rem); }
.sheet-card { position: relative; display: flex; flex-direction: column; text-align: left; padding: 7px 7px 10px; border: 0; border-radius: 2px; background: var(--paper); color: var(--paper-ink); box-shadow: var(--shadow-sheet); transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s; }
.sheet-card:hover, .sheet-card:focus-visible { transform: translateY(-4px) rotate(-0.6deg); }
.sheet-card img { width: 100%; aspect-ratio: 420 / 629; object-fit: cover; background: #ece6d4; }
.sheet-species { font-family: var(--serif); font-style: italic; font-size: 0.98rem; line-height: 1.2; margin-top: 0.55rem; }
.sheet-info { font-family: var(--mono); font-size: 0.68rem; line-height: 1.35; color: #575548; margin-top: 0.3rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sheet-stamp { position: absolute; top: 14px; right: 12px; transform: rotate(4deg); font-family: var(--mono); font-size: 0.62rem; text-transform: uppercase; color: #9d2b18; border: 1.3px solid currentColor; border-radius: 40% / 60%; padding: 0.15em 0.55em; background: rgba(247, 244, 234, 0.86); white-space: nowrap; }
.sheet-type { position: absolute; top: 14px; left: 12px; font-family: var(--sans); font-size: 0.62rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: #fff; background: #9d2b18; padding: 0.12em 0.45em; border-radius: 2px; }
.empty-state { grid-column: 1 / -1; padding: 2rem 0; font-family: var(--sans); color: var(--muted); }

/* Map */
.map-figure { margin: 0; }
.map-stage {
  position: relative; height: min(80svh, 780px); min-height: 460px; border-radius: 14px; overflow: hidden;
  background: radial-gradient(60% 70% at 50% 50%, var(--map-sea-2), var(--map-sea) 75%);
  border: 1px solid var(--rule); touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.map-stage.is-zoomed { cursor: grab; }
.map-stage.is-dragging { cursor: grabbing; }
#map-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.map-ctl { position: absolute; z-index: 4; }
.map-ctl-scale { top: 14px; left: 14px; }
.map-ctl-zoom { right: 14px; bottom: 14px; display: grid; gap: 6px; }
.map-ctl-zoom .icon-btn { background: var(--bg); width: 36px; height: 36px; }
.map-reset { top: 14px; right: 14px; }
.map-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--ink); color: var(--bg); font-family: var(--sans); font-size: 0.78rem; line-height: 1.35; padding: 0.45rem 0.6rem; border-radius: 6px; max-width: 240px; transform: translate(-50%, calc(-100% - 12px)); box-shadow: 0 6px 16px rgba(0,0,0,.25); }
.map-tip small { display: block; opacity: 0.75; }
.map-pop { position: absolute; z-index: 6; width: min(300px, calc(100% - 28px)); background: var(--bg); color: var(--ink); border: 1px solid var(--rule); border-radius: 10px; box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.45); padding: 0.95rem 1rem 1rem; font-family: var(--sans); font-size: 0.85rem; line-height: 1.45; }
.map-pop h4 { font-family: var(--serif); font-weight: 500; font-size: 1.12rem; line-height: 1.2; margin: 0 1.8rem 0.25rem 0; }
.map-pop .pop-meta { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); margin: 0 0 0.55rem; }
.map-pop p { margin: 0 0 0.6rem; }
.map-pop .pop-close { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; font-size: 1rem; }
.pop-thumbs { display: flex; gap: 6px; margin: 0.4rem 0 0.7rem; }
.pop-thumbs button { padding: 0; border: 0; background: var(--paper); width: 54px; box-shadow: 0 2px 6px rgba(0,0,0,.25); border-radius: 1px; }
.pop-thumbs img { width: 100%; aspect-ratio: 420 / 629; object-fit: cover; }
.pop-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pop-alt { margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px solid var(--rule-soft); display: flex; flex-wrap: wrap; gap: 0.3rem; }
.pop-alt span { width: 100%; font-size: 0.74rem; color: var(--muted); }
.btn { display: inline-flex; align-items: center; gap: 0.35rem; border: 1px solid var(--ink); background: var(--ink); color: var(--bg); border-radius: 999px; padding: 0.4rem 0.85rem; font-family: var(--sans); font-size: 0.8rem; text-decoration: none; }
.btn:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn-small { padding: 0.2rem 0.6rem; font-size: 0.74rem; }
.map-legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1.4rem; margin-top: 0.8rem; font-family: var(--sans); font-size: 0.78rem; color: var(--muted); align-items: center; }
.map-legend i { display: inline-block; vertical-align: middle; margin-right: 0.45rem; }
.lg-thread { width: 22px; height: 0; border-top: 1.5px solid var(--accent); opacity: 0.6; }
.lg-node { width: 10px; height: 10px; border-radius: 50%; background: var(--map-node); box-shadow: 0 0 0 2px var(--map-node-ring), 0 0 0 3px var(--map-node); }
.lg-home { width: 10px; height: 10px; border: 1.5px solid var(--map-home); }
.map-hint { margin-left: auto; }
.map-picker { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1.2rem; }
.chip { border: 1px solid var(--rule); background: transparent; border-radius: 999px; padding: 0.3rem 0.75rem; font-family: var(--sans); font-size: 0.78rem; color: var(--ink-2); }
.chip b { font-weight: 600; color: var(--ink); margin-left: 0.25rem; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip[aria-pressed="true"] b { color: inherit; }
.chip.is-home { border-style: dashed; }
.chip[hidden] { display: none; }
.chip-more { border-style: dotted; }
.picker-homes { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }
.map-pop h4:focus { outline: none; }

/* Waves */
.waves-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: clamp(1.2rem, 3vw, 2.5rem); align-items: start; }
.waves-svg { width: 100%; height: auto; display: block; overflow: visible; font-family: var(--sans); }
.wgrid { stroke: var(--rule-soft); }
.wgtxt { fill: var(--muted); font-size: 11px; text-anchor: end; }
.wtick { fill: var(--muted); font-size: 11.5px; text-anchor: middle; font-family: var(--mono); }
.pre-band { fill: light-dark(rgba(47, 90, 60, 0.05), rgba(143, 195, 155, 0.05)); }
.pre-lbl { fill: var(--green); font-size: 11px; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.08em; }
.wbar { cursor: pointer; }
.wbar-hit { fill: transparent; }
.wbar-fill { fill: light-dark(#9aa596, #4a574e); transition: fill 0.2s; }
.wbar.pre .wbar-fill { fill: light-dark(#5f7a65, #6c8f75); }
.wbar:hover .wbar-fill { fill: var(--ink-2); }
.wbar.is-active .wbar-fill { fill: var(--accent); }
.wave-ann path { fill: none; stroke: var(--ink-2); stroke-width: 1; }
.wave-ann text { fill: var(--ink); font-size: 12.5px; font-family: var(--serif); font-style: italic; }
.waves-controls { display: flex; align-items: center; gap: 0.9rem; margin-top: 1rem; font-family: var(--sans); font-size: 0.85rem; flex-wrap: wrap; }
.play-btn { border: 1px solid var(--ink); background: var(--ink); color: var(--bg); border-radius: 999px; padding: 0.4rem 1rem; font-family: var(--sans); font-size: 0.82rem; min-width: 9.5rem; }
.play-btn:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#wave-range { flex: 1; min-width: 140px; accent-color: var(--accent); }
.wave-readout { font-family: var(--mono); font-size: 0.85rem; min-width: 11rem; }
.wave-map { margin: 0; }
.wave-map canvas { width: 100%; aspect-ratio: 1.42 / 1; display: block; border-radius: 10px; background: var(--map-sea-2); border: 1px solid var(--rule); }
.wave-map figcaption { font-family: var(--sans); font-size: 0.78rem; color: var(--muted); margin-top: 0.55rem; }

/* Home vs abroad */
.home-compare { margin: 2rem 0 2.2rem; }
.home-row { display: flex; gap: 6px; align-items: stretch; height: clamp(110px, 16vw, 168px); }
.home-bar { flex: 1; display: flex; gap: 3px; min-width: 0; }
.home-seg {
  min-width: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; padding: 8px 9px; border-radius: 3px;
  color: #e9dcc0;
  background: repeating-linear-gradient(92deg, transparent 0 9px, rgba(0, 0, 0, 0.06) 9px 10px), linear-gradient(180deg, var(--wood-2), var(--wood-1));
  box-shadow: inset 0 1px 0 var(--wood-hi), inset 0 0 0 1px rgba(0, 0, 0, 0.3);
  font-family: var(--sans); font-size: 0.72rem; line-height: 1.25; white-space: nowrap;
}
.home-seg b { font-family: var(--mono); font-size: 0.85rem; color: var(--brass-1); }
.home-seg em { font-style: normal; font-family: var(--mono); opacity: 0.8; }
.home-seg.is-rest { justify-content: center; align-items: center; }
.abroad-bar { flex: 0 0 max(6px, calc(var(--ratio) * 100%)); background: var(--accent); border-radius: 3px; box-shadow: 0 0 18px var(--accent); }
.home-labels { display: flex; justify-content: space-between; gap: 1rem; margin-top: 0.6rem; font-family: var(--sans); font-size: 0.82rem; color: var(--ink-2); }
.abroad-lbl { color: var(--accent); text-align: right; }
.home-compare figcaption { font-family: var(--sans); font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; max-width: 46rem; }

/* Register */
.license-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; margin: 0.4rem 0 0.7rem; }
.lic-by { background: var(--green); }
.lic-cc0 { background: light-dark(#8fb39a, #4f7a5c); }
.lic-nc { background: var(--accent); }
.license-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; font-family: var(--sans); font-size: 0.82rem; color: var(--ink-2); margin-bottom: 2rem; }
.license-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 0.4rem; vertical-align: -1px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 0.88rem; }
caption { caption-side: bottom; text-align: left; font-size: 0.78rem; color: var(--muted); padding-top: 0.8rem; }
th, td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
th { font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border-bottom-color: var(--rule); }
td small { display: block; color: var(--muted); font-size: 0.74rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.num { position: relative; }
.cell-bar { position: absolute; right: 0.7rem; bottom: 0.25rem; height: 3px; width: calc(var(--w) * 0.9); max-width: 9rem; background: var(--accent); opacity: 0.55; border-radius: 2px; }
.expand-btn { margin-top: 1rem; border: 1px solid var(--rule); background: transparent; border-radius: 999px; padding: 0.4rem 1rem; font-family: var(--sans); font-size: 0.82rem; }
.expand-btn:hover { border-color: var(--ink-2); }

.method-list { padding-left: 1.1rem; font-size: 0.98rem; color: var(--ink-2); }
.method-list li { margin-bottom: 0.8rem; }
.method-list b { color: var(--ink); font-weight: 600; }

.site-footer { display: flex; flex-wrap: wrap; gap: 0.6rem 1.6rem; padding: 2rem 0 3.5rem; border-top: 1px solid var(--rule); font-family: var(--sans); font-size: 0.82rem; color: var(--muted); }

/* Dialog */
dialog#sheet-dialog { padding: 0; border: 0; max-width: min(1220px, 96vw); width: 96vw; height: min(92svh, 920px); max-height: 92svh; border-radius: 14px; background: var(--bg); color: var(--ink); box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.6); overflow: hidden; }
dialog#sheet-dialog::backdrop { background: rgba(8, 12, 10, 0.72); backdrop-filter: blur(3px); }
.dlg { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 1fr); height: 100%; }
.dlg-stage { position: relative; background: radial-gradient(70% 70% at 50% 45%, #2a332c, #121713); display: grid; place-items: center; overflow: hidden; touch-action: none; cursor: none; }
.dlg-stage img { position: absolute; left: 20px; top: 20px; width: calc(100% - 40px); height: calc(100% - 64px); max-width: none; object-fit: contain; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.5)); }
.lens { position: absolute; width: 230px; height: 230px; border-radius: 50%; pointer-events: none; display: none; border: 3px solid var(--brass-1); box-shadow: 0 0 0 1px rgba(0,0,0,.5), 0 18px 40px rgba(0, 0, 0, 0.55), inset 0 0 22px rgba(0,0,0,.35); background-repeat: no-repeat; background-color: #ece6d4; transform: translate(-50%, -50%); z-index: 3; }
.lens.on { display: block; }
.dlg-hint { position: absolute; left: 0; right: 0; bottom: 10px; margin: 0; text-align: center; font-family: var(--sans); font-size: 0.74rem; color: rgba(255, 255, 255, 0.62); padding: 0 1rem; pointer-events: none; }
.dlg-dossier { padding: 1.3rem 1.5rem 1.4rem; overflow-y: auto; display: flex; flex-direction: column; gap: 0.9rem; }
.dlg-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.dlg-kicker { margin: 0; font-family: var(--mono); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
#sheet-title { font-style: italic; font-size: 1.75rem; }
.dossier-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.45rem 1rem; margin: 0; font-family: var(--sans); font-size: 0.86rem; }
.dossier-list dt { font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding-top: 0.15rem; }
.dossier-list dd { margin: 0; }
.dossier-links, .dlg-nav { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.dlg-nav span { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.dlg-nav .btn { padding: 0.3rem 0.8rem; }

/* Responsive */
@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; min-height: 0; gap: 1.6rem; }
  .lighttable { order: 2; }
  .lt-surface { aspect-ratio: auto; height: min(40svh, 340px); }
  .lt-sheet { top: calc(var(--y) * 0.9 + 6%); }
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { padding-left: 0; border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--rule-soft); }
  .waves-grid { grid-template-columns: 1fr; }
  .wave-map { max-width: 520px; }
  .dlg { grid-template-columns: 1fr; grid-template-rows: 56% 44%; }
  .dlg-stage { cursor: default; }
}
@media (max-width: 640px) {
  body { font-size: 1.06rem; }
  .topbar-home span { display: none; }
  .topbar-nav { gap: 0.9rem; margin-left: 0.2rem; }
  .drawer-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .drawer-face { min-height: 74px; padding: 7px 5px 6px; gap: 5px; }
  .label-frame { padding: 3px; }
  .label-card { padding: 4px 2px; }
  .label-latin { font-size: clamp(0.56rem, 2.5vw, 0.72rem); font-variant: normal; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: clip; }
  .label-count { font-size: 0.6rem; }
  .label-vern { display: none; }
  .drawer-pull { width: 30px; height: 8px; }
  .cabinet-crown span + span { display: none; }
  .tray-controls input[type="search"] { width: 100%; }
  .tray-controls { width: 100%; }
  .map-stage { height: auto; aspect-ratio: 1 / 1.12; min-height: 0; }
  .map-ctl-scale { top: 10px; left: 10px; right: 10px; display: flex; }
  .map-ctl-scale .seg-btn { flex: 1; padding: 0.3rem 0.4rem; font-size: 0.74rem; }
  .map-reset { top: 52px; right: 10px; }
  .map-pop { left: 8px !important; right: 8px; bottom: 8px; top: auto !important; width: auto; max-height: 62%; overflow-y: auto; }
  .map-hint { margin-left: 0; }
  .home-row { height: 120px; }
  .home-seg { padding: 6px 5px; font-size: 0.62rem; }
  .home-seg span, .home-seg em { display: none; }
  dialog#sheet-dialog { width: 100vw; max-width: 100vw; height: 100svh; max-height: 100svh; border-radius: 0; }
  .dlg-dossier { padding: 1rem 1.1rem 1.2rem; }
  #sheet-title { font-size: 1.45rem; }
}

/* keep the reading rail clear of wide figures on mid-size screens */
@media (min-width: 1180px) and (max-width: 1400px) {
  .wrap-wide, .hero-grid { width: min(100% - 6.5rem, var(--wide)); }
}

/* v2.1: stacked waves, gathering, near-you, notes */
.waves-view { margin-bottom: 0.8rem; }
.wstack { display: none; }
.is-stacked .wstack { display: inline; }
.is-stacked .wbar-fill { fill: transparent !important; }
.wstack.s0, .stack-legend .s0 { fill: #a3301d; background: #a3301d; }
.wstack.s1, .stack-legend .s1 { fill: #c9763d; background: #c9763d; }
.wstack.s2, .stack-legend .s2 { fill: #d8b25a; background: #d8b25a; }
.wstack.s3, .stack-legend .s3 { fill: #5f8f6b; background: #5f8f6b; }
.wstack.s4, .stack-legend .s4 { fill: #3d6f8f; background: #3d6f8f; }
.wstack.s5, .stack-legend .s5 { fill: #6b5a8f; background: #6b5a8f; }
.wstack.s6, .stack-legend .s6 { fill: light-dark(#b8bfb3, #4a554d); background: light-dark(#b8bfb3, #4a554d); }
.wbar.is-active .wstack { stroke: var(--ink); stroke-width: 1; }
.stack-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; margin-top: 0.7rem; font-family: var(--sans); font-size: 0.78rem; color: var(--ink-2); }
.stack-legend[hidden], .stack-note[hidden] { display: none; }
.stack-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 0.35rem; vertical-align: -1px; }
.stack-note { font-family: var(--sans); font-size: 0.85rem; color: var(--ink-2); margin: 0.6rem 0 0; max-width: 46rem; }

.gathering { margin: clamp(2.5rem, 5vw, 4rem) 0 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: clamp(1.2rem, 3vw, 2.5rem); align-items: center; padding: clamp(1rem, 2.5vw, 2rem); border-radius: 14px; background: var(--bg-2); border: 1px solid var(--rule-soft); }
.gathering h3 { font-size: 1.5rem; margin-bottom: 0.8rem; }
.gathering p { margin: 0; font-size: 1rem; color: var(--ink-2); }
.g-sheets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(0.5rem, 1.4vw, 1rem); }
.g-sheet { position: relative; padding: 6px 6px 8px; border: 0; background: var(--paper); color: var(--paper-ink); text-align: left; border-radius: 2px; box-shadow: var(--shadow-sheet); transition: transform 0.25s; }
.g-sheet:nth-child(odd) { transform: rotate(-1.2deg); }
.g-sheet:nth-child(even) { transform: rotate(1deg) translateY(8px); }
.g-sheet:hover, .g-sheet:focus-visible { transform: translateY(-4px); }
.g-sheet img { width: 100%; aspect-ratio: 420 / 640; object-fit: cover; background: #ece6d4; }
.g-inst { display: block; font-family: var(--mono); font-size: 0.66rem; text-transform: uppercase; color: #9d2b18; margin-top: 0.4rem; line-height: 1.3; }
.g-cat { display: block; font-family: var(--mono); font-size: 0.6rem; color: #6b685a; }

.near-list { list-style: none; margin: 0.4rem 0 0.5rem; padding: 0; max-height: 300px; overflow-y: auto; }
.near-list li { padding: 0.45rem 0; border-top: 1px solid var(--rule-soft); display: grid; gap: 1px; }
.near-list a { color: var(--ink); }
.near-list span { font-size: 0.76rem; color: var(--ink-2); }
.near-loc { font-family: var(--serif); font-style: italic; color: var(--muted) !important; }
.near-hold { font-family: var(--mono); font-size: 0.7rem !important; color: var(--accent) !important; }
.pop-note { font-size: 0.78rem; color: var(--muted); border-left: 2px solid var(--accent); padding-left: 0.5rem; }
.map-fail { position: absolute; inset: auto 1rem 50% 1rem; text-align: center; font-family: var(--sans); color: var(--ink-2); }

@media (max-width: 980px) {
  .gathering { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .g-sheets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-ctl-zoom { top: 52px; bottom: auto; right: 10px; }
  .map-reset { top: 52px; right: 56px; }
}
