:root {
  --bg-0: #f7f2f6;
  --bg-1: #f3e8ee;
  --panel: rgba(255, 250, 253, 0.82);
  --panel-strong: rgba(255, 248, 252, 0.94);
  --line: rgba(50, 33, 46, 0.14);
  --line-strong: rgba(50, 33, 46, 0.22);
  --text: #211722;
  --muted: rgba(33, 23, 34, 0.62);
  --accent-dark: #1a121a;
  --accent-mid: #4a2f45;
  --accent-soft: #e2bfd0;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --fs-xxs: 11px;
  --fs-xs: 12px;
  --fs-sm: 12.5px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --border-1: 1px;
  --shadow-soft: 0 12px 30px rgba(56, 36, 54, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  color: var(--text);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(circle at 10% 12%, rgba(239, 213, 230, 0.44) 0%, transparent 38%),
    radial-gradient(circle at 84% 18%, rgba(229, 198, 221, 0.38) 0%, transparent 42%),
    linear-gradient(145deg, var(--bg-0) 0%, var(--bg-1) 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

.studio-shell {
  height: 100dvh;
  padding: 14px;
  display: grid;
  gap: 12px;
  grid-template-columns: 96px 320px minmax(560px, 1fr) 340px;
}

.studio-shell > * {
  min-height: 0;
  height: 100%;
}

.panel {
  border: var(--border-1) solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow-soft);
}

.SidebarNav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 14px 10px;
}

.brand-block {
  width: 100%;
  border: var(--border-1) solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  padding: 10px 10px;
  text-align: center;
  overflow: hidden;
  container-type: inline-size;
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  display: block;
  margin: -2px auto 2px;
  animation: logoFloat 2.6s ease-in-out infinite;
}

.brand-block h1 {
  margin: 0;
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  font-weight: 700;
}

.brand-title {
  margin: -1px 0 0;
  display: grid;
  gap: 2px;
  justify-items: center;
  font-size: clamp(15px, 1.2vw, 20px);
  font-weight: 760;
  line-height: 1.1;
  letter-spacing: 0.14em;
}

.brand-title > span {
  display: block;
  width: 3.6em;
  text-align: center;
  white-space: nowrap;
}

.brand-block p {
  margin: 4px 0 0;
  font-size: var(--fs-xxs);
  color: var(--muted);
  line-height: 1.3;
}

.brand-subtitle {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 9px auto 0;
  overflow: visible;
  white-space: nowrap;
  text-overflow: clip;
  padding: 0;
  box-sizing: border-box;
  text-align: center;
  line-height: 1.25;
  min-height: 1.25em;
  font-size: clamp(9px, 11cqw, 12px);
  letter-spacing: 0.01em;
  transform: translateX(-4px);
}

.brand-subtitle::after {
  content: "|";
  margin-left: 1px;
  vertical-align: baseline;
  color: rgba(33, 23, 34, 0.55);
  animation: cursorBlink 0.8s steps(1, end) infinite;
}

.nav-list {
  width: 100%;
  display: grid;
  gap: 8px;
}

.nav-item {
  border: var(--border-1) solid var(--line);
  background: var(--panel-strong);
  border-radius: 16px;
  min-height: 64px;
  padding: 6px;
  color: var(--text);
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.18s ease;
}

.nav-item:hover {
  transform: translateY(-1px);
  background: #fff9fd;
  border-color: var(--line-strong);
}

.nav-item.active {
  background: linear-gradient(150deg, #261b26, #1a121a);
  color: #fceef7;
  border-color: transparent;
}

.nav-item.active:hover {
  background: linear-gradient(150deg, #3a2738, #241925);
  color: #fff3fa;
  border-color: rgba(255, 226, 243, 0.28);
}

.nav-icon {
  font-size: var(--fs-md);
  line-height: 1;
}

.nav-label {
  font-size: var(--fs-xxs);
  letter-spacing: 0.06em;
  font-weight: 650;
}

.ContentPanel,
.PropertyPanel {
  overflow: auto;
  padding: 12px;
}

.PropertyPanel .panel-title {
  font-size: 12px;
  line-height: 1.15;
}

.PropertyPanel .sub-note {
  font-size: 11px;
  line-height: 1.25;
}

.PropertyPanel .prop-block {
  border-radius: 14px;
  padding: 10px 12px;
}

.PropertyPanel .control-stack {
  gap: 8px;
}

.PropertyPanel .control-item {
  gap: 4px;
}

.PropertyPanel .control-item label {
  font-size: 11px;
  line-height: 1.1;
}

.PropertyPanel input[type="range"] {
  min-height: 16px;
}

.panel-title {
  margin: 0;
  font-size: var(--fs-sm);
  letter-spacing: 0.08em;
  font-weight: 700;
  color: rgba(30, 20, 29, 0.86);
}

.sub-note {
  margin: 4px 0 0;
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.45;
}

.tool-pane {
  display: none;
  gap: 10px;
}

.tool-pane.active {
  display: grid;
}

.card-block,
.prop-block {
  margin-top: 8px;
  border: var(--border-1) solid var(--line);
  border-radius: var(--radius-lg);
  padding: 10px;
  background: var(--panel-strong);
}

.prop-block h3,
.field-title {
  margin: 0 0 6px;
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  color: rgba(33, 23, 34, 0.74);
  font-weight: 650;
}

input[type="file"] {
  width: 100%;
  min-height: 48px;
  border: var(--border-1) solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 7px 8px;
  font-size: var(--fs-sm);
  font-weight: 540;
  letter-spacing: 0.01em;
}

input[type="file"]::file-selector-button {
  border: var(--border-1) solid rgba(45, 28, 42, 0.22);
  border-radius: 11px;
  padding: 7px 12px;
  margin-right: 10px;
  background: linear-gradient(145deg, #fff8fd, #f4e7f0);
  color: #1f1320;
  font-size: var(--fs-sm);
  font-weight: 560;
  letter-spacing: 0.02em;
  cursor: pointer;
}

button {
  border: var(--border-1) solid var(--line);
  background: linear-gradient(150deg, #fff9fd, #f9edf4);
  border-radius: 999px;
  min-height: 36px;
  padding: 0 11px;
  color: #221622;
  cursor: pointer;
  font-size: var(--fs-xxs);
  font-weight: 540;
  line-height: 1.2;
  transition: transform 0.18s ease, background 0.2s ease, border-color 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  background: linear-gradient(150deg, #fff4fb, #f4dfe9);
  border-color: var(--line-strong);
}

button.primary {
  width: 100%;
  color: #fff;
  font-weight: 700;
  border-color: transparent;
  background: linear-gradient(120deg, #2d1d2d, #1a121a 60%, #4f3548);
}

button.is-active {
  background: linear-gradient(130deg, #2a1c2a, #1a121a);
  color: #fef2f8;
  border-color: transparent;
}

button.is-active:hover {
  background: linear-gradient(130deg, #3a2738, #241925);
  color: #fff5fb;
  border-color: rgba(255, 226, 243, 0.28);
}

.inline-actions {
  display: grid;
  gap: 10px;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.inline-actions button {
  min-height: 42px;
  height: auto;
  padding: 8px 12px;
  white-space: normal;
  line-height: 1.28;
}

.filter-panel-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 3px;
  border: 1px solid rgba(50, 33, 46, 0.1);
  border-radius: 999px;
  background: rgba(255, 250, 253, 0.72);
}

.filter-panel-tab {
  min-height: 28px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 11px;
  font-weight: 650;
  color: rgba(33, 23, 34, 0.58);
}

.filter-panel-tab.is-active {
  background: linear-gradient(130deg, #2a1c2a, #1a121a);
  color: #fef2f8;
}

.preset-grid,
.text-template-list,
.sticker-pack-list,
.control-stack,
.layer-list {
  display: grid;
  gap: 6px;
}

.preset-chip {
  display: grid;
  gap: 3px;
  align-content: center;
  min-height: 48px;
  border-radius: 16px;
  text-align: left;
  padding: 8px 11px;
  font-size: var(--fs-sm);
  font-weight: 540;
  line-height: 1.4;
  letter-spacing: 0;
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
}

.preset-name {
  display: block;
  font-size: 14px;
  font-weight: 620;
  line-height: 1.25;
  color: #271b29;
}

.preset-desc {
  display: block;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  color: rgba(39, 27, 41, 0.68);
}

.preset-chip.is-active .preset-name,
.preset-chip.is-active .preset-desc {
  color: #fff2f8;
}

.preset-chip.is-active {
  background: linear-gradient(130deg, #2f1f2f, #1d141d);
  border-color: rgba(255, 216, 236, 0.24);
}

.preset-chip.is-active:hover {
  background: linear-gradient(130deg, #3a2738, #241925);
  border-color: rgba(255, 226, 243, 0.3);
}

.preset-chip:hover {
  background: linear-gradient(150deg, #fff6fb, #f6e5ef);
}

.text-template-list .text-preset-chip {
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 12px;
  gap: 0;
}

.text-preset-content {
  display: block;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 560;
  color: #2d2030;
  letter-spacing: 0.01em;
}

.sticker-pack {
  border: var(--border-1) solid var(--line);
  border-radius: 16px;
  padding: 10px;
  background: #fffafe;
}

.sticker-pack h4 {
  margin: 0 0 7px;
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  color: rgba(33, 23, 34, 0.76);
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.sticker-btn {
  min-height: 48px;
  border-radius: 12px;
  padding: 5px;
  background: #fff;
}

.sticker-btn img {
  width: 100%;
  height: 38px;
  object-fit: contain;
}

.CanvasStage {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  padding: 12px;
  overflow: hidden;
}

.mobile-stage-logo {
  display: none;
}

.mobile-layer-dock {
  display: none;
}

.canvas-toolbar {
  display: grid;
  grid-template-columns: repeat(4, auto) 1fr;
  gap: 8px;
  align-items: center;
}

.toolbar-btn {
  min-height: 34px;
  font-size: var(--fs-xxs);
}

#undoBtn {
  font-weight: 700;
}

.toolbar-btn.compare {
  justify-self: end;
  padding-inline: 18px;
}

.toolbar-btn.is-active {
  background: linear-gradient(130deg, #2a1c2a, #1a121a);
  color: #fef2f8;
  border-color: transparent;
}

.toolbar-btn.is-active:hover {
  background: linear-gradient(130deg, #3a2738, #241925);
  color: #fff5fb;
  border-color: rgba(255, 226, 243, 0.3);
}

.canvas-stage {
  min-height: 0;
  display: grid;
  place-items: center;
  border: var(--border-1) solid var(--line);
  border-radius: 20px;
  background:
    radial-gradient(circle at 35% 20%, rgba(251, 234, 244, 0.74) 0%, transparent 40%),
    radial-gradient(circle at 72% 74%, rgba(239, 208, 227, 0.62) 0%, transparent 44%),
    #f2e6ec;
  padding: 12px;
}

.canvas-frame {
  position: relative;
  width: min(100%, 980px);
  height: min(100%, 100%);
  border-radius: 18px;
  border: var(--border-1) solid var(--line);
  overflow: hidden;
  background: #f6eef2;
}

.canvas-frame.interactive {
  cursor: zoom-in;
}

#editorCanvas,
.overlay-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.overlay-layer {
  pointer-events: auto;
}

.canvas-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
  font-size: var(--fs-md);
  color: var(--muted);
  cursor: pointer;
}

.control-stack.muted {
  color: var(--muted);
  font-size: var(--fs-sm);
}

.layer-control-title {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: rgba(33, 23, 34, 0.78);
}

.control-item {
  display: grid;
  gap: 5px;
}

.control-item label {
  font-size: 11px;
  color: rgba(33, 23, 34, 0.74);
  line-height: 1.15;
}

.color-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-swatch {
  width: 52px;
  min-width: 52px;
  height: 30px;
  min-height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0;
  background: #e7d3ea;
}

.native-color-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

input[type="range"] {
  width: 100%;
  accent-color: #3b2536;
  min-height: 20px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #4a2f45 0%, #4a2f45 var(--range-progress, 50%), rgba(33, 23, 34, 0.1) var(--range-progress, 50%), rgba(33, 23, 34, 0.1) 100%);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border: none;
  border-radius: 999px;
  background: rgba(33, 23, 34, 0.1);
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: #4a2f45;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 1px solid rgba(43, 30, 41, 0.18);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 5px rgba(32, 20, 31, 0.18);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(43, 30, 41, 0.18);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 5px rgba(32, 20, 31, 0.18);
}

input[type="range"].hsl-range {
  -webkit-appearance: none;
  appearance: none;
  height: 16px;
  background: transparent;
}

input[type="range"].hsl-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--hsl-track, linear-gradient(90deg, #aaa, #ddd));
}

input[type="range"].hsl-range::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  border: none;
  background: var(--hsl-track, linear-gradient(90deg, #aaa, #ddd));
}

input[type="range"].hsl-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border-radius: 999px;
  border: 1px solid rgba(43, 30, 41, 0.24);
  background: #fff;
  box-shadow: 0 1px 6px rgba(32, 20, 31, 0.2);
}

input[type="range"].hsl-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(43, 30, 41, 0.24);
  background: #fff;
  box-shadow: 0 1px 6px rgba(32, 20, 31, 0.2);
}

input[type="text"],
input[type="color"],
textarea {
  border: var(--border-1) solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 8px;
}

textarea {
  resize: vertical;
  min-height: 88px;
}

.layer-row {
  border: var(--border-1) solid var(--line);
  border-radius: 13px;
  padding: 6px;
  background: #fffafe;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.layer-row.selected {
  border-color: rgba(52, 33, 47, 0.42);
  box-shadow: 0 0 0 2px rgba(226, 191, 208, 0.5);
}

.layer-actions {
  display: flex;
  gap: 4px;
}

.layer-row > button {
  min-width: 0;
  min-height: 30px;
  font-size: var(--fs-xs);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-actions button {
  min-width: 26px;
  min-height: 26px;
  padding: 0 6px;
  border-radius: 9px;
  font-size: var(--fs-xxs);
}

.hsl-channel-btn {
  min-height: 30px;
  min-width: 30px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.hsl-heart {
  font-size: 20px;
  line-height: 1;
  display: inline-block;
  transform: translateY(1px);
  text-shadow: 0 0 0.5px rgba(26, 18, 26, 0.2);
}

.hsl-channel-btn.is-active {
  box-shadow: none;
}

.hsl-channel-btn.is-active .hsl-heart {
  filter: drop-shadow(0 0 5px rgba(160, 235, 145, 0.9)) drop-shadow(0 0 9px rgba(160, 235, 145, 0.45));
  transform: translateY(1px) scale(1.04);
}

.overlay-item {
  position: absolute;
  transform: translate(-50%, -50%);
  transform-origin: center;
  touch-action: none;
  user-select: none;
  cursor: move;
}

.overlay-item.selected {
  outline: 2px dashed rgba(64, 43, 61, 0.66);
  outline-offset: 4px;
}

.overlay-item.overlay-mosaic.selected {
  outline: none;
}

.overlay-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(32, 21, 31, 0.4);
  background: rgba(255, 248, 252, 0.96);
  box-shadow: 0 1px 6px rgba(33, 22, 31, 0.2);
}

.overlay-handle.scale {
  right: -9px;
  bottom: -9px;
  cursor: nwse-resize;
}

.overlay-handle.rotate {
  left: 50%;
  top: -22px;
  transform: translateX(-50%);
  cursor: grab;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  color: #311f30;
  display: grid;
  place-items: center;
}

.overlay-handle.delete {
  right: -10px;
  top: -10px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(54, 34, 49, 0.55);
  background: rgba(255, 244, 250, 0.98);
  color: #3a2234;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.overlay-handle.copy {
  left: -11px;
  top: -10px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(54, 34, 49, 0.45);
  background: rgba(255, 248, 252, 0.98);
  color: #3a2234;
  font-size: 10px;
  line-height: 1;
  cursor: copy;
  display: grid;
  place-items: center;
}

.export-modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(24, 16, 24, 0.35);
  z-index: 999;
  padding: 16px;
}

.export-modal.show {
  display: grid;
}

.export-modal-panel {
  width: min(680px, 100%);
  max-height: min(90dvh, 860px);
  overflow: auto;
  border: var(--border-1) solid var(--line);
  border-radius: 20px;
  background: rgba(255, 248, 252, 0.96);
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.export-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.export-modal-note {
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: var(--fs-xs);
}

.export-preview-wrap {
  border: var(--border-1) solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 8px;
}

#exportPreviewImage {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
}

.export-download-btn {
  min-height: 36px;
  border: var(--border-1) solid var(--line);
  background: linear-gradient(150deg, #fff9fd, #f9edf4);
  border-radius: 999px;
  padding: 8px 11px;
  color: #221622;
  text-decoration: none;
  font-size: var(--fs-xxs);
  font-weight: 540;
  display: grid;
  place-items: center;
}

@keyframes logoFloat {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-7px);
  }
}

@keyframes cursorBlink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}


.overlay-handle.stretch-x {
  right: -9px;
  top: 50%;
  transform: translateY(-50%);
  cursor: ew-resize;
}

.overlay-handle.stretch-y {
  left: 50%;
  bottom: -9px;
  transform: translateX(-50%);
  cursor: ns-resize;
}

@media (max-width: 1360px) {
  .studio-shell {
    grid-template-columns: 88px 290px minmax(440px, 1fr) 310px;
  }
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .studio-shell {
    height: auto;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-areas:
      "nav"
      "content"
      "canvas"
      "props";
  }

  .studio-shell > * {
    height: auto;
  }

  .SidebarNav {
    grid-area: nav;
    flex-direction: row;
    align-items: stretch;
    overflow-x: auto;
  }

  .brand-block {
    min-width: 130px;
  }

  .nav-list {
    display: flex;
    gap: 8px;
    width: auto;
  }

  .nav-item {
    min-width: 86px;
    min-height: 56px;
  }

  .ContentPanel {
    grid-area: content;
  }

  .CanvasStage {
    grid-area: canvas;
    min-height: 62vh;
  }

  .PropertyPanel {
    grid-area: props;
  }

  .canvas-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar-btn.compare {
    justify-self: auto;
    grid-column: 1 / -1;
  }

  .canvas-frame {
    height: auto;
    max-height: none;
  }
}

@media (max-width: 760px) {
  :root {
    --radius-xl: 18px;
    --radius-lg: 14px;
    --radius-md: 10px;
    --fs-xs: 12px;
    --fs-sm: 13px;
    --mobile-canvas-h: clamp(430px, 58dvh, 620px);
    --mobile-nav-h: 46px;
    --mobile-controls-top: calc(var(--mobile-canvas-h) + var(--mobile-nav-h));
  }

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

  body {
    background:
      radial-gradient(circle at 12% 8%, rgba(239, 213, 230, 0.48) 0%, transparent 38%),
      radial-gradient(circle at 88% 14%, rgba(229, 198, 221, 0.42) 0%, transparent 42%),
      linear-gradient(145deg, var(--bg-0) 0%, var(--bg-1) 100%);
  }

  .studio-shell {
    height: 100dvh;
    min-height: 0;
    padding: 0;
    gap: 0;
    display: block;
    background:
      radial-gradient(circle at 10% 12%, rgba(239, 213, 230, 0.44) 0%, transparent 38%),
      radial-gradient(circle at 84% 18%, rgba(229, 198, 221, 0.38) 0%, transparent 42%),
      linear-gradient(145deg, var(--bg-0) 0%, var(--bg-1) 100%);
  }

  .panel {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  .CanvasStage {
    position: fixed;
    z-index: 2;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mobile-canvas-h);
    min-height: var(--mobile-canvas-h);
    padding: 0;
    gap: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }

  .mobile-stage-logo {
    position: absolute;
    z-index: 4;
    left: 14px;
    top: 56px;
    display: block;
    width: 34px;
    height: 34px;
    object-fit: contain;
    padding: 5px;
    border: 1px solid rgba(50, 33, 46, 0.12);
    border-radius: 12px;
    background: rgba(255, 248, 252, 0.76);
    box-shadow: 0 8px 20px rgba(56, 36, 54, 0.08);
    backdrop-filter: blur(10px);
  }

  .mobile-layer-dock {
    position: absolute;
    z-index: 5;
    top: 56px;
    right: 14px;
    display: grid;
    justify-items: end;
    gap: 6px;
    pointer-events: none;
  }

  .mobile-layer-toggle {
    pointer-events: auto;
    min-height: 34px;
    min-width: 58px;
    padding: 0 10px;
    border-radius: 999px;
    border-color: rgba(50, 33, 46, 0.14);
    background: rgba(255, 248, 252, 0.78);
    color: rgba(33, 23, 34, 0.72);
    font-size: 11px;
    font-weight: 650;
    box-shadow: 0 8px 20px rgba(56, 36, 54, 0.08);
    backdrop-filter: blur(10px);
  }

  .mobile-layer-dock:not(.has-layers) .mobile-layer-toggle {
    display: none;
  }

  .mobile-layer-menu {
    pointer-events: auto;
    display: none;
    width: min(72vw, 260px);
    max-height: min(42dvh, 280px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    border: 1px solid rgba(50, 33, 46, 0.14);
    border-radius: 16px;
    background: rgba(255, 248, 252, 0.94);
    box-shadow: 0 18px 38px rgba(56, 36, 54, 0.14);
    backdrop-filter: blur(16px);
  }

  .mobile-layer-dock.is-open .mobile-layer-menu {
    display: grid;
    gap: 6px;
  }

  .mobile-layer-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 5px;
    align-items: center;
    padding: 5px;
    border: 1px solid rgba(50, 33, 46, 0.1);
    border-radius: 12px;
    background: rgba(255, 250, 253, 0.74);
  }

  .mobile-layer-row.selected {
    border-color: rgba(80, 51, 74, 0.34);
    background: rgba(255, 240, 248, 0.95);
  }

  .mobile-layer-select,
  .mobile-layer-action {
    min-height: 28px;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.15;
    background: transparent;
  }

  .mobile-layer-select {
    min-width: 0;
    padding: 0 6px;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-layer-action {
    min-width: 28px;
    padding: 0 7px;
  }

  .canvas-toolbar {
    order: 0;
    position: relative;
    z-index: 3;
    grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(90px, 1.2fr);
    gap: 7px;
    padding: 7px 12px 8px;
    border-bottom: 1px solid rgba(50, 33, 46, 0.12);
    background: rgba(255, 248, 252, 0.88);
    backdrop-filter: blur(14px);
  }

  .toolbar-btn {
    min-height: 34px;
    border-radius: 999px;
    font-size: 12px;
    border-color: rgba(50, 33, 46, 0.16);
    background: rgba(255, 250, 253, 0.88);
    color: #241825;
  }

  #clearCanvasBtn,
  #restoreOriginalBtn {
    display: none;
  }

  .toolbar-btn.compare {
    grid-column: auto;
    justify-self: stretch;
    padding-inline: 12px;
  }

  .canvas-stage {
    min-height: 0;
    border: 0;
    border-radius: 0;
    padding: 8px 10px 12px;
    background:
      radial-gradient(circle at 35% 20%, rgba(251, 234, 244, 0.78) 0%, transparent 40%),
      radial-gradient(circle at 72% 74%, rgba(239, 208, 227, 0.66) 0%, transparent 44%),
      linear-gradient(145deg, #f8f2f6 0%, #f1e4eb 100%);
  }

  .canvas-frame {
    width: min(92vw, 440px);
    max-width: 100%;
    max-height: 100%;
    border-radius: 12px;
    border: 1px solid rgba(50, 33, 46, 0.14);
    background: #f6eef2;
    box-shadow: 0 14px 36px rgba(56, 36, 54, 0.08);
  }

  .canvas-empty {
    inset: 50% auto auto 50%;
    width: min(68vw, 260px);
    min-height: 126px;
    transform: translate(-50%, -50%);
    border: 2px dashed rgba(74, 47, 69, 0.24);
    border-radius: 22px;
    background: rgba(255, 250, 253, 0.44);
    color: rgba(35, 28, 34, 0.46);
    font-size: 0;
  }

  .canvas-empty::before {
    content: "地雷系编辑器";
    display: block;
    font-size: 18px;
    font-weight: 760;
    color: rgba(33, 25, 32, 0.82);
  }

  .canvas-empty::after {
    content: "点击上传图片";
    display: block;
    margin-top: 8px;
    font-size: 15px;
    font-weight: 540;
    color: rgba(35, 28, 34, 0.45);
  }

  .SidebarNav {
    position: fixed;
    z-index: 6;
    top: var(--mobile-canvas-h);
    left: 0;
    right: 0;
    height: var(--mobile-nav-h);
    display: block;
    padding: 0;
    overflow: visible;
    border-top: 1px solid rgba(50, 33, 46, 0.14);
    border-bottom: 1px solid rgba(50, 33, 46, 0.12);
    background: rgba(255, 248, 252, 0.94);
    backdrop-filter: blur(14px);
  }

  .brand-block {
    display: none;
  }

  .nav-list {
    height: 100%;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0;
    overflow: hidden;
  }

  .nav-item {
    min-width: 0;
    min-height: var(--mobile-nav-h);
    padding: 3px 2px 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: rgba(33, 23, 34, 0.48);
    gap: 1px;
  }

  .nav-item:hover {
    transform: none;
    background: transparent;
  }

  .nav-item.active {
    position: relative;
    background: transparent;
    color: #1f161f;
  }

  .nav-item.active::after {
    content: "";
    position: absolute;
    left: 18%;
    right: 18%;
    bottom: 0;
    height: 3px;
    border-radius: 999px 999px 0 0;
    background: linear-gradient(90deg, #e679ad, #c68ba7);
  }

  .nav-icon {
    font-size: 15px;
  }

  .nav-label {
    font-size: 10px;
    letter-spacing: 0;
    white-space: nowrap;
  }

  .ContentPanel,
  .PropertyPanel {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 5;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 9px 14px;
    border-top: 1px solid rgba(50, 33, 46, 0.12);
    background: rgba(255, 248, 252, 0.96);
    backdrop-filter: blur(14px);
  }

  .ContentPanel {
    top: var(--mobile-controls-top);
    bottom: max(0px, env(safe-area-inset-bottom));
    max-height: none;
  }

  .PropertyPanel {
    top: var(--mobile-controls-top);
    bottom: max(0px, env(safe-area-inset-bottom));
    max-height: none;
    padding-top: 8px;
    border-top: 1px solid rgba(50, 33, 46, 0.12);
    font-size: 12px;
  }

  .PropertyPanel.is-empty {
    display: none;
  }

  .studio-shell[data-active-tool="filters"] .ContentPanel {
    bottom: auto;
    height: 54px;
  }

  .studio-shell[data-active-tool="filters"] .PropertyPanel {
    top: calc(var(--mobile-controls-top) + 54px);
  }

  .studio-shell[data-active-tool="project"] .ContentPanel {
    bottom: max(0px, env(safe-area-inset-bottom));
  }

  .studio-shell[data-active-tool="mosaic"] .ContentPanel,
  .studio-shell[data-active-tool="stickers"] .ContentPanel,
  .studio-shell[data-active-tool="text"] .ContentPanel {
    bottom: auto;
    height: 94px;
  }

  .studio-shell[data-active-tool="mosaic"] .PropertyPanel,
  .studio-shell[data-active-tool="stickers"] .PropertyPanel,
  .studio-shell[data-active-tool="text"] .PropertyPanel {
    top: calc(var(--mobile-controls-top) + 94px);
  }

  .PropertyPanel > .panel-title,
  .PropertyPanel > .sub-note {
    display: none;
  }

  #propListBlock {
    display: none !important;
  }

  .tool-pane.active {
    gap: 8px;
  }

  .tool-pane[data-pane="project"].active {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .tool-pane[data-pane="project"] .import-upload-block {
    display: none;
  }

  .tool-pane[data-pane="filters"].active {
    grid-template-columns: 64px minmax(0, 1fr);
    align-items: stretch;
  }

  .tool-pane > .panel-title,
  .tool-pane > .sub-note {
    display: none;
  }

  .card-block,
  .prop-block {
    margin-top: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .prop-block {
    padding-top: 8px;
  }

  .prop-block + .prop-block {
    margin-top: 8px;
    border-top: 1px solid rgba(50, 33, 46, 0.1);
  }

  .field-title,
  .prop-block h3 {
    margin: 0 0 5px;
    font-size: 11px;
    color: rgba(33, 23, 34, 0.62);
  }

  .preset-grid,
  .text-template-list,
  .sticker-pack-list,
  .control-stack,
  .layer-list {
    gap: 8px;
  }

  .control-stack.muted {
    font-size: 12px;
    line-height: 1.35;
    font-weight: 500;
    color: rgba(33, 23, 34, 0.5);
  }

  .layer-control-title {
    font-size: 12px;
    line-height: 1.25;
    font-weight: 620;
  }

  .preset-chip {
    min-height: 28px;
    border-radius: 11px;
    padding: 4px 8px;
    border-color: rgba(50, 33, 46, 0.14);
    background: rgba(255, 250, 253, 0.9);
    box-shadow: 0 4px 12px rgba(56, 36, 54, 0.035);
  }

  .preset-name {
    font-size: 12px;
    line-height: 1.12;
  }

  .preset-desc {
    font-size: 12px;
  }

  .preset-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tool-pane[data-pane="filters"] .field-title,
  .tool-pane[data-pane="filters"] .preset-desc {
    display: none;
  }

  .tool-pane[data-pane="filters"] .card-block {
    min-width: 0;
  }

  .tool-pane[data-pane="filters"] #originalFilterBtn {
    height: 100%;
    min-height: 36px;
    padding-inline: 8px;
  }

  .tool-pane[data-pane="filters"] .preset-chip {
    min-height: 36px;
    justify-items: center;
    text-align: center;
    padding: 4px 6px;
  }

  .tool-pane[data-pane="filters"] .preset-name {
    font-size: 11px;
  }

  .inline-actions {
    gap: 6px;
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  }

  .filter-panel-tabs {
    gap: 4px;
    padding: 2px;
  }

  .filter-panel-tab {
    min-height: 24px;
    font-size: 10.5px;
  }

  .hsl-channel-row {
    gap: 4px;
  }

  .inline-actions button,
  button.primary,
  input[type="file"] {
    min-height: 30px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
  }

  input[type="file"],
  input[type="text"],
  input[type="color"],
  textarea,
  select {
    border-color: rgba(50, 33, 46, 0.14);
    background: rgba(255, 250, 253, 0.92);
    color: #211722;
  }

  input[type="range"] {
    accent-color: #4a2f45;
    min-height: 20px;
  }

  .sticker-pack {
    padding: 0;
    border: 0;
    background: transparent;
  }

  .sticker-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    overflow: visible;
    padding-bottom: 2px;
    max-height: 78px;
  }

  .sticker-btn {
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 36px;
    padding: 3px;
    border-radius: 10px;
    border-color: rgba(50, 33, 46, 0.14);
    background: rgba(255, 250, 253, 0.92);
  }

  .sticker-btn img {
    width: 100%;
    height: 28px;
  }

  .text-template-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .text-template-list .text-preset-chip {
    min-height: 30px;
    padding: 4px 8px;
  }

  .text-preset-content {
    font-size: 11px;
    line-height: 1.15;
  }

  .control-item {
    gap: 5px;
  }

  .control-item label {
    font-size: 11px;
  }

  input[type="range"] {
    min-height: 22px;
  }

  .layer-row {
    border-radius: 14px;
    padding: 8px;
    border-color: rgba(50, 33, 46, 0.14);
    background: rgba(255, 250, 253, 0.9);
  }

  .layer-row > button {
    font-size: 11px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .overlay-handle {
    width: 20px;
    height: 20px;
  }

  .overlay-handle.scale {
    right: -13px;
    bottom: -13px;
  }

  .overlay-handle.stretch-x {
    right: -13px;
  }

  .overlay-handle.stretch-y {
    bottom: -13px;
  }

  .overlay-handle.delete,
  .overlay-handle.copy {
    width: 24px;
    height: 24px;
    font-size: 13px;
  }

  .overlay-handle.rotate {
    top: -30px;
    width: 30px;
    height: 30px;
  }
}

@media (max-width: 390px) {
  .nav-label {
    font-size: 9.5px;
  }

  .nav-icon {
    font-size: 14px;
  }

  .toolbar-btn {
    padding-inline: 8px;
  }

  .ContentPanel {
    max-height: none;
  }

  .PropertyPanel {
    max-height: none;
  }
}
