/* 表情包工坊（/tools/maker）页面样式 —— 复用 /public/styles.css 主题变量，深色随 body.dark */
.mk-main { width: 100%; max-width: 1440px; margin: 0 auto; padding: 78px 16px 42px; box-sizing: border-box; }
body.gj-has-dock .mk-main { padding-bottom: 96px; }

.mk-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; box-sizing: border-box;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px) saturate(1.5);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  color: var(--text-color);
  border-bottom: 1px solid rgba(77, 107, 254, 0.14);
  box-shadow: 0 1px 12px rgba(23, 35, 80, 0.06);
}
body.dark .mk-topbar { background: rgba(28, 30, 38, 0.82); border-bottom: 1px solid rgba(255, 255, 255, 0.09); box-shadow: none; }
.mk-topbar h1 { font-size: 1em; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk-topbar a { color: var(--text-color); text-decoration: none; white-space: nowrap; }
.mk-topbar select { padding: 4px 6px; border-radius: 6px; border: 1px solid var(--primary-color); background: var(--bg-color); color: var(--text-color); font-size: 0.85em; }

.mk-hero { text-align: center; margin: 4px 0 14px; }
.mk-hero .sub { font-size: 0.88em; opacity: 0.75; margin-top: 4px; max-width: 720px; margin-left: auto; margin-right: auto; }

/* —— 双栏：左素材库 / 右编辑器 —— */
.mk-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1023.98px) { .mk-layout { grid-template-columns: 1fr; } .mk-lib { order: 2; } .mk-edit { order: 1; } }

