/* ==========================================================================
   PHOSPHOR DRAFT v1.0 — 4-Theme Vector Drafting, Room Planner & Wireframe CSS
   Themes: CRT '96 (Blueprint) | DARK | OFFICE (Daylight) | TURBO '96 (CAD)
   ========================================================================== */

:root,
[data-theme="crt"] {
  --font-ui: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Consolas", "Cascadia Mono", "Courier New", monospace;

  --bg-app: #07121b;
  --bg-panel: #0e1c28;
  --bg-panel-alt: #142636;
  --bg-surface: #0a1620;
  --bg-input: #060e15;
  --bg-canvas: #071522;
  --grid-minor: rgba(56, 189, 248, 0.11);
  --grid-major: rgba(56, 189, 248, 0.24);

  --border: #20394d;
  --border-hi: #325773;

  --text-main: #e6f3ec;
  --text-muted: #8ea7b6;
  --text-dim: #627b8c;

  --accent: #38bdf8;
  --accent-bg: rgba(56, 189, 248, 0.14);
  --accent-text: #04131d;
  --green: #39ff88;
  --amber: #ffb84d;
  --red: #ff5c77;

  --radius: 5px;
  --radius-lg: 8px;
  --scanline-opacity: 0.06;
}

[data-theme="dark"] {
  --font-ui: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Consolas", "Cascadia Mono", "SFMono-Regular", monospace;

  --bg-app: #111317;
  --bg-panel: #181c23;
  --bg-panel-alt: #202631;
  --bg-surface: #14181f;
  --bg-input: #0e1015;
  --bg-canvas: #131720;
  --grid-minor: rgba(148, 163, 184, 0.08);
  --grid-major: rgba(148, 163, 184, 0.18);

  --border: #2b313e;
  --border-hi: #3e4759;

  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --accent: #7aa2f7;
  --accent-bg: rgba(122, 162, 247, 0.15);
  --accent-text: #0b101b;
  --green: #4ade80;
  --amber: #f59e0b;
  --red: #f87171;

  --radius: 6px;
  --radius-lg: 10px;
  --scanline-opacity: 0;
}

[data-theme="office"] {
  --font-ui: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Consolas", "SFMono-Regular", monospace;

  --bg-app: #eef2f6;
  --bg-panel: #ffffff;
  --bg-panel-alt: #f5f8fb;
  --bg-surface: #f8fafc;
  --bg-input: #ffffff;
  --bg-canvas: #ffffff;
  --grid-minor: #e2e8f0;
  --grid-major: #cbd5e1;

  --border: #cbd5e1;
  --border-hi: #94a3b8;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --accent: #1d4ed8;
  --accent-bg: rgba(29, 78, 216, 0.10);
  --accent-text: #ffffff;
  --green: #16a34a;
  --amber: #b45309;
  --red: #dc2626;

  --radius: 6px;
  --radius-lg: 10px;
  --scanline-opacity: 0;
}

[data-theme="turbo"] {
  --font-ui: "Consolas", "Cascadia Mono", "Courier New", monospace;
  --font-mono: "Consolas", "Cascadia Mono", "Courier New", monospace;

  --bg-app: #020804;
  --bg-panel: #041208;
  --bg-panel-alt: #061c0d;
  --bg-surface: #030e06;
  --bg-input: #010502;
  --bg-canvas: #020a04;
  --grid-minor: rgba(0, 255, 102, 0.09);
  --grid-major: rgba(0, 255, 102, 0.24);

  --border: #0f6f34;
  --border-hi: #00ff66;

  --text-main: #7affaa;
  --text-muted: #34c76e;
  --text-dim: #1d7a42;

  --accent: #00ff66;
  --accent-bg: rgba(0, 255, 102, 0.15);
  --accent-text: #011407;
  --green: #00ff66;
  --amber: #ffb000;
  --red: #ff4757;

  --radius: 0px;
  --radius-lg: 0px;
  --scanline-opacity: 0.18;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 13.5px;
  line-height: 1.45;
  height: 100%;
  overflow-x: hidden;
}

