:root {
  color-scheme: dark;
  --bg: #090b12;
  --panel: rgba(19, 22, 33, 0.88);
  --panel-strong: rgba(24, 27, 40, 0.96);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f6f8ff;
  --muted: #aeb7d9;
  --accent: #7f52ff;
  --accent-2: #f445b0;
  --radius: 24px;
  --radius-sm: 16px;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(127, 82, 255, 0.22), transparent 24%),
    radial-gradient(circle at bottom left, rgba(244, 69, 176, 0.18), transparent 28%),
    linear-gradient(140deg, #05070d 0%, #0b1020 45%, #090b12 100%);
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 12px 28px rgba(127, 82, 255, 0.32);
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.secondary,
button.ghost,
.preset-item,
.layer-list-item,
.project-card {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}

button.ghost {
  color: var(--muted);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

input[type="range"] {
  padding: 0;
}

.hidden {
  display: none !important;
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  padding: 12px 18px 0;
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 0 18px;
  border-radius: 20px;
  background: rgba(11, 13, 22, 0.94);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.3);
}

.app-header-title {
  font-size: 24px;
  font-weight: 700;
}

.app-header-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.view-stack {
  height: 100vh;
  padding-top: 74px;
}

.view {
  height: 100%;
}

.home-shell,
.editor-shell {
  display: grid;
  gap: 18px;
  height: 100%;
  padding: 12px 18px 18px;
}

.home-shell {
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.editor-shell {
  grid-template-columns: 200px minmax(0, 1fr) 270px;
}

.panel,
.workspace {
  min-height: 0;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
  overflow: auto;
}

.upload-panel {
  box-shadow:
    inset 0 0 0 1px rgba(127, 82, 255, 0.12),
    var(--shadow);
}

.library-panel {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    var(--shadow);
}

.panel-left {
  min-width: 0;
  padding: 16px;
}

.panel-right {
  min-width: 0;
  padding: 16px;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
  padding: 18px;
  overflow: hidden;
}

.panel-section + .panel-section {
  margin-top: 24px;
}

.project-rename-field {
  margin-top: 14px;
}

.compact-section {
  margin-top: 16px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(127, 82, 255, 0.12);
  color: #c4b2ff;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  margin-top: 10px;
  font-size: 32px;
  line-height: 1.08;
}

h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

.panel-left h2,
.panel-right h2 {
  font-size: 15px;
}

.muted,
.hint,
.topbar-label,
.topbar-note,
.project-meta,
.layer-meta,
.preset-meta,
.preset-note,
.editor-subtle {
  color: var(--muted);
}

.muted,
.hint {
  line-height: 1.7;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-grid.single {
  grid-template-columns: 1fr;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.panel-left label span,
.panel-right label span,
.panel-left .muted,
.panel-right .muted,
.panel-left .hint,
.panel-right .hint,
.panel-left .asset-item,
.panel-right .asset-item {
  font-size: 12px;
}

.file-field input {
  padding: 10px;
}

.upload-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.upload-actions button {
  min-width: 0;
  padding: 10px 14px;
  font-size: 13px;
}

.upload-actions .is-active {
  background: linear-gradient(135deg, rgba(127, 82, 255, 0.24), rgba(244, 69, 176, 0.18));
  color: #fff;
  box-shadow:
    inset 0 0 0 1px rgba(196, 178, 255, 0.38),
    0 10px 24px rgba(127, 82, 255, 0.16);
}

.dropzone {
  display: grid;
  gap: 4px;
  place-items: center;
  min-height: 120px;
  margin-top: 10px;
  padding: 18px 16px;
  border: 1px dashed rgba(196, 178, 255, 0.24);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(127, 82, 255, 0.08), rgba(244, 69, 176, 0.04));
  text-align: center;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.dropzone strong {
  font-size: 14px;
}

.dropzone span {
  color: var(--muted);
  font-size: 12px;
}

.dropzone.drag-over {
  border-color: rgba(196, 178, 255, 0.82);
  background: linear-gradient(135deg, rgba(127, 82, 255, 0.18), rgba(244, 69, 176, 0.12));
  transform: translateY(-1px);
}

.dropzone.paste-target {
  border-color: rgba(255, 255, 255, 0.68);
  background: linear-gradient(135deg, rgba(127, 82, 255, 0.16), rgba(244, 69, 176, 0.1));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.dropzone:focus-visible {
  outline: none;
  border-color: rgba(196, 178, 255, 0.82);
  box-shadow:
    0 0 0 1px rgba(196, 178, 255, 0.82),
    0 0 0 6px rgba(127, 82, 255, 0.16);
}

.dropzone-compact {
  min-height: 92px;
}

.upload-picked {
  margin-top: 8px;
  font-size: 12px;
  word-break: break-word;
}

.button-stack,
.preset-list,
.layer-list,
.asset-list {
  display: grid;
  gap: 10px;
}

.button-stack.compact {
  gap: 8px;
}

.button-inline {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
}

.workspace-topbar .button-inline button {
  padding: 10px 16px;
  font-size: 14px;
  white-space: nowrap;
}

.workspace-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.mode-switch {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.mode-switch button {
  padding: 9px 14px;
  font-size: 13px;
  box-shadow: none;
}

.mode-switch .is-active {
  background: linear-gradient(135deg, rgba(127, 82, 255, 0.26), rgba(244, 69, 176, 0.18));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(196, 178, 255, 0.32);
}

.library-switch {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.library-switch button {
  padding: 9px 14px;
  font-size: 13px;
  box-shadow: none;
}

.library-switch .is-active {
  background: linear-gradient(135deg, rgba(127, 82, 255, 0.26), rgba(244, 69, 176, 0.18));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(196, 178, 255, 0.32);
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.project-card {
  border-radius: 22px;
  padding: 18px;
}

.project-cover {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(127, 82, 255, 0.12), rgba(244, 69, 176, 0.08)),
    rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.project-cover-image,
.project-cover-empty {
  position: absolute;
  inset: 0;
}

.project-cover-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.project-cover-empty {
  display: grid;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.project-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.project-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.project-card-actions button {
  padding: 9px 13px;
  font-size: 12px;
  white-space: nowrap;
}

.project-open-button {
  flex-shrink: 0;
}

.project-trash-button,
.project-delete-button {
  color: #ffb4cf;
}

.project-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-title {
  font-size: 18px;
  line-height: 1.2;
}

.project-rename-trigger {
  min-width: 28px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.48);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.project-rename-trigger:hover {
  color: rgba(255, 255, 255, 0.78);
}

.project-title-input {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 14px;
}

.project-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.file-chip,
.footer-chip,
.asset-item {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  border-radius: 22px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
}

.preset-item,
.layer-list-item {
  position: relative;
  width: 100%;
  border-radius: 18px;
  padding: 12px 13px;
  text-align: left;
  transition: transform 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.layer-list-item {
  cursor: grab;
}

.preset-item.active,
.layer-list-item.active {
  background: linear-gradient(135deg, rgba(127, 82, 255, 0.16), rgba(244, 69, 176, 0.12));
  box-shadow: inset 0 0 0 1px rgba(196, 178, 255, 0.24);
}

.layer-list-item.dragging {
  cursor: grabbing;
  opacity: 0.56;
  transform: scale(0.985);
  filter: saturate(0.92);
  box-shadow:
    inset 0 0 0 1px rgba(196, 178, 255, 0.18),
    0 14px 28px rgba(0, 0, 0, 0.22);
}

.layer-list-item.drop-before::before,
.layer-list-item.drop-after::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(127, 82, 255, 0.96), rgba(244, 69, 176, 0.96));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 0 18px rgba(127, 82, 255, 0.28);
  pointer-events: none;
}

.layer-list-item.drop-before::before {
  top: -6px;
}

.layer-list-item.drop-before {
  transform: translateY(7px);
}

.layer-list-item.drop-after::after {
  bottom: -6px;
}

.layer-list-item.drop-after {
  transform: translateY(-7px);
}

.preset-title,
.layer-title {
  display: block;
  font-size: 12px;
  font-weight: 700;
}

.layer-meta,
.preset-note {
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.4;
}

.workspace-topbar,
.workspace-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.workspace-footer {
  flex-wrap: wrap;
}

.topbar-value {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
}

.topbar-note {
  margin-top: 6px;
  max-width: 360px;
  font-size: 11px;
  line-height: 1.45;
}

.topbar-label {
  font-size: 11px;
}

.stage-viewport {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 10px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01)),
    rgba(6, 7, 12, 0.46);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 0 18px 48px rgba(255, 255, 255, 0.02);
}

.stage {
  position: relative;
  border-radius: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 40%),
    #08070f;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

.stage-background,
.layer-root,
.stage-guides {
  position: absolute;
  inset: 0;
}

.stage-background {
  z-index: 1;
}

.layer-root {
  z-index: 4;
}

.stage-guides {
  z-index: 12;
  pointer-events: none;
}

.stage-background img {
  position: absolute;
  user-select: none;
  pointer-events: none;
}

.guide {
  position: absolute;
  background: rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

.guide-v {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
}

.guide-h {
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  transform: translateY(-50%);
}

.guide-base-v,
.guide-base-h {
  opacity: 0.34;
}

.guide-dynamic {
  background: linear-gradient(180deg, rgba(127, 82, 255, 0.96), rgba(244, 69, 176, 0.96));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 0 24px rgba(127, 82, 255, 0.42);
  opacity: 1;
}

.guide-dynamic-v {
  width: 2px;
}

.guide-dynamic-h {
  height: 2px;
}

.guide-dynamic.is-active {
  animation: guidePulse 0.18s ease-out;
}

.spacing-guide {
  position: absolute;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 212, 77, 0.96), rgba(255, 145, 77, 0.96));
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.14),
    0 0 22px rgba(255, 184, 77, 0.38);
  pointer-events: none;
}

.spacing-guide-h {
  height: 2px;
}

.spacing-guide-v {
  width: 2px;
}

.stage-layer {
  position: absolute;
  transform-origin: center center;
}

.stage-layer.movable {
  cursor: move;
}

.stage-layer.selected {
  outline: 2px solid rgba(255, 255, 255, 0.92);
  outline-offset: 7px;
}

.stage-layer img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  user-select: none;
}

.resize-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 3px rgba(9, 11, 18, 0.7);
}

.resize-handle.corner-nw {
  left: -8px;
  top: -8px;
  cursor: nwse-resize;
}

.resize-handle.corner-ne {
  right: -8px;
  top: -8px;
  cursor: nesw-resize;
}

.resize-handle.corner-sw {
  left: -8px;
  bottom: -8px;
  cursor: nesw-resize;
}

.resize-handle.corner-se {
  right: -8px;
  bottom: -8px;
  cursor: nwse-resize;
}

.resize-handle.edge-n,
.resize-handle.edge-s {
  left: 50%;
  width: 26px;
  height: 10px;
  margin-left: -13px;
  border-radius: 999px;
  cursor: ns-resize;
}

.resize-handle.edge-n {
  top: -6px;
}

.resize-handle.edge-s {
  bottom: -6px;
}

.resize-handle.edge-e,
.resize-handle.edge-w {
  top: 50%;
  width: 10px;
  height: 26px;
  margin-top: -13px;
  border-radius: 999px;
  cursor: ew-resize;
}

.resize-handle.edge-e {
  right: -6px;
}

.resize-handle.edge-w {
  left: -6px;
}

.stage.snap-feedback::after {
  border-color: rgba(196, 178, 255, 0.4);
  box-shadow: 0 0 0 1px rgba(196, 178, 255, 0.16);
}

@keyframes guidePulse {
  0% {
    opacity: 0.28;
    filter: brightness(1.3);
  }
  100% {
    opacity: 1;
    filter: brightness(1);
  }
}

.editor-heading {
  display: grid;
  gap: 4px;
}

.layer-editor {
  display: grid;
  gap: 16px;
}

@media (max-width: 1240px) {
  .editor-shell {
    grid-template-columns: 320px minmax(420px, 1fr);
  }

  .panel-right {
    grid-column: 1 / -1;
    min-height: auto;
  }
}

@media (max-width: 1180px) {
  .home-shell,
  .editor-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100%;
  }

  body {
    overflow: auto;
  }

  .view-stack {
    height: auto;
    min-height: 100vh;
  }
}

@media (max-width: 860px) {
  .app-header-inner,
  .workspace-topbar,
  .workspace-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }
}
