/* ══════════════════════════════════════════════════════════
   SmartGenPlan Publish Runtime — Dark Theme
   Pixel-perfect replica of editor canvas preview
   ══════════════════════════════════════════════════════════ */

/* ── Inter font (local, no Google dependency) ── */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/inter-cyrillic-400-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/inter-cyrillic-500-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/inter-cyrillic-600-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/inter-cyrillic-700-normal.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/inter-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/inter-latin-500-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/inter-latin-600-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/inter-latin-700-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: dark;
  --publish-radius-xl: 4px 12px 4px 12px;
  --publish-radius-lg: 3px 8px 3px 8px;
  --publish-radius-md: 2px 6px 2px 6px;
  --publish-panel: rgba(15, 23, 42, 0.92);
  --publish-panel-strong: rgba(15, 23, 42, 0.98);
  --publish-ink: #ecfeff;
  --publish-muted: rgba(148, 163, 184, 0.7);
  --publish-line: rgba(255, 255, 255, 0.12);
  --publish-accent: #06B6D4;
  font-family: 'Inter', 'Segoe UI', 'Helvetica Neue', system-ui, sans-serif;
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: #0f172a;
  color: var(--publish-ink);
  -webkit-user-select: none;
  user-select: none;
}

button, input, textarea, select { font: inherit; }

/* ── Layout: full viewport ── */

.publish-root {
  min-height: 100vh;
  padding: 0;
}

.publish-frame {
  display: grid;
  gap: 0;
  max-width: none;
  margin: 0;
}

/* ── Status pages (blocked / empty) ── */

.publish-status-surface {
  max-width: 680px;
  margin: clamp(40px, 10vh, 120px) auto;
  padding: clamp(22px, 4vw, 34px);
  background: var(--publish-panel);
  border: 1px solid var(--publish-line);
  border-radius: var(--publish-radius-xl);
  backdrop-filter: blur(12px);
}

.publish-status-surface h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.04;
}

.publish-status-surface p {
  margin: 0;
  color: var(--publish-muted);
  font-size: 16px;
  line-height: 1.55;
}

.publish-status-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.publish-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--publish-line);
  border-radius: var(--publish-radius-md);
  background: rgba(255, 255, 255, 0.06);
  color: var(--publish-ink);
  font-size: 13px;
}

.publish-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: var(--publish-radius-md);
  background: currentColor;
}

