/* ═══════════════════════════════════════════════════════════════════
   SeekMake 3D Print Analyzer — Design System
   Font: DM Sans | Colors: Navy dark + Green CTA
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Variables ─────────────────────────────────────────────── */
:root {
  --bg-primary: #0B1120;
  --bg-secondary: #111827;
  --bg-card: #1E293B;
  --bg-card-hover: #253449;
  --bg-input: #0F172A;
  --bg-navbar: rgba(11, 17, 32, 0.85);
  --border: #334155;
  --border-light: #475569;

  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  --accent-green: #22C55E;
  --accent-green-glow: rgba(34, 197, 94, 0.15);
  --accent-blue: #3B82F6;
  --accent-blue-glow: rgba(59, 130, 246, 0.15);
  --accent-amber: #F59E0B;
  --accent-amber-glow: rgba(245, 158, 11, 0.15);
  --accent-red: #EF4444;
  --accent-red-glow: rgba(239, 68, 68, 0.15);
  --accent-purple: #A855F7;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow-green: 0 0 30px rgba(34, 197, 94, 0.2);

  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

[data-theme="light"] {
  --bg-primary: #F8FAFC;
  --bg-secondary: #E2E8F0;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F1F5F9;
  --bg-input: #FFFFFF;
  --bg-navbar: rgba(255, 255, 255, 0.85);
  --border: #CBD5E1;
  --border-light: #94A3B8;

  --text-primary: #0F172A;
  --text-secondary: #334155;
  --text-muted: #475569;

  --accent-green: #059669;
  --accent-green-glow: rgba(5, 150, 105, 0.15);
  --accent-blue: #2563EB;
  --accent-blue-glow: rgba(37, 99, 235, 0.15);
  --accent-amber: #D97706;
  --accent-amber-glow: rgba(217, 119, 6, 0.15);
  --accent-red: #DC2626;
  --accent-red-glow: rgba(220, 38, 38, 0.15);
  --accent-purple: #7C3AED;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow-green: 0 0 30px rgba(5, 150, 105, 0.2);
}

/* ── Reset & Base ──────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle noise texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.06), transparent);
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── Navbar ────────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  background: var(--bg-navbar);
  backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

[data-theme="light"] .sun-icon {
  display: none !important;
}

[data-theme="light"] .moon-icon {
  display: block !important;
}

html:not([data-theme="light"]) .sun-icon {
  display: block !important;
}

html:not([data-theme="light"]) .moon-icon {
  display: none !important;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar-brand img {
  height: 32px;
  width: auto;
}

.navbar-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.navbar-title span {
  color: var(--accent-green);
}

.navbar-title .analyzer-accent {
  color: #ff2ea6;
  text-shadow: 0 0 18px rgba(255, 46, 166, 0.28);
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.navbar-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
}

button.navbar-link {
  background: transparent;
}

.navbar-link:hover {
  color: var(--text-primary);
  background: var(--bg-card);
  border-color: var(--border);
  text-decoration: none;
}

.navbar-link.active {
  color: var(--text-primary);
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(59, 130, 246, 0.35);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2) inset;
}

.navbar-link svg {
  width: 18px;
  height: 18px;
}

/* ── Main Container ────────────────────────────────────────────── */
.main-container {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ── Upload Zone ───────────────────────────────────────────────── */
.upload-section {
  margin-bottom: 32px;
}

.upload-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 220px;
  padding: 40px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all var(--transition-normal);
  overflow: hidden;
}

.upload-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(34, 197, 94, 0.03), transparent 70%);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent-green);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-glow-green);
}

.upload-zone:hover::before,
.upload-zone.drag-over::before {
  opacity: 1;
}

.upload-zone-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: var(--accent-green-glow);
  color: var(--accent-green);
  transition: transform var(--transition-normal);
}

.upload-zone:hover .upload-zone-icon {
  transform: translateY(-4px);
}

.upload-zone-icon svg {
  width: 28px;
  height: 28px;
}

