/* ============================================================
   Etch Viewer — app shell (consumes the design-language tokens)
   ============================================================ */
/* slightly tighter overall scale to match the Etch ERP (rem-based kit scales) */
html { font-size: 15px; }
html, body { height: 100%; }
body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.ds-app-header { flex: none; }

/* the top bar spans the full window width (matches the full-width .ev-main) */
.ds-app-header__inner { max-width: none; padding: 0 1.1rem; }
.ev-logo { height: 1.1rem; width: auto; display: block; }

/* light theme swaps the white logo for the dark-ink variant */
html:not(.dark) .ev-logo { content: url("../design-language/etch_logo_k.svg"); }

/* "prepress" masthead word — matches the "ELEMENTS" treatment in the Etch ERP */
.ev-product {
  margin-left: 0.5rem;
  color: #52525b;                 /* zinc-600 */
  letter-spacing: 0.14em;
  font-weight: 600;
  font-size: 0.95rem;
}
html.dark .ev-product { color: #a1a1aa; }   /* zinc-400 */

/* current document name, right-aligned in the header */
.ev-docname {
  margin-left: auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 0.85rem; font-weight: 500;
  color: #52525b;
}
html.dark .ev-docname { color: #a1a1aa; }

/* "beta" badge after the masthead word */
.ev-beta {
  margin-left: 0.45rem; align-self: center;
  font-size: 0.6rem; font-weight: 700; line-height: 1;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ds-primary-foreground);
  background: var(--ds-primary);
  padding: 0.18rem 0.4rem; border-radius: 9999px;
}

/* 2D / 3D view slider (segmented toggle with a sliding thumb) */
.ev-viewtoggle {
  position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  height: 2.25rem; padding: 2px; border-radius: 9999px;
  background: var(--ds-muted); border: 1px solid var(--ds-border);
}
.ev-viewtoggle__opt {
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer; font: inherit;
  font-size: 0.8rem; font-weight: 600; white-space: nowrap;
  padding: 0 0.85rem; border-radius: 9999px;
  color: var(--ds-muted-foreground); transition: color 0.18s ease;
}
.ev-viewtoggle__opt.is-on { color: var(--ds-primary-foreground); }
.ev-viewtoggle__thumb {
  position: absolute; z-index: 0; left: 2px; top: 2px; bottom: 2px; width: calc(50% - 2px);
  background: var(--ds-primary); border-radius: 9999px;
  transition: transform 0.2s ease;
}
.ev-viewtoggle[data-view="3d"] .ev-viewtoggle__thumb { transform: translateX(100%); }

/* full-window app layout: fixed-width sidebars, the artwork pane (centre) takes
   ALL remaining width — no max-width cap, so it fills wide screens. */
.ev-main {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: 230px minmax(0, 1fr) 340px;
  gap: 0.85rem; width: 100%;
  padding: 0.85rem 1.1rem;
}
/* the left tool panel is slimmer than the document sidebar so the artwork
   keeps the space; its inspector list scrolls within a bounded height */
.ev-sidebar--left #object-list { max-height: 44vh; overflow-y: auto; }

/* ---- foldable sidebar cards ----
   Every card header carries a chevron toggle; folding hides the content so
   long separation/layer lists can't push other panes off-screen. Tool cards
   (Inspector / TAC / Press movement) auto-expand when their tool activates. */
.ev-fold__toggle {
  flex: 1 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: 0.45rem;
  background: none; border: 0; padding: 0; margin: 0;
  font: inherit; color: var(--ds-foreground); text-align: left; cursor: pointer;
}
.ev-fold__toggle svg { flex: none; color: var(--ds-muted-foreground); transition: transform 0.15s ease; }
.ev-fold.is-folded .ev-fold__toggle svg { transform: rotate(-90deg); }
.ev-fold__title { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* !important: content blocks like #doc-info / #object-list set their own
   display (grid/flex) via ID selectors, which would outrank this class rule
   and leave the pane visibly un-folded */
.ev-fold.is-folded .ds-card__content { display: none !important; }
.ev-fold.is-folded .ds-card__header { padding-bottom: 0.7rem; }

/* floating tool palette — interaction modes, top-left over the canvas */
.ev-palette {
  position: absolute; left: 12px; top: 12px; z-index: 9;
  display: flex; flex-direction: column; gap: 4px; padding: 4px;
  background: color-mix(in srgb, var(--ds-card) 92%, transparent);
  border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md);
  box-shadow: var(--ds-shadow-md);
}
.ev-palette__btn {
  width: 2.25rem; height: 2.25rem; display: grid; place-items: center; padding: 0;
  border: none; background: transparent; color: var(--ds-foreground);
  border-radius: var(--ds-radius-sm); cursor: pointer;
}
.ev-palette__btn:hover:not(:disabled) { background: color-mix(in srgb, var(--ds-muted-foreground) 18%, transparent); }
.ev-palette__btn.is-on { background: var(--ds-primary); color: var(--ds-primary-foreground); }
.ev-palette__btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---- stage ---- */
.ev-stage-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.ev-toolbar {
  flex: none; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--ds-border); background: var(--ds-card);
}
.ev-tool-group { display: flex; align-items: center; gap: 0.4rem; }
/* the class display:flex would otherwise override the `hidden` attribute the JS
   sets on the Page / Duplex groups (they must stay hidden until relevant) */