.publish-chip[data-tone="blocked"] { color: #ef4444; }
.publish-chip[data-tone="empty"]   { color: #f59e0b; }
.publish-chip[data-tone="ready"]   { color: #22c55e; }

/* ── Stage card (map container) ── */

.publish-stage-card {
  display: grid;
  gap: 0;
  min-height: 100vh;
}

.publish-stage-header {
  display: none;
}

.publish-stage-shell {
  position: relative;
  overflow: hidden;
  background: #0f172a;
  max-height: 100vh;
  margin: 0 auto;
}

.publish-stage-shell::before {
  content: "";
  display: block;
  width: 100%;
  padding-top: calc(100% / var(--publish-stage-aspect, 1.6));
}

/* Constrain width so map fits viewport height */
@supports (aspect-ratio: 1) {
  .publish-stage-shell {
    aspect-ratio: var(--publish-stage-aspect, 1.6);
    max-height: 100vh;
    max-width: min(100%, calc(100vh * var(--publish-stage-aspect, 1.6)));
    margin: 0 auto;
  }
  .publish-stage-shell::before {
    display: none;
  }
}

/* ── Viewport layers (absolute fill) ── */

.publish-stage-viewport,
.publish-stage-scene,
.publish-stage-overlay,
.publish-stage-svg {
  position: absolute;
  inset: 0;
}

.publish-stage-viewport {
  overflow: hidden;
  touch-action: none;
}

.publish-stage-viewport[data-dragging="true"]  { cursor: grabbing; }
.publish-stage-viewport[data-dragging="false"] { cursor: grab; }

.publish-stage-scene { border-radius: inherit; }

.publish-stage-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ── Plots ── */

.publish-plot-label {
  font-family: 'Inter', 'SF Pro Display', system-ui, sans-serif;
  font-weight: 700;
  fill: #d7e4f7;
  paint-order: stroke;
  stroke: rgba(15, 23, 42, 0.55);
  stroke-width: 0.5;
  letter-spacing: 0.01em;
  pointer-events: none;
}

.publish-plot,
.publish-infra-polygon {
  outline: none;
}

.publish-plot {
  cursor: pointer;
  stroke-linejoin: round;
  transition: opacity 140ms ease, fill 140ms ease, stroke 140ms ease, filter 140ms ease, stroke-width 140ms ease;
}

.publish-plot[data-publish-filter-match="inactive"] {
  opacity: 0.28;
}

.publish-plot[data-publish-hover="true"],
.publish-plot[data-publish-focus="true"],
.publish-plot[data-publish-popup-open="true"] {
  stroke-width: 3.4;
}

/* ── Plot hover animations ── */

@keyframes publishBadgeFlyToTop {
  0%   { left: var(--from-x, 50%); top: var(--from-y, 50%); transform: translate(-50%, -100%) scale(0.7); opacity: 0; }
  100% { left: 50%; top: 8px; transform: translate(-50%, 0) scale(1); opacity: 1; }
}

@keyframes publishBadgeFlyAway {
  0%   { left: 50%; top: 8px; transform: translate(-50%, 0) scale(1); opacity: 1; }
  100% { left: 50%; top: -20px; transform: translate(-50%, 0) scale(0.9); opacity: 0; }
}

@keyframes publishGlowPulse {
  0%   { opacity: 0; stroke-width: 3; }
  40%  { opacity: 0.72; stroke-width: 16; }
  100% { opacity: 0.4; stroke-width: 10; }
}

@keyframes publishSonarPing {
  0%   { r: 0; opacity: 0.85; stroke-width: 4; }
  100% { r: 58; opacity: 0; stroke-width: 0.5; }
}

@keyframes publishFillFlash {
  0%   { fill-opacity: 0.4; }
  30%  { fill-opacity: 0.94; }
  100% {}
}

.publish-badge-host {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
}

.publish-plot-badge {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translate(-50%, 0);
  pointer-events: none;
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 4px 12px 4px 12px;
  color: #ecfeff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: publishBadgeFlyToTop 250ms ease-out both;
}

.publish-plot-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.publish-plot-badge--leaving {
  animation: publishBadgeFlyAway 250ms ease-in forwards;
  backdrop-filter: none;
}

.publish-infra-badge {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translate(-50%, 0);
  pointer-events: none;
  padding: 6px 14px;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 4px 12px 4px 12px;
  color: #ecfeff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: publishBadgeFlyToTop 250ms ease-out both;
}

.publish-infra-badge svg {
  flex-shrink: 0;
  shape-rendering: geometricPrecision;
}

.publish-infra-badge--leaving {
  animation: publishBadgeFlyAway 250ms ease-in forwards;
  backdrop-filter: none;
}

.publish-plot-glow {
  fill: none;
  pointer-events: none;
  opacity: 0;
  filter: blur(4px);
}

.publish-plot-glow[data-glow-active="true"] {
  animation: publishGlowPulse 500ms ease-out forwards;
}

.publish-plot-glow[data-glow-leaving="true"] {
  animation: publishGlowFadeout 350ms ease-in forwards;
}

@keyframes publishGlowFadeout {
  0%   { opacity: 0.4; stroke-width: 10; }
  100% { opacity: 0; stroke-width: 3; }
}

.publish-plot-sonar {
  fill: none;
  pointer-events: none;
  opacity: 0;
}

.publish-plot-sonar[data-sonar-active="true"] {
  animation: publishSonarPing 700ms ease-out forwards;
}

.publish-plot[data-publish-hover="true"] {
  animation: publishFillFlash 350ms ease-out;
}

/* Suppress hover effects during zoom animation */
[data-zooming="true"] .publish-plot-glow {
  filter: none !important;
  opacity: 0 !important;
  animation: none !important;
}
[data-zooming="true"] .publish-plot-sonar {
  opacity: 0 !important;
  animation: none !important;
}
[data-zooming="true"] .publish-plot[data-publish-hover="true"] {
  animation: none !important;
}

.publish-plot[data-publish-leaving="true"] {
  animation: publishFillFadeout 300ms ease-in forwards;
}

@keyframes publishFillFadeout {
  0%   { fill-opacity: 0.45; }
  100% {}
}

.publish-boundary {
  fill: none;
  stroke-linecap: round;
}

/* Path label counter-scaling transition (smooth after zoom) */
[data-publish-path-label-layer] text {
  transition: font-size 180ms ease, stroke-width 180ms ease, letter-spacing 180ms ease;
}

/* ── Overlay (positioned on top of map) ── */

.publish-stage-overlay {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
}

.publish-overlay-aside {
  margin-left: auto;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

/* ── Project name chip (top-left) — matches editor .plots-stage-overlay-chip ── */

.publish-project-name {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--publish-radius-lg);
  backdrop-filter: blur(8px);
  color: #f0e8d8;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Viewport tools (fullscreen + zoom hint) ── */

.publish-viewport-tools {
  display: grid;
  justify-items: end;
  gap: 10px;
  width: min(100%, 320px);
}

.publish-fullscreen-control {
  position: absolute;
  top: 42px;
  right: 8px;
  z-index: 10;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--publish-radius-md);
  background: rgba(15, 23, 42, 0.7);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 150ms, color 150ms;
}

.publish-fullscreen-control:hover:not(:disabled) {
  background: rgba(15, 23, 42, 0.9);
  color: rgba(255, 255, 255, 0.95);
}

.publish-fullscreen-control[data-publish-fullscreen-state="active"] {
  background: rgba(28, 105, 74, 0.76);
  color: rgba(255, 255, 255, 0.9);
}

.publish-fullscreen-control:disabled {
  cursor: default;
  opacity: 0.72;
}

.publish-zoom-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
  padding: 4px 12px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--publish-radius-lg);
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}

/* ── SEO link (bottom-left watermark) ── */

.publish-seo-link {
  position: absolute;
  bottom: 4px;
  left: 12px;
  z-index: 10;
  font-size: 10px;
  color: rgba(148, 163, 184, 0.35);
  text-decoration: none;
  pointer-events: auto;
}

.publish-seo-link:hover {
  color: rgba(148, 163, 184, 0.6);
}

/* ── Infra tooltip (dark, on hover) ── */

.publish-infra-tooltip-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.publish-infra-tooltip-anchor {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
  anchor-name: --infra-tooltip-target;
}

.publish-infra-tooltip {
  position: absolute;
  left: clamp(16px, var(--publish-infra-tooltip-x, 50%), calc(100% - 16px));
  top: clamp(16px, var(--publish-infra-tooltip-y, 50%), calc(100% - 16px));
  display: none;
  gap: 4px;
  max-width: min(220px, calc(100% - 32px));
  padding: 6px 14px;
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 4px 10px 4px 10px;
  background: rgba(15, 23, 42, 0.92);
  color: #ecfeff;
  font-size: 12px;
  font-weight: 600;
  transform: translate(-50%, calc(-100% - 18px));
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.publish-infra-tooltip[data-publish-infra-tooltip-state="open"] {
  display: grid;
}

.publish-infra-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 14px;
  height: 14px;
  background: rgba(15, 23, 42, 0.92);
  border-right: 1px solid rgba(34, 197, 94, 0.25);
  border-bottom: 1px solid rgba(34, 197, 94, 0.25);
  transform: translateX(-50%) rotate(45deg);
}

@supports (anchor-name: --a) {
  .publish-infra-tooltip {
    inset: auto;
    bottom: anchor(top);
    justify-self: anchor-center;
    transform: none;
    translate: none;
    margin: 8px;
    position-anchor: --infra-tooltip-target;
    position-try-fallbacks: flip-block;
    position-try-order: most-block-size;
    position-visibility: always;
  }

  .publish-infra-tooltip::after { display: none; }
}

.publish-infra-tooltip-type {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.7);
  font-weight: 400;
}

