/* 3D Studio Pro — Ultra-HD Lithophane, Lamp & 3D Relief CAD */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #060913;
  --surface: #0d1424;
  --surface2: #141e33;
  --surface3: #1c2944;
  --border: rgba(99, 160, 255, 0.15);
  --border-strong: rgba(99, 160, 255, 0.36);
  --accent: #4f8eff;
  --accent-rgb: 79, 142, 255;
  --accent2: #a855f7;
  --emerald: #10b981;
  --amber: #f59e0b;
  --danger: #ef4444;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --dim: #64748b;
  --glow: rgba(79, 142, 255, 0.34);
  --radius: 12px;
}

html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body[data-lang="en"] [data-fr] { display: none !important; }
body[data-lang="fr"] [data-en] { display: none !important; }

/* ── INTEGRATED HEADER (Zero Overlap!) ── */
header.topbar {
  position: relative; z-index: 25;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 16px; min-height: 56px;
  background: rgba(13, 20, 36, 0.94);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.header-left, .header-right { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; min-width: 0; }

.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 10px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.18s; white-space: nowrap; flex-shrink: 0;
}
.btn-back:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.logo { display: flex; align-items: center; gap: 9px; min-width: 0; }
.logo-icon {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  box-shadow: 0 0 16px var(--glow);
}
.logo-meta { display: flex; flex-direction: column; min-width: 0; }
.logo-text {
  font-family: 'Space Grotesk', sans-serif; font-size: 16px; font-weight: 700;
  line-height: 1.15; white-space: nowrap; display: flex; align-items: center; gap: 7px;
  background: linear-gradient(90deg, #f8fafc, #818cf8, #e879f9);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.logo-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill {
  font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 20px;
  background: rgba(79, 142, 255, 0.14); border: 1px solid rgba(79, 142, 255, 0.32);
  color: #93c5fd; white-space: nowrap;
}
.pill.emerald { background: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.38); color: #34d399; }
.pill.pro { background: rgba(245, 158, 11, 0.2); border-color: rgba(245, 158, 11, 0.48); color: #fcd34d; }

.h-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: 9px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.16s; white-space: nowrap;
}
.h-btn:hover:not(:disabled) { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.14); color: #fff; }
.h-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.h-btn.accent { background: linear-gradient(135deg, #4f8eff, #9333ea); border-color: transparent; color: #fff; }
.h-btn.accent:hover:not(:disabled) { filter: brightness(1.1); }
.h-btn.icon-only { padding: 6px 8px; }
.h-sep { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }

/* Mobile Switcher */
.mobile-bar {
  display: none; padding: 6px 12px; gap: 8px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.mobile-tab {
  flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer;
}
.mobile-tab.active { background: rgba(var(--accent-rgb), 0.2); border-color: var(--accent); color: #fff; }

/* ── WORKSPACE: LEFT 3D VIEWPORT + RIGHT CAD CONTROLS ── */
.workspace {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 1fr 375px;
}

/* ── MAIN 3D STAGE ── */
main.stage {
  display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden;
  background: var(--bg);
}

.stage-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; background: rgba(13, 20, 36, 0.85);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.bar-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.progress-strip {
  display: none; align-items: center; gap: 10px;
  padding: 6px 14px; background: rgba(79, 142, 255, 0.12);
  border-bottom: 1px solid rgba(79, 142, 255, 0.28); flex-shrink: 0;
}
.progress-strip.active { display: flex; }
.progress-track { flex: 1; height: 6px; border-radius: 3px; background: var(--surface3); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width 0.2s; }
.progress-txt { font-size: 11px; font-weight: 700; color: #93c5fd; white-space: nowrap; }

.viewport-box {
  position: relative; flex: 1; min-height: 300px; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #0f172a, #050811);
}
#canvas3d { width: 100%; height: 100%; display: block; }

/* Welcome Overlay on Empty Canvas */
.welcome-overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(6, 9, 19, 0.72); backdrop-filter: blur(6px);
}
.welcome-card {
  max-width: 560px; width: 100%; text-align: center;
  background: rgba(13, 20, 36, 0.94); border: 1px dashed rgba(99, 160, 255, 0.42);
  border-radius: 20px; padding: 30px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6); cursor: pointer;
}
.welcome-card h2 { font-family: 'Space Grotesk', sans-serif; font-size: 22px; }
.welcome-card p { font-size: 13px; color: var(--muted); line-height: 1.5; }
.demo-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }

/* Floating 3D Specs HUD */
.hud-bottom {
  position: absolute; bottom: 12px; left: 12px; right: 12px; z-index: 6;
  display: none; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  pointer-events: none;
}
.hud-bottom.show { display: flex; }
.hud-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.hud-chip {
  padding: 5px 10px; border-radius: 8px; background: rgba(13, 20, 36, 0.84);
  border: 1px solid var(--border); font-size: 11px; color: #cbd5e1; font-weight: 600;
  backdrop-filter: blur(8px); font-variant-numeric: tabular-nums;
}
.hud-chip strong { color: #60a5fa; }

/* Live Cross-Section Thickness Caliper Bar */
.caliper-dock {
  flex-shrink: 0; background: var(--surface); border-top: 1px solid var(--border);
  padding: 8px 14px; display: flex; flex-direction: column; gap: 6px;
}
.caliper-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 11px; font-weight: 700; color: var(--muted);
}
#caliperCanvas { width: 100%; height: 64px; display: block; border-radius: 8px; background: #070b14; }

/* ── RIGHT SIDEBAR ── */
aside.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: rgba(13, 20, 36, 0.96);
  border-left: 1px solid var(--border);
}
.side-tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  padding: 8px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.side-tab {
  padding: 7px 4px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--muted); font-size: 11px; font-weight: 700;
  cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: all 0.16s;
}
.side-tab .ti { font-size: 15px; }
.side-tab:hover { color: var(--text); background: var(--surface2); }
.side-tab.active { background: rgba(var(--accent-rgb), 0.18); border-color: rgba(var(--accent-rgb), 0.45); color: #93c5fd; }

.side-scroll {
  flex: 1; overflow-y: auto; padding: 12px;
  scrollbar-width: thin; scrollbar-color: var(--surface3) transparent;
}
.side-pane { display: none; flex-direction: column; gap: 11px; }
.side-pane.active { display: flex; }

.card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px 12px;
  display: flex; flex-direction: column; gap: 9px;
}
.card-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.65px; color: var(--muted);
}

