/* stlview.app — base layout, palette, toast, modal, tool strip, side panel are taken from dxfviewer.app css/style.css (same family look); sv- prefixes renamed to sv-. */
* {
  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%;
  position: relative;   /* positioning context for the full-height layers panel */
}

/* 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 {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

/* "Add to Chrome" header button — the colored Chrome logo carries the accent, the
   surface stays theme-appropriate. Kept hidden until JS confirms desktop Chrome. */
.cws-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: linear-gradient(180deg, #2e2e48, #26263c);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #3f3f5a;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.cws-btn:hover {
  border-color: #8ab4f8;
  box-shadow: 0 0 0 3px rgba(138, 180, 248, 0.15);
}

:root.light .cws-btn {
  background: #fff;
  border-color: var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

:root.light .cws-btn:hover {
  border-color: #8ab4f8;
  box-shadow: 0 0 0 3px rgba(138, 180, 248, 0.25);
}

.cws-btn[hidden] {
  display: none;
}

.nav {
  display: flex;
  gap: 8px;
  transition: margin-right 0.25s ease;
}
/* When the layers panel is open, slide the header buttons left so they sit over the
   drawing (not over the panel) and visually track the panel edge. */
body.sv-panel-open .nav { margin-right: 280px; }

.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;
}

/* Pro · Terms · Privacy · Refunds · Support · Manage subscription — цвета темы вместо синих ссылок браузера */
.status-bar .legal-links a,
.status-bar #pwManage {
  color: var(--text-secondary) !important;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
.status-bar .legal-links a:hover,
.status-bar #pwManage:hover {
  color: var(--text-primary) !important;
}

/* Layers panel */
.info-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: var(--footer-h, 41px);   /* stop at the footer so bottom borders align */
  width: 280px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: transform 0.25s ease;
}
/* Slide out to the right instead of vanishing (override the global display:none). */
.info-panel.hidden { display: flex !important; transform: translateX(100%); }

/* Drawer handle — always-visible toggle that hides AND re-opens the panel. */
.info-handle {
  position: absolute;
  top: 50%;
  right: 280px;                 /* sits at the panel's left edge when open */
  transform: translateY(-50%);
  width: 24px;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 10px 0 0 10px;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  z-index: 51;
  transition: right 0.25s ease, color 0.15s ease;
}
.info-handle:hover { color: var(--text-primary); }
.info-handle.hidden { display: none !important; }           /* no drawing → no handle */
body:not(.sv-panel-open) .info-handle { right: 0; }       /* panel closed → park at edge */
.info-handle .lh-arrow { transition: transform 0.25s ease; line-height: 1; }
body.sv-panel-open .info-handle .lh-arrow { transform: rotate(180deg); }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--header-h, 60px);   /* match the page header so the top borders line up */
  box-sizing: border-box;
  padding: 0 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);
}

#infoBody {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  list-style: none;
}

#infoBody li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
}

#infoBody 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);
}
/* ── File-type / parse-error modal ─────────────────────────────────────────── */
.sv-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;
}
.sv-modal.hidden { display: none; }
@keyframes dxfModalFade { from { opacity: 0; } to { opacity: 1; } }

