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

:root {
  --bg: #08080c;
  --bg2: #0e0e14;
  --surface: rgba(255,255,255,0.03);
  --surface-2: rgba(255,255,255,0.06);
  --border: rgba(255,255,255,0.07);
  --border-2: rgba(255,255,255,0.13);
  --accent: #3b82f6;
  --accent-dim: rgba(59,130,246,0.12);
  --accent-glow: rgba(59,130,246,0.25);
  --text: #f0f0f4;
  --text-muted: #6b6b7a;
  --text-dim: #3a3a46;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 10px;
  --radius-sm: 6px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}


/* ── topbar ─────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 50px;
  background: rgba(8,8,12,0.85);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -0.2px;
  color: var(--text);
  margin-right: auto;
  user-select: none;
}

.logo svg { flex-shrink: 0; }

.topbar-actions { display: flex; gap: 6px; }

.btn {
  padding: 6px 13px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  line-height: 1;
  outline: none;
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
}
.btn-primary:hover { background: #5a95f7; }


/* ── layout ─────────────────────────────────────────────────── */

.editor-layout {
  display: flex;
  flex: 1;
  gap: 10px;
  padding: 10px;
  min-height: 0;
  overflow: hidden;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.panel-3d { flex: 0 0 44%; }
.panel-2d { flex: 1; min-width: 0; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 13px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: rgba(255,255,255,0.015);
}

.panel-header .hint {
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
}


/* ── 3D panel ────────────────────────────────────────────────── */

.three-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 40% 25%, #111628 0%, var(--bg) 72%);
}

#three-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(8,8,12,0.75);
  color: var(--text-muted);
  font-size: 12.5px;
  transition: opacity 0.25s;
  backdrop-filter: blur(4px);
}

.loading-overlay code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 2px 6px;
  border-radius: 3px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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


/* ── editor tools ────────────────────────────────────────────── */

.editor-tools {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(255,255,255,0.012);
  flex-wrap: wrap;
  row-gap: 4px;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 8px;
  border-right: 1px solid var(--border);
}
.tool-group:last-child { border-right: none; }

.tool-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.12s;
  outline: none;
}
.tool-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.tool-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(59,130,246,0.28);
}
.tool-btn.btn-danger:hover {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
  border-color: rgba(239,68,68,0.2);
}

.color-wrap {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.12s;
}
.color-wrap:hover { border-color: var(--border-2); }

input[type="color"] {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  border: none;
  padding: 0;
  cursor: pointer;
  background: none;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 76px;
  height: 3px;
  background: var(--border-2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.12s;
}
input[type="range"]::-webkit-slider-thumb:hover { background: #60a5fa; }

.size-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  min-width: 22px;
  text-align: right;
  user-select: none;
}


/* ── canvas wrapper ──────────────────────────────────────────── */

.canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 14px;
  position: relative;
  min-height: 0;
  background: repeating-conic-gradient(rgba(255,255,255,0.015) 0% 25%, transparent 0% 50%) 0 0 / 16px 16px;
}

.canvas-inner {
  line-height: 0;
  position: relative;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 8px 32px rgba(0,0,0,0.5);
}

#editor-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 2px;
}

.drop-overlay {
  position: absolute;
  inset: 10px;
  border: 1.5px dashed var(--accent);
  border-radius: var(--radius);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  pointer-events: none;
  background: rgba(59,130,246,0.06);
  backdrop-filter: blur(8px);
  transition: opacity 0.15s;
  z-index: 10;
}
.drop-overlay.visible { display: flex; }


/* ── footer ─────────────────────────────────────────────────── */

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 18px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
  flex-shrink: 0;
  background: rgba(8,8,12,0.5);
}

.footer a {
  color: var(--text-muted);
  text-decoration: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  transition: color 0.15s;
}
.footer a:hover { color: var(--accent); }


/* ── toast ──────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: rgba(20,20,28,0.95);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 7px 16px;
  font-size: 12.5px;
  color: var(--text);
  backdrop-filter: blur(16px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.success { border-color: rgba(34,197,94,0.3); color: var(--success); }
.toast.error { border-color: rgba(239,68,68,0.3); color: var(--danger); }


/* ── type badge ─────────────────────────────────────────────── */

.type-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(59,130,246,0.2);
  margin-left: 7px;
  vertical-align: middle;
  line-height: 1.6;
}


/* ── type picker modal ──────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.modal-backdrop.visible {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: #111117;
  border: 1px solid var(--border-2);
  border-radius: 14px;
  padding: 32px 36px;
  text-align: center;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  transform: translateY(8px);
  transition: transform 0.18s;
}
.modal-backdrop.visible .modal-box {
  transform: translateY(0);
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.2px;
}

.modal-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 26px;
}

.type-cards {
  display: flex;
  gap: 12px;
}

.type-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 22px 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.13s, border-color 0.13s, color 0.13s;
  outline: none;
}
.type-card:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--text);
}
.type-card:hover svg { stroke: var(--accent); }

.type-card svg {
  transition: stroke 0.13s;
}

.type-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.1px;
}

.type-file {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
}