.crt-scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  opacity: var(--scanline-opacity);
  background: repeating-linear-gradient(to bottom, transparent 0px, transparent 2px, rgba(0, 0, 0, 0.5) 3px, transparent 4px);
}
body.no-scanlines .crt-scanlines,
[data-theme="dark"] .crt-scanlines,
[data-theme="office"] .crt-scanlines { display: none; }

/* TOPBAR */
.topbar {
  position: sticky; top: 0; z-index: 100;
  min-height: 54px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 6px 14px; flex-wrap: wrap;
}
.brand-cluster { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-text);
  font-family: var(--font-mono); font-weight: 900; font-size: 12px;
  display: grid; place-items: center;
}
.brand-title { font-weight: 800; font-size: 14.5px; letter-spacing: 0.5px; display: flex; align-items: center; gap: 6px; }
.ver-badge {
  font-family: var(--font-mono); font-size: 10px; padding: 1px 6px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.brand-sub { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-muted); letter-spacing: 0.4px; }

.proof-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--green) 45%, var(--border));
  background: color-mix(in srgb, var(--green) 11%, transparent);
  color: var(--green);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 800; cursor: pointer;
}
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }

.controls-cluster { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.theme-switch {
  display: inline-flex; background: var(--bg-input); border: 1px solid var(--border-hi);
  border-radius: var(--radius); padding: 2px; gap: 2px;
}
.theme-btn {
  border: none; background: transparent; color: var(--text-muted);
  font-family: var(--font-ui); font-size: 11px; font-weight: 700;
  padding: 4px 7px; border-radius: calc(var(--radius) - 1px); cursor: pointer; white-space: nowrap;
}
.theme-btn:hover { color: var(--text-main); }
.theme-btn.active { background: var(--accent); color: var(--accent-text); }

.save-as-btn {
  height: 30px; padding: 0 10px; border-radius: var(--radius);
  border: 1px solid var(--border-hi); background: var(--bg-panel-alt); color: var(--text-main);
  font-size: 11.5px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.save-as-btn.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }

.icon-btn {
  width: 30px; height: 30px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-surface);
  color: var(--text-main); cursor: pointer; display: grid; place-items: center; font-size: 13px;
}
.icon-btn.muted { opacity: 0.45; }

/* MAIN SHELL */
.app-shell {
  display: grid;
  grid-template-columns: 274px minmax(0, 1fr);
  height: calc(100vh - 54px);
}

.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 10px;
  display: flex; flex-direction: column; gap: 9px;
  overflow-y: auto;
  min-width: 0;
}

.lib-tabs {
  display: flex; flex-direction: column; gap: 4px;
}
.lib-tab {
  width: 100%;
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.lib-tab:hover { border-color: var(--border-hi); background: var(--bg-panel-alt); }
.lib-tab.active {
  background: var(--accent-bg);
  border-color: var(--accent);
}
.lt-ico { font-size: 16px; flex-shrink: 0; }
.lt-body { display: flex; flex-direction: column; min-width: 0; }
.lt-name { font-size: 12.5px; font-weight: 800; line-height: 1.2; color: var(--text-main); }
.lib-tab.active .lt-name { color: var(--accent); }
.lt-desc { font-size: 10.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-section-lbl {
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 900;
  letter-spacing: 0.8px; color: var(--text-dim); padding: 2px 2px 0;
}

.stamp-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 5px;
}
.stamp-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-surface);
  color: var(--text-main); font-size: 11.5px; font-weight: 700;
  cursor: pointer; text-align: left; min-width: 0;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.stamp-btn:hover { border-color: var(--accent); background: var(--accent-bg); }
.st-ico { font-size: 14px; flex-shrink: 0; }
.st-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* INSPECTOR */
.inspector-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-lg);
  padding: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.insp-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.insp-kind { font-family: var(--font-mono); font-size: 10px; font-weight: 800; color: var(--accent); }
.insp-empty { font-size: 11.5px; color: var(--text-muted); line-height: 1.45; }
.insp-fields { display: flex; flex-direction: column; gap: 8px; }

.field-lbl {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 11px; font-weight: 700; color: var(--text-muted); min-width: 0;
}
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }

.tb-input, .tb-textarea, .tb-select {
  width: 100%; min-width: 0; max-width: 100%;
  padding: 6px 8px; border-radius: var(--radius);
  border: 1px solid var(--border-hi);
  background: var(--bg-input); color: var(--text-main);
  font-family: var(--font-ui); font-size: 12px;
}
.tb-select.compact { width: auto; padding: 5px 7px; font-family: var(--font-mono); font-size: 11px; font-weight: 800; }