.upload-zone-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.upload-zone-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.upload-zone-formats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.format-badge {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.upload-zone input[type="file"] {
  display: none;
}

/* ── File info bar ─────────────────────────────────────────────── */
.file-info-bar {
  display: none;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.file-info-bar.visible {
  display: flex;
}

.file-info-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--accent-blue-glow);
  color: var(--accent-blue);
  flex-shrink: 0;
}

.file-info-icon svg {
  width: 20px;
  height: 20px;
}

.file-info-details {
  flex: 1;
  min-width: 0;
}

.file-info-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-info-size {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.file-info-actions {
  display: flex;
  gap: 8px;
}

/* ── Config Bar ────────────────────────────────────────────────── */
.config-bar {
  display: none;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.config-bar.visible {
  display: flex;
}

.config-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.config-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.config-select {
  appearance: none;
  padding: 8px 32px 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--transition-fast);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.config-select:hover,
.config-select:focus {
  border-color: var(--accent-blue);
  outline: none;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: var(--accent-green);
  color: #fff;
  border-color: var(--accent-green);
}

.btn-primary:hover {
  background: #16A34A;
  box-shadow: var(--shadow-glow-green);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-secondary:hover {
  color: var(--text-primary);
  background: var(--bg-card);
  border-color: var(--border-light);
}

.btn-danger {
  background: transparent;
  color: var(--accent-red);
  border-color: var(--accent-red);
}

.btn-danger:hover {
  background: var(--accent-red-glow);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem;
}

.btn-blue {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}

.btn-blue:hover {
  background: #2563EB;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
}

.btn-outline-light {
  background: transparent;
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.4);
}

/* ── Loading / Progress ────────────────────────────────────────── */
.analysis-progress {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 48px;
  text-align: center;
}

.analysis-progress.visible {
  display: flex;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.progress-text {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.progress-detail {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Results Layout ────────────────────────────────────────────── */
.results-section {
  display: none;
}

.results-section.visible {
  display: block;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

/* ── 3D Viewer ─────────────────────────────────────────────────── */
.viewer-container {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  height: 500px;
}

.viewer-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.viewer-controls {
  position: absolute;
  bottom: 12px;
  left: 12px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.viewer-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.viewer-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-light);
}

.viewer-btn.active {
  color: var(--accent-green);
  border-color: var(--accent-green);
  background: rgba(34, 197, 94, 0.1);
}

.viewer-btn svg {
  width: 18px;
  height: 18px;
}

.viewer-legend {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  font-size: 0.75rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.legend-count {
  margin-left: auto;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
  letter-spacing: 0.02em;
}

.legend-count:empty {
  display: none;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-dot.thin-wall {
  background: #EF4444;
}

.legend-dot.overhang {
  background: #F59E0B;
}

.legend-dot.boundary {
  background: #3B82F6;
}

.legend-dot.intersection {
  background: #A855F7;
}

/* ── Results Panel ─────────────────────────────────────────────── */
.results-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.results-panel::-webkit-scrollbar {
  width: 6px;
}

.results-panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.results-panel::-webkit-scrollbar-track {
  background: transparent;
}

/* ── Verdict Card ──────────────────────────────────────────────── */
.verdict-card {
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.verdict-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.verdict-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.verdict-badge.pass {
  background: var(--accent-green-glow);
  color: var(--accent-green);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.verdict-badge.warn {
  background: var(--accent-amber-glow);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.verdict-badge.fail {
  background: var(--accent-red-glow);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.verdict-badge svg {
  width: 24px;
  height: 24px;
}

.confidence-meter {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.confidence-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.confidence-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.verdict-headline {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Check Matrix ──────────────────────────────────────────────── */
.check-matrix {
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.check-matrix-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}

.check-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.check-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.check-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.check-icon.pass {
  color: var(--accent-green);
}

.check-icon.warn {
  color: var(--accent-amber);
}

.check-icon.fail {
  color: var(--accent-red);
}

.check-icon.info {
  color: var(--accent-blue);
}

.check-icon.skip {
  color: var(--text-muted);
}

.check-icon svg {
  width: 18px;
  height: 18px;
}

.check-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}

.check-item.pass .check-label {
  color: var(--accent-green);
}

.check-item.warn .check-label {
  color: var(--accent-amber);
}

.check-item.fail .check-label {
  color: var(--accent-red);
}

.check-item.info .check-label {
  color: var(--accent-blue);
}

.check-detail {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Metrics Cards ─────────────────────────────────────────────── */
.metrics-section {
  margin-bottom: 24px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.metric-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: border-color var(--transition-fast);
}

.metric-card:hover {
  border-color: var(--border-light);
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.metric-value {
  font-size: 1.375rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.metric-unit {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 4px;
}

/* ── Warnings & Recommendations ────────────────────────────────── */
.info-section {
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.info-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-section-title svg {
  width: 18px;
  height: 18px;
}

.info-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-list-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-secondary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
}

.info-list-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.info-list-item.warning svg {
  color: var(--accent-amber);
}

.info-list-item.recommendation svg {
  color: var(--accent-blue);
}

.info-list-item.error svg {
  color: var(--accent-red);
}

.bottom-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

/* ── Preset Details ────────────────────────────────────────────── */
.preset-details {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.preset-details-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.preset-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--border);
}

.preset-row:last-child {
  border-bottom: none;
}

.preset-key {
  color: var(--text-muted);
}

.preset-val {
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

/* ── Footer ────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.footer a {
  color: var(--text-secondary);
}

.footer a:hover {
  color: var(--accent-green);
}

/* ── Error state ───────────────────────────────────────────────── */
.error-banner {
  display: none;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: var(--accent-red-glow);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--accent-red);
  font-size: 0.875rem;
  margin-bottom: 24px;
  align-items: center;
  gap: 10px;
}

.error-banner.visible {
  display: flex;
}

/* ── AI Edit Workspace ────────────────────────────────────────── */
.ai-edit-section {
  display: none;
  margin-bottom: 24px;
}

.ai-edit-section.visible {
  display: block;
}

.ai-edit-ui-section {
  display: none;
  margin-bottom: 24px;
}

.ai-edit-ui-section.visible {
  display: block;
}

.ai-edit-ui-card {
  border-color: rgba(168, 85, 247, 0.35);
  box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.08) inset;
}

.ai-ui-version-badge {
  color: #DDD6FE;
  background: rgba(124, 58, 237, 0.16);
  border-color: rgba(124, 58, 237, 0.4);
}

.ai-edit-card {
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-edit-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-edit-header-row h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
}

.ai-version-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #93C5FD;
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.ai-step-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 9999px;
  border: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
}

.ai-edit-header-row p {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.ai-edit-actions {
  display: flex;
  gap: 8px;
}

.ai-edit-upload-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-edit-upload-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-session-label {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.ai-connection-badge {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.ai-connection-badge.online {
  color: var(--accent-green);
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.08);
}

.ai-connection-badge.offline {
  color: var(--accent-red);
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
}

.ai-execution-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 9999px;
  background: var(--accent-amber-glow);
  color: var(--accent-amber);
  font-size: 0.74rem;
  font-weight: 600;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.spinner-small {
  width: 12px;
  height: 12px;
  animation: spin 1.5s linear infinite;
  stroke: currentColor;
}

.ai-export-row {
  min-height: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-preview-link {
  font-size: 0.78rem;
  color: var(--accent-blue);
  text-decoration: none;
}

.ai-preview-link:hover {
  text-decoration: underline;
}

.ai-workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.ai-viewer-card {
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 540px;
}

.ai-viewer-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-viewer-title .viewer-coord-badge {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.12);
  border: 1px solid rgba(124, 58, 237, 0.3);
  color: #c4b5fd;
  letter-spacing: 0.03em;
  font-weight: 700;
}

.ai-viewer-canvas {
  width: 100%;
  flex: 1;
  min-height: 480px;
  display: block;
  border-radius: var(--radius-sm);
  background: radial-gradient(ellipse at 30% 20%, #111827, #050810);
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.ai-chat-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.ai-chat-log {
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  min-height: 220px;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-trace-panel {
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 10px;
  min-width: 0;
}

.ai-trace-title {
  font-size: 0.74rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.ai-trace-log {
  margin: 0;
  max-height: 380px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

.ai-trace-entry {
  line-height: 1.4;
  word-break: break-word;
}

.ai-trace-entry.error {
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.05);
  padding: 4px 6px;
  border-radius: 4px;
  border-left: 2px solid var(--accent-red);
}

.ai-trace-time {
  color: var(--text-muted);
  margin-right: 6px;
}

.ai-trace-text {
  color: var(--text-primary);
}

.ai-trace-entry.error .ai-trace-text {
  color: var(--accent-red);
}

.ai-msg {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.82rem;
  line-height: 1.45;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ai-msg.user {
  align-self: flex-end;
  background: var(--accent-blue-glow);
  border-color: rgba(59, 130, 246, 0.35);
}

.ai-msg.assistant {
  align-self: flex-start;
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.25);
}

.ai-msg.system {
  align-self: center;
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.28);
  color: var(--text-secondary);
}

.ai-input-send-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ai-input-send-row textarea {
  flex: 1;
  min-height: 92px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  padding: 10px 12px;
  resize: vertical;
  font-family: var(--font-sans);
}

.ai-input-send-row textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.ai-input-send-row #aiUiSendBtn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin-bottom: 4px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ai-input-send-row #aiUiSendBtn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.35);
}

.ai-chat-input-row textarea {
  width: 100%;
  min-height: 92px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  padding: 10px 12px;
  resize: vertical;
  font-family: var(--font-sans);
}

.ai-chat-input-row textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.ai-chat-attachment-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.ai-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.08);
  color: var(--text-secondary);
  font-size: 0.75rem;
}

.ai-attachment-chip span {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-attachment-remove {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  width: 18px;
  height: 18px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ai-attachment-remove:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

/* ── AI Edit UI: Stop Button ───────────────────────────────────── */
.btn-stop {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
  cursor: pointer;
}

.btn-stop:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.6);
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.2);
}

.btn-stop:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── AI Edit UI: Thinking / Shimmer bar ────────────────────────── */
.ai-thinking-bar {
  display: none;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(168, 85, 247, 0.7) 30%,
    rgba(59, 130, 246, 0.9) 60%,
    transparent 100%);
  background-size: 200% 100%;
  animation: aiShimmer 1.6s ease-in-out infinite;
  margin: -4px -16px 0;
}

.ai-thinking-bar.visible {
  display: block;
}

@keyframes aiShimmer {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

/* ── AI Edit UI: Thinking text ─────────────────────────────────── */
.ai-thinking-text {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: #c4b5fd;
  font-weight: 500;
}

.ai-thinking-text.visible {
  display: inline-flex;
}

.ai-thinking-dots span {
  display: inline-block;
  animation: aiDotPulse 1.2s ease-in-out infinite;
  color: #a78bfa;
}

.ai-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiDotPulse {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%            { opacity: 1;   transform: translateY(-3px); }
}

/* ── AI Edit UI: Toolbar row ───────────────────────────────────── */
.ai-ui-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-ui-toolbar .toolbar-separator {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 2px;
}

/* ── AI Edit UI: Chat column height balance ────────────────────── */
.ai-edit-ui-section .ai-chat-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  height: 100%;
}

.ai-edit-ui-section .ai-chat-log {
  flex: 1;
  min-height: 180px;
  max-height: none;
}

.ai-edit-ui-section .ai-trace-panel {
  flex-shrink: 0;
}

.error-banner svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .results-grid {
    grid-template-columns: 1fr;
  }

  .results-panel {
    max-height: none;
  }

  .viewer-container {
    height: 400px;
  }

  .bottom-info-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .ai-workspace-grid {
    grid-template-columns: 1fr;
  }

  .ai-viewer-canvas {
    min-height: 300px;
    height: auto;
  }

  .ai-viewer-card {
    min-height: auto;
  }

  .navbar {
    padding: 0 16px;
  }

  .main-container {
    padding: 20px 16px 48px;
  }

  .upload-zone {
    padding: 32px 20px;
    min-height: 180px;
  }

  .config-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .config-group {
    justify-content: space-between;
  }

  .viewer-container {
    height: 320px;
  }

  .metrics-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .navbar-title {
    font-size: 0.9375rem;
  }

  .navbar-links {
    gap: 8px;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .file-info-bar {
    flex-wrap: wrap;
  }
}

/* ── Reduced motion ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Controls Panel ───────────────────────────────────────────── */
.controls-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
  padding: 20px 24px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.controls-panel.visible {
  display: flex;
}

.controls-row {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.toggles-row {
  gap: 24px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-green);
  cursor: pointer;
}

.toggle-text {
  transition: color var(--transition-fast);
}

.toggle-label:hover .toggle-text {
  color: var(--text-primary);
}

.buttons-row {
  gap: 12px;
}

/* Wall thickness button */
.btn-wall-thickness {
  background: rgba(34, 211, 238, 0.1);
  color: #67E8F9;
  border: 1px solid rgba(34, 211, 238, 0.3);
}

.btn-wall-thickness:hover {
  background: rgba(34, 211, 238, 0.18);
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.15);
}

.btn-wall-thickness:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Highlight errors button */
.btn-highlight {
  background: rgba(168, 85, 247, 0.1);
  color: #C084FC;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.btn-highlight:hover {
  background: rgba(168, 85, 247, 0.18);
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.15);
}

.btn-highlight:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Wall thickness section */
.wall-thickness-section {
  margin-bottom: 24px;
}

.wt-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.wt-result-card {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.wt-result-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.wt-result-value {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.wt-result-value.good {
  color: var(--accent-green);
}

.wt-result-value.warn {
  color: var(--accent-amber);
}

.wt-result-value.bad {
  color: var(--accent-red);
}

@media (max-width: 768px) {
  .controls-row {
    flex-direction: column;
    align-items: stretch;
  }

  .buttons-row {
    gap: 8px;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ── Print Time button ────────────────────────────────────────── */
.btn-time {
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.08);
}

.btn-time:hover {
  background: rgba(245, 158, 11, 0.18);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.15);
}

.btn-time:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Layer Simulation button ───────────────────────────────────── */
.btn-simulation {
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #93C5FD;
  background: rgba(59, 130, 246, 0.1);
}

.btn-simulation:hover {
  background: rgba(59, 130, 246, 0.2);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.16);
}

.btn-simulation:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Print Time Section ───────────────────────────────────────── */
.print-time-section {
  margin-bottom: 24px;
}

.pt-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.pt-result-card {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.pt-result-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.pt-result-value {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-amber);
}

/* ── Engine Logs ──────────────────────────────────────────────── */
.engine-logs-section {
  margin-bottom: 24px;
}

.logs-toggle {
  cursor: pointer;
  user-select: none;
}

.logs-toggle:hover {
  color: var(--accent-blue);
}

.toggle-arrow {
  margin-left: auto;
  font-size: 0.85rem;
  transition: transform var(--transition-normal);
}

.toggle-arrow.collapsed {
  transform: rotate(-90deg);
}

.engine-logs-content {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 12px;
  max-height: 500px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.engine-logs-content.collapsed {
  display: none;
}

/* ── Confidence tooltip ───────────────────────────────────────── */
.confidence-meter {
  cursor: help;
  position: relative;
}

.confidence-meter[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  right: 0;
  width: 280px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.75rem;
  line-height: 1.5;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  pointer-events: none;
}

/* ── Print Time Estimation ─────────────────────────────────────── */
.pt-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  padding: 8px 0;
}

.pt-result-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pt-result-label,
.preset-key {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pt-result-value,
.preset-val {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent-amber);
  font-family: var(--font-mono);
}

/* ── Layer-by-Layer Simulation ─────────────────────────────────── */
.simulation-section {
  margin-bottom: 24px;
}

.simulation-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.simulation-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.simulation-status {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
}

.simulation-fidelity-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.simulation-fidelity-wrap label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.simulation-fidelity-wrap select,
#simulationSpeed {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.8rem;
  padding: 6px 8px;
}

.simulation-canvas {
  width: 100%;
  height: 280px;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #050a14;
}

.simulation-controls-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.simulation-controls-row input[type="range"] {
  width: 100%;
}

.simulation-meta {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-muted);
}