/* ============================================================
   BEST DESIGNS — SPLAT VIEWER
   Visual system: archival herbarium specimen sheet.
   Restrained, technical, graceful. A single seamless warm-paper
   canvas; sober ink typography; generous negative space; quiet
   marks of scientific rigour that never compete with the object.
   Reference: Rijksherbarium, Leiden (Naturalis digitisation).
   (Pure visual reskin — all IDs/classes wired to app.js kept.)
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Dark slate ground — warm off-white "ink" reads like chalk on slate */
  --paper:    #191d22;   /* dark slate — the whole canvas */
  --paper-2:  #232932;   /* faint lighter slate for quiet fills */
  --ink:      #e9e4d9;   /* warm off-white — primary text */
  --pencil:   #9a958b;   /* warm grey — secondary text, captions */
  --pencil-2: #6f6b62;   /* dim grey — tertiary, hints */
  --edge:     #333a43;   /* slate hairlines, dividers, borders */
  --white:    #ffffff;   /* reference/contrast only */

  /* Selection/active is shown with ink + weight + rule, never colour */
  --accent:   var(--ink);

  --panel-width: 384px;
  --rail-width:  76px;

  --font:  'Inter', 'Helvetica Neue', Arial, sans-serif;
  --mono:  'Space Mono', 'Courier New', monospace;

  /* Gentle, settled motion — ink soaking into paper, no bounce */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --fade: 0.65s;
}

html, body {
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- App shell — object on top, copy underneath ---- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--paper);
  position: relative;
}

/* ============================================================
   ARCHIVAL PAPER SURFACE
   Procedural grain + mottle + warm vignette, multiplied over the
   whole sheet (object included) so it reads as one printed page.
   No image assets.
   ============================================================ */
#paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  mix-blend-mode: soft-light;   /* reads as fine tooth on a dark ground */
  opacity: 0.14;   /* whisper of grain — raise a touch for more */
  /* fine high-frequency tooth only — no low-freq mottle (it seamed on flat dark) */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)' opacity='0.55'/%3E%3C/svg%3E");
  background-size: 160px 160px;
  background-repeat: repeat;
}
/* Tame the grain on the splat itself a touch via overall opacity above. */

#paper-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 61;
  mix-blend-mode: multiply;
  background:
    radial-gradient(135% 120% at 50% 42%,
      rgba(43, 39, 36, 0) 50%,
      rgba(43, 39, 36, 0.05) 78%,
      rgba(43, 39, 36, 0.14) 100%);
}

@media (prefers-reduced-motion: no-preference) {
  /* (grain is static; no motion) */
}

/* ============================================================
   OBJECT CAROUSEL  (left index — quiet specimen list)
   ============================================================ */
#object-carousel {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--rail-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px 0 22px;
  gap: 14px;
  background: var(--paper);
  border-right: 1px solid var(--edge);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  z-index: 3;
  counter-reset: idx;
}
#object-carousel::-webkit-scrollbar { display: none; }

/* Vertical field label — like a margin note on the sheet */
#object-carousel::before {
  content: 'INDEX';
  position: absolute;
  left: 6px;
  bottom: 18px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--mono);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.34em;
  color: var(--pencil-2);
  pointer-events: none;
}

#carousel-heading {
  font-family: var(--mono);
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--pencil-2);
  text-align: center;
  width: 100%;
  padding-bottom: 2px;
  user-select: none;
  flex-shrink: 0;
}

.carousel-item {
  counter-increment: idx;
  flex-shrink: 0;
  width: 56px;
  min-height: 30px;
  height: auto;
  border: none;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  overflow: hidden;
  position: relative;
  padding: 4px 2px;
  opacity: 0.55;
  transition: opacity 0.3s var(--ease), transform 0.2s var(--ease);
}
.carousel-item img {
  width: 100%;
  height: 38px;
  object-fit: cover;
  display: block;
  border: 1px solid var(--edge);
  filter: grayscale(1) contrast(0.95);
  transition: filter 0.3s var(--ease);
}
.carousel-label {
  font-family: var(--font);
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--pencil);
  user-select: none;
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
  transition: color 0.3s var(--ease);
}
/* Serial-style index number, quiet */
.carousel-item::after {
  content: counter(idx, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.46rem;
  font-weight: 700;
  line-height: 1;
  color: var(--pencil-2);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.carousel-item:hover:not(.active) { opacity: 0.85; }
.carousel-item:hover:not(.active) img { filter: grayscale(0.4) contrast(1); }
.carousel-item:hover::after { opacity: 1; }

.carousel-item.active {
  opacity: 1;
}
.carousel-item.active img { filter: none; border-color: var(--ink); }
.carousel-item.active .carousel-label { color: var(--ink); font-weight: 700; }
.carousel-item.active::after { opacity: 1; color: var(--ink); }
/* Active marker — a small ink tick on the rail edge */
.carousel-item.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink);
}

