/* ============================================================
   case-next — viewer styles (Medcase redesign — v5 simplified)
   Tokens come from /colors_and_type.css (loaded before this file).
   Theme: light by default; html[data-theme="dark"] flips a small
   set of viewer-local tokens for the dark variant. The design
   system's accent (#C8412C) is shared across themes.
   ============================================================ */

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

/* ---------- VIEWER-LOCAL THEME TOKENS ------------------------
   Light is default. The dark variant only overrides what reads
   differently on a dark canvas. Names mirror mockup conventions
   (--w-*) for fidelity to the handoff. */
:root {
  --w-base:         #FFFFFF;
  --w-soft:         #FAFAFA;
  --w-recess:       #F5F5F5;
  --w-ink:          #15171A;
  --w-ink-2:        #4A5058;
  --w-ink-3:        #6B7177;
  --w-rule:         rgba(21,23,26,0.10);
  --w-rule-strong:  rgba(21,23,26,0.18);
  --w-muted-fill:   rgba(21,23,26,0.04);
  --w-track-dim:    rgba(21,23,26,0.10);
  --w-canvas-bg:    #EDEFF2;
  --w-pill-bg:      rgba(255,255,255,0.78);
  --w-pill-blur:    blur(14px) saturate(140%);
  --w-menu-bg:      rgba(255,255,255,0.96);
  /* HUD over canvas — dark in light theme to read on the video. */
  --w-hud-bg:       rgba(11,14,17,0.82);
  --w-hud-border:   rgba(255,255,255,0.18);
  --w-hud-fg:       #FFFFFF;
}
html[data-theme="dark"] {
  --w-base:         #0B0E11;
  --w-soft:         #14181C;
  --w-recess:       #1F2429;
  --w-ink:          #F2F3F4;
  --w-ink-2:        #A8B0B6;
  --w-ink-3:        #7A848C;
  --w-rule:         rgba(242,243,244,0.10);
  --w-rule-strong:  rgba(242,243,244,0.18);
  --w-muted-fill:   rgba(242,243,244,0.06);
  --w-track-dim:    rgba(242,243,244,0.10);
  --w-canvas-bg:    #000000;
  --w-pill-bg:      rgba(20,24,28,0.72);
  --w-menu-bg:      rgba(11,14,17,0.94);
}

html, body {
  height: 100%;
  background: var(--w-base);
  color: var(--w-ink);
  font-family: var(--font-text);
  overflow: hidden;
  transition: background 200ms;
}

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

/* ============================================================
   VIEWER SHELL — 2-col grid (stage + right structures panel)
   Single col on mobile (<900px); the right panel becomes the
   bottom sheet via the legacy .panel position:fixed rules.
   ============================================================ */
.viewer {
  display: grid;
  grid-template-rows: 56px 1fr;
  grid-template-columns: 1fr 320px;
  grid-template-areas:
    "top top"
    "stage right";
  height: 100vh;
  background: var(--w-base);
}
@media (max-width: 1180px) { .viewer { grid-template-columns: 1fr 280px; } }
@media (max-width: 900px) {
  .viewer {
    grid-template-rows: 56px 1fr;
    grid-template-columns: 1fr;
    grid-template-areas:
      "top"
      "stage";
  }
  .vw-right { display: contents; }
}

/* ============================================================
   TOP BAR
   ============================================================ */
.vw-top {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--w-rule);
  background: var(--w-base);
}
.vw-top-left, .vw-top-right { display: flex; align-items: center; gap: 14px; }

.vw-brand { display: inline-flex; align-items: center; color: var(--w-ink); }
.vw-brand-stack { display: flex; flex-direction: column; line-height: 1; gap: 3px; }
.vw-brand-product {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--w-ink);
}
.vw-brand-company {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--w-ink-3);
  font-weight: 500;
}
.vw-sep { color: var(--w-ink-3); margin: 0 4px; font-weight: 300; }
.vw-case-id {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--w-ink-2);
  text-transform: uppercase;
}
.vw-case-id b { color: var(--w-ink); font-weight: 600; }

