/* 制作工作台样式 */
:root {
  --red: #FF2442;
  --red-soft: #FFF0F2;
  --t1: #1A1A1A;
  --t2: #6B6B6B;
  --t3: #9B9B9B;
  --line: #E7E8EA;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #F4F5F7;
  color: var(--t1);
  font: 14px/1.5 "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 0 14px; height: 34px; }
button:hover { border-color: #D5D6D9; }
button.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 500; }
button.primary:disabled { opacity: .6; cursor: default; }
button.danger { color: #D8384F; border-color: #F3C7CE; }
input[type=text], input:not([type]), textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: 7px 11px; background: #fff; outline: none;
}
input:focus, textarea:focus { border-color: var(--red); }

/* ---------- 布局 ---------- */
.ed { height: 100%; display: flex; flex-direction: column; }
.ed-top {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--line);
}
.ed-id { width: 150px; }
.ed-title { width: 230px; }
.ed-sub { flex: 1 1 auto; min-width: 90px; max-width: 320px; }
.ed-spacer { flex: 1 1 auto; }
.ed-state { font-size: 12px; color: var(--t3); white-space: nowrap; }
.ed-state.dirty { color: var(--red); }

.ed-body {
  flex: 1 1 auto; min-height: 0; display: grid;
  grid-template-columns: 118px minmax(0, 1fr) 268px; gap: 12px; padding: 12px;
}

/* ---------- 左：步骤列表 ---------- */
.ed-list { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 2px; }
.ed-item {
  position: relative; border-radius: 10px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.ed-item.on { border-color: var(--red); }
.ed-item img { width: 100%; display: block; aspect-ratio: 390/844; object-fit: fill; background: #EDEDED; }
.ed-item .n {
  position: absolute; left: 4px; top: 4px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}
.ed-item.on .n { background: var(--red); }
.ed-item .warn {
  position: absolute; right: 4px; top: 4px; width: 18px; height: 18px; border-radius: 50%;
  background: #F5A623; color: #fff; font-size: 12px; font-style: normal;
  display: flex; align-items: center; justify-content: center;
}
/* 窄屏专用：步骤面板里的添加入口（宽屏走底部工具条，不重复出现） */
.ed-listadd { display: none; width: 100%; height: 46px; border: 1px dashed rgba(255,36,66,.45);
  background: var(--red-soft); color: var(--red); font-size: 14px; }

/* ---------- 中：画布 ---------- */
.ed-stage-wrap { min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ed-stage {
  position: relative; flex: 1 1 auto; min-height: 0; aspect-ratio: 390/844; max-width: 100%;
  background: #EDEDED; border-radius: 18px; overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,.1); cursor: crosshair; touch-action: none; user-select: none;
}
.ed-stage img { width: 100%; height: 100%; display: block; object-fit: fill; -webkit-user-drag: none; }
.ed-spot { position: absolute; display: none; border: 2px solid var(--red); background: rgba(255,36,66,.16); border-radius: 6px; }
.ed-drag { position: absolute; display: none; border: 2px dashed var(--red); background: rgba(255,36,66,.1); border-radius: 6px; }
.ed-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--t3); font-size: 13px; }

.ed-tools { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
.ed-tools select { height: 34px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 0 8px; max-width: 190px; }
.ed-endin { width: 210px; height: 34px; }
.ed-tip { font-size: 12px; color: var(--t3); }

/* ---------- 右：属性 ---------- */
.ed-props { overflow-y: auto; background: #fff; border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 14px; height: fit-content; }
.ed-props .ph { color: var(--t3); font-size: 13px; margin: 0; }
.ed-props .f { display: flex; flex-direction: column; gap: 6px; }
.ed-props .f > span { font-size: 12px; color: var(--t2); }
.ed-props textarea { resize: vertical; line-height: 1.6; }
.ed-props .hint { margin: -6px 0 0; font-size: 11px; color: var(--t3); line-height: 1.5; }
.ed-props .ck { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.ed-props .row { display: flex; gap: 8px; }
.ed-props .row button { flex: 1 1 0; }
.ed-props .coord { font-size: 11px; color: var(--t3); font-family: ui-monospace, Consolas, monospace; }

/* ---------- 提示条 ---------- */
.ed-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(12px);
  background: #1A1A1A; color: #fff; padding: 9px 18px; border-radius: 999px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; z-index: 99;
  max-width: 80vw; text-align: center;
}
.ed-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.ed-toast.bad { background: #C8102E; }

/* ---------- 窄屏 ---------- */
/* ---------- 底部 Tab（只在窄屏出现） ---------- */
.ed-tabs { display: none; }

/* ---------- 窄屏：改成 Tab 切换，一次只做一件事 ---------- */
@media (max-width: 900px) {
  body { overflow: hidden; }

  /* 顶栏：输入放大到 16px（否则 iOS 会自动放大页面） */
  .ed-top { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .ed-top input { height: 40px; font-size: 16px; }
  .ed-id { flex: 0 1 108px; width: auto; }
  .ed-title { flex: 1 1 150px; width: auto; }
  .ed-sub { flex: 1 1 100%; width: auto; max-width: none; }
  .ed-state { order: 9; }
  .ed-top button { height: 40px; padding: 0 12px; }

  /* 主体：一次只显示一个面板 */
  .ed-body { display: block; flex: 1 1 auto; min-height: 0; padding: 8px; overflow: hidden; }
  .ed-list, .ed-stage-wrap, .ed-props { display: none; height: 100%; }
  body[data-view="steps"] .ed-list { display: flex; }
  body[data-view="stage"] .ed-stage-wrap { display: flex; }
  body[data-view="props"] .ed-props { display: flex; }

  /* 步骤：两列网格，缩略图大一点好点 */
  .ed-list { flex-direction: row; flex-wrap: wrap; align-content: flex-start;
    gap: 10px; overflow-y: auto; padding: 4px; }
  .ed-item { flex: 0 0 calc(50% - 5px); }
  .ed-listadd { display: block; flex: 0 0 100%; }

  /* 画布：占满可用区域（拖框按百分比算，比例不影响坐标） */
  .ed-stage { flex: 1 1 auto; width: 100%; height: 100%; aspect-ratio: auto; }
  .ed-tools { gap: 8px; }
  .ed-tools button, .ed-tools select, .ed-endin { height: 42px; }
  .ed-endin { flex: 1 1 150px; width: auto; }
  .ed-tip { display: none; }

  /* 属性面板：按钮和输入都放大 */
  .ed-props { width: 100%; border-radius: 14px; padding: 14px; }
  .ed-props textarea { font-size: 16px; min-height: 120px; }
  .ed-props input, .ed-props button { height: 44px; font-size: 15px; }
  .ed-props .ck { font-size: 15px; }

  /* 底部 Tab */
  .ed-tabs { display: flex; flex: 0 0 auto; background: #fff; border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom); }
  .ed-tabs button { flex: 1 1 0; height: 52px; border: 0; border-radius: 0; background: transparent;
    font-size: 14px; color: var(--t2); }
  .ed-tabs button.on { color: var(--red); font-weight: 600; box-shadow: inset 0 2px 0 var(--red); }
}
