* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #252538;
  --text-primary: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --accent: #6c63ff;
  --accent-hover: #5b54e6;
  --border: #27272a;
  --error: #ef4444;
  --success: #22c55e;
  --viewer-bg: #1a1a2e;
}

/* Light theme */
:root.light {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #e5e5e5;
  --text-primary: #1a1a1a;
  --text-secondary: #525252;
  --text-muted: #737373;
  --border: #d4d4d4;
  --viewer-bg: #ffffff;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

/* The tool fills exactly one viewport; the page does not scroll. */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.nav {
  display: flex;
  gap: 8px;
}

.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: var(--border);
  color: var(--text-primary);
}

/* Disabled buttons (e.g. Layers/Fit with no drawing loaded): greyed out, no hover,
   "this isn't clickable" cursor. :disabled:hover out-specifies .btn-secondary:hover. */
.btn:disabled,
.btn:disabled:hover {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* Viewer container */
.viewer-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#viewer {
  width: 100%;
  height: 100%;
  display: block;
}

.hidden {
  display: none !important;
}

/* Drop zone */
.drop-zone {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  cursor: pointer;
}

.drop-content {
  text-align: center;
  padding: 40px;
  border: 2px dashed var(--border);
  border-radius: 16px;
  transition: all 0.2s;
}

.drop-zone:hover .drop-content,
.drop-zone.drag-over .drop-content {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.05);
}

.drop-icon {
  color: var(--text-muted);
  margin-bottom: 16px;
}

.drop-content h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.drop-content p {
  color: var(--text-muted);
}

/* Loading */
.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(26, 26, 46, 0.95);
  z-index: 100;
}

:root.light .loading {
  background: rgba(255, 255, 255, 0.95);
}

:root.light .loading p,
:root.light #progressPercent {
  color: var(--text-secondary);
}

:root.light .spinner {
  border-color: var(--border);
  border-top-color: var(--accent);
}

:root.light .progress-bar {
  background: var(--border);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading p {
  margin-top: 16px;
  color: var(--text-secondary);
}

.progress-bar {
  width: 200px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  margin-top: 16px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.1s ease-out;
}

#progressPercent {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Status bar */
.status-bar {
  display: flex;
  gap: 24px;
  padding: 8px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.status-bar span:first-child {
  flex: 1;
}

/* Layers panel */
.layers-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 280px;
  height: 100%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.panel-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.btn-close:hover {
  color: var(--text-primary);
}

#layersList {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  list-style: none;
}

#layersList li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
}

#layersList li:hover {
  background: var(--bg-tertiary);
}

/* Error message */
.error-message {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
  max-width: 400px;
  z-index: 10;
}

/* Layer controls */
.layer-controls {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
}

.layer-item:hover {
  background: var(--bg-tertiary);
}

.layer-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.layer-item label {
  flex: 1;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* SEO: H1 in logo styled to look identical */
.logo h1 {
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
  padding: 0;
  display: inline;
  color: inherit;
  line-height: inherit;
}

/* Rating widget - floating card */
.rating-widget {
  position: fixed;
  bottom: 60px;
  right: 20px;
  z-index: 40;
  display: none;
}

.rating-widget.visible {
  display: block;
  animation: ratingFadeIn 0.4s ease forwards;
  transition: right 0.3s ease;
}

@keyframes ratingFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Shift left when layers panel is open - controlled by JS */

.rating-content {
  position: relative;
  background: linear-gradient(135deg, #2a2a42 0%, #1e1e32 100%);
  border: 1px solid rgba(108, 99, 255, 0.3);
  border-radius: 24px;
  padding: 24px 30px;
  text-align: center;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(108, 99, 255, 0.1);
  backdrop-filter: blur(8px);
}

.rating-text {
  font-size: 21px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 6px;
  text-shadow: 0 0 30px rgba(108, 99, 255, 0.5);
}

.rating-subtext {
  font-size: 18px;
  color: #a78bfa;
  margin-bottom: 18px;
}

.rating-stars {
  display: flex;
  flex-direction: row-reverse;
  justify-content: center;
  gap: 6px;
}

.rating-stars input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.rating-stars label {
  cursor: pointer;
  font-size: 42px;
  color: #4a4a5a;
  transition: color 0.2s, transform 0.2s, text-shadow 0.2s;
  line-height: 1;
}

.rating-stars label:hover,
.rating-stars label:hover ~ label {
  color: #ffc107;
  transform: scale(1.2);
  text-shadow: 0 0 12px rgba(255, 193, 7, 0.5);
}

/* Light theme adjustments */
:root.light .rating-content {
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.18), 0 0 0 1px rgba(99, 102, 241, 0.1);
}

:root.light .rating-text {
  color: #312e81;
  text-shadow: none;
}

:root.light .rating-subtext {
  color: #6366f1;
}

:root.light .rating-stars label {
  color: #c7d2fe;
}

/* Same specificity fix as the sidebar — keep the yellow hover/glow in light theme. */
:root.light .rating-stars label:hover,
:root.light .rating-stars label:hover ~ label {
  color: #ffc107;
  transform: scale(1.2);
  text-shadow: 0 0 12px rgba(255, 193, 7, 0.5);
}

/* Rating close button */
.rating-close {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  background: #3b3b5c;
  border: 2px solid #4a4a6a;
  border-radius: 50%;
  color: #ccc;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: background 0.2s, color 0.2s;
}

.rating-close:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}