@media (max-width: 600px) {
  .vw-sep, .vw-case-id { display: none; }
  .vw-brand-company { display: none; }
}

/* Responsive visibility helpers for top-bar chrome. !important wins over
   the .pill base display:inline-flex defined later in this file.
   Desktop ≥769px: theme + Compartilhar pills are visible; hamburger hidden.
   Mobile  <769px: theme + Compartilhar move into the hamburger popover. */
.vw-mobile-only { display: none !important; }
@media (max-width: 768px) {
  .vw-desktop-only { display: none !important; }
  button.vw-mobile-only { display: inline-flex !important; }
  /* The popover div itself uses dataset-driven display, so reset its
     base hiding rule and let [data-open] decide. */
  div.vw-mobile-only { display: none !important; }
  div.vw-mobile-only[data-open="true"] { display: block !important; }
}

/* Mobile top-bar polish — pills tighten up and AR/Medir lose their
   text labels (the hamburger handles the rest). */
@media (max-width: 768px) {
  .vw-top { padding: 0 var(--space-4); }
  .vw-top-right { gap: 8px; }
  .pill { padding: 0; width: 36px; }
  .pill .label { display: none; }
}

/* ============================================================
   OVERFLOW MENU (mobile) — opens from the hamburger pill, lists
   theme toggle + Compartilhar. Anchored via JS to the pill rect.
   ============================================================ */
.overflow-menu {
  position: fixed;
  z-index: 1000;
  width: 240px;
  background: var(--w-menu-bg);
  border: 1px solid var(--w-rule-strong);
  border-radius: 14px;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 24px 48px -16px rgba(0,0,0,0.20);
  overflow: hidden;
  display: none;
}
@media (max-width: 768px) {
  .overflow-menu[data-open="true"] { display: block; }
}
.overflow-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--w-ink);
  text-align: left;
  font-family: inherit;
}
.overflow-item + .overflow-item { border-top: 1px solid var(--w-rule); }
.overflow-item:hover { background: var(--w-soft); }
.overflow-item .ic {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--w-muted-fill);
  border: 1px solid var(--w-rule);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--w-ink-2);
}
.overflow-item .ic svg { width: 18px; height: 18px; }
.overflow-item .lbl { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.overflow-item .lbl .l1 {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--w-ink);
}
.overflow-item .lbl .l2 {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--w-ink-3);
}
/* Show light/dark labels per current theme — pure CSS. */
.overflow-item .lbl-light, .overflow-item .sub-light { display: inline; }
.overflow-item .lbl-dark,  .overflow-item .sub-dark  { display: none; }
html[data-theme="dark"] .overflow-item .lbl-light,
html[data-theme="dark"] .overflow-item .sub-light { display: none; }
html[data-theme="dark"] .overflow-item .lbl-dark,
html[data-theme="dark"] .overflow-item .sub-dark  { display: inline; }
/* The .ic in the theme row shows the icon for the theme you'd switch TO:
   sun appears in dark mode (= "switch to light"), moon in light mode. */
.overflow-item .ic .ic-moon { display: inline-block; }
.overflow-item .ic .ic-sun  { display: none; }
html[data-theme="dark"] .overflow-item .ic .ic-moon { display: none; }
html[data-theme="dark"] .overflow-item .ic .ic-sun  { display: inline-block; }

/* ============================================================
   PILL SYSTEM — used by AR / Medir / Theme / Compartilhar
   All four chrome controls share this primitive. 36px floor.
   ============================================================ */
