:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3f56;
  --text: #e8eef4;
  --text-muted: #8fa3b8;
  --accent: #4a9eff;
  --accent-hover: #6bb0ff;
  --success: #34d399;
  --radius: 12px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.logo {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo h1 span { color: var(--accent); }

.logo .tagline {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
  min-height: 0;
}

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
}

.viewport-wrap {
  position: relative;
  min-height: 400px;
}

#drop-zone {
  position: absolute;
  inset: 0;
  cursor: pointer;
}

#viewport {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 400px;
}

#drop-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  pointer-events: none;
  background: rgba(15, 20, 25, 0.6);
  transition: opacity 0.3s;
}

#drop-hint.hidden { opacity: 0; }

.drop-icon {
  width: 64px;
  height: 64px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: var(--accent);
}

#drop-hint p { color: var(--text-muted); text-align: center; max-width: 280px; line-height: 1.5; }

#drop-hint strong { color: var(--text); }

.drag-over #drop-hint { background: rgba(74, 158, 255, 0.1); }

.sidebar {
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
}

@media (max-width: 900px) {
  .sidebar { border-left: none; border-top: 1px solid var(--border); }
}

.panel h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

#mesh-info {
  font-size: 0.9rem;
  color: var(--text-muted);
  min-height: 1.4em;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:not(:disabled):hover { background: var(--accent-hover); }
.btn-primary:not(:disabled):active { transform: scale(0.98); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.field label {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.field input[type="range"] { width: 100%; accent-color: var(--accent); }

.field select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
}

.checkbox-row input { accent-color: var(--accent); }

#progress-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#progress-panel.hidden { display: none; }

.progress-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 999px;
  transition: width 0.3s ease;
}

#progress-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.note {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 0.75rem;
  background: var(--surface-2);
  border-radius: 8px;
  border: 1px solid var(--border);
}

footer {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

#load-error {
  display: none;
  position: fixed;
  inset: 1rem;
  background: #1a0a0a;
  border: 1px solid #7f1d1d;
  border-radius: var(--radius);
  padding: 1.5rem;
  color: #fecaca;
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 0.85rem;
  z-index: 1000;
  overflow: auto;
}