:root.light .rating-close {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #64748b;
}

:root.light .rating-close:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
}

/* Mobile: compact rating widget */
@media (max-width: 768px) {
  .rating-widget {
    bottom: 16px;
    right: 12px;
    left: 12px;
  }

  .rating-content {
    padding: 16px 20px;
    border-radius: 16px;
  }

  .rating-text {
    font-size: 16px;
  }

  .rating-subtext {
    font-size: 14px;
    margin-bottom: 12px;
  }

  .rating-stars label {
    font-size: 32px;
  }

  .rating-close {
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    font-size: 12px;
  }
}

/* Sidebar rating row */
.sidebar-rating {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-rating-text {
  font-size: 12px;
  color: var(--text-muted);
}

.sidebar-rating-stars {
  display: flex;
  flex-direction: row-reverse;
  gap: 2px;
}

.sidebar-rating-stars input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.sidebar-rating-stars label {
  cursor: pointer;
  font-size: 18px;
  color: #4a4a5a;
  transition: color 0.15s, transform 0.15s;
  line-height: 1;
}

:root.light .sidebar-rating-stars label {
  color: #c7d2fe;
}

.sidebar-rating-stars label:hover,
.sidebar-rating-stars label:hover ~ label {
  color: #ffc107;
  transform: scale(1.15);
}

/* Light theme: the light base color above (:root.light …) out-specifies the shared
   :hover rule, so restate the hover with matching specificity — otherwise stars
   never light up yellow / animate in light theme (they do in dark). */
:root.light .sidebar-rating-stars label:hover,
:root.light .sidebar-rating-stars label:hover ~ label {
  color: #ffc107;
  transform: scale(1.15);
}

/* ── File-type / parse-error modal ─────────────────────────────────────────── */
.dxf-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 10, 20, 0.6);
  backdrop-filter: blur(6px);
  animation: dxfModalFade 0.2s ease;
}
.dxf-modal.hidden { display: none; }
@keyframes dxfModalFade { from { opacity: 0; } to { opacity: 1; } }