/* ============================================================
   VIEWPORT  (the specimen, floating on paper)
   ============================================================ */
#viewport-wrapper {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  background: var(--paper);
  transition: opacity var(--fade) ease;
}
#viewport-wrapper.departing { opacity: 0; }
/* Fade the caption bar (hotspot titles + copy) with the object on model change */
#viewport-wrapper.departing ~ #content-panel { opacity: 0; }

#canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ---- Specimen title — centred over the object, sheet heading ---- */
#object-titlebar {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 6px 16px 7px;
  pointer-events: none;   /* never blocks orbiting the model */
  max-width: calc(100% - 48px);
}
#object-title {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.16em;
  color: var(--ink);
  text-transform: uppercase;
  max-width: 100%;
}
#object-subtitle {
  display: block;
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--pencil);
  margin-top: 4px;
}
#object-subtitle:empty { display: none; }

/* ---- Exhibition framing chrome ---- */
/* The sci-fi HUD chrome is retired for the restrained sheet look.
   Elements are kept in the DOM (app.js positions them) but hidden. */
#vp-frame {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.vp-corner,
.vp-axis,
.vp-tag { display: none; }

/* Projected bounding-box corners — retired (kept in DOM, hidden) */
.vp-bbox { display: none; }

/* The one piece of chrome we keep: a quiet instrument hint that
   fades in like a pencilled margin note. */
.vp-hint-mobile { display: none; }
.vp-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 26px;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--pencil-2);
  opacity: 0;
  animation: ink-in 1.1s var(--ease) 0.6s forwards;
}

@keyframes ink-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Intro drag cursor */
#intro-cursor {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--pencil);
  border-radius: 50%;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transform: translate(-50%, -50%);
}
#intro-cursor::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 4px; height: 4px;
  background: var(--pencil);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* ---- Anchor markers — subtle ink dots ---- */
#anchor-overlays {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}

.anchor-marker {
  position: absolute;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  width: 26px;
  height: 26px;
  cursor: pointer;
  user-select: none;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  animation: ink-in 0.8s var(--ease) forwards;
  transition: transform 0.25s var(--ease);
}
/* The dot itself */
.anchor-marker::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--pencil);
  box-shadow: 0 0 0 5px rgba(25, 29, 34, 0.55);
  transition: background 0.25s var(--ease), box-shadow 0.25s var(--ease),
              width 0.25s var(--ease), height 0.25s var(--ease),
              opacity 0.3s var(--ease);
}

/* No targeting ticks / no number in the restrained look */
.anchor-marker::after { content: none; }
.anchor-marker .am-num { display: none; }

.anchor-marker:hover { transform: translate(-50%, -50%) scale(1.12); }
.anchor-marker:hover::before { background: var(--ink); }

.anchor-marker.active::before {
  width: 8px;
  height: 8px;
  background: var(--ink);
  /* a quiet hairline ring — a registration mark, not a reticle */
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px var(--ink);
}

/* Draft markers (placement tool) — hollow ink ring */
.anchor-marker.draft-marker::before {
  background: transparent;
  box-shadow: 0 0 0 1.5px var(--pencil), 0 0 0 5px rgba(25, 29, 34, 0.55);
}
.anchor-marker.draft-marker.selected-marker::before {
  background: var(--ink);
  box-shadow: 0 0 0 1.5px var(--ink), 0 0 0 5px rgba(25, 29, 34, 0.55);
}

