:root {
  --bg: #0e0e0d;
  --dot: rgba(255,255,255,.07);
  --text: #f1efe7;
  --muted: #8d8b82;
  --line: rgba(255,255,255,.1);
  --accent: #d8ff5c;
  --ease: cubic-bezier(.2,.8,.2,1);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 13px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

/* ---------- canvas ---------- */
.viewport {
  position: fixed; inset: 0; overflow: hidden; cursor: grab; touch-action: none;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.3px);
}
.viewport.dragging { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.world.moving { will-change: transform; }

.region-title {
  position: absolute; font-weight: 800; letter-spacing: -.04em; line-height: .9; white-space: nowrap;
  color: var(--text); pointer-events: none; transition: opacity .3s;
}
.region-title small { display: block; font-size: .16em; letter-spacing: .02em; font-weight: 500; color: var(--muted); margin-top: .5em; }
.board {
  position: absolute; border-radius: 28px; background: rgba(255,255,255,.025);
  border: 2px solid rgba(255,255,255,.05);
}
.board-label {
  position: absolute; left: 36px; top: 26px; right: 36px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 40px; font-weight: 700; letter-spacing: -.02em; transition: opacity .3s; pointer-events: none;
}
.board-label span { color: var(--muted); font-weight: 500; margin-left: 14px; }
.lowzoom .board-label { opacity: 0; }

.item {
  position: absolute; border-radius: 10px; overflow: hidden; cursor: zoom-in;
  background: #1b1b19; box-shadow: 0 6px 24px rgba(0,0,0,.35);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.item img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block;
  user-select: none; -webkit-user-drag: none; pointer-events: none; }
.item.contain img { object-fit: contain; }
.item.transparent { background: repeating-conic-gradient(#232320 0% 25%, #1c1c1a 0% 50%) 50% / 24px 24px; }
.item:hover { transform: translateY(-6px) scale(1.015); box-shadow: 0 22px 60px rgba(0,0,0,.55); z-index: 2; }
.item.long::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 22%;
  background: linear-gradient(transparent, rgba(14,14,13,.85)); pointer-events: none;
}
.item.hidden-for-lb { visibility: hidden; }
.moving .item { transition: none; }

/* ---------- HUD ---------- */
.hud { position: fixed; z-index: 5; }
.top {
  top: 14px; left: 14px; right: 14px; display: flex; align-items: center; gap: 10px;
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.mark {
  font-weight: 800; letter-spacing: -.02em; font-size: 15px; padding: 8px 14px; border-radius: 999px;
  background: rgba(20,20,19,.72); backdrop-filter: blur(14px); border: 1px solid var(--line);
}
.mark span { color: var(--muted); font-weight: 500; margin-left: 4px; }
.clients { display: flex; gap: 6px; }
.pill {
  border: 1px solid var(--line); background: rgba(20,20,19,.72); backdrop-filter: blur(14px);
  border-radius: 999px; padding: 8px 14px; text-decoration: none; white-space: nowrap;
  transition: background .2s, border-color .2s;
}
.pill:hover { background: rgba(40,40,37,.9); border-color: rgba(255,255,255,.2); }
.pill kbd { font: 10px ui-monospace, Menlo, monospace; color: var(--muted); margin-left: 6px; }
.spacer { flex: 1; }
.zoom { color: var(--muted); min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.hint {
  left: 50%; bottom: 18px; transform: translateX(-50%); color: var(--muted); padding: 8px 14px; border-radius: 999px;
  background: rgba(20,20,19,.72); backdrop-filter: blur(14px); border: 1px solid var(--line);
  transition: opacity .6s; pointer-events: none;
}
.hint.gone { opacity: 0; }
.minimap {
  position: fixed; right: 14px; bottom: 14px; z-index: 5; border-radius: 12px; cursor: pointer;
  background: rgba(20,20,19,.72); backdrop-filter: blur(14px); border: 1px solid var(--line);
  width: 220px; height: 150px;
}

/* ---------- lightbox ---------- */
.lb { position: fixed; inset: 0; z-index: 20; }
.lb-backdrop {
  position: absolute; inset: 0; background: rgba(8,8,7,.82); backdrop-filter: blur(18px) saturate(.8);
  opacity: 0; transition: opacity .45s var(--ease);
}
.lb.open .lb-backdrop { opacity: 1; }
.lb-stage { position: absolute; inset: 0; right: 340px; bottom: 96px; }
.lb-stage.scroll { overflow-y: auto; overscroll-behavior: contain; }
.lb-img {
  position: absolute; border-radius: 12px; box-shadow: 0 40px 120px rgba(0,0,0,.6);
  transform-origin: 0 0; object-fit: contain; background: #1b1b19;
}
.lb-img.transparent { background: repeating-conic-gradient(#232320 0% 25%, #1c1c1a 0% 50%) 50% / 24px 24px; }
.lb-img.swap { transition: opacity .35s var(--ease); }
.lb-info {
  position: absolute; top: 0; right: 0; bottom: 96px; width: 340px; padding: 74px 28px 28px;
  opacity: 0; transform: translateX(24px); transition: opacity .45s var(--ease) .08s, transform .45s var(--ease) .08s;
  overflow-y: auto;
}
.lb.open .lb-info { opacity: 1; transform: none; }
.lb-info .eyebrow { color: var(--muted); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.lb-info h2 { font-size: 24px; letter-spacing: -.02em; line-height: 1.15; margin: 8px 0 18px; overflow-wrap: anywhere; }
.lb-info dl { display: grid; grid-template-columns: 84px 1fr; gap: 8px 12px; margin: 0; font-size: 12.5px; }
.lb-info dt { color: var(--muted); }
.lb-info dd { margin: 0; overflow-wrap: anywhere; }
.lb-info .tags { display: flex; flex-wrap: wrap; gap: 5px; }
.lb-info .tags span { background: rgba(255,255,255,.08); padding: 2px 8px; border-radius: 999px; font-size: 11px; }
.lb-info .links { display: flex; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
.lb-info .note { margin-top: 18px; color: #d6d4cb; line-height: 1.55; white-space: pre-wrap; }
.lb-strip {
  position: absolute; left: 0; right: 0; bottom: 0; height: 96px; display: flex; gap: 8px; align-items: center;
  padding: 0 20px; overflow-x: auto; scrollbar-width: none;
  opacity: 0; transform: translateY(16px); transition: opacity .45s var(--ease) .12s, transform .45s var(--ease) .12s;
}
.lb.open .lb-strip { opacity: 1; transform: none; }
.lb-strip::-webkit-scrollbar { display: none; }
.lb-strip button {
  flex: 0 0 auto; height: 64px; border-radius: 6px; overflow: hidden; border: 2px solid transparent; padding: 0;
  background: #1b1b19; opacity: .55; transition: opacity .2s, border-color .2s, transform .2s var(--ease);
}
.lb-strip button:hover { opacity: .9; transform: translateY(-2px); }
.lb-strip button.on { border-color: var(--accent); opacity: 1; }
.lb-strip img { height: 100%; display: block; }
.lb-close, .lb-nav {
  position: absolute; border: 1px solid var(--line); background: rgba(20,20,19,.72); backdrop-filter: blur(14px);
  border-radius: 999px; width: 42px; height: 42px; font-size: 16px; opacity: 0; transition: opacity .3s, background .2s;
}
.lb.open .lb-close, .lb.open .lb-nav { opacity: 1; }
.lb-close:hover, .lb-nav:hover { background: rgba(40,40,37,.95); }
.lb-close { top: 16px; right: 16px; }
.lb-nav { top: calc(50% - 48px - 21px); font-size: 24px; line-height: 1; }
.lb-nav.prev { left: 16px; }
.lb-nav.next { right: 356px; }
.lb-count { color: var(--muted); font-size: 12px; margin-top: 16px; }

@media (max-width: 860px) {
  .lb-stage { right: 0; bottom: 96px; }
  .lb-info { display: none; }
  .lb-nav.next { right: 16px; }
  .clients, .zoom { display: none; }
  .minimap { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}
