* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #101010;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#scene {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 10%, rgba(244, 242, 255, 0.9), rgba(255, 255, 255, 0) 42%),
    linear-gradient(180deg, #fbfaff 0%, #ffffff 46%, #fbfbff 100%);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.28);
  cursor: grab;
  touch-action: none;
}

#scene.is-dragging {
  cursor: grabbing;
}

.scene-workspace {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 96px 72px 72px;
  overflow: auto;
  background: #101010;
}

.scene-topbar {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f4f1ff;
}

.scene-tab,
.scene-preset-select,
.scene-size-field {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #f4f1ff;
  background: rgba(8, 8, 12, 0.82);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(16px);
  font-size: 13px;
  font-weight: 700;
}

.scene-tab {
  display: grid;
  place-items: center;
  padding: 0 12px;
}

.scene-preset-select {
  width: 190px;
  padding: 0 10px;
}

.scene-size-field {
  display: grid;
  grid-template-columns: auto 86px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
}

.scene-size-field span {
  color: rgba(244, 241, 255, 0.62);
}

.scene-size-field input {
  width: 86px;
  border: 0;
  color: #f4f1ff;
  background: transparent;
  font: inherit;
  text-align: right;
  outline: none;
}

.position-field {
  grid-template-columns: auto 62px;
}

.position-field input {
  width: 62px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

.toolbar {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 2;
  display: grid;
  grid-template-columns: 38px minmax(58px, auto) 38px 46px 38px 38px 38px 52px 38px;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(8, 8, 12, 0.82);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(16px);
}

.toolbar.is-hidden {
  display: none;
}

.tool-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  color: #f4f1ff;
  background: rgba(255, 255, 255, 0.11);
  font: 600 18px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
}

.lucide-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-button:hover {
  background: rgba(255, 255, 255, 0.18);
}

.tool-button:active {
  transform: translateY(1px);
}

.tool-button:focus-visible {
  outline: 2px solid rgba(74, 61, 220, 0.48);
  outline-offset: 2px;
}

.reset-button {
  width: 46px;
  font-size: 13px;
}

.zoom-readout {
  min-width: 58px;
  color: #f2efff;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.panel-toggle {
  font-size: 16px;
}

.language-select-wrap {
  position: relative;
  display: grid;
  width: 52px;
  height: 34px;
  place-items: center;
  border-radius: 6px;
  color: #f4f1ff;
  background: rgba(255, 255, 255, 0.11);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.language-select-wrap:hover {
  background: rgba(255, 255, 255, 0.18);
}

.language-current {
  pointer-events: none;
}

.language-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.parameter-panel,
.export-panel,
.settings-panel {
  position: fixed;
  top: 78px;
  right: 18px;
  z-index: 2;
  width: min(360px, calc(100vw - 36px));
  max-height: calc(100vh - 100px);
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(8, 8, 12, 0.86);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(18px);
}

.parameter-panel.is-hidden,
.export-panel.is-hidden,
.settings-panel.is-hidden {
  display: none;
}

.show-ui {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #f2efff;
  background: rgba(8, 8, 12, 0.82);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(16px);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.show-ui:hover {
  background: rgba(20, 20, 30, 0.92);
}

.show-ui.is-hidden {
  display: none;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 4;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #f4f1ff;
  background: rgba(8, 8, 12, 0.9);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
  font-size: 13px;
  font-weight: 700;
}

.toast-progress {
  width: 100%;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.toast-progress-bar {
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: #c9c1ff;
  animation: toast-progress 1s ease-in-out infinite alternate;
}

@keyframes toast-progress {
  from {
    transform: translateX(-40%);
  }

  to {
    transform: translateX(180%);
  }
}

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

.panel-title {
  margin: 0;
  color: #f4f1ff;
  font-size: 14px;
  font-weight: 700;
}

.panel-action {
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  color: #f4f1ff;
  background: rgba(255, 255, 255, 0.11);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.panel-action:hover {
  background: rgba(255, 255, 255, 0.18);
}

.panel-action:disabled {
  cursor: progress;
  opacity: 0.55;
}

.export-row {
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: center;
  gap: 10px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  accent-color: #c9c1ff;
}

.checkbox-row.is-disabled {
  opacity: 0.45;
}

.panel-select {
  width: 100%;
  height: 30px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  color: #f4f1ff;
  background: rgba(255, 255, 255, 0.09);
  font-size: 12px;
  font-weight: 700;
}

.panel-select:focus {
  outline: 2px solid rgba(74, 61, 220, 0.36);
  outline-offset: 1px;
}

.export-button {
  width: 100%;
}

.export-status {
  min-height: 16px;
  margin: 0;
  color: #c9c1ff;
  font-size: 12px;
}

.export-manual-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  color: #dcd6ff;
  background: rgba(255, 255, 255, 0.11);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.export-manual-link:hover {
  background: rgba(255, 255, 255, 0.18);
}

.export-manual-link.is-hidden {
  display: none;
}

.export-preview {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.10) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.10) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.10) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.10) 75%);
  background-color: rgba(255, 255, 255, 0.04);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.export-preview.is-hidden {
  display: none;
}

