:root {
  --bg: #1a1a1e;
  --panel-bg: #222228;
  --panel-border: #333338;
  --text: #e8e8ec;
  --text-dim: #888890;
  --accent: #5b8def;
  --accent-hover: #6d9af5;
  --slider-track: #3a3a42;
  --slider-thumb: #5b8def;
  --preset-bg: #2a2a32;
  --preset-border: #3a3a44;
  --preset-active-bg: #3a4a5e;
  --preset-active-border: #5b8def;
  --error-bg: #2a1a1a;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
}

#error-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
}

#error-overlay.hidden {
  display: none;
}

.error-box {
  max-width: 400px;
  padding: 32px;
  text-align: center;
  background: var(--error-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

.error-box h2 {
  font-size: 18px;
  margin-bottom: 12px;
  color: #e07070;
}

.error-box p {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
}

#panel {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 280px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 16px;
  z-index: 10;
}

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

.panel-header h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

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

.header-actions button {
  font-size: 11px;
  padding: 5px 10px;
  background: var(--preset-bg);
  border: 1px solid var(--preset-border);
  border-radius: 5px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.header-actions button:hover {
  background: var(--preset-active-bg);
  color: var(--text);
}

.panel-section {
  margin-bottom: 14px;
}

.panel-section:last-child {
  margin-bottom: 0;
}

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.color-row label {
  font-size: 13px;
  color: var(--text-dim);
}

.color-row input[type="color"] {
  width: 48px;
  height: 32px;
  border: 1px solid var(--preset-border);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  padding: 2px;
}

.color-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-row input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

.slider-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.slider-value {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--slider-track);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--slider-thumb);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--panel-bg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--slider-thumb);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--panel-bg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.presets-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
  display: block;
}

.presets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.preset-btn {
  font-size: 11px;
  padding: 8px 6px;
  background: var(--preset-bg);
  border: 1px solid var(--preset-border);
  border-radius: 5px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-align: center;
}

.preset-btn:hover {
  background: var(--preset-active-bg);
  color: var(--text);
  border-color: var(--accent);
}

.preset-btn.active {
  background: var(--preset-active-bg);
  border-color: var(--preset-active-border);
  color: var(--text);
}

.auto-rotate-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}

.auto-rotate-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

@media (max-width: 640px) {
  #panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 45vh;
    border-radius: 10px 10px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 12px 16px 16px;
  }

  #panel::-webkit-scrollbar {
    width: 4px;
  }

  #panel::-webkit-scrollbar-thumb {
    background: var(--preset-border);
    border-radius: 2px;
  }
}