.pill {
  height: 36px;
  min-width: 36px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid var(--w-rule-strong);
  background: transparent;
  color: var(--w-ink);
  font-family: var(--font-text);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.pill[hidden] { display: none; }
.pill svg { width: 17px; height: 17px; flex-shrink: 0; }
.pill.icon-only { padding: 0; width: 36px; }

/* Theme-toggle icon swap — pure CSS, no JS needed. Sun shows in light,
   moon in dark. Avoids the "both icons render briefly" overlap glitch. */
.theme-toggle .ic-moon { display: none; }
html[data-theme="dark"] .theme-toggle .ic-sun { display: none; }
html[data-theme="dark"] .theme-toggle .ic-moon { display: inline-block; }
.pill:hover { background: var(--w-soft); }
.pill.active,
.pill[aria-expanded="true"] {
  background: var(--w-ink);
  color: var(--w-base);
  border-color: var(--w-ink);
}
.pill.primary {
  background: var(--w-ink);
  color: var(--w-base);
  border-color: var(--w-ink);
  font-weight: 600;
  padding: 0 16px;
}
.pill.primary:hover {
  background: var(--w-ink-2);
  border-color: var(--w-ink-2);
}

/* AR pill specifics — visibility is driven by ar.js via data-visible.
   .pill base hides via [hidden]; here we layer [data-visible="false"]
   to also hide. data-loading dims with a wait cursor. */
.ar-button { color: var(--w-accent); border-color: var(--w-accent); }
.ar-button:hover {
  background: var(--w-accent);
  color: var(--w-base);
  border-color: var(--w-accent);
}
.ar-button[data-visible="false"] { display: none; }
.ar-button[data-loading="true"] { opacity: 0.65; cursor: progress; }

/* Measurement pill — same shape; coral active state when popover open. */
.measure-fab[data-state="placing-p1"],
.measure-fab[data-state="placing-p2"],
.measure-fab[data-state="result"] { display: none !important; }

/* ============================================================
   STAGE — paper-gray canvas surround with a soft top vignette
   ============================================================ */
.vw-stage {
  grid-area: stage;
  position: relative;
  background: var(--w-canvas-bg);
  overflow: hidden;
}
.vw-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(120% 60% at 50% 0%, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0) 60%);
}

/* ============================================================
   ZOOM CHIP — floats top-left of stage
   ============================================================ */
.vw-zoom {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--w-pill-bg);
  backdrop-filter: var(--w-pill-blur);
  -webkit-backdrop-filter: var(--w-pill-blur);
  border: 1px solid var(--w-rule-strong);
  border-radius: 12px;
}
.vw-zoom-btn {
  width: 28px; height: 28px;
  border: 0;
  background: transparent;
  color: var(--w-ink-2);
  cursor: pointer;
  border-radius: 6px;
  display: grid; place-items: center;
}
.vw-zoom-btn:hover { background: var(--w-muted-fill); color: var(--w-ink); }
.vw-zoom-btn svg { width: 14px; height: 14px; }
.vw-zoom-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--w-ink);
  font-weight: 500;
  padding: 0 8px;
}
@media (max-width: 768px) { .vw-zoom { display: none; } }

/* ============================================================
   RIGHT PANEL — slot for #structures-panel on desktop;
   collapses to bottom-sheet on mobile (the .panel rule lives
   in the legacy Structures Panel block below).
   ============================================================ */
.vw-right {
  grid-area: right;
  border-left: 1px solid var(--w-rule);
  overflow: hidden;
  background: var(--w-base);
  position: relative;
}

/* ============================================================
   STRUCTURES PANEL (preserved selectors — restyled in place)
   Desktop ≥769px: lives inside .vw-right.
   Mobile <769px: position:fixed bottom sheet.
   ============================================================ */
.panel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: 100%;
  overflow-y: auto;
  padding: 0;
  border-radius: 0;
  background: var(--w-base);
  color: var(--w-ink);
  z-index: 1;
}

.panel-title {
  font-family: var(--font-text);
  font-weight: 600;
  font-size: 14px;
  margin: 0;
  padding: 20px var(--space-5) 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  letter-spacing: -0.005em;
}
.panel-count {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--w-ink-3);
}

.panel ul { list-style: none; }