/* ---- Loading overlay ---- */
#loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--paper);
  pointer-events: none;
  transition: opacity var(--fade) var(--ease);
  z-index: 10;
}
#loading-overlay.hidden { opacity: 0; }
#loading-mark {
  font-size: 0.6rem;
  color: var(--pencil);
  animation: soft-pulse 1.6s ease-in-out infinite;
}
@keyframes soft-pulse { 0%,100% { opacity: 0.85; } 50% { opacity: 0.2; } }
#loading-text {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--pencil);
}

/* ---- Floating hotspot prev / next — quiet ink outlines ---- */
#hotspot-nav {
  position: fixed;
  z-index: 150;
  display: flex;
  gap: 10px;
  pointer-events: none;
}
#hotspot-prev-btn,
#hotspot-next-btn {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--edge);
  background: transparent;
  color: var(--pencil);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
#hotspot-prev-btn:hover { color: var(--ink); border-color: var(--ink); transform: translateX(-2px); }
#hotspot-next-btn:hover { color: var(--ink); border-color: var(--ink); transform: translateX(2px); }
#hotspot-prev-btn[hidden],
#hotspot-next-btn[hidden] { display: none; }

/* ============================================================
   CONTENT PANEL  (specimen labelling — backgroundless)
   ============================================================ */
/* Caption bar beneath the object — buttons + one-line copy */
#content-panel {
  flex: 0 0 auto;
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  background: var(--paper);
  color: var(--ink);
  border-top: 1px solid var(--edge);
  padding: 13px 24px 15px;
  overflow: hidden;
  transition: opacity var(--fade) var(--ease);
}
#content-panel::before { content: none; }

/* ---- Anchor nav — centred row of marker buttons ---- */
#anchor-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px 26px;
  padding: 0;
  background: transparent;
  flex-shrink: 0;
  counter-reset: anc;
}
.anchor-pill {
  counter-increment: anc;
  flex: 0 0 auto;
  font-family: var(--font);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border: none;
  background: transparent;
  color: var(--pencil);
  cursor: pointer;
  padding: 4px 2px 6px;
  display: flex;
  align-items: baseline;
  gap: 6px;
  transition: color 0.2s var(--ease);
  position: relative;
}
.anchor-pill::before {
  content: counter(anc, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1;
  color: var(--pencil-2);
  transition: color 0.2s var(--ease);
}
.anchor-pill:hover { color: var(--ink); }
.anchor-pill:hover::before { color: var(--pencil); }
.anchor-pill.active { color: var(--ink); font-weight: 700; }
.anchor-pill.active::before { color: var(--ink); }
/* underline tick under the active label */
.anchor-pill.active::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  height: 2px;
  background: var(--ink);
}

/* ---- Panel body ---- */
#panel-body {
  flex: 0 0 auto;
  overflow: visible;
  padding: 0;
  max-width: 640px;
  text-align: center;
  /* reserve one line so the bar never jumps between empty and copy */
  min-height: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

#panel-placeholder p {
  font-size: 0.76rem;
  font-weight: 400;
  color: var(--pencil-2);
  line-height: 1.5;
  padding: 0;
  border: none;
  text-align: center;
}

/* Ink-fade — copy settles in gently as the camera moves */
#panel-content:not([hidden]) {
  animation: ink-settle var(--fade) var(--ease) both;
}
@keyframes ink-settle {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---- Content text ---- */
#content-text {
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink);
  text-align: center;
}
#content-text p   { margin-bottom: 0; }
#content-text h1  {
  font-size: 1.18rem; font-weight: 800; line-height: 1.1;
  margin: 1.4em 0 0.5em; color: var(--ink); text-transform: uppercase;
  letter-spacing: 0.01em;
}
#content-text h1:first-child { margin-top: 0; }
#content-text h2  {
  font-size: 0.64rem; font-weight: 700; margin: 1.9em 0 0.8em;
  color: var(--pencil); letter-spacing: 0.16em; text-transform: uppercase;
  padding-bottom: 0.7em;
  border-bottom: 1px solid var(--edge);
}
#content-text h3  {
  font-size: 0.82rem; font-weight: 700; margin: 1.3em 0 0.4em; color: var(--ink);
  letter-spacing: 0.02em;
}
#content-text em  { font-style: italic; }
#content-text strong { font-weight: 700; color: var(--ink); }
#content-text a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
#content-text ul,
#content-text ol  { padding-left: 0; margin-bottom: 1em; list-style: none; }
#content-text li  {
  margin-bottom: 0.5em; padding-left: 20px; position: relative;
}
#content-text ul li::before {
  content: ''; position: absolute; left: 2px; top: 0.62em;
  width: 5px; height: 5px; border-radius: 50%; background: var(--pencil);
}
#content-text ol { counter-reset: li2; }
#content-text ol li { counter-increment: li2; }
#content-text ol li::before {
  content: counter(li2, decimal-leading-zero);
  position: absolute; left: 0; top: 0.15em;
  font-family: var(--mono); font-size: 0.7rem; font-weight: 700; color: var(--pencil);
}