.publish-infra-tooltip-title {
  font-size: 14px;
  line-height: 1.3;
}

/* ── Plot popup — matches editor .editor-plot-popup ── */

.publish-popup-host {
  position: absolute;
  left: 16px;
  bottom: 48px;
  width: min(calc(100% - 32px), 280px);
  pointer-events: none;
  z-index: 30;
}

.publish-popup-anchor {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
  anchor-name: --popup-target;
}

.publish-popup-host--floating {
  left: clamp(16px, var(--popup-x, 50%), calc(100% - 16px));
  top: clamp(16px, var(--popup-y, 50%), calc(100% - 16px));
  bottom: auto;
  width: min(calc(100% - 32px), 280px);
  transform: translate(-50%, calc(-100% - 12px));
}

.publish-popup-host--floating .publish-popup {
  animation: publishPopupFloatIn 200ms ease both;
}

@keyframes publishPopupFloatIn {
  0%   { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

@supports (anchor-name: --a) {
  @position-try --publish-popup-below {
    inset: auto;
    top: anchor(bottom);
    margin-top: 32px;
    justify-self: anchor-center;
  }

  .publish-popup-host--floating {
    inset: auto;
    bottom: anchor(top);
    justify-self: anchor-center;
    transform: none;
    translate: none;
    margin: 16px;
    position-anchor: --popup-target;
    position-try-fallbacks: --publish-popup-below;
    position-visibility: always;
  }
}

.publish-popup {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: var(--publish-radius-xl);
  color: #ecfeff;
  font-size: 13px;
  line-height: 1.4;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
}

.publish-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.publish-popup-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 8px;
}

.publish-popup-title svg {
  flex-shrink: 0;
  shape-rendering: geometricPrecision;
}

.publish-popup-infra-desc {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 400;
  color: #94a3b8;
  line-height: 1.4;
  white-space: pre-wrap;
}

.publish-popup-close {
  background: none;
  border: none;
  color: rgba(148, 163, 184, 0.7);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  transition: color 150ms;
}

.publish-popup-close:hover { color: #ecfeff; }

.publish-popup-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.publish-popup[data-publish-popup-target-kind="plot"] .publish-popup-body:not(:empty) {
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  padding-top: 8px;
  margin-top: 8px;
}

.publish-popup-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.publish-popup-label {
  color: rgba(148, 163, 184, 0.8);
  font-size: 12px;
}

.publish-popup-value {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}

.publish-popup-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
  padding: 5px 10px;
  border: none;
  border-radius: var(--publish-radius-md);
  background: rgba(6, 182, 212, 0.12);
  color: #22d3ee;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 150ms;
}

.publish-popup-action:hover { background: rgba(6, 182, 212, 0.22); }

/* ── Legend — matches editor .plots-stage-legend ── */

.publish-legend {
  position: absolute;
  bottom: 42px;
  right: 8px;
  z-index: 12;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--publish-radius-lg);
  font-size: 11px;
}