.panel li {
  position: relative;
  padding: 12px 16px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--w-rule);
}
.panel li::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 12px;
  bottom: 14px;
  width: 3px;
  border-radius: 2px;
  background: var(--struct-color, transparent);
}

.structure-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.opacity-row { display: block; }

/* Slider — hairline track, ink thumb */
.opacity-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  margin: 0;
  padding: 0;
}
@media (hover: hover) and (pointer: fine) { .opacity-slider { height: 18px; } }
.opacity-slider::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--w-track-dim);
  border-radius: 1px;
}
.opacity-slider::-moz-range-track {
  height: 2px;
  background: var(--w-track-dim);
  border-radius: 1px;
}
.opacity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--w-ink);
  border: 2px solid var(--w-base);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  margin-top: -6px;
  cursor: pointer;
}
.opacity-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--w-ink);
  border: 2px solid var(--w-base);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  cursor: pointer;
}

.structure-name {
  font-family: var(--font-text);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--w-ink);
  letter-spacing: -0.005em;
  flex: 1;
}

.eye-toggle {
  background: transparent;
  border: 1px solid var(--w-rule);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, border-color 0.15s;
  color: var(--w-ink);
}
.eye-toggle:hover { background: var(--w-soft); border-color: var(--w-rule-strong); }
.eye-toggle img {
  width: 16px;
  height: 16px;
}
/* In dark theme the eye icon source is dark; invert to render as foreground. */
html[data-theme="dark"] .eye-toggle img { filter: invert(1); }

/* Loading / error overlays */
.overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 16px 24px;
  border-radius: 8px;
  background: var(--w-base);
  color: var(--w-ink);
  font-size: 14px;
  text-align: center;
  max-width: 80vw;
  border: 1px solid var(--w-rule-strong);
  box-shadow: 0 12px 32px -12px rgba(21,23,26,0.20);
  z-index: 100;
}
.overlay.error {
  border-color: var(--signal-err);
  color: var(--signal-err);
}

/* ============================================================
   MOBILE BOTTOM SHEET (≤768px) — keeps the existing JS contract
   ============================================================ */
@media (max-width: 768px) {
  .vw-right { display: contents; }
  .panel {
    position: fixed;
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: var(--panel-height, 30vh);
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px -4px rgba(21,23,26,0.12);
    transition: height 0.25s ease-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: rgba(255,255,255,0.85);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    border-top: 1px solid var(--w-rule-strong);
    z-index: 40;
  }
  html[data-theme="dark"] .panel {
    background-color: rgba(11,14,17,0.72);
  }
  .panel.is-dragging { transition: none; }
  .panel-handle {
    flex: 0 0 auto;
    height: 22px;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    user-select: none;
  }
  .panel-handle:active { cursor: grabbing; }
  .panel-handle::before {
    content: "";
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: rgba(21,23,26,0.22);
  }
  html[data-theme="dark"] .panel-handle::before {
    background: rgba(242,243,244,0.28);
  }
  .panel-title { flex: 0 0 auto; padding: 4px 18px 10px; border-bottom: 1px solid var(--w-rule); }
  .panel ul { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; }
}
@media (min-width: 769px) { .panel-handle { display: none; } }

/* ============================================================
   MEASUREMENT — selectors preserved, colors flipped to coral
   ============================================================ */

