:root {
  --bg: #070c18;
  --surface: #0e1628;
  --surface-2: #141f38;
  --border: #1e2d4d;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --blue: #38bdf8;
  --amber: #fb923c;
  --green: #4ade80;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top center, #111c36 0%, var(--bg) 55%);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 12, 24, 0.85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-badge {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #071120;
  background: linear-gradient(135deg, var(--blue), #818cf8);
  padding: 8px 11px;
  border-radius: 8px;
}
.topbar h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.subtitle { font-size: 12.5px; color: var(--muted); }

.hero-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.pill-blue { color: #7dd3fc; background: rgba(56,189,248,0.12); border-color: rgba(56,189,248,0.3); }
.pill-amber { color: #fdba74; background: rgba(251,146,60,0.12); border-color: rgba(251,146,60,0.3); }
.pill-green { color: #86efac; background: rgba(74,222,128,0.12); border-color: rgba(74,222,128,0.3); }

.container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 22px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.viewer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

.mode-btn, .cam-btn, .tab-btn {
  font-family: 'Inter', sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.mode-btn:hover, .cam-btn:hover, .tab-btn:hover {
  color: var(--text);
  border-color: #3b558a;
  background: rgba(30, 45, 77, 0.75);
}
.mode-btn.active, .tab-btn.active {
  color: #06101f;
  background: var(--blue);
  border-color: var(--blue);
}
.cam-btn { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; padding: 6px 10px; }

.viewport-wrap {
  position: relative;
  width: 100%;
  height: 590px;
  background: radial-gradient(circle at 50% 42%, #182542 0%, #0a1020 75%);
  overflow: hidden;
  user-select: none;
}

#cad-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.dim-labels-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.dim-badge {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
  background: rgba(7, 12, 24, 0.88);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.55);
  box-shadow: 0 3px 10px rgba(0,0,0,0.45);
  transition: opacity 0.15s;
}
.dim-badge.amber {
  color: #fdba74;
  border-color: rgba(251, 146, 60, 0.65);
}
.dim-badge.green {
  color: #86efac;
  border-color: rgba(74, 222, 128, 0.6);
}

.viewport-toggles {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  z-index: 5;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(9, 15, 29, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.28);
  backdrop-filter: blur(8px);
  cursor: pointer;
}
.toggle-chip input { accent-color: var(--blue); cursor: pointer; }

.viewport-hint {
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: rgba(148, 163, 184, 0.8);
  background: rgba(9, 15, 29, 0.72);
  padding: 4px 10px;
  border-radius: 6px;
  pointer-events: none;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7, 12, 24, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 20;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--blue);
}
.loading-overlay.hidden { display: none; }
.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(56,189,248,0.2);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  border-top: 1px solid var(--border);
  background: rgba(11, 17, 32, 0.9);
}
.metric {
  padding: 13px 15px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.metric:last-child { border-right: none; }
.metric-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.metric-val { font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 700; color: #f8fafc; }
.metric-sub { font-size: 11px; color: #64748b; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
}
.section h2 { font-size: 18px; font-weight: 700; margin-bottom: 3px; }
.section p { font-size: 13.5px; color: var(--muted); }
.tab-group { display: flex; gap: 6px; flex-wrap: wrap; }

.drawings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
.drawing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.drawing-wide { grid-column: 1 / -1; }
.drawing-card.hidden { display: none; }
.drawing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: #cbd5e1;
}
.zoom-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--blue);
  background: transparent;
  border: 1px solid rgba(56,189,248,0.35);
  border-radius: 6px;
  padding: 3px 9px;
  cursor: pointer;
}
.zoom-btn:hover { background: rgba(56,189,248,0.12); }
.drawing-card img {
  width: 100%;
  height: auto;
  display: block;
  cursor: zoom-in;
}

.two-col {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 20px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
}
.panel h2 { font-size: 17px; margin-bottom: 12px; }

.spec-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.spec-table th, .spec-table td {
  padding: 8px 6px;
  border-bottom: 1px solid rgba(30, 45, 77, 0.75);
  text-align: left;
  vertical-align: top;
}
.spec-table th { color: var(--muted); font-weight: 500; width: 38%; }
.spec-table code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #7dd3fc;
  background: rgba(56,189,248,0.09);
  padding: 1px 5px;
  border-radius: 4px;
}

.subcard {
  background: rgba(10, 16, 30, 0.6);
  border: 1px solid rgba(30, 45, 77, 0.8);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.subcard:last-child { margin-bottom: 0; }
.subcard h3 { font-size: 13.5px; color: #fdba74; margin-bottom: 8px; }
.bullet-list { padding-left: 18px; font-size: 13px; color: #cbd5e1; display: flex; flex-direction: column; gap: 6px; }
.bullet-list code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: #86efac;
  background: rgba(74,222,128,0.1);
  padding: 1px 5px;
  border-radius: 4px;
}

.downloads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.dl-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(10, 16, 30, 0.7);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.15s ease;
}
.dl-card:hover { border-color: var(--blue); transform: translateY(-1px); background: rgba(20, 31, 56, 0.85); }
.dl-card strong { display: block; font-size: 13.5px; }
.dl-card span:not(.dl-tag) { font-size: 11.5px; color: var(--muted); }
.dl-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 6px;
}
.dl-tag.stl { background: rgba(56,189,248,0.16); color: #7dd3fc; border: 1px solid rgba(56,189,248,0.4); }
.dl-tag.step { background: rgba(251,146,60,0.16); color: #fdba74; border: 1px solid rgba(251,146,60,0.4); }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 18, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  z-index: 100;
}
.lightbox.hidden { display: none; }
.lightbox img { max-width: 95vw; max-height: 92vh; border-radius: 10px; border: 1px solid var(--border); }
.lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}

@media (max-width: 1024px) {
  .metrics-strip { grid-template-columns: repeat(3, 1fr); }
  .two-col, .drawings-grid { grid-template-columns: 1fr; }
  .viewport-wrap { height: 470px; }
}
@media (max-width: 640px) {
  .metrics-strip { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 12px 16px; }
  .container { padding: 14px 12px 48px; }
}