.dxf-modal__card {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: linear-gradient(135deg, #2a2a42 0%, #1e1e32 100%);
  border: 1px solid rgba(108, 99, 255, 0.3);
  border-radius: 20px;
  padding: 28px 26px 24px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(108, 99, 255, 0.1);
  text-align: center;
  animation: ratingFadeIn 0.3s ease;
}
.dxf-modal__x {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; color: var(--text-muted);
  font-size: 24px; line-height: 1; cursor: pointer; padding: 4px;
}
.dxf-modal__x:hover { color: #fff; }
.dxf-modal__icon { font-size: 44px; margin-bottom: 8px; }
.dxf-modal__title { font-size: 20px; font-weight: 700; color: #fff; margin: 0 0 8px; }
.dxf-modal__msg { font-size: 14px; color: var(--text-secondary); line-height: 1.55; margin: 0 0 16px; }
.dxf-modal__msg a { color: #a78bfa; }
.dxf-modal__msg b { color: #fff; font-weight: 600; }

.dxf-modal__intake {
  text-align: left;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(108, 99, 255, 0.18);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}
.dxf-modal__intake.hidden { display: none; }
.dxf-modal__intake-lead { font-size: 13px; color: var(--text-secondary); margin: 0 0 10px; }
.dxf-modal__intake-hint { font-size: 11px; color: var(--text-muted); line-height: 1.45; margin: 8px 0 0; }
.dxf-modal__input {
  width: 100%; box-sizing: border-box;
  background: var(--bg-primary); color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 10px;
  padding: 9px 11px; font-size: 13px; font-family: inherit; margin-bottom: 8px;
  resize: vertical;
}
.dxf-modal__input:focus { outline: none; border-color: var(--accent); }

.dxf-modal__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.dxf-modal__btn {
  appearance: none; cursor: pointer;
  background: var(--bg-tertiary); color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px;
  padding: 10px 18px; font-size: 14px; font-weight: 600; font-family: inherit;
  text-decoration: none; display: inline-block;
}
.dxf-modal__btn:hover { border-color: var(--accent); }
.dxf-modal__btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; width: 100%; }
.dxf-modal__btn--primary:hover { background: var(--accent-hover); }
.dxf-modal__btn--primary:disabled { opacity: 0.6; cursor: default; }
.dxf-modal__status { font-size: 13px; margin-top: 10px; min-height: 18px; color: var(--text-muted); }
.dxf-modal__status.ok { color: #4ade80; }
.dxf-modal__status.err { color: #f87171; }

/* Light theme — file/parse modal (mirrors the rating-content palette) */
:root.light .dxf-modal__card {
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 12px 48px rgba(99, 102, 241, 0.18), 0 0 0 1px rgba(99, 102, 241, 0.1);
}
:root.light .dxf-modal__title { color: #312e81; }
:root.light .dxf-modal__msg b { color: #312e81; }
:root.light .dxf-modal__msg a { color: #4f46e5; }
:root.light .dxf-modal__x:hover { color: #312e81; }
:root.light .dxf-modal__intake {
  background: rgba(99, 102, 241, 0.06);
  border-color: rgba(99, 102, 241, 0.2);
}
:root.light .dxf-modal__input { border-color: #cbd5e1; }
:root.light .dxf-modal__btn { border-color: #cbd5e1; }
:root.light .dxf-modal__status.ok { color: #16a34a; }
:root.light .dxf-modal__status.err { color: #dc2626; }

@media (max-width: 768px) {
  .dxf-modal { padding: 12px; }
  .dxf-modal__card { border-radius: 16px; padding: 22px 18px 18px; }
  .dxf-modal__title { font-size: 18px; }
  .dxf-modal__icon { font-size: 38px; }
}

/* ── Viewer tools: toolbar, export menu, toast (js/viewer-tools.js) ──────── */
.dxf-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.dxf-tool {
  font-size: 14px;
  line-height: 1;
}
.dxf-menu {
  position: relative;
  display: inline-block;
}
.dxf-menu__list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  display: none;
  z-index: 1200;
}
.dxf-menu.open .dxf-menu__list { display: block; }
.dxf-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text-primary);
  font-size: 14px;
  padding: 9px 12px;
  border-radius: 7px;
  cursor: pointer;
}
.dxf-menu__item:hover { background: var(--accent); color: #fff; }

.dxf-toast {
  position: fixed;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%) translateY(12px);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 4000;
}
.dxf-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.dxf-toast.err { border-color: var(--error); }
.dxf-toast.ok { border-color: var(--success); }

/* ── Vertical tool strip (left edge) ────────────────────────────────────── */
.dxf-strip {
  position: fixed;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  z-index: 1100;
}
.dxf-strip__sep { height: 1px; background: var(--border); margin: 2px 4px; }
.dxf-stripbtn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.dxf-stripbtn:hover:not(:disabled) { background: var(--border); }
.dxf-stripbtn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.dxf-stripbtn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Export flyout opens to the RIGHT of the strip */
.dxf-strip .dxf-menu__list {
  top: 0;
  left: calc(100% + 10px);
  right: auto;
}

/* ── Measure overlay ────────────────────────────────────────────────────── */
#dxfMeasureLayer {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none; /* never blocks the canvas — pan/zoom keep working while measuring */
}
body.dxf-measuring #viewerContainer { cursor: crosshair; }
.dxf-measure-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.dxf-measure-svg .m-line { stroke: #ffcc33; stroke-width: 1.5; stroke-dasharray: 6 4; }
.dxf-measure-svg .m-dot { fill: #ffcc33; stroke: #1a1a2e; stroke-width: 1; }
.dxf-measure-svg .m-cursor { fill: none; stroke: #ffcc33; stroke-width: 1.5; }
.dxf-measure-svg .m-snap { fill: none; stroke: #22c55e; stroke-width: 2; }
.dxf-measure-svg .m-lbl-bg { fill: #ffcc33; }
.dxf-measure-svg .m-lbl { fill: #1a1a2e; font: 600 12px -apple-system, Segoe UI, Roboto, sans-serif; }

/* ── Layers panel: filter + solo ────────────────────────────────────────── */
.layer-filter {
  width: calc(100% - 24px);
  margin: 8px 12px 4px;
  padding: 7px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px;
  box-sizing: border-box;
}
.layer-filter:focus { outline: none; border-color: var(--accent); }
.layer-item { position: relative; }
.layer-item .layer-solo {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s;
}
.layer-item:hover .layer-solo { opacity: 1; }
.layer-item .layer-solo:hover { color: var(--accent); }
.layer-item.soloed .layer-solo { opacity: 1; color: var(--accent); }

/* ── Find bar ───────────────────────────────────────────────────────────── */
.dxf-findbar {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  display: none;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 1300;
}
.dxf-findbar.open { display: flex; }
.dxf-find-input {
  width: 220px;
  padding: 7px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-primary);
  font-size: 14px;
}
.dxf-find-input:focus { outline: none; border-color: var(--accent); }
.dxf-find-count { color: var(--text-muted); font-size: 12px; min-width: 48px; text-align: center; }
.dxf-find-btn {
  width: 28px; height: 28px;
  background: transparent; border: 0; color: var(--text-primary);
  font-size: 18px; line-height: 1; cursor: pointer; border-radius: 6px;
}
.dxf-find-btn:hover { background: var(--border); }

#dxfFindMark {
  position: absolute;
  left: 50%; top: 50%;
  width: 60px; height: 60px;
  margin: -30px 0 0 -30px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  z-index: 60;
}
#dxfFindMark.pulse { animation: dxfFindPulse 1.1s ease-out; }
@keyframes dxfFindPulse {
  0% { opacity: 0.9; transform: scale(0.4); }
  100% { opacity: 0; transform: scale(1.6); }
}

/* ── Minimap ────────────────────────────────────────────────────────────── */
.dxf-minimap {
  position: fixed;
  right: 16px;
  bottom: 48px;
  display: none;
  padding: 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1000;
}
.dxf-minimap.open { display: block; }
.dxf-minimap canvas { display: block; border-radius: 6px; cursor: crosshair; }

/* ── Side panel (Recent files / Saved views) ────────────────────────────── */
.dxf-sidepanel {
  position: fixed;
  top: 0; right: 0;
  width: 300px; height: 100%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 1400;
  display: flex;
  flex-direction: column;
}
.dxf-sidepanel.open { transform: translateX(0); }
.dxf-sidepanel__hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.dxf-sidepanel__hd h3 { margin: 0; font-size: 16px; color: var(--text-primary); }
.dxf-sidepanel__x { background: transparent; border: 0; color: var(--text-muted); font-size: 22px; cursor: pointer; line-height: 1; }
.dxf-sidepanel__body { padding: 10px; overflow-y: auto; }
.dxf-panel__add {
  width: 100%; padding: 10px; margin-bottom: 8px;
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  font-size: 14px; cursor: pointer;
}
.dxf-panel__add:hover { background: var(--accent-hover); }
.dxf-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 24px 8px; }
.dxf-row { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.dxf-row__main {
  flex: 1; text-align: left; background: var(--bg-tertiary); border: 1px solid var(--border);
  color: var(--text-primary); padding: 9px 11px; border-radius: 8px; cursor: pointer;
  font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dxf-row__main:hover { border-color: var(--accent); }
.dxf-row__x {
  width: 30px; height: 32px; background: transparent; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-muted); cursor: pointer; font-size: 14px;
}
.dxf-row__x:hover { color: var(--accent); border-color: var(--accent); }

/* ── Compare overlay ────────────────────────────────────────────────────── */
#dxfCompareHost {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: none;
  pointer-events: none;       /* base controls keep working underneath */
}
#dxfCompareHost canvas { width: 100% !important; height: 100% !important; display: block; }

.dxf-comparebar {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  z-index: 1350;
  font-size: 13px;
  color: var(--text-primary);
}
.dxf-comparebar.open { display: flex; }
.dxf-comparebar .cmp-name { color: var(--accent); }
.dxf-comparebar .cmp-tgl,
.dxf-comparebar .cmp-exit {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.dxf-comparebar .cmp-tgl.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.dxf-comparebar .cmp-exit:hover { border-color: var(--error); color: var(--error); }
.dxf-comparebar .cmp-op-lbl { color: var(--text-muted); }
.dxf-comparebar .cmp-opacity { width: 110px; }

/* ── Select-area overlay (screenshot / export / print of a region) ───────── */
#dxfSelectLayer {
  position: absolute;
  inset: 0;
  z-index: 55;
  cursor: crosshair;
  background: rgba(0, 0, 0, 0.04);
}
.dxf-select-box {
  position: absolute;
  border: 1.5px dashed var(--accent);
  background: rgba(108, 99, 255, 0.14);
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.18);
}