/* ---- Image gallery — hidden in the minimal caption layout ---- */
#content-images { display: none; }
#content-images.always-off {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
#content-images.single { grid-template-columns: 1fr; }

.content-thumb-wrap {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: 0;
  cursor: pointer;
  background: var(--paper-2);
  border: 1px solid var(--edge);
}
.content-thumb-wrap::after {
  content: '⤢';
  position: absolute;
  right: 0; bottom: 0;
  z-index: 2;
  font-size: 0.66rem;
  line-height: 1;
  color: var(--paper);
  background: var(--ink);
  padding: 3px 5px;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.content-thumb-wrap:hover::after { opacity: 1; }
.content-thumb-wrap:hover .content-thumb { opacity: 0.92; }

/* blurred fill retired — contained images sit on quiet paper */
.content-thumb-blur { display: none; }
.content-thumb {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: opacity 0.2s var(--ease);
}

/* ============================================================
   ANCHOR PLACEMENT TOOL  (admin — restrained sheet styling)
   ============================================================ */
#placement-ui {
  position: fixed;
  inset: 0;
  z-index: 400;
  pointer-events: none;
}
#placement-ui[hidden] { display: none; }

#placement-banner {
  pointer-events: auto;
  position: absolute;
  top: 0;
  left: var(--rail-width);
  right: var(--panel-width);
  height: 40px;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
}
.pb-dot { color: var(--ink); font-size: 0.55rem; animation: soft-pulse 1.6s ease-in-out infinite; }

#pf-lock-btn,
#placement-exit-btn {
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
#placement-exit-btn { margin-left: auto; }
#pf-lock-btn:hover,
#placement-exit-btn:hover { background: var(--ink); color: var(--paper); }
#pf-lock-btn.active { background: var(--ink); color: var(--paper); }

#placement-panel {
  pointer-events: auto;
  position: absolute;
  top: 52px;
  left: calc(var(--rail-width) + 12px);
  width: 300px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--edge) transparent;
}

#placement-idle-hint {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.55;
  padding-left: 12px;
  border-left: 1px solid var(--ink);
}

/* ---- View limits panel ---- */
#pf-bounds {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--edge);
  background: var(--paper-2);
  padding: 9px 10px;
}
.pf-bounds-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}
#pf-live-orbit {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--pencil);
}
.pf-bound-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pf-bound-label {
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--pencil);
  width: 34px;
  flex-shrink: 0;
}
.pf-bound-row .pf-num { padding: 4px 3px; }
.pf-set {
  flex-shrink: 0;
  width: 20px;
  height: 24px;
  background: var(--white);
  border: 1px solid var(--ink);
  color: var(--ink);
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.pf-set:hover { background: var(--ink); color: var(--paper); }
.pf-bound-toggle {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink);
  cursor: pointer;
}
.pf-bound-toggle input { cursor: pointer; }