.sv-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;
}
.sv-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;
}
.sv-modal__x:hover { color: #fff; }
.sv-modal__icon { font-size: 44px; margin-bottom: 8px; }
.sv-modal__title { font-size: 20px; font-weight: 700; color: #fff; margin: 0 0 8px; }
.sv-modal__msg { font-size: 14px; color: var(--text-secondary); line-height: 1.55; margin: 0 0 16px; }
.sv-modal__msg a { color: #a78bfa; }
.sv-modal__msg b { color: #fff; font-weight: 600; }

.sv-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;
}
.sv-modal__intake.hidden { display: none; }
.sv-modal__intake-lead { font-size: 13px; color: var(--text-secondary); margin: 0 0 10px; }
.sv-modal__intake-hint { font-size: 11px; color: var(--text-muted); line-height: 1.45; margin: 8px 0 0; }
.sv-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;
}
.sv-modal__input:focus { outline: none; border-color: var(--accent); }

.sv-modal__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.sv-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;
}
.sv-modal__btn:hover { border-color: var(--accent); }
.sv-modal__btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; width: 100%; }
.sv-modal__btn--primary:hover { background: var(--accent-hover); }
.sv-modal__btn--primary:disabled { opacity: 0.6; cursor: default; }
.sv-modal__status { font-size: 13px; margin-top: 10px; min-height: 18px; color: var(--text-muted); }
.sv-modal__status.ok { color: #4ade80; }
.sv-modal__status.err { color: #f87171; }

/* Light theme — file/parse modal (mirrors the rating-content palette) */
:root.light .sv-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 .sv-modal__title { color: #312e81; }
:root.light .sv-modal__msg b { color: #312e81; }
:root.light .sv-modal__msg a { color: #4f46e5; }
:root.light .sv-modal__x:hover { color: #312e81; }
:root.light .sv-modal__intake {
  background: rgba(99, 102, 241, 0.06);
  border-color: rgba(99, 102, 241, 0.2);
}
:root.light .sv-modal__input { border-color: #cbd5e1; }
:root.light .sv-modal__btn { border-color: #cbd5e1; }
:root.light .sv-modal__status.ok { color: #16a34a; }
:root.light .sv-modal__status.err { color: #dc2626; }

@media (max-width: 768px) {
  .sv-modal { padding: 12px; }
  .sv-modal__card { border-radius: 16px; padding: 22px 18px 18px; }
  .sv-modal__title { font-size: 18px; }
  .sv-modal__icon { font-size: 38px; }
}

/* ── Viewer tools: toolbar, export menu, toast (js/viewer-tools.js) ──────── */
.sv-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.sv-tool {
  font-size: 14px;
  line-height: 1;
}
.sv-menu {
  position: relative;
  display: inline-block;
}
.sv-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;
}
.sv-menu.open .sv-menu__list { display: block; }
.sv-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;
}
.sv-menu__item:hover { background: var(--accent); color: #fff; }
/* Pro tools: small badge next to a Pro-only action (shown only while the paywall is on) */
.sv-pro-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.4;
  vertical-align: middle;
  color: #fff;
  background: linear-gradient(135deg, #6c63ff, #a78bfa);
  border-radius: 4px;
}
.sv-stripbtn { position: relative; }
.sv-stripbtn .sv-pro-badge { position: absolute; right: -6px; bottom: -4px; margin: 0; font-size: 8px; padding: 0 3px; }

.sv-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;
}
.sv-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.sv-toast.err { border-color: var(--error); }
.sv-toast.ok { border-color: var(--success); }

/* ── Vertical tool strip (left edge) ────────────────────────────────────── */
.sv-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;
}
.sv-strip__sep { height: 1px; background: var(--border); margin: 2px 4px; }
.sv-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;
}
.sv-stripbtn:hover:not(:disabled) { background: var(--border); }
.sv-stripbtn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.sv-stripbtn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Export flyout opens to the RIGHT of the strip */
.sv-strip .sv-menu__list {
  top: 0;
  left: calc(100% + 10px);
  right: auto;
}

/* ── Measure overlay ────────────────────────────────────────────────────── */
/* (#svMeasureLayer styles live in stlview.css) */
/* ── Side panel (Recent files / Saved views) ────────────────────────────── */
.sv-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;
}
.sv-sidepanel.open { transform: translateX(0); }
.sv-sidepanel__hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.sv-sidepanel__hd h3 { margin: 0; font-size: 16px; color: var(--text-primary); }
.sv-sidepanel__x { background: transparent; border: 0; color: var(--text-muted); font-size: 22px; cursor: pointer; line-height: 1; }
.sv-sidepanel__body { padding: 10px; overflow-y: auto; }
.sv-panel__add {
  width: 100%; padding: 10px; margin-bottom: 8px;
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  font-size: 14px; cursor: pointer;
}
.sv-panel__add:hover { background: var(--accent-hover); }
.sv-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 24px 8px; }
.sv-row { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.sv-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;
}
.sv-row__main:hover { border-color: var(--accent); }
.sv-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;
}
.sv-row__x:hover { color: var(--accent); border-color: var(--accent); }