.publish-legend-header { display: none; }
.publish-legend-toggle { display: none; }

.publish-legend-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.publish-legend-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
  line-height: 1.4;
  transition: opacity 140ms;
}

.publish-legend-entry:disabled { cursor: default; }

.publish-legend-entry[data-publish-legend-active="true"] { color: #fff; }

.publish-legend-entry-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.publish-legend-entry-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--publish-legend-tone, var(--publish-accent));
  flex-shrink: 0;
}

.publish-legend-entry-label {
  white-space: nowrap;
  text-align: left;
}

.publish-legend-entry-count {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  font-size: 10px;
  min-width: 14px;
  text-align: right;
}

/* ── Infrastructure catalog panel ── */

.publish-infra-catalog {
  position: absolute;
  bottom: 42px;
  right: 8px;
  z-index: 12;
  display: none;
  flex-direction: column;
  gap: 1px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--publish-radius-lg);
  padding: 6px 8px;
  pointer-events: auto;
}

.publish-infra-catalog-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 6px;
  border-radius: 2px 6px 2px 6px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
  white-space: nowrap;
  border: none;
  background: transparent;
  font-family: inherit;
}

.publish-infra-catalog-row:hover,
.publish-infra-catalog-row[data-active="true"] {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.9);
}

.publish-infra-catalog-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Bottom-right controls — matches editor .plots-stage-bottom-right-controls ── */

.publish-bottom-right-controls {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: auto;
}

.publish-overlay-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--publish-radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: color 120ms, border-color 120ms, background 120ms;
  position: relative;
  padding: 0;
}

.publish-overlay-btn:hover {
  color: rgba(255, 255, 255, 0.7);
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.6);
}

.publish-overlay-btn--active {
  color: rgba(255, 247, 232, 0.8);
  border-color: rgba(255, 247, 232, 0.3);
}

.publish-overlay-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  z-index: 20;
  padding: 4px 8px;
  border-radius: var(--publish-radius-md);
  background: rgba(0, 0, 0, 0.85);
  color: #e5e7eb;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms;
}