#placement-form { display: flex; flex-direction: column; gap: 10px; }
.pf-row { display: flex; flex-direction: column; gap: 5px; }
.pf-label {
  font-size: 0.58rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--pencil);
}
.pf-input {
  background: var(--white);
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.84rem;
  font-weight: 400;
  padding: 7px 9px;
  outline: none;
  transition: border-color 0.2s var(--ease);
}
.pf-input:focus { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.pf-coords { display: flex; gap: 4px; }
.pf-num {
  flex: 1;
  background: var(--white);
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 6px 4px;
  text-align: center;
  outline: none;
  min-width: 0;
}
.pf-num:focus { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.pf-buttons { display: flex; gap: 6px; }
.pf-primary {
  flex: 1;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--paper);
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 10px;
  cursor: pointer;
  transition: opacity 0.2s var(--ease);
}
.pf-primary:hover { opacity: 0.82; }
.pf-secondary {
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 10px;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.pf-secondary:hover { background: var(--ink); color: var(--paper); }

#placement-list { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.placement-item {
  background: var(--white);
  border: 1px solid var(--edge);
  border-radius: 0;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.placement-item:hover { background: var(--paper-2); border-color: var(--ink); }
.placement-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.placement-item-label {
  font-size: 0.78rem;
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#pf-camera-info {
  background: var(--paper-2);
  border: 1px solid var(--edge);
  border-radius: 0;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pf-cam-row { display: flex; align-items: baseline; gap: 8px; }
.pf-cam-label {
  font-size: 0.53rem; font-weight: 700; letter-spacing: 0.14em;
  color: var(--pencil); min-width: 34px;
}
#pf-cam-pos, #pf-cam-look {
  font-family: var(--mono); font-size: 0.72rem; color: var(--ink);
}
#pf-axis-hint {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--pencil);
  letter-spacing: 0.02em;
  transition: opacity 0.1s var(--ease);
}
.placement-item-pos {
  font-size: 0.62rem;
  color: var(--pencil);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.placement-item-save,
.placement-item-del {
  background: none;
  border: none;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 2px 3px;
  line-height: 1;
  flex-shrink: 0;
  transition: opacity 0.2s var(--ease), color 0.2s var(--ease);
}
.placement-item-save { opacity: 0.65; }
.placement-item-save:hover { opacity: 1; }
.placement-item-del { color: var(--pencil); }
.placement-item-del:hover { color: var(--ink); }
.placement-item.selected { background: var(--ink); border-color: var(--ink); }
.placement-item.selected .placement-item-label { color: var(--paper); }
.placement-item.selected .placement-item-pos   { color: var(--edge); }
.placement-item.selected .placement-item-del   { color: var(--paper); }

/* ---- Per-anchor editor ---- */
#pf-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--edge);
  background: var(--paper-2);
  padding: 12px;
}
#pf-editor[hidden] { display: none; }
.pf-editor-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.pf-editor-tag {
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--paper);
  background: var(--ink);
  padding: 3px 6px 2px;
}
#pf-editor-id { font-family: var(--mono); font-size: 0.7rem; }
#pf-edit-done {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--pencil);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
}
#pf-edit-done:hover { color: var(--ink); }
.pf-textarea {
  background: var(--white);
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.5;
  padding: 8px;
  outline: none;
  resize: vertical;
  min-height: 90px;
}
.pf-textarea:focus { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.pf-thumbs { display: flex; flex-wrap: wrap; gap: 5px; }
.pf-thumb {
  position: relative;
  width: 56px;
  height: 42px;
  border: 1px solid var(--edge);
  background: var(--paper-2);
  overflow: hidden;
}
.pf-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-thumb-del {
  position: absolute;
  top: 0; right: 0;
  width: 16px; height: 16px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.pf-addimg {
  align-self: flex-start;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--ink);
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.pf-addimg:hover { background: var(--ink); color: var(--paper); }

/* ---- 3-axis move gizmo (functional dev colours retained, muted) ---- */
.giz-line {
  position: absolute;
  height: 2px;
  transform-origin: 0 50%;
  pointer-events: none;
  z-index: 205;
}
.giz-knob {
  position: absolute;
  width: 15px;
  height: 15px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.5rem;
  font-weight: 700;
  color: var(--ink);
  cursor: grab;
  pointer-events: auto;
  z-index: 206;
  user-select: none;
}
.giz-knob:active { cursor: grabbing; }
.giz-x { background: #c2685a; }   /* X — muted brick */
.giz-y { background: #c9a24a; }   /* Y — muted ochre */
.giz-z { background: #6f9aa3; }   /* Z — muted slate */
.giz-line.giz-x { background: #c2685a; }
.giz-line.giz-y { background: #c9a24a; }
.giz-line.giz-z { background: #6f9aa3; }
.giz-hidden { display: none !important; }

#placement-export { display: flex; flex-direction: column; gap: 8px; }
#pf-export-hint {
  font-size: 0.66rem;
  line-height: 1.5;
  color: var(--pencil);
}
#pf-export-hint code {
  font-family: var(--mono);
  font-size: 0.62rem;
  background: var(--paper-2);
  padding: 1px 4px;
  color: var(--ink);
}
#pf-json-preview {
  background: var(--paper-2);
  border: 1px solid var(--edge);
  border-radius: 0;
  padding: 10px;
  font-size: 0.65rem;
  color: var(--ink);
  font-family: var(--mono);
  white-space: pre;
  overflow-x: auto;
  max-height: 200px;
  overflow-y: auto;
  user-select: all;
}

/* ============================================================
   LIGHTBOX  (specimen plate, on warm paper)
   ============================================================ */
#lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#lightbox[hidden] { display: none; }
#lightbox-backdrop { position: absolute; inset: 0; background: var(--paper); }

#lightbox-img-wrap {
  position: relative;
  z-index: 1;
  max-width: min(90vw, 920px);
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--edge);
  background: var(--white);
}
#lightbox-img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 0;
  display: block;
}

#lightbox-close {
  position: fixed;
  top: 22px;
  right: 24px;
  z-index: 2;
  background: transparent;
  border: 1px solid var(--ink);
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  width: 40px; height: 40px;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
#lightbox-close:hover { background: var(--ink); color: var(--paper); }

#lightbox-prev,
#lightbox-next {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  background: transparent;
  border: 1px solid var(--edge);
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  width: 48px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
#lightbox-prev { left: 20px; }
#lightbox-next { right: 20px; }
#lightbox-prev:hover,
#lightbox-next:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
#lightbox-prev[hidden],
#lightbox-next[hidden] { display: none; }

#lightbox-counter {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--pencil);
}

/* ============================================================
   MOBILE  (<= 768 px)
   ============================================================ */
@media (max-width: 768px) {
  #app { flex-direction: column; height: 100dvh; }

  #viewport-wrapper { flex: 1 1 auto; min-height: 0; }

  .vp-hint-desktop { display: none; }
  .vp-hint-mobile  { display: block; font-size: 0.5rem; left: 0; right: 0; text-align: center; }

  /* Carousel is a slim solid strip at the top of the viewport */
  #object-carousel {
    width: 100%;
    height: 40px;
    flex-direction: row;
    padding: 4px 10px;
    gap: 12px;
    background: var(--paper);
    border-right: none;
    border-bottom: 1px solid var(--edge);
    overflow-x: auto;
    overflow-y: hidden;
    align-items: center;
    justify-content: flex-start;
    counter-reset: idx;
  }
  #object-carousel::before { display: none; }
  #carousel-heading { display: none; }
  .carousel-item { flex-direction: row; width: auto; min-width: 0; min-height: 0; height: auto; padding: 4px 2px; flex-shrink: 0; gap: 5px; }
  .carousel-item img { display: none; }
  .carousel-item.active::before { display: none; }
  .carousel-item.active::after { content: counter(idx, decimal-leading-zero); }
  .carousel-label { font-size: 0.6rem; white-space: nowrap; }

  #canvas { padding-left: 0; }

  .anchor-pill { font-size: 0.6rem; padding: 3px 2px 5px; }
  .anchor-pill::before { font-size: 0.54rem; }

  /* Caption bar stays a slim solid strip at the bottom */
  #content-panel {
    flex: 0 0 auto;
    width: 100%;
    padding: 10px 16px 14px;
    gap: 7px;
  }
  #panel-body { padding: 0; max-width: none; }

  /* Title sits just below the carousel strip */
  #object-titlebar { top: 48px; padding: 4px 14px 5px; max-width: calc(100% - 24px); }
  #object-title { font-size: 0.78rem; }
  #object-subtitle { font-size: 0.56rem; margin-top: 3px; }

  #anchor-nav { gap: 2px 18px; padding: 0; }

  .content-thumb-wrap { aspect-ratio: 4 / 3; }
  #content-images { margin-top: 14px; gap: 4px; }
  #content-images.single .content-thumb-wrap { aspect-ratio: 4 / 3; }

  #placement-banner { left: 0; right: 0; }
  #placement-panel  { left: 8px; right: 8px; width: auto; top: 50px; }

  #lightbox-prev { left: 6px; }
  #lightbox-next { right: 6px; }
}