.swatch-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
.swatch-btn {
  width: 100%; height: 22px; border-radius: 4px;
  border: 2px solid; cursor: pointer;
}
.swatch-btn:hover { transform: scale(1.1); }

.insp-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }

/* FLEET-STANDARD SIDEBAR FOOTER */
.sidebar-footer-stack {
  margin-top: auto;
  padding-top: 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.guide-sidebar-btn {
  width: 100%; padding: 8px 10px; border-radius: var(--radius);
  border: 1.5px solid var(--green); background: color-mix(in srgb, var(--green) 12%, transparent);
  color: var(--green); font-family: var(--font-ui); font-size: 12.5px; font-weight: 800; cursor: pointer;
}
.guide-sidebar-btn:hover { background: var(--green); color: #04150a; }

.sidebar-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 10px 11px;
  display: flex; flex-direction: column; gap: 6px;
}
.sidebar-card.brand-card { border-style: dashed; border-color: var(--border-hi); }
.scard-kicker { font-family: var(--font-mono); font-size: 10px; font-weight: 900; color: var(--text-muted); }
.scard-text { margin: 0; font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }
.scard-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; padding: 6px 8px; border-radius: var(--radius);
  border: 1px solid var(--border-hi); background: var(--bg-panel-alt);
  color: var(--text-main); text-decoration: none; font-size: 11.5px; font-weight: 800;
}
.scard-btn:hover { border-color: var(--accent); color: var(--accent); }
.bcard-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.bcard-title { font-family: var(--font-mono); font-size: 10px; font-weight: 900; }
.bcard-badge {
  font-family: var(--font-mono); font-size: 9px; font-weight: 900; padding: 2px 6px; border-radius: 4px;
  background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green);
  border: 1px solid color-mix(in srgb, var(--green) 45%, transparent);
}
.bcard-links { font-size: 11px; color: var(--text-dim); text-align: center; line-height: 1.5; }
.bcard-links a { color: var(--accent); text-decoration: none; font-weight: 600; }
.bcard-links a:hover { text-decoration: underline; }
.bcard-links.legal a { color: var(--text-muted); font-size: 10.5px; }

/* WORKBENCH + LEFT-JUSTIFIED TOOLBAR */
.workbench {
  display: flex; flex-direction: column;
  min-width: 0; height: 100%; overflow: hidden;
}

