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

:root {
  --bg: #0c0c0f;
  --surface: #131318;
  --surface2: #1a1a22;
  --surface3: #22222d;
  --border: rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.14);
  --accent: #6c63ff;
  --accent-dim: rgba(108,99,255,0.15);
  --accent-glow: rgba(108,99,255,0.35);
  --text: #e8e8f0;
  --text-muted: #7a7a90;
  --text-dim: #44445a;
  --success: #3ecf8e;
  --danger: #ff5c5c;
  --mono: 'JetBrains Mono', monospace;
  --sans: 'DM Sans', sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

.app {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: 52px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ── */
.header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-logo {
  width: 26px; height: 26px;
  background: var(--accent);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}

.header-logo svg { width: 14px; height: 14px; }

.header-title {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text);
}

.header-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }

.header-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.header-spacer { flex: 1; }

.render-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.render-btn:hover { opacity: 0.88; }
.render-btn:active { transform: scale(0.97); }
.render-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.render-btn svg { width: 14px; height: 14px; }

/* ── Sidebar ── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 2px; }

/* ── Panels ── */
.panel {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--mono);
}

.panel-body { padding: 14px; }

/* ── Form elements ── */
.field { display: flex; flex-direction: column; gap: 5px; }

.field-label {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
  letter-spacing: 0.03em;
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

input[type=number], select {
  width: 100%;
  padding: 7px 10px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }

input[type=number]:focus, select:focus {
  border-color: var(--accent);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237a7a90' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

select option { background: var(--surface3); }

.height-display {
  display: flex; align-items: center;
  padding: 7px 10px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

/* ── Sphere input ── */
.xyz-grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 6px; margin-bottom: 10px; }

.xyz-field { display: flex; flex-direction: column; gap: 4px; }

.xyz-label {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--mono);
  text-align: center;
  letter-spacing: 0.06em;
}

.add-btn {
  width: 100%;
  padding: 8px;
  background: var(--accent-dim);
  border: 1px solid rgba(108,99,255,0.3);
  border-radius: var(--radius-sm);
  color: #a89fff;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.add-btn:hover {
  background: rgba(108,99,255,0.25);
  border-color: rgba(108,99,255,0.5);
}

/* ── Sphere list ── */
.sphere-list { display: flex; flex-direction: column; gap: 6px; }

.sphere-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.sphere-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
  flex-shrink: 0;
}

.sphere-dot.ground { background: var(--success); box-shadow: 0 0 6px rgba(62,207,142,0.4); }

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

.sphere-coords {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sphere-radius {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
}

.sphere-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.sphere-remove:hover { color: var(--danger); background: rgba(255,92,92,0.1); }

.empty-state {
  text-align: center;
  padding: 20px;
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--mono);
}

.sphere-count-badge {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid rgba(108,99,255,0.2);
}

/* ── Canvas area ── */
.canvas-area {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.canvas-info {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

.canvas-info span { color: var(--text); }

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-dot.ready { background: var(--success); box-shadow: 0 0 5px rgba(62,207,142,0.5); }
.status-dot.rendering { background: var(--accent); box-shadow: 0 0 5px var(--accent-glow); animation: pulse 1s infinite; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 24px;
}

#img {
  display: block;
  border-radius: 6px;
  border: 1px solid var(--border);
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.canvas-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
}

.canvas-placeholder svg { width: 48px; height: 48px; opacity: 0.3; }

.canvas-placeholder p {
  font-size: 13px;
  font-family: var(--mono);
}

.progress-bar {
  height: 2px;
  background: var(--surface3);
  position: relative;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.2s ease;
}

.progress-fill.indeterminate {
  width: 40%;
  animation: slide 1.2s ease-in-out infinite;
}

@keyframes slide {
  0% { transform: translateX(-200%); }
  100% { transform: translateX(350%); }
}