.publish-overlay-btn:hover::after {
  opacity: 1;
}

:fullscreen .publish-bottom-right-controls { bottom: 16px; right: 16px; }

/* ── Scale bar — matches editor .plots-stage-scale-bar ── */

.publish-scale-bar {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  pointer-events: none;
  z-index: 2;
}

.publish-scale-bar-line {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 2px 4px 2px 4px;
  border-left: 2px solid rgba(255, 255, 255, 0.9);
  border-right: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.publish-scale-bar-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

/* ── Infrastructure polygons ── */

.publish-infra-polygon {
  transition: fill-opacity 0.35s ease;
  pointer-events: all;
}

.publish-infra-discharge {
  transition: stroke-opacity 0.3s ease;
  pointer-events: none;
}

.publish-infra-discharge[data-discharge-active="true"] {
  animation: publishInfraDischarge 1.2s ease-out forwards;
}

@keyframes publishInfraDischarge {
  0%   { stroke-dashoffset: var(--discharge-perimeter); stroke-opacity: 0.9; }
  100% { stroke-dashoffset: 0; stroke-opacity: 0.3; }
}

/* ── Stack layer dropdown ── */

.publish-layer-dropdown {
  position: relative;
  margin-bottom: 6px;
}

.publish-layer-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--publish-panel);
  border: 1px solid var(--publish-line);
  border-radius: var(--publish-radius-md);
  color: var(--publish-ink);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s;
}

.publish-layer-trigger:hover { border-color: var(--publish-accent); }

.publish-layer-trigger-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.publish-layer-trigger-chevron {
  opacity: 0.4;
  font-size: 10px;
}

.publish-layer-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 160px;
  max-width: 240px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--publish-panel-strong);
  border: 1px solid var(--publish-line);
  border-radius: var(--publish-radius-md);
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 20;
}

.publish-layer-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  background: none;
  border: none;
  border-radius: var(--publish-radius-md);
  color: var(--publish-muted);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}

.publish-layer-item:hover { background: rgba(255, 255, 255, 0.05); }

.publish-layer-item[data-active="true"] {
  background: rgba(6, 182, 212, 0.08);
  color: var(--publish-accent);
  font-weight: 600;
  cursor: default;
}

.publish-layer-item-index {
  color: var(--publish-muted);
  font-size: 10px;
  width: 16px;
  flex-shrink: 0;
  opacity: 0.6;
}

.publish-layer-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Stack layer spinner ── */

.publish-layer-spinner {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.85);
}

.publish-layer-spinner-ring {
  width: 32px;
  height: 32px;
  border: 3px solid var(--publish-line);
  border-top-color: var(--publish-accent);
  border-radius: 50%;
  animation: publishLayerSpin 0.7s linear infinite;
}

@keyframes publishLayerSpin {
  to { transform: rotate(360deg); }
}

/* ── Responsive (mobile) ── */

@media (max-width: 720px) {
  .publish-stage-overlay {
    padding: 10px;
  }

  .publish-overlay-aside {
    max-width: min(100%, 280px);
  }

  .publish-popup-host {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
  }

  .publish-popup-host--floating {
    right: auto;
    width: min(calc(100% - 20px), 280px);
  }

  .publish-zoom-hint {
    text-align: left;
  }

  .publish-legend-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border: 1px solid var(--publish-line);
    border-radius: var(--publish-radius-md);
    background: rgba(0, 0, 0, 0.45);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    font-size: 11px;
  }

  .publish-legend-header { display: flex; }

  .publish-legend[data-publish-compact-open="false"] .publish-legend-body {
    display: none;
  }
}

/* ── Fullscreen overrides ── */

:fullscreen .publish-stage-viewport {
  max-width: calc(100vh * var(--publish-stage-aspect, 1.6));
  max-height: 100vh;
  margin: 0 auto;
}
:fullscreen .publish-project-name { top: 16px; left: 16px; }
:fullscreen .publish-fullscreen-control { top: 50px; right: 16px; }
:fullscreen .publish-stage-overlay { padding: 16px; }
:fullscreen .publish-popup-host { bottom: 56px; left: 16px; }
:fullscreen .publish-scale-bar { bottom: 20px; left: 20px; }
:fullscreen .publish-zoom-hint { bottom: 16px; }
