@import url("https://fonts.googleapis.com/css2?family=Long+Cang&family=Ma+Shan+Zheng&family=Noto+Sans+SC:wght@400;500;700;900&family=Noto+Serif+SC:wght@700;900&family=ZCOOL+KuaiLe&display=swap");

:root {
  color-scheme: light;
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-soft: #f7f8fa;
  --ink: #1d232b;
  --muted: #69727f;
  --line: #d9dee6;
  --accent: #0f766e;
  --accent-strong: #0b5f58;
  --coral: #d95c45;
  --dark: #151a21;
  --shadow: 0 18px 50px rgba(21, 26, 33, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Noto Sans SC",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

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

button {
  cursor: pointer;
}

.app {
  min-height: 100vh;
  padding: 14px;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(21, 26, 33, 0.08);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 12px;
  position: sticky;
  top: 10px;
  z-index: 20;
}

.brand {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 210px;
}

.brand-mark {
  align-items: center;
  background: var(--dark);
  border-radius: 8px;
  color: #fff;
  display: inline-flex;
  font-weight: 900;
  height: 40px;
  justify-content: center;
  width: 40px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
  line-height: 1.15;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

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

.button,
.chip,
.sticker-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    transform 0.16s ease;
}

.button {
  min-height: 38px;
  padding: 8px 12px;
}

.button:hover,
.chip:hover,
.sticker-button:hover,
.icon-button:hover {
  border-color: #aeb8c6;
  transform: translateY(-1px);
}

.button:disabled,
.chip:disabled,
.sticker-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button.primary:hover {
  background: var(--accent-strong);
}

.button.dark {
  background: var(--dark);
  border-color: var(--dark);
  color: #fff;
}

.button.small {
  min-height: 34px;
  padding: 7px 10px;
}

.workspace {
  display: grid;
  gap: 14px;
  grid-template-columns: 270px minmax(320px, 1fr) 320px;
  margin-top: 14px;
}

.panel,
.editor-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  align-self: start;
  max-height: calc(100vh - 104px);
  overflow: auto;
}

.section {
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.section:last-child {
  border-bottom: 0;
}

.section-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 12px;
}

.field {
  color: var(--muted);
  display: grid;
  gap: 7px;
  font-size: 12px;
  margin-bottom: 12px;
}

.field span {
  font-weight: 700;
}

.inline-field {
  align-items: center;
  grid-template-columns: 1fr auto;
}

select,
textarea,
input[type="number"] {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 36px;
  outline: none;
  padding: 8px 10px;
  width: 100%;
}

textarea {
  line-height: 1.45;
  min-height: 92px;
  resize: vertical;
}

input[type="color"] {
  background: transparent;
  border: 0;
  height: 34px;
  padding: 0;
  width: 46px;
}

input[type="range"] {
  accent-color: var(--accent);
  width: 100%;
}

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

.chip {
  min-height: 36px;
  padding: 8px;
}

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

.sticker-button {
  align-items: center;
  display: inline-flex;
  font-size: 24px;
  height: 48px;
  justify-content: center;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  margin: 0;
}

.editor-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: calc(100vh - 104px);
  overflow: hidden;
}

.canvas-toolbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
}

.icon-row {
  display: flex;
  gap: 6px;
}

.icon-button {
  align-items: center;
  display: inline-flex;
  font-size: 20px;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.icon-button.danger {
  color: var(--coral);
}

.canvas-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.canvas-viewport {
  align-items: center;
  background:
    linear-gradient(45deg, #dfe4eb 25%, transparent 25%),
    linear-gradient(-45deg, #dfe4eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dfe4eb 75%),
    linear-gradient(-45deg, transparent 75%, #dfe4eb 75%);
  background-color: #f4f6f8;
  background-position:
    0 0,
    0 12px,
    12px -12px,
    -12px 0;
  background-size: 24px 24px;
  display: flex;
  justify-content: center;
  min-height: 0;
  overflow: auto;
  padding: 24px;
}

.canvas-viewport.is-dragging {
  outline: 3px solid var(--accent);
  outline-offset: -8px;
}

#editorCanvas {
  background: #f6f2ed;
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(21, 26, 33, 0.24);
  display: block;
  max-width: 100%;
  touch-action: none;
}

.empty-state {
  align-items: center;
  background: var(--panel-soft);
  border: 1px dashed #bdc6d3;
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  font-size: 13px;
  justify-content: center;
  line-height: 1.6;
  min-height: 118px;
  padding: 16px;
  text-align: center;
}

.inspector-group[hidden] {
  display: none;
}

.two-col {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.segmented {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 2px;
  grid-template-columns: repeat(3, 1fr);
  padding: 3px;
}

.segmented button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  min-height: 32px;
}

.segmented button.active {
  background: #fff;
  color: var(--accent);
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(21, 26, 33, 0.08);
}

.layer-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
}

.toast {
  background: var(--dark);
  border-radius: 8px;
  bottom: 20px;
  color: #fff;
  left: 50%;
  min-width: 180px;
  opacity: 0;
  padding: 10px 14px;
  pointer-events: none;
  position: fixed;
  text-align: center;
  transform: translate(-50%, 12px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 250px minmax(320px, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
    max-height: none;
  }
}

@media (max-width: 780px) {
  .app {
    padding: 8px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    position: static;
  }

  .brand {
    min-width: 0;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions .button {
    flex: 1 1 130px;
  }

  .workspace {
    display: flex;
    flex-direction: column;
  }

  .panel,
  .editor-panel {
    max-height: none;
    min-height: auto;
  }

  .canvas-viewport {
    min-height: 520px;
    padding: 14px;
  }
}