.draft-toolbar {
  display: flex; align-items: center; justify-content: flex-start;
  gap: 6px; flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
.tb-sep {
  display: inline-block; width: 1px; height: 22px; margin: 0 4px;
  background: var(--border-hi); opacity: 0.65; flex-shrink: 0;
}
.tool-seg {
  display: inline-flex; background: var(--bg-input); border: 1px solid var(--border-hi);
  border-radius: var(--radius); padding: 2px; gap: 2px;
}
.seg-btn {
  border: none; background: transparent; color: var(--text-muted);
  font-family: var(--font-mono); font-size: 11px; font-weight: 800;
  padding: 5px 9px; border-radius: calc(var(--radius) - 1px); cursor: pointer; white-space: nowrap;
}
.seg-btn:hover { color: var(--text-main); }
.seg-btn.active { background: var(--accent); color: var(--accent-text); }

.tb-group { display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.tb-lbl {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  margin-right: 2px;
}
.tb-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 9px; border-radius: var(--radius);
  border: 1px solid var(--border-hi); background: var(--bg-panel-alt);
  color: var(--text-main); font-family: var(--font-mono); font-size: 11px; font-weight: 800;
  cursor: pointer; white-space: nowrap;
}
.tb-btn:hover { border-color: var(--accent); color: var(--accent); }
.tb-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tb-btn.active { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.tb-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.tb-btn.danger:hover { border-color: var(--red); color: var(--red); }
.file-lbl { cursor: pointer; }
.zoom-readout { font-family: var(--font-mono); font-size: 11px; font-weight: 900; min-width: 40px; text-align: center; color: var(--text-muted); }

/* INTERACTIVE SVG BOARD */
.canvas-stage {
  flex: 1; position: relative; overflow: hidden;
  background: var(--bg-canvas);
}
.draft-svg {
  width: 100%; height: 100%; display: block;
  touch-action: none; user-select: none;
  cursor: default;
}
.draft-svg[data-mode="pan"] { cursor: grab; }
.draft-svg[data-mode="sketch"], .draft-svg[data-mode="measure"] { cursor: crosshair; }
.grid-minor-line { stroke: var(--grid-minor); }
.grid-major-line { stroke: var(--grid-major); }
.node-g { cursor: move; }
.resize-handle { cursor: nwse-resize; }
.resize-handle[data-handle="ne"], .resize-handle[data-handle="sw"] { cursor: nesw-resize; }

.board-hud {
  position: absolute; bottom: 12px; left: 12px;
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 12px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-panel) 90%, transparent);
  border: 1px solid var(--border-hi);
  font-family: var(--font-mono); font-size: 11px; color: var(--text-muted);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
#hudMode { color: var(--accent); font-weight: 900; }

/* MODALS & TOAST */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0, 0, 0, 0.72); display: grid; place-items: center; padding: 16px;
}
.modal-window {
  width: min(560px, 96vw); background: var(--bg-panel);
  border: 1.5px solid var(--border-hi); border-radius: var(--radius-lg); overflow: hidden;
}
.modal-guide-win { width: min(720px, 96vw); }
.modal-titlebar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: var(--bg-panel-alt); border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 12px; font-weight: 900;
}
.modal-close {
  background: none; border: 1px solid var(--border); color: var(--text-main);
  width: 26px; height: 26px; border-radius: 4px; cursor: pointer;
}
.modal-body { padding: 16px; font-size: 13px; }
.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.guide-col {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px;
}
.guide-col h4 { margin: 0 0 8px; font-family: var(--font-mono); font-size: 12px; color: var(--accent); }
.guide-col ul { margin: 0; padding-left: 16px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-muted); }
.guide-col strong { color: var(--text-main); }
.tiny-note { font-size: 11.5px; color: var(--text-dim); }

.toast {
  position: fixed; bottom: 18px; right: 18px; z-index: 600;
  padding: 9px 14px; border-radius: var(--radius);
  background: var(--bg-panel); border: 1.5px solid var(--accent);
  color: var(--text-main); font-family: var(--font-mono); font-size: 12px; font-weight: 800;
}

/* PRINT */
.draft-print-mount { display: none; }
@media print {
  .no-print, .crt-scanlines { display: none !important; }
  body { background: #ffffff !important; }
  .draft-print-mount { display: block !important; width: 100%; }
  .draft-print-mount svg { width: 100%; height: auto; max-height: 98vh; display: block; }
}

/* RESPONSIVE */
@media (max-width: 920px) {
  .brand-sub, .proof-pill { display: none; }
  .app-shell { grid-template-columns: minmax(0, 1fr); height: auto; min-height: calc(100vh - 54px); }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: none; overflow: visible; }
  .sidebar-card { display: none; }
  .workbench { height: 74vh; min-height: 500px; }
  .tb-sep { display: none; }
  .tool-seg { flex-wrap: wrap; }
  .guide-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   STANDARDIZED 8-POINT PRIVACY PROOF MODAL & FOOTER PARITY (PHASE 2 SYNC)
   ========================================================================== */
.proof-pill { white-space: nowrap; }
.proof-checklist {
  margin: 0; padding: 0; list-style: none;
  display: flex; flex-direction: column; gap: 6px;
}
.proof-checklist li {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 9px;
  font-size: 12px; line-height: 1.42; color: var(--text-muted);
}
.proof-checklist li strong { color: var(--text-main); }
.proof-checklist code {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--bg-panel); border: 1px solid var(--border);
  padding: 1px 4px; border-radius: 3px; color: var(--accent);
}
.proof-status-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--green) 10%, var(--bg-input));
  border: 1px solid color-mix(in srgb, var(--green) 42%, var(--border));
  font-family: var(--font-mono); font-size: 11px; color: var(--green);
}
.proof-status-bar a { color: var(--accent); font-weight: 800; text-decoration: none; }
.proof-status-bar a:hover { text-decoration: underline; }
