@font-face {
  font-family: "Alibaba PuHuiTi";
  src: url("AlibabaPuHuiTi-3-85-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #18202b;
  --muted: #788492;
  --line: #dfe5eb;
  --paper: #ffffff;
  --panel: #f7f9fb;
  --blue: #3568ef;
  --blue-light: #eaf0ff;
  --red: #ed3c3f;
  --red-light: #ffedef;
  --shadow: 0 18px 50px rgba(26, 38, 58, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: #edf1f5;
  font-family: "Alibaba PuHuiTi", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input { font: inherit; }

button { cursor: pointer; }

.app-shell { min-height: 100vh; }

.topbar {
  height: 76px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.brand, .topbar-actions, .asset-card, .selected-layer-row, .canvas-toolbar, .stage-footer, .control-label-row { display: flex; align-items: center; }

.brand { gap: 11px; }

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--red);
  font-size: 20px;
  box-shadow: 3px 3px 0 #ffbec1;
}

h1, p { margin: 0; }

h1 { font-size: 18px; line-height: 23px; }
.brand p { color: var(--muted); font-size: 12px; line-height: 16px; }

.topbar-actions { gap: 10px; }

.format-badge {
  padding: 7px 10px;
  border: 1px solid #b8cafb;
  border-radius: 5px;
  color: #315ab9;
  background: #f4f7ff;
  font-size: 12px;
}

.button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}

.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button.ghost { border-color: var(--line); }
.button.ghost:hover { background: #f6f8fa; }
.button.primary { color: #fff; background: var(--blue); box-shadow: 0 6px 14px rgba(53, 104, 239, .22); }
.button.primary:hover { background: #2758da; }
.button.secondary { border-color: #cbd6e4; background: #f8fafc; }
.full-width { width: 100%; }

.workspace {
  width: min(1540px, 100%);
  min-height: calc(100vh - 76px);
  margin: 0 auto;
  padding: 28px 32px;
  display: grid;
  grid-template-columns: 260px minmax(500px, 1fr) 260px;
  align-items: start;
  gap: 24px;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 8px 24px rgba(45, 57, 74, .04);
}

.panel-heading {
  min-height: 61px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.panel-heading > span { font-size: 15px; }
.panel-heading small { color: var(--muted); font-size: 11px; }

.asset-card {
  min-height: 86px;
  padding: 12px 14px;
  gap: 10px;
  border-bottom: 1px solid #edf0f3;
  transition: background .16s ease;
}

.asset-card:hover, .asset-card.is-selected { background: #f8fbff; }

.asset-preview, .selected-swatch {
  overflow: hidden;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  background-color: #f0f2f5;
  background-size: cover;
  background-position: center;
}

.asset-preview {
  width: 55px;
  height: 55px;
  border: 1px dashed #b8c4d1;
  border-radius: 5px;
  color: #8995a3;
  font-size: 12px;
}

.asset-preview.has-image { border-style: solid; }
.preview-left { color: #cf4c52; background-color: var(--red-light); }
.preview-right { color: #416fd2; background-color: var(--blue-light); }

.asset-copy { min-width: 0; flex: 1; display: grid; gap: 5px; }
.asset-copy strong { font-size: 13px; font-weight: 700; }
.asset-copy span { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.icon-button {
  width: 30px;
  height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid #d4dde7;
  border-radius: 5px;
  color: #536171;
  background: #fff;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.icon-button:hover { border-color: var(--blue); color: var(--blue); background: #f5f8ff; }
.upload-button { font-size: 20px; line-height: 1; }
.upload-button input { display: none; }

.drop-area {
  margin: 14px;
  padding: 18px 8px;
  border: 1px dashed #bcc8d5;
  border-radius: 6px;
  text-align: center;
  color: var(--muted);
  transition: border-color .16s ease, background .16s ease;
}

.drop-area.is-dragover { border-color: var(--blue); background: var(--blue-light); }
.drop-symbol { margin-bottom: 5px; color: #7491c7; font-size: 21px; }
.drop-area p { font-size: 12px; }
.drop-area small { display: block; margin-top: 4px; color: #9aa5b2; font-size: 10px; }

.batch-panel, .template-panel { padding: 13px 14px; border-top: 1px solid #edf0f3; }
.batch-panel { outline: 0; user-select: none; }
.batch-panel:focus-visible { box-shadow: inset 0 0 0 2px #dce6ff; }
.batch-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.batch-panel-heading div { display: grid; gap: 3px; }
.batch-panel-heading strong { font-size: 12px; }
.batch-panel-heading small { color: var(--muted); font-family: "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 10px; }
.batch-panel-heading > span { color: var(--blue); font-size: 10px; }
.preview-index-field { padding: 7px 8px; display: flex; align-items: center; justify-content: space-between; border: 1px solid #dbe2ea; border-radius: 4px; color: #677585; font-size: 11px; }
.preview-index-field select { min-width: 92px; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 12px; text-align: right; }
.batch-summary { padding: 8px 0 10px; display: flex; justify-content: space-between; color: #7e8a98; font-family: "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 10px; }
.batch-panel .button { min-height: 32px; padding: 0 8px; font-size: 11px; }
.template-panel { padding-bottom: 14px; }
.template-list { display: grid; gap: 5px; }
.template-row { min-height: 30px; padding: 4px 6px; display: grid; grid-template-columns: 48px minmax(28px, 1fr) auto auto auto auto; align-items: center; gap: 4px; border: 1px solid #e4e9ef; border-radius: 4px; background: #fbfcfd; }
.template-row > span { font-size: 10px; font-weight: 700; }
.template-row > small { overflow: hidden; color: #9aa5b2; font-family: "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.template-action { min-height: 23px; padding: 0 6px; border: 1px solid #d5deea; border-radius: 3px; color: #526273; background: #fff; font-size: 10px; }
.template-action:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); background: #f3f6ff; }
.template-action:disabled { color: #b6c0ca; background: #f3f5f7; cursor: not-allowed; }
.template-save { min-height: 23px; padding: 0 6px; border: 1px solid #d5deea; border-radius: 3px; color: #526273; background: #fff; font-size: 10px; }
.template-save:hover { border-color: var(--blue); color: var(--blue); background: #f3f6ff; }
.template-delete { color: #c65a60; }
.template-delete:hover:not(:disabled) { border-color: #efb7ba; color: #bd343c; background: var(--red-light); }
.template-file-actions { margin-top: 9px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.template-file-actions .button { min-height: 30px; padding: 0 6px; font-size: 10px; }
.import-template-button { display: grid; place-items: center; cursor: pointer; }
.import-template-button input { display: none; }

.panel-note { margin: 0 14px 15px; padding: 10px 11px; display: flex; gap: 8px; border-radius: 5px; background: #f6f8fa; }
.panel-note p { color: #6d7885; font-family: "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 11px; line-height: 17px; }
.note-dot { width: 6px; height: 6px; flex: 0 0 auto; margin-top: 5px; border-radius: 50%; background: var(--red); }

.editor-area { min-width: 0; }

.canvas-toolbar {
  min-height: 42px;
  padding: 0 2px 0 8px;
  justify-content: space-between;
}

.canvas-toolbar-title { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #49b978; box-shadow: 0 0 0 3px #e0f6e9; }
.canvas-hint { color: var(--muted); font-size: 11px; }

.canvas-stage {
  position: relative;
  width: min(100%, 800px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #d1d9e3;
  background: #fff;
  box-shadow: var(--shadow);
  aspect-ratio: 1;
}

canvas { width: 100%; height: 100%; display: block; touch-action: none; }

.stage-footer {
  min-height: 38px;
  padding: 0 8px;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.stage-footer span:last-child { color: #4d5f73; }

.right-panel { min-height: 418px; }
.layer-stack { padding: 13px 16px 12px; border-bottom: 1px solid #e7ecf1; }
.stack-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; color: #4d5a68; font-size: 12px; }
.stack-heading small { color: #9aa5b2; font-size: 10px; }
.layer-chip-list { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.layer-chip { min-width: 0; min-height: 30px; padding: 0 7px; display: flex; align-items: center; gap: 6px; border: 1px solid #e0e6ed; border-radius: 4px; color: #5b6978; background: #fbfcfd; text-align: left; font-size: 10px; transition: border-color .15s ease, background .15s ease, color .15s ease; }
.layer-chip:hover, .layer-chip.is-selected { border-color: #aabff7; color: #315fc9; background: #f2f6ff; }
.layer-chip.arrow-chip { grid-column: 1 / -1; }
.layer-chip em { margin-left: auto; color: #8b98a6; font-size: 9px; font-style: normal; }
.layer-type { width: 18px; height: 18px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 3px; font-style: normal; font-size: 10px; }
.text-type { color: #c94348; background: #ffeaeb; }
.arrow-type { color: #fff; background: var(--red); font-size: 14px; }
.empty-controls { padding: 54px 20px; text-align: center; color: #8c98a6; }
.empty-icon { margin-bottom: 13px; color: #b4c0ce; font-size: 34px; }
.empty-controls p { font-family: "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 12px; line-height: 20px; }

.layer-controls { padding: 14px 16px 16px; }
.selected-layer-row { gap: 10px; padding-bottom: 15px; border-bottom: 1px solid #e9edf1; }
.selected-swatch { width: 36px; height: 36px; border: 1px solid #cfd9e5; border-radius: 4px; background-color: #f3f6f9; background-size: cover; background-position: center; }
.selected-layer-row > div:nth-child(2) { min-width: 0; flex: 1; display: grid; gap: 2px; }
.selected-layer-row strong { font-size: 13px; }
.selected-layer-row span { color: var(--muted); font-family: "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 10px; }
.remove-button { color: #d45a5f; font-size: 20px; }
.remove-button:hover { border-color: #efb7ba; color: #c93238; background: var(--red-light); }
.remove-button:disabled { border-color: #e4e8ed; color: #b8c0c9; background: #f7f9fb; cursor: not-allowed; }
.remove-button:disabled:hover { border-color: #e4e8ed; color: #b8c0c9; background: #f7f9fb; }

.control-section { padding-top: 16px; }
.text-controls { padding-top: 14px; }
.text-field-label { display: block; margin-bottom: 7px; color: #4d5a68; font-size: 12px; }
.text-content-input { width: 100%; height: 34px; padding: 0 9px; border: 1px solid #dbe2ea; border-radius: 4px; outline: 0; color: var(--ink); background: #fff; font-size: 12px; }
.text-content-input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px #e7edff; }
.text-style-grid { margin-top: 8px; }
.text-color-field { margin-top: 8px; }
.color-field { padding: 4px 7px; display: flex; align-items: center; justify-content: space-between; gap: 7px; border: 1px solid #dbe2ea; border-radius: 4px; color: #85919e; font-size: 11px; }
.color-field input { width: 34px; height: 22px; padding: 0; border: 0; border-radius: 3px; background: none; cursor: pointer; }
.control-section > label, .control-label-row label { color: #4d5a68; font-size: 12px; }
.control-label-row { justify-content: space-between; }
.control-label-row output { color: var(--blue); font-size: 11px; }
.number-grid { margin-top: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.number-field { padding: 6px 8px; display: flex; align-items: center; gap: 5px; border: 1px solid #dbe2ea; border-radius: 4px; color: #85919e; font-size: 11px; }
.number-field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px #e7edff; }
.number-field input { width: 100%; min-width: 0; padding: 0; border: 0; outline: 0; color: var(--ink); background: transparent; text-align: right; font-size: 12px; }
input[type="range"] { width: 100%; height: 18px; margin: 6px 0 0; accent-color: var(--blue); cursor: pointer; }
.layer-controls .button { margin-top: 18px; }

.shortcut-list { margin: 0 16px; padding: 14px 0 6px; border-top: 1px solid #e7ecf1; }
.shortcut-list > div { padding: 5px 0; display: flex; align-items: center; justify-content: space-between; color: #84909e; font-family: "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 11px; }
kbd { min-width: 47px; padding: 3px 5px; border: 1px solid #d9e1e9; border-bottom-width: 2px; border-radius: 3px; color: #607080; background: #fff; font-family: inherit; font-size: 10px; text-align: center; }

.toast { position: fixed; left: 50%; bottom: 26px; z-index: 5; padding: 10px 16px; border-radius: 5px; color: #fff; background: #253443; box-shadow: 0 10px 24px rgba(30, 43, 58, .22); font-size: 13px; opacity: 0; pointer-events: none; transform: translate(-50%, 18px); transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 230px minmax(410px, 1fr); }
  .right-panel { grid-column: 1 / -1; min-height: auto; }
  .right-panel .panel-heading { border-bottom: 0; }
  .empty-controls { display: none; }
  .layer-controls { max-width: 520px; }
  .shortcut-list { position: absolute; top: 106px; right: 48px; border-top: 0; }
}

@media (max-width: 760px) {
  .topbar { height: auto; min-height: 70px; padding: 12px 16px; align-items: flex-start; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .format-badge, .button.ghost { display: none; }
  .workspace { padding: 14px; grid-template-columns: 1fr; gap: 14px; }
  .left-panel { order: 2; }
  .editor-area { order: 1; }
  .right-panel { order: 3; }
  .canvas-toolbar { padding-left: 0; }
  .canvas-hint { max-width: 165px; text-align: right; line-height: 16px; }
  .shortcut-list { position: static; padding-bottom: 10px; }
  .asset-card { min-height: 76px; }
}

@media (max-width: 430px) {
  .brand h1 { font-size: 16px; }
  .topbar { gap: 12px; }
  .button.primary { padding: 0 10px; font-size: 12px; }
  .canvas-hint { display: none; }
}
