:root {
  --bg-primary: #0f1117;
  --bg-secondary: #161922;
  --bg-glass: rgba(22, 25, 34, 0.75);
  --border-color: rgba(255, 255, 255, 0.12);
  --border-hover: rgba(255, 255, 255, 0.25);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 20;
}

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

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.topbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar p {
  margin: 2px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.open-button, .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px var(--accent-glow);
}

.open-button:hover, .btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--accent-glow);
}

/* 3D Canvas Container */
#viewer {
  position: relative;
  flex: 1;
  min-height: 0;
  background: radial-gradient(circle at 50% 40%, #1e2330 0%, #0f1117 70%);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

/* Drop Zone */
.drop-zone {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 20px;
  background: rgba(15, 17, 23, 0.6);
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}

.drop-card {
  width: min(440px, 100%);
  padding: 40px 28px;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
}

.drop-zone.dragover .drop-card {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.12);
  transform: scale(1.02);
  box-shadow: 0 0 30px var(--accent-glow);
}

.drop-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.drop-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
}

.drop-card p {
  margin: 0 0 24px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

/* Loading & Toast */
.loading {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 14px;
  font-weight: 500;
  z-index: 30;
}

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

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

.toast {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  font-size: 13px;
  font-weight: 500;
  z-index: 40;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  max-width: 90%;
  text-align: center;
}

/* Floating Toolbar */
.toolbar {
  position: absolute;
  left: 20px;
  bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  z-index: 15;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.toolbar button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.toolbar button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.toolbar button.active {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.anim-select {
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.anim-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Model Info Box */
.model-info {
  position: absolute;
  right: 20px;
  bottom: 20px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-secondary);
  z-index: 15;
  min-width: 180px;
}

.model-info strong {
  color: var(--text-primary);
  font-size: 13px;
  display: block;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.model-info .stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.model-info .stat-val {
  color: var(--text-primary);
  font-weight: 600;
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 16px;
  }
  .toolbar {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
  .model-info {
    right: 12px;
    bottom: 80px;
  }
}

