/* ====== 制作器专属样式（复用 style.css 的 CSS 变量与 .up-* 弹窗类） ====== */

/* 制作页整页不滚动：三段式布局自己管高度 */
body.mk-page {
  overflow: hidden;
}

/* 弹窗静态放在页面里（不是 upload.js 那样现开现插），未打开时不能挡点击 */
[hidden] { display: none !important; }
.up-overlay { pointer-events: none; }
.up-overlay.show { pointer-events: auto; }
.mk-success-actions a { text-decoration: none; }

.mk-app {
  height: 100vh;              /* 回退 */
  height: 100dvh;             /* iOS 地址栏/键盘收缩 */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- 顶栏 ---- */
.mk-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.mk-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
}

.mk-top-btn {
  flex-shrink: 0;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--card-bg);
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

.mk-top-btn.mk-top-primary {
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.mk-top-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---- 上下文面板（横滚，模式照 letter-nav） ---- */
.mk-panel {
  flex-shrink: 0;
  padding: 8px 12px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--border);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.mk-panel::-webkit-scrollbar { height: 4px; }
.mk-panel::-webkit-scrollbar-track { background: var(--border); border-radius: 2px; }
.mk-panel::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }

.mk-panel-group {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.mk-panel-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-right: 2px;
}

.mk-swatches,
.mk-opts {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mk-swatch {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
}

.mk-swatch.active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mk-opt {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}

.mk-opt.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.mk-eraser-hint {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ---- 画布区 ---- */
.stage {
  flex: 1;
  min-height: 0;               /* flex 子项允许收缩，画布按比例缩放 */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #e9e9e9;         /* 衬底色，突出白画布 */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* iOS 键盘位移层：位移与 fitStage 的 scale 分层互不干扰 */
.stage-shift {
  transition: transform 0.15s ease-out;
}

.stage-inner {
  transform-origin: top left;  /* fitStage 以左上角为缩放锚点 */
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  background: #ffffff;
}

.stage-inner .canvas-container {
  display: block;
}

/* ---- 汉堡菜单（工具统一入口） ---- */
.mk-menu-btn { flex-shrink:0; display:flex; flex-direction:column; align-items:center;
  justify-content:center; gap:4px; width:44px; height:44px; border:none;
  background:transparent; cursor:pointer; }
.mk-menu-btn .menu-bar { width:18px; height:2px; background:var(--text); border-radius:1px; }
.mk-menu { position:fixed; top:0; left:0; bottom:0; width:min(280px,82vw);
  background:var(--card-bg); z-index:900; transform:translateX(-100%);
  transition:transform .22s ease; padding:12px; overflow-y:auto;
  display:flex; flex-direction:column; gap:2px; }
.mk-menu.open { transform:translateX(0); }
.mk-menu-backdrop { position:fixed; inset:0; background:rgba(0,0,0,.35); z-index:899; }
.mk-menu-item { display:flex; align-items:center; gap:8px; width:100%; min-height:44px;
  padding:0 14px; border:none; border-radius:8px; background:transparent;
  font-size:15px; color:var(--text); text-decoration:none; cursor:pointer; text-align:left; }
.mk-menu-item:hover { background:var(--bg); }
.mk-menu-item.active { background:var(--accent); color:#fff; }
.mk-menu-item:disabled { opacity:.45; cursor:not-allowed; }
.mk-menu-sep { border:none; border-top:1px solid var(--border); margin:6px 8px; }

/* ---- 尺寸选择弹窗 ---- */
.mk-size-presets {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.mk-size-preset {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 0;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--card-bg);
  cursor: pointer;
}

.mk-size-preset:hover {
  background: #eef5fc;
}

.mk-size-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
}

.mk-size-desc {
  font-size: 11px;
  color: var(--text-secondary);
}

.mk-size-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.mk-size-inputs input {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;             /* ≥16px 防 iOS 聚焦自动放大 */
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
}

.mk-size-inputs input:focus {
  outline: none;
  border-color: var(--accent);
}

.mk-size-times {
  color: var(--text-secondary);
}

.mk-size-go {
  flex-shrink: 0;
  height: 38px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

/* ---- 编辑器启动失败诊断面板 ----
   根因：原样式用 var(--bg) 近白底 + 15px 小字，与正常页面肉眼不可区分 = 真机报告的「白屏」。
   重做为深色底 + 分步清单 + 原因 + UA + 重试；关键兜底样式另有一份在 maker/index.html head 内联
   <style>（css/maker.css 加载失败时面板仍深色可见），改动需同步两处。 */
.mk-fail {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;          /* 不用 inset：Chrome 87+ 才支持，老 WebView 兼容 */
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;   /* 小屏矮屏也能看到全部诊断信息 */
  background: #2b2b2b;
  color: #eee;
  font-size: 15px;
  line-height: 1.6;
  text-align: left;
}
.mk-fail-box {
  width: 100%;
  max-width: 360px;
  padding: 20px 18px;
  border: 1px solid #444;
  border-radius: 10px;
  background: #202020;
}
.mk-fail-title {
  margin: 0 0 10px;
  font-size: 18px;
  color: #fff;
  text-align: center;
}
.mk-fail-hint {
  margin: 0 0 8px;
  color: #aaa;
  font-size: 13px;
}
.mk-fail-steps {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}
.mk-fail-steps li {
  padding: 6px 0 6px 14px;
  border-bottom: 1px dashed #3a3a3a;
  color: #ccc;
}
.mk-fail-reason {
  margin: 0 0 10px;
  padding: 10px;
  border-left: 3px solid #e53935;
  background: #2c2222;
  color: #ffcdd2;
  white-space: pre-line;   /* 原因两行：诊断 + 桌面端提示（换行文本） */
  word-break: break-all;
}
.mk-fail-ua {
  margin: 0 0 14px;
  color: #888;
  font-size: 12px;
  word-break: break-all;
}
.mk-fail-retry {
  display: block;
  width: 100%;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: #e53935;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

/* ====== 编辑器升级：面板滚动 / 滑条 / 贴纸库 / 图层 ====== */

/* 14 项菜单小屏可能超屏 */
.mk-menu { -webkit-overflow-scrolling: touch; }

/* 面板多组内容（滤镜+变换/文字特效）纵向滚动，单组行仍可横滚 */
#mk-panel {
  max-height: 60vh;
  overflow-y: auto;
}

/* ---- range 滑条（iOS 默认滑条难点：-webkit-appearance:none 定制） ---- */
.mk-range {
  -webkit-appearance: none;
  appearance: none;
  width: 92px;
  height: 36px;              /* ≥44px 含边距触控区 */
  margin: 0 2px;
  background: transparent;
  flex-shrink: 0;
}

.mk-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.mk-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #fff;
}

.mk-range::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

.mk-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #fff;
}

/* ---- 混合模式下拉 ---- */
.mk-select {
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text);
  flex-shrink: 0;
}

/* ---- 滤镜面板态提示（菜单「✨ 滤镜」未选中图片时） ---- */
.mk-filter-hint {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ---- 贴纸素材弹窗 ---- */
.mk-sticker-dialog {
  max-width: 420px;
  height: 80vh;
  display: flex;
  flex-direction: column;
}

.mk-sticker-tabs {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.mk-sticker-tab {
  flex: 1;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}

.mk-sticker-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.mk-sticker-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  align-content: start;
}

.mk-sticker-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
}

.mk-sticker-cell:active { background: #eef5fc; }

.mk-sticker-cell img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  pointer-events: none;   /* 点击恒落在 cell 上 */
}

.mk-sticker-license {
  flex-shrink: 0;
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
}

/* ---- 图层弹窗 ---- */
.mk-layers-list {
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.mk-layer-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 48px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
}

.mk-layer-row.mk-layer-off { opacity: 0.5; }

.mk-layer-thumb {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  font-size: 12px;
  color: var(--text-secondary);
}

.mk-layer-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.mk-layer-icon {
  width: 28px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.mk-layer-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mk-layer-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
}

.mk-layer-btn:active { background: #eef5fc; }