/* —— 素材库面板 —— */
.mk-lib {
  border: 1px solid var(--shadow-color); border-radius: 14px; padding: 12px;
  background: var(--bg-color);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 2px 10px rgba(23, 35, 80, 0.08);
}
.mk-lib-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mk-lib-head h2 { margin: 0; font-size: 1em; flex: 1; }
.mk-lib-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.mk-search { margin-top: 8px; width: 100%; box-sizing: border-box; padding: 8px 12px; border-radius: 9px; border: 1px solid var(--shadow-color); background: var(--bg-color); color: var(--text-color); }
.mk-chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 6px; scrollbar-width: thin; }
.mk-chip {
  flex: 0 0 auto; padding: 4px 12px; border-radius: 999px; cursor: pointer; font-size: 0.82em;
  border: 1px solid var(--shadow-color); background: transparent; color: var(--text-color); white-space: nowrap;
}
.mk-chip.on { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.mk-count { font-size: 0.75em; opacity: 0.6; margin: 2px 0 6px; }
.mk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; max-height: min(62vh, 640px); overflow-y: auto; padding: 2px; }
.mk-thumb {
  position: relative; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; background: var(--shadow-color);
}
.mk-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mk-thumb:hover { border-color: var(--shadow-color); }
.mk-thumb.on { border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(77, 107, 254, 0.35); }
.mk-thumb .tag {
  position: absolute; left: 4px; bottom: 4px; font-size: 0.62em; padding: 1px 6px; border-radius: 6px;
  background: rgba(20, 30, 60, 0.6); color: #fff; max-width: calc(100% - 8px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mk-lib-note { font-size: 0.78em; opacity: 0.7; text-align: center; padding: 10px 0 4px; }
.mk-sentinel { height: 8px; }

/* —— 编辑器 —— */
.mk-edit { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.mk-card {
  border: 1px solid var(--shadow-color); border-radius: 14px; padding: 14px;
  background: var(--bg-color);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 2px 10px rgba(23, 35, 80, 0.08);
}
.mk-card > h3 { margin: 0 0 10px; font-size: 0.95em; }
.mk-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.mk-seg { display: inline-flex; border: 1px solid var(--primary-color); border-radius: 9px; overflow: hidden; }
.mk-seg button { border: 0; background: transparent; color: var(--text-color); padding: 6px 12px; cursor: pointer; font-size: 0.84em; }
.mk-seg button.on { background: var(--primary-color); color: #fff; }
.mk-btn {
  padding: 7px 14px; border-radius: 9px; border: 1px solid var(--primary-color);
  background: var(--bg-color); color: var(--text-color); cursor: pointer; font-size: 0.86em;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mk-btn:active:not(:disabled) { transform: scale(0.93); transition-duration: 0.08s; }
.mk-btn:hover:not(:disabled) { background: var(--primary-color); color: #fff; }
.mk-btn.primary { background: var(--primary-color); color: #fff; font-weight: 600; }
.mk-btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--primary-color); }
.mk-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.mk-btn.ghost { border-color: var(--shadow-color); }

/* 画布舞台：透明底用棋盘格示意 */
.mk-stage { display: flex; justify-content: center; padding: 6px 0 2px; }
.mk-canvas-wrap { position: relative; max-width: min(440px, 100%); }
.mk-canvas-wrap canvas {
  display: block; width: 100%; height: auto; border-radius: 10px; cursor: crosshair; touch-action: none;
  background-repeat: repeat;
  background-image:
    linear-gradient(45deg, rgba(128, 128, 128, 0.18) 25%, transparent 25%, transparent 75%, rgba(128, 128, 128, 0.18) 75%),
    linear-gradient(45deg, rgba(128, 128, 128, 0.18) 25%, transparent 25%, transparent 75%, rgba(128, 128, 128, 0.18) 75%);
  background-size: 18px 18px; background-position: 0 0, 9px 9px;
  box-shadow: 0 3px 16px rgba(23, 35, 80, 0.14);
}
.mk-canvas-wrap.white canvas { background: #fff; box-shadow: 0 3px 16px rgba(23, 35, 80, 0.14); }
.mk-hint { text-align: center; font-size: 0.76em; opacity: 0.6; margin-top: 6px; }

/* 文字与样式控件 */
.mk-textarea {
  width: 100%; box-sizing: border-box; min-height: 84px; resize: vertical;
  border-radius: 10px; border: 1px solid var(--shadow-color); background: var(--bg-color); color: var(--text-color);
  padding: 10px 12px; font-size: 0.95em; line-height: 1.5;
}
.mk-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 14px; margin-top: 12px; }
.mk-ctl { display: flex; flex-direction: column; gap: 4px; font-size: 0.8em; }
.mk-ctl > .row { display: flex; align-items: center; gap: 8px; }
.mk-ctl label { opacity: 0.8; }
.mk-ctl input[type="range"] { flex: 1; accent-color: var(--primary-color); }
.mk-ctl output { min-width: 40px; text-align: right; font-variant-numeric: tabular-nums; opacity: 0.75; }
.mk-ctl select, .mk-ctl input[type="number"] {
  padding: 6px 8px; border-radius: 8px; border: 1px solid var(--shadow-color); background: var(--bg-color); color: var(--text-color);
}
.mk-ctl input[type="color"] { width: 42px; height: 28px; padding: 0; border: 1px solid var(--shadow-color); border-radius: 6px; background: none; cursor: pointer; }
.mk-ctl.inline { flex-direction: row; align-items: center; gap: 8px; }
.mk-ctl.inline input[type="checkbox"] { accent-color: var(--primary-color); width: 16px; height: 16px; }
.mk-text-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* 导出面板 */
.mk-export-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.mk-export-row .mk-ctl { min-width: 130px; }
.mk-custom-size { display: none; gap: 10px; align-items: end; }
.mk-custom-size.show { display: flex; }
.mk-export-btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.mk-export-hint { font-size: 0.75em; opacity: 0.6; margin-top: 8px; }
.mk-license { font-size: 0.75em; opacity: 0.55; text-align: center; margin-top: 14px; }

/* —— 弹窗（AI / 裁剪）—— */
dialog.mk-dialog {
  border: 1px solid var(--shadow-color); border-radius: 16px; padding: 0;
  background: var(--bg-color); color: var(--text-color);
  max-width: min(560px, 92vw); width: 100%;
  box-shadow: 0 18px 60px rgba(10, 20, 50, 0.35);
}
dialog.mk-dialog::backdrop { background: rgba(10, 16, 36, 0.45); backdrop-filter: blur(2px); }
.mk-dlg-head { display: flex; align-items: center; padding: 14px 16px 0; }
.mk-dlg-head h3 { margin: 0; flex: 1; font-size: 1.02em; }
.mk-dlg-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; max-height: min(76vh, 720px); overflow-y: auto; }
.mk-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.84em; }
.mk-field label { opacity: 0.8; }
.mk-field input[type="text"], .mk-field input[type="password"], .mk-field textarea, .mk-field select {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--shadow-color); background: var(--bg-color); color: var(--text-color);
  font-size: 1em; width: 100%; box-sizing: border-box;
}
.mk-field textarea { min-height: 70px; resize: vertical; }
.mk-field .endpoint { font-size: 0.78em; opacity: 0.6; word-break: break-all; }
.mk-inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 0.84em; }
.mk-inline input[type="checkbox"] { accent-color: var(--primary-color); width: 15px; height: 15px; }
.mk-ideas { display: flex; gap: 6px; flex-wrap: wrap; font-size: 0.8em; align-items: center; }
.mk-idea-chip { padding: 3px 10px; border-radius: 999px; border: 1px dashed var(--primary-color); cursor: pointer; background: transparent; color: var(--text-color); }
.mk-idea-chip:hover { background: rgba(77, 107, 254, 0.12); }
.mk-dlg-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.mk-ai-result { display: none; flex-direction: column; gap: 8px; align-items: center; }
.mk-ai-result.show { display: flex; }
.mk-ai-result img { max-width: 100%; max-height: 46vh; border-radius: 10px; background: repeating-conic-gradient(#ccc 0% 25%, #fff 0% 50%) 0 0/16px 16px; }
.mk-err { color: #c0392b; font-size: 0.8em; min-height: 1em; word-break: break-all; }
body.dark .mk-err { color: #ff8f7d; }
.mk-close { border: 0; background: transparent; color: var(--text-color); font-size: 1.1em; cursor: pointer; opacity: 0.6; }
.mk-close:hover { opacity: 1; }

/* 裁剪弹窗 */
.mk-crop-box { position: relative; align-self: center; max-width: 100%; line-height: 0; }
.mk-crop-box img { max-width: 100%; max-height: 52vh; border-radius: 8px; }
.mk-crop-rect {
  position: absolute; border: 2px solid var(--primary-color); box-shadow: 0 0 0 9999px rgba(8, 14, 34, 0.5);
  cursor: move; touch-action: none; border-radius: 2px;
}
.mk-crop-handle {
  position: absolute; width: 14px; height: 14px; border-radius: 50%; background: #fff;
  border: 2px solid var(--primary-color); box-shadow: none;
}
.mk-crop-handle.nw { left: -8px; top: -8px; cursor: nwse-resize; }
.mk-crop-handle.ne { right: -8px; top: -8px; cursor: nesw-resize; }
.mk-crop-handle.sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.mk-crop-handle.se { right: -8px; bottom: -8px; cursor: nwse-resize; }

/* toast */
.mk-toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px);
  background: rgba(23, 35, 80, 0.92); color: #fff; padding: 9px 18px; border-radius: 10px;
  font-size: 0.86em; opacity: 0; pointer-events: none; transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1200; max-width: 86vw; text-align: center;
}
.mk-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 767.98px) {
  .mk-main { padding: 70px 10px 96px; }
  .mk-grid { max-height: 56vh; }
  .mk-canvas-wrap { max-width: min(360px, 100%); }
}