.measurement-pill {
  background: var(--w-accent, #C8412C);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 4px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(21,23,26,0.30);
  pointer-events: none;
  user-select: none;
  transform: translate(-50%, -50%);
  position: relative;
}

/* Volume non-manifold warning — gold #ffb000 reads on both light and
   dark canvas without needing two values. */
.measurement-pill[data-warn="true"] {
  background: #ffb000;
  color: #15171A;
}
.measurement-pill[data-warn="true"]::after {
  content: " ⚠";
  font-size: 0.9em;
  margin-left: 4px;
}

.measurement-endpoint-label {
  background: var(--w-ink);
  color: var(--w-accent, #C8412C);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--w-accent, #C8412C);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  transform: translate(8px, calc(-100% - 4px));
}

/* Hint banner (top-center). HUD-style: dark over the canvas regardless
   of theme — reads through the model's brighter passages. */
.measure-hint {
  position: fixed;
  top: 70px;   /* below the 56px top bar + 14px */
  left: 50%;
  transform: translateX(-50%);
  background: var(--w-hud-bg);
  color: var(--w-hud-fg);
  font-family: var(--font-text);
  font-weight: 500;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 999px;
  pointer-events: none;
  z-index: 49;
  white-space: nowrap;
  border: 1px solid var(--w-hud-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.measure-hint[hidden] { display: none; }

/* Mini-toolbar bottom-center (confirm row / result row). */
.measure-toolbar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 1000;
}
.measure-toolbar[hidden] { display: none; }
@media (max-width: 768px) {
  .measure-toolbar {
    bottom: calc(30vh + 16px);
    width: calc(100% - 16px);
    max-width: 480px;
  }
  .measure-toolbar button { flex: 1; justify-content: center; }
}
.measure-toolbar button {
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  font-family: var(--font-text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.measure-toolbar .btn-primary {
  background: var(--w-accent, #C8412C);
  color: #fff;
  border-color: var(--w-accent, #C8412C);
  box-shadow: 0 6px 16px -4px rgba(200,65,44,0.40);
}
.measure-toolbar .btn-primary:hover {
  background: var(--accent-hover, #A8341F);
  border-color: var(--accent-hover, #A8341F);
}
.measure-toolbar .btn-secondary {
  background: var(--w-hud-bg);
  color: var(--w-hud-fg);
  border-color: var(--w-hud-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.measure-toolbar .btn-secondary:hover { border-color: #fff; }

/* Lupa */
.measure-loupe {
  position: fixed;
  width: 100px;
  height: 100px;
  pointer-events: none;
  z-index: 52;
  transform: translate(-50%, -100%);
  display: none;
}
.measure-loupe[data-visible="true"] { display: block; }
.measure-loupe[data-flip="below"] { transform: translate(-50%, 0); }
.measure-loupe-frame {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid #fff;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(21,23,26,0.40);
  background: rgba(11,14,17,0.42);
  position: relative;
}
.measure-loupe-canvas { display: block; width: 100%; height: 100%; }
.measure-loupe-crosshair {
  position: absolute;
  left: 50%; top: 50%;
  width: 24px; height: 24px;
  transform: translate(-50%, -50%);
}
.measure-loupe-crosshair::before,
.measure-loupe-crosshair::after {
  content: "";
  position: absolute;
  background: var(--w-accent, #C8412C);
}
.measure-loupe-crosshair::before { left: 50%; top: 0; width: 1.5px; height: 100%; transform: translateX(-50%); }
.measure-loupe-crosshair::after  { top: 50%; left: 0; height: 1.5px; width: 100%; transform: translateY(-50%); }
.measure-loupe-tail {
  position: absolute;
  width: 0; height: 0;
  left: 50%;
  bottom: -14px;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 14px solid #fff;
}
.measure-loupe[data-flip="below"] .measure-loupe-tail {
  bottom: auto;
  top: -14px;
  border-top: none;
  border-bottom: 14px solid #fff;
}
.measure-loupe-label {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(11,14,17,0.82);
  color: #fff;
  font-size: 9px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
}
.measure-loupe-label[hidden] { display: none; }

/* Measure menu — popover anchored to the Medir pill in the top bar.
   main.js positions it on open; CSS handles the visual treatment. */
.measure-menu {
  position: fixed;
  z-index: 1000;
  width: 208px;
  background: var(--w-menu-bg);
  border: 1px solid var(--w-rule-strong);
  border-radius: 12px;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 24px 48px -16px rgba(0,0,0,0.18);
  overflow: hidden;
  display: none;
}
.measure-menu[data-open="true"] { display: block; }
.measure-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--w-ink);
  text-align: left;
  font-family: inherit;
}
.measure-menu-item + .measure-menu-item { border-top: 1px solid var(--w-rule); }
.measure-menu-item:hover { background: var(--w-soft); }
.measure-menu-item .ic {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--w-muted-fill);
  border: 1px solid var(--w-rule);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--w-ink-2);
}
.measure-menu-item .ic svg { width: 18px; height: 18px; }
.measure-menu-item .lbl { flex: 1; }
.measure-menu-item .lbl .l1 {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--w-ink);
}
.measure-menu-item .lbl .l2 {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--w-ink-3);
  margin-top: 2px;
}

/* ============================================================
   AR root — model-viewer lives off-screen
   ============================================================ */
.ar-root {
  position: fixed;
  left: -9999px;
  top: -9999px;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
}

/* ============================================================
   AR modal — QR code dialog (desktop)
   ============================================================ */
.ar-modal {
  position: fixed;
  inset: 0;
  background: rgba(11,14,17,0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.ar-modal[data-visible="true"] { display: flex; }
.ar-modal-content {
  background: var(--w-base);
  border-radius: 12px;
  padding: 28px 24px 22px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  position: relative;
  font-family: var(--font-text);
  color: var(--w-ink);
  box-shadow: 0 24px 60px -16px rgba(21,23,26,0.40);
  border: 1px solid var(--w-rule);
}
.ar-modal-close {
  position: absolute;
  top: 6px;
  right: 12px;
  background: none;
  border: none;
  color: var(--w-ink);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}
.ar-modal-close:hover { color: var(--w-accent, #C8412C); }
.ar-modal-qr {
  margin: 8px auto 14px;
  width: 240px;
  height: 240px;
  background: #fff;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--w-rule);
}
.ar-modal-qr img { width: 100%; height: 100%; display: block; }
.ar-modal p {
  font-family: var(--font-text);
  font-size: 14px;
  margin: 0;
  line-height: 1.4;
  color: var(--w-ink-2);
}

/* ============================================================
   SHARE MODAL — opens via [data-action="share"] in the top bar
   ============================================================ */
.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(11,14,17,0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: vw-scrim-in 160ms ease-out;
}
.modal-scrim[hidden] { display: none; }
@keyframes vw-scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes vw-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal {
  width: min(520px, calc(100vw - 48px));
  background: var(--w-base);
  color: var(--w-ink);
  border: 1px solid var(--w-rule-strong);
  border-radius: 14px;
  box-shadow: 0 24px 64px -16px rgba(0,0,0,0.32), 0 4px 12px -4px rgba(0,0,0,0.12);
  overflow: hidden;
  animation: vw-modal-in 220ms cubic-bezier(0.16,1,0.3,1);
}
.modal-h {
  padding: 20px 24px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--w-rule);
}
.modal-ttl {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
  color: var(--w-ink);
}
.modal-sub {
  font-family: var(--font-text);
  font-size: 13px;
  color: var(--w-ink-3);
  line-height: 1.4;
}
.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--w-rule);
  background: transparent;
  color: var(--w-ink-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 120ms;
}
.modal-close:hover { background: var(--w-soft); color: var(--w-ink); }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 18px; }
.modal-field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--w-ink-3);
  font-weight: 500;
  margin-bottom: 8px;
  display: block;
}
.link-row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--w-rule-strong);
  border-radius: 8px;
  overflow: hidden;
}
.link-input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 0 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--w-ink);
  letter-spacing: 0;
  outline: none;
  min-width: 0;
  height: 40px;
}
.link-copy {
  border: 0;
  border-left: 1px solid var(--w-rule);
  background: var(--w-soft);
  padding: 0 14px;
  font-family: var(--font-text);
  font-weight: 500;
  font-size: 12px;
  color: var(--w-ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 120ms;
}
.link-copy:hover { background: var(--w-recess); }
.link-copy.ok { background: var(--w-ink); color: var(--w-base); }
.link-copy svg { width: 13px; height: 13px; }