.ev-tool-group[hidden] { display: none; }
/* .ds-btn/.ds-select set `display`, which overrides the `hidden` attribute's UA
   `display:none` — so toolbar controls JS hides via `hidden` (Show back / Use
   page until a 2nd side loads, the settings popover) leaked into view. Restore
   `hidden` for everything inside the bar. */
.ev-toolbar [hidden] { display: none; }
/* opaque-white toggle row inside the Separations card (shown only for white-ink jobs) */
.ev-sep-opts {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.35rem 0.85rem 0.5rem; border-bottom: 1px solid var(--ds-border);
}
.ev-sep-opts[hidden] { display: none; }
/* Opaque-white state at a glance: GREEN = on (whites print as opaque under-base),
   RED = off (whites render as transmissive spot inks). The plain ghost button
   didn't read as "disabled" when off. Colours chosen to hold up on both themes. */
#tool-opaque-white { background: #b91c1c; color: #fff; border-color: #b91c1c; }
#tool-opaque-white:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
#tool-opaque-white.is-on { background: #15803d; color: #fff; border-color: #15803d; }
#tool-opaque-white.is-on:hover { background: #16a34a; border-color: #16a34a; }
/* the view / output cluster (snapshot, 2D-3D, settings) hugs the right edge, so
   the toolbar reads as "what I'm viewing" on the left, "how" on the right */
.ev-tool-group--right { margin-left: auto; }
/* thin divider between logical toolbar groups */
.ev-tool-sep { align-self: stretch; width: 1px; margin: 0.2rem 0.15rem; background: var(--ds-border); }
/* section divider: a group that opens a new toolbar section (Duplex, Substrate+
   View, Settings) gets a left rule. Using border-left rather than a standalone
   divider span means a section that collapses to display:none (Page / Duplex
   when nothing is loaded) never leaves a dangling divider floating in the bar. */
.ev-tool-group--divide { border-left: 1px solid var(--ds-border); padding-left: 0.85rem; margin-left: 0.1rem; }
.ev-toggle.is-on { background: var(--ds-primary); color: var(--ds-primary-foreground); border-color: var(--ds-primary); }
/* 2nd-side drop area: a dashed toolbar chip you drag the reverse-side PDF onto
   (Browse… inside as the picker fallback). Loaded → solid chip with the source
   name + a ✕ to unload. .is-drag highlights while a file hovers over it. */