.field { display: flex; flex-direction: column; gap: 4px; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; }
.field-row label { color: var(--text); font-weight: 500; font-size: 12px; }
.val-tag { font-size: 11px; font-weight: 700; color: #60a5fa; font-variant-numeric: tabular-nums; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

select.inp, input[type="number"].inp, input[type="text"].inp {
  width: 100%; padding: 7px 9px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; font-family: inherit;
}
select.inp:focus, input.inp:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.22); }

input[type="range"] {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 5px; border-radius: 3px; background: var(--surface3); cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: 2px solid var(--surface); box-shadow: 0 0 8px var(--glow); cursor: pointer;
}

.check-row { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text); cursor: pointer; user-select: none; }
.check-row input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface3); color: var(--text);
  font-size: 12px; font-weight: 700; cursor: pointer; transition: all 0.16s;
}
.btn:hover:not(:disabled) { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.16); color: #fff; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, #4f8eff, #9333ea); border-color: transparent; color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-led-on { background: linear-gradient(135deg, #f59e0b, #ea580c); border-color: transparent; color: #fff; box-shadow: 0 0 14px rgba(245, 158, 11, 0.4); }
.btn-emerald { background: linear-gradient(135deg, #059669, #06b6d4); border-color: transparent; color: #fff; }
.btn-sm { padding: 5px 9px; font-size: 11px; border-radius: 7px; }
.btn-full { width: 100%; }

/* 2D Preview Box */
.preview2d-box {
  width: 100%; height: 115px; border-radius: 9px; overflow: hidden;
  background: #060913; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
#preview2dCanvas { max-width: 100%; max-height: 110px; display: block; object-fit: contain; }

/* 9 Shapes & Presets & Materials Grids */
.shape-btn, .preset-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 4px; color: var(--text); font-size: 10.5px; font-weight: 600;
  cursor: pointer; transition: all 0.16s;
  display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center;
}
.shape-btn:hover, .preset-btn:hover { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.14); }
.shape-btn.active, .preset-btn.active { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.24); color: #fff; box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.26); }
.shape-btn .si, .preset-btn .si { font-size: 16px; }

.mat-swatch {
  height: 36px; border-radius: 9px; border: 2px solid transparent; cursor: pointer;
  display: flex; align-items: flex-end; justify-content: center; padding: 3px;
  font-size: 9px; font-weight: 800; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9); color: #fff;
  transition: transform 0.15s;
}
.mat-swatch:hover { transform: scale(1.04); }
.mat-swatch.active { border-color: #60a5fa; box-shadow: 0 0 12px var(--glow); }

/* Export Cards */
.export-list { display: flex; flex-direction: column; gap: 7px; }
.exp-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 11px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; transition: all 0.16s; text-align: left; width: 100%;
}
.exp-card:hover:not(:disabled) { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.13); transform: translateY(-1px); }
.exp-card:disabled { opacity: 0.42; cursor: not-allowed; }
.exp-card.featured { background: linear-gradient(135deg, rgba(79, 142, 255, 0.18), rgba(168, 85, 247, 0.18)); border-color: rgba(79, 142, 255, 0.42); }
.exp-card.ar-card { background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(139, 92, 246, 0.22)); border-color: rgba(6, 182, 212, 0.48); }
.exp-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.exp-ico { font-size: 18px; flex-shrink: 0; }
.exp-title { font-size: 12px; font-weight: 700; color: var(--text); }
.exp-sub { font-size: 10px; color: var(--muted); }
.exp-tag { font-size: 10px; font-weight: 800; padding: 3px 7px; border-radius: 6px; background: var(--surface3); color: #93c5fd; flex-shrink: 0; }
.exp-tag.free { background: rgba(16, 185, 129, 0.2); color: #34d399; }

/* Modals */
.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(2, 6, 23, 0.84); backdrop-filter: blur(10px);
  align-items: center; justify-content: center; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 18px;
  width: 100%; max-width: 560px; max-height: 88vh; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
}
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-family: 'Space Grotesk', sans-serif; font-size: 16px; }
.modal-close { background: var(--surface2); border: 1px solid var(--border); color: var(--muted); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 16px; }
.modal-close:hover { color: #fff; border-color: var(--accent); }
.modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 11px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.score-ring { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--border); }
.score-num { font-family: 'Space Grotesk', sans-serif; font-size: 32px; font-weight: 800; }
.issue-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border-radius: 10px; background: var(--surface2); border-left: 3px solid var(--amber); font-size: 12px; }
.issue-item.error { border-left-color: var(--danger); }
.issue-item.info { border-left-color: var(--accent); }
.issue-item.ok { border-left-color: var(--emerald); }
.tips-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.tips-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); }
.tips-table td:last-child { text-align: right; color: #93c5fd; font-weight: 600; }

.quote-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.quote-kpi { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.quote-kpi .kl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.quote-kpi .kv { font-family: 'Space Grotesk', sans-serif; font-size: 20px; font-weight: 700; margin-top: 2px; }

.pay-hero { text-align: center; padding: 8px 0; }
.pay-hero .ico { font-size: 40px; margin-bottom: 8px; }
.pay-hero p { color: var(--muted); font-size: 13px; line-height: 1.5; margin-top: 6px; }
.btn-pro-upgrade { width: 100%; padding: 13px; border-radius: 12px; border: none; background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; font-size: 14px; font-weight: 800; cursor: pointer; }
.btn-pro-upgrade:hover { filter: brightness(1.08); }

.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast-item { background: var(--surface2); border: 1px solid var(--border-strong); color: var(--text); padding: 10px 14px; border-radius: 10px; font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 8px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5); }

.global-drop-overlay {
  display: none; position: fixed; inset: 0; z-index: 1500;
  background: rgba(6, 9, 19, 0.86); backdrop-filter: blur(8px);
  border: 3px dashed var(--accent); align-items: center; justify-content: center;
  flex-direction: column; gap: 10px; font-size: 20px; font-weight: 700; color: #fff;
}
.global-drop-overlay.show { display: flex; }

@media (max-width: 1180px) {
  .logo-sub, .hide-md { display: none; }
  .workspace { grid-template-columns: 1fr 330px; }
}
@media (max-width: 940px) {
  body { overflow: auto; }
  .mobile-bar { display: flex; }
  .workspace { display: block; height: auto; }
  main.stage, aside.sidebar { display: none; }
  body[data-mobile-pane="viewport"] main.stage { display: flex; min-height: 75vh; }
  body[data-mobile-pane="controls"] aside.sidebar { display: flex; border-left: none; }
  .header-right .h-sep { display: none; }
}