.subgroup-title {
  color: #c9c1ff;
  font-size: 12px;
  font-weight: 700;
}

.export-size-readout {
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: center;
  gap: 10px;
}

.export-size-value {
  color: #f4f1ff;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.settings-preview-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.mini-action {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  color: #f4f1ff;
  background: rgba(255, 255, 255, 0.09);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.mini-action:hover {
  background: rgba(255, 255, 255, 0.16);
}

.settings-json-preview {
  width: 100%;
  min-height: 220px;
  max-height: 42vh;
  resize: vertical;
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  color: #ece8ff;
  background: rgba(0, 0, 0, 0.34);
  font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre;
  tab-size: 2;
}

.settings-json-preview:focus {
  outline: 2px solid rgba(74, 61, 220, 0.36);
  outline-offset: 1px;
}

.control-group {
  display: grid;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.11);
}

.group-title {
  margin: 0;
  color: #c9c1ff;
  font-size: 12px;
  font-weight: 700;
}

.control-row {
  display: grid;
  grid-template-columns: 112px 1fr 64px;
  align-items: center;
  gap: 10px;
}

.control-label,
.control-value {
  color: #ebe7ff;
  font-size: 12px;
  font-weight: 600;
}

.control-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.control-row input[type="range"] {
  width: 100%;
  accent-color: #5c49e6;
}

.control-row input[type="number"],
.quantity-input {
  width: 64px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  color: #f4f1ff;
  background: rgba(255, 255, 255, 0.09);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.control-row input[type="number"]:focus,
.quantity-input:focus {
  outline: 2px solid rgba(74, 61, 220, 0.36);
  outline-offset: 1px;
}

.control-row input[type="color"] {
  width: 100%;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.color-value {
  font-size: 11px;
}

@media (max-width: 560px) {
  .scene-workspace {
    padding: 120px 12px 48px;
    align-items: flex-start;
    justify-content: flex-start;
  }

  .scene-topbar {
    top: 12px;
    left: 12px;
    right: 12px;
    flex-wrap: wrap;
  }

  .scene-preset-select {
    width: 160px;
  }

  .scene-size-field {
    grid-template-columns: auto 68px;
  }

  .scene-size-field input {
    width: 68px;
  }

  .position-field {
    grid-template-columns: auto 58px;
  }

  .position-field input {
    width: 58px;
  }

  .toolbar {
    top: 12px;
    right: 12px;
    grid-template-columns: 36px 52px 36px 36px 36px 36px 52px 36px;
  }

  .reset-button {
    display: none;
  }

  .parameter-panel,
  .export-panel,
  .settings-panel {
    top: 66px;
    right: 12px;
    width: calc(100vw - 24px);
    max-height: calc(100vh - 84px);
  }

  .show-ui {
    top: 12px;
    right: 12px;
  }

  .toast-region {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }

  .control-row {
    grid-template-columns: 92px 1fr 58px;
  }

  .export-row,
  .export-size-readout {
    grid-template-columns: 92px 1fr;
  }

  .control-row input[type="number"],
  .quantity-input {
    width: 58px;
    padding: 0 4px;
  }
}