.ev-dropzone {
  display: flex; align-items: center; gap: 0.35rem; height: 2.25rem;
  padding: 0 0.4rem 0 0.6rem; border: 1.5px dashed var(--ds-border);
  border-radius: var(--ds-radius); font-size: 0.8rem; color: var(--ds-muted-foreground);
  /* a lighter fill than the toolbar (--ds-card) so the drop target reads as an
     obvious "put the 2nd side here" chip rather than blending into the bar */
  background: var(--ds-muted);
  transition: border-color 120ms, background-color 120ms;
}
.ev-dropzone.is-drag {
  border-color: var(--ds-primary); border-style: solid;
  background: color-mix(in srgb, var(--ds-primary) 12%, transparent);
  color: var(--ds-foreground);
}
.ev-dropzone.is-loaded { border-style: solid; color: var(--ds-foreground); }
.ev-dropzone__hint { pointer-events: none; white-space: nowrap; }
.ev-dropzone__name {
  max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600;
}
.ev-dropzone__clear {
  border: 0; background: none; cursor: pointer; padding: 0.15rem 0.3rem;
  color: var(--ds-muted-foreground); font-size: 0.75rem; line-height: 1; border-radius: var(--ds-radius);
}
.ev-dropzone__clear:hover { color: #dc2626; background: color-mix(in srgb, #dc2626 10%, transparent); }
.ev-dropzone [hidden] { display: none; }

.ev-stage {
  position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden;
  /* Transparency checkerboard. Light is the default on EVERY theme — most artwork
     reads best against a neutral light contrast background (independent of the app
     theme). The semi-transparent grey squares show on both light and dark. */
  background-color: #e9eaec;
  background-image:
    repeating-conic-gradient(rgb(128 128 128 / 0.22) 0% 25%, transparent 0% 50%);
  background-size: 22px 22px;
  background-position: 50%;
}
/* #pane-bg toggle: switch the viewer checker to dark (light is the default above). */
.ev-stage.pane-dark { background-color: #15171c; }
.ev-stage-scroll {
  position: absolute; inset: 0; transform-origin: 0 0;
  will-change: transform; touch-action: none;
}
.ev-composite, .ev-overlay {
  position: absolute; left: 0; top: 0; display: block;
  image-rendering: auto;
}
.ev-composite { box-shadow: 0 6px 24px rgb(0 0 0 / 0.25); }
/* Film is a CLEAR sheet: a drop shadow cast by the canvas rectangle sits UNDER its
   transparent areas and reads as a stray shadow with nothing casting it. Drop it on
   film (kept for the opaque paper / foil sheets, where it reads as a real object). */
.ev-stage[data-substrate="film"] .ev-composite { box-shadow: none; }
.ev-overlay { pointer-events: none; }

/* density tool: eyedropper cursor, hotspot on the pipette tip (2,22). Drawn
   twice (dark wide + light narrow stroke) so it reads on any artwork. Listed
   BEFORE is-grabbing so an active space-drag pan still shows the grab cursor. */
.ev-stage.is-density,
.ev-stage.is-density .ev-foil-stage canvas {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke-linecap="round" stroke-linejoin="round"><g stroke="%23111" stroke-width="3.4"><path d="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z"/></g><g stroke="%23fff" stroke-width="1.6"><path d="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z"/></g></svg>') 2 22, crosshair;
}
.ev-stage.is-dots { cursor: crosshair; }
.ev-stage.is-grabbing { cursor: grabbing; }
.ev-stage.is-pannable { cursor: grab; }

/* ---- Dot inspector: a floating stage overlay, top-right ---- */
.ev-dotpanel {
  position: absolute; top: 0.75rem; right: 0.75rem; z-index: 30;
  width: 30rem; max-width: calc(100% - 4.5rem);
  max-height: calc(100% - 1.5rem); overflow-y: auto;
  padding: 0.7rem 0.8rem;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}
.ev-dotpanel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.ev-dot { display: flex; flex-direction: column; gap: 0.55rem; }
#dot-loupe {
  width: 100%; aspect-ratio: 1; border-radius: 6px;
  background: #14161b; border: 1px solid var(--ds-border, #2a2d34);
}
.ev-dot-row { display: flex; align-items: center; gap: 0.5rem; }
.ev-dot-row .ds-select { height: 1.9rem; width: auto; }
.ev-dot-strip { display: flex; height: 1.15rem; border-radius: 4px; overflow: hidden; border: 1px solid var(--ds-border, #2a2d34); }
.ev-dot-strip:empty { display: none; }
.ev-dot-strip span { flex: 1; }
.ev-dot-grade--ok { color: var(--ds-emerald-fg, #5dd47e); }
.ev-dot-grade--warn { color: var(--ds-amber-fg, #f6c445); }
.ev-dot-grade--bad { color: var(--ds-red-fg, #ff6767); }
.ev-dot-list { display: flex; flex-direction: column; gap: 0.3rem; }
.ev-dot-sep {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) 3.4rem 3.6rem auto;
  align-items: center; gap: 0.4rem; font-size: 0.82rem;
}
.ev-dot-sep .swatch {
  width: 0.85rem; height: 0.85rem; border-radius: 3px; display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.ev-dot-sep__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-dot-sep .ds-input { height: 1.75rem; padding: 0 0.3rem; font-size: 0.8rem; }
.ev-dot-sep .ds-select { height: 1.75rem; padding: 0 0.2rem; font-size: 0.9rem; width: auto; max-width: 3.4rem; }
.ev-dot-sep--head { font-size: 0.68rem; letter-spacing: 0.03em; text-transform: uppercase; opacity: 0.55; margin-bottom: -0.15rem; }

/* viewport-sharpening patch: a screen-space canvas overlaid on the (CSS-scaled,
   soft) composite once zoomed past the base raster. Click-through so all tools
   keep working on the stage beneath. */
.ev-hires { position: absolute; z-index: 2; pointer-events: none; }
.ev-hires[hidden] { display: none; }

/* non-blocking busy bar for re-renders (layer/quality changes) — only shown
   if a render actually takes a moment, so fast/cached toggles feel instant */
.ev-busy {
  position: absolute; left: 0; right: 0; top: 0; height: 3px; z-index: 8;
  overflow: hidden; pointer-events: none; background: transparent;
}
.ev-busy[hidden] { display: none; }
.ev-busy::before {
  content: ''; position: absolute; top: 0; height: 100%; width: 35%;
  background: var(--ds-primary); border-radius: 0 2px 2px 0;
  animation: ev-busy-slide 0.9s ease-in-out infinite;
}
@keyframes ev-busy-slide { 0% { left: -35%; } 100% { left: 100%; } }
/* while a render / recomposite is in flight, a page-wide progress cursor signals
   "working" even during a main-thread freeze (when the bar above can't animate) */
body.ev-working, body.ev-working * { cursor: progress !important; }

/* drop overlay */
.ev-drop {
  position: absolute; inset: 12px; display: none; place-items: center; z-index: 6;
  border: 2px dashed var(--ds-primary); border-radius: var(--ds-radius-lg);
  background: color-mix(in srgb, var(--ds-primary) 12%, transparent);
  font-weight: 600; pointer-events: none;
}
.ev-stage.ev-dragover .ev-drop { display: grid; }

/* readout (density probe) */
.ev-readout {
  position: absolute; left: 0; top: 0; z-index: 7; min-width: 8.5rem; max-width: 60%;
  background: color-mix(in srgb, var(--ds-popover) 92%, transparent);
  color: var(--ds-popover-foreground);
  border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md);
  padding: 0.5rem 0.6rem; font-size: 0.78rem; box-shadow: var(--ds-shadow-md);
  font-variant-numeric: tabular-nums; pointer-events: none;
}
/* top-right hint: how to pan the preview */
.ev-pan-hint {
  position: absolute; right: 12px; top: 12px; z-index: 7;
  background: color-mix(in srgb, var(--ds-popover) 85%, transparent);
  color: var(--ds-muted-foreground);
  border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md);
  padding: 0.25rem 0.55rem; font-size: 0.72rem; pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.ev-pan-hint[hidden] { display: none; }

.ev-readout .rk { color: var(--ds-muted-foreground); }
.ev-readout > div { display: flex; align-items: center; gap: 0.4rem; }
.ev-readout > div b { margin-left: auto; }
.ev-readout .dp-tac { margin-top: 0.25rem; border-top: 1px solid var(--ds-border); padding-top: 0.25rem; }
.ev-readout .swatch { display:inline-block;width:9px;height:9px;border-radius:2px;border:1px solid var(--ds-border);vertical-align:baseline;margin-right:4px; }

/* empty + loading */
.ev-empty, .ev-loading {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 5;
  background: color-mix(in srgb, var(--ds-background) 70%, transparent);
}
.ev-empty[hidden], .ev-loading[hidden] { display: none; }
.ev-empty__box { text-align: center; max-width: 440px; padding: 2rem; }
.ev-empty__title { font-size: 1.15rem; font-weight: 600; }
.ev-empty__sub { color: var(--ds-muted-foreground); margin-top: 0.5rem; font-size: 0.875rem; }
.ev-loading { flex-direction: column; gap: 0.75rem; }
.ev-spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--ds-border); border-top-color: var(--ds-primary);
  animation: ev-spin 0.8s linear infinite;
}
@keyframes ev-spin { to { transform: rotate(360deg); } }

/* ---- sidebar ---- */
.ev-sidebar { min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 0.7rem; }
.ev-card .ds-card__header { padding: 0.7rem 0.85rem 0.35rem; }
.ev-card .ds-card__content { padding: 0 0.85rem 0.8rem; }
.ev-card__head { flex-direction: row; align-items: center; justify-content: space-between; }

#doc-info { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.75rem; font-size: 0.82rem; }
#doc-info .k { color: var(--ds-muted-foreground); }
#doc-info .v { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* separation rows */
.sep-row {
  display: flex; align-items: center; gap: 0.55rem; padding: 0.4rem 0.3rem;
  border-radius: var(--ds-radius-md); cursor: pointer;
}
.sep-row + .sep-row { border-top: 1px solid var(--ds-border); }
.sep-row:hover { background: color-mix(in srgb, var(--ds-muted) 50%, transparent); }
.sep-row.is-off { opacity: 0.4; }
/* sep present in the doc but only on a hidden layer — inert placeholder row */
.sep-row.is-dormant { opacity: 0.35; cursor: default; }
.sep-row.is-dormant:hover { background: none; }
.sep-row.is-solo { background: color-mix(in srgb, var(--ds-primary) 14%, transparent); }
.sep-swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--ds-border); flex: none; }
.sep-name { flex: 1; font-size: 0.84rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sep-cov { font-size: 0.72rem; color: var(--ds-muted-foreground); font-variant-numeric: tabular-nums; }
.sep-tag { font-size: 0.6rem; padding: 0 0.3rem; border-radius: 9999px; background: var(--ds-muted); color: var(--ds-muted-foreground); }
.sep-solo-btn { font-size: 0.65rem; padding: 0.1rem 0.35rem; border-radius: var(--ds-radius-sm); border: 1px solid var(--ds-border); background: transparent; color: var(--ds-muted-foreground); cursor: pointer; }
.sep-solo-btn.is-on { background: var(--ds-primary); color: var(--ds-primary-foreground); border-color: var(--ds-primary); }
/* thin ink-coverage bar along the row's bottom edge (sqrt scale) */
.sep-row { position: relative; padding-bottom: 0.55rem; }
.sep-bar { position: absolute; left: 1.85rem; right: 0.3rem; bottom: 3px; height: 2px; border-radius: 1px; background: color-mix(in srgb, var(--ds-muted) 55%, transparent); overflow: hidden; pointer-events: none; }
.sep-bar > span { display: block; height: 100%; border-radius: 1px; }
/* solo display mode (ink colour vs black) — shown only while a sep is soloed */
.sep-solo-display { display: flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0.3rem 0.45rem; font-size: 0.72rem; }
.sep-solo-display .ds-muted { flex: 1; }
.sep-solo-mode {
  font-size: 0.68rem; padding: 0.12rem 0.5rem; cursor: pointer;
  border: 1px solid var(--ds-border); border-radius: 9999px;
  background: transparent; color: var(--ds-muted-foreground);
}
.sep-solo-mode.is-on { background: var(--ds-primary); color: var(--ds-primary-foreground); border-color: var(--ds-primary); }

/* pinned density samples (left panel) */
#density-list { display: flex; flex-direction: column; gap: 0.45rem; max-height: 38vh; overflow-y: auto; }
.dp-pin { border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md); padding: 0.35rem 0.5rem; font-size: 0.76rem; }
.dp-pin__head { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.2rem; }
.dp-pin__head .ds-muted { flex: 1; font-size: 0.7rem; }
.dp-pin__tac { font-weight: 600; font-variant-numeric: tabular-nums; }
.dp-pin__row { display: flex; align-items: center; gap: 0.35rem; }
.dp-pin__row b { margin-left: auto; font-variant-numeric: tabular-nums; }
.dp-pin .swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; border: 1px solid var(--ds-border); flex: none; }

/* "locate" pulse marker (TAC max) */
.ev-ping {
  position: absolute; z-index: 8; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border: 3px solid #00e65a; border-radius: 50%; pointer-events: none;
  animation: ev-ping 0.55s ease-out 3;
}
@keyframes ev-ping { 0% { transform: scale(0.6); opacity: 1; } 100% { transform: scale(3.2); opacity: 0; } }
.sep-section-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ds-muted-foreground); margin: 0.5rem 0 0.15rem; }

/* layer rows — visibility toggle per OCG layer */
.layer-row {
  display: flex; align-items: center; gap: 0.55rem; padding: 0.4rem 0.3rem;
  border-radius: var(--ds-radius-md); cursor: pointer;
}
.layer-row + .layer-row { border-top: 1px solid var(--ds-border); }
.layer-row:hover { background: color-mix(in srgb, var(--ds-muted) 50%, transparent); }
.layer-row.is-off { opacity: 0.45; }
.layer-name { flex: 1; font-size: 0.84rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer-check {
  width: 16px; height: 16px; border-radius: 4px; flex: none; position: relative;
  border: 1px solid var(--ds-border); background: transparent;
}
.layer-check.is-on { background: var(--ds-primary); border-color: var(--ds-primary); }
.layer-check.is-on::after {
  content: ''; position: absolute; left: 5px; top: 2px; width: 4px; height: 8px;
  border: solid var(--ds-primary-foreground); border-width: 0 2px 2px 0; transform: rotate(45deg);
}

/* object inspector — stack of vector ops under the clicked point */
#object-list { display: flex; flex-direction: column; gap: 0.4rem; max-height: 42vh; overflow-y: auto; }
.obj-row { padding: 0.4rem 0.5rem; border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md); font-size: 0.78rem; cursor: pointer; }
.obj-row.is-hidden { opacity: 0.5; }
.obj-row.is-selected { border-color: var(--ds-primary); box-shadow: inset 0 0 0 1px var(--ds-primary); }
.obj-head { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; }
.obj-z { color: var(--ds-muted-foreground); font-variant-numeric: tabular-nums; }
.obj-layer { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obj-kind { color: var(--ds-muted-foreground); font-weight: 500; }
.obj-top { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 0 0.3rem; border-radius: 9999px; background: var(--ds-primary); color: var(--ds-primary-foreground); }
.obj-inks { margin-top: 0.2rem; font-variant-numeric: tabular-nums; }
.obj-flags { margin-top: 0.15rem; color: var(--ds-muted-foreground); }
.obj-behavior { margin-top: 0.15rem; }
#object-list .swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; border: 1px solid var(--ds-border); vertical-align: baseline; margin-right: 3px; }

/* pre-render page chooser (multi-page PDFs) */
.ev-pagechooser {
  position: absolute; inset: 0; z-index: 10; display: grid; place-items: center;
  background: color-mix(in srgb, var(--ds-background) 82%, transparent);
}
.ev-pagechooser[hidden] { display: none; }
.ev-pagechooser__box {
  background: var(--ds-card); border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg); box-shadow: var(--ds-shadow-lg);
  padding: 1.5rem; max-width: 620px; text-align: center;
}
.ev-pagechooser__title { font-size: 1.15rem; font-weight: 600; }
.ev-pagechooser__sub { color: var(--ds-muted-foreground); margin: 0.4rem 0 1rem; font-size: 0.9rem; }
.ev-pagechooser__grid {
  display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center;
  max-height: 56vh; overflow-y: auto;
}
/* one selectable page: worker-rendered thumbnail above the page number */
.ev-pagechooser__page {
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  padding: 0.5rem; cursor: pointer;
  background: none; color: var(--ds-foreground);
  border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md);
}
.ev-pagechooser__page:hover { border-color: var(--ds-primary); background: color-mix(in srgb, var(--ds-primary) 8%, transparent); }
.ev-pagechooser__thumb {
  width: 124px; height: 96px; display: grid; place-items: center; overflow: hidden;
  background: var(--ds-background); border-radius: 4px;
}
.ev-pagechooser__thumb canvas { max-width: 100%; max-height: 100%; }
.ev-pagechooser__label { font-size: 0.82rem; color: var(--ds-muted-foreground); }
.ev-pagechooser__quality { display: flex; align-items: center; justify-content: center; gap: 0.55rem; margin-top: 1.1rem; }
.ev-spinner--sm { width: 16px; height: 16px; border-width: 2px; }

/* ---- 3D view: replaces the 2D stage in place, controls stay ---- */
/* transparent: the WebGL canvas clears transparent, so the .ev-stage checkerboard
   behind shows around the sheet (and through a clear-film sheet). */
.ev-foil-stage { position: absolute; inset: 0; z-index: 4; background: transparent; }
.ev-foil-stage[hidden] { display: none; }
.ev-foil-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.ev-foil-stage:active canvas { cursor: grabbing; }

/* ---- settings popover (gear) ---- */
.ev-settings { position: relative; display: inline-flex; }
.ev-settings-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20;
  display: flex; flex-direction: column; gap: 0.5rem; min-width: 16rem;
  padding: 0.7rem 0.8rem; background: var(--ds-popover); color: var(--ds-popover-foreground);
  border: 1px solid var(--ds-border); border-radius: var(--ds-radius-md); box-shadow: var(--ds-shadow-md);
}
.ev-settings-pop[hidden] { display: none; }
.ev-settings-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.ev-settings-row .ds-select { width: 8rem; }
.ev-settings-row .ds-label { white-space: nowrap; }

/* ---- 1st / 2nd side badge on the stage ---- */
.ev-side-badge {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 8;
  padding: 0.25rem 0.75rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.02em; pointer-events: none; white-space: nowrap;
  background: color-mix(in srgb, var(--ds-popover) 90%, transparent);
  color: var(--ds-popover-foreground); border: 1px solid var(--ds-border); box-shadow: var(--ds-shadow-md);
}
.ev-side-badge[hidden] { display: none; }
.ev-side-badge.is-back {        /* 2nd side: tinted so it's unmistakable you've flipped */
  background: color-mix(in srgb, var(--ds-primary) 88%, transparent);
  color: var(--ds-primary-foreground); border-color: var(--ds-primary);
}

/* ---- frosted film edge (retired) ---- */
/* The edge blur that used to cue "looking through the film thickness" is gone —
   all 3D blur was dropped in favour of a 1px sheet-edge hairline drawn in the
   scene. Rule kept as a hard no-op so any stale markup can never blur the canvas. */
.ev-film-frost { display: none !important; }

/* ---- separations panel: per-side source title (duplex) ---- */
.sep-source-title {
  margin: 0.6rem 0 0.2rem; padding-top: 0.5rem; border-top: 1px solid var(--ds-border);
  font-size: 0.72rem; font-weight: 600; color: var(--ds-foreground);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sep-source-title:first-child { margin-top: 0; padding-top: 0; border-top: none; }

@media (max-width: 900px) {
  .ev-main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .ev-sidebar { max-height: 38vh; }
  .ev-sidebar--left { display: none; }   /* tool panel is desktop-width only */
}

/* ---- prepress shell (hosted in FETCH) ------------------------------------ */
/* html.shell = a FETCH host is present (set pre-paint in index.html). The page
   boots as an invisible render service; the host reveals the full viewer
   (html.mode-viewer) or the light preview strip (html.mode-preview). In a
   plain browser none of these classes exist and the viewer shows normally. */
html.shell:not(.mode-viewer) .ds-app-header,
html.shell:not(.mode-viewer) .ev-main { display: none !important; }

/* "updating" pill: the visible image is temporary (a sharp viewport patch or
   deferred colour layers are in flight) — small, bottom-centre, inert */
.ev-updating {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.3rem 0.75rem; border-radius: 999px;
  background: color-mix(in srgb, var(--ds-card) 88%, transparent);
  border: 1px solid var(--ds-border);
  color: var(--ds-muted-foreground); font-size: 0.78rem;
  pointer-events: none; z-index: 30;
  animation: ev-updating-in 200ms ease-out both;
}
.ev-updating[hidden] { display: none; }
.ev-updating__dot {
  width: 0.5rem; height: 0.5rem; border-radius: 50%;
  background: var(--ds-primary);
  animation: ev-updating-pulse 1.1s ease-in-out infinite;
}
@keyframes ev-updating-in { from { opacity: 0; transform: translateX(-50%) translateY(4px); } to { opacity: 1; transform: translateX(-50%); } }
@keyframes ev-updating-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* prepress chrome materialises around the artwork on reveal — the host grows
   the window around the flat proof first (QuickLookWindow's morph), presents
   the viewer, and the controls fade in while the artwork stays put */
html.chrome-in .ds-app-header,
html.chrome-in .ev-sidebar,
html.chrome-in .ev-toolbar,
html.chrome-in .ev-palette {
  animation: ev-chrome-in 420ms ease-out both;
}
@keyframes ev-chrome-in { from { opacity: 0; } to { opacity: 1; } }

/* preview strip: one centred composite (replaces PreviewHarness.html) */
#preview-root { display: none; }
html.mode-preview #preview-root {
  display: block; position: fixed; inset: 0;
  background: var(--ds-background, #09090b);
  font: 12.5px "Segoe UI", sans-serif;
  color: var(--ds-muted-foreground, #a1a1aa);
}
#preview-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
#preview-wrap canvas { max-width: calc(100% - 32px); max-height: calc(100% - 40px); }
#preview-status { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 40px; }
#preview-status[hidden] { display: none; }
#preview-msg { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; color: var(--ds-muted-foreground, #71717a); font-size: 11px; }
