/* ================= 快码 KuaiMask ================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d12;
  --panel: #1a1a22;
  --panel-2: #22222c;
  --border: #2e2e3a;
  --text: #f2f2f5;
  --text-dim: #9a9aa8;
  --accent: #ffd60a;
  --accent-dark: #1a1a19;
  --danger: #ff5b5b;
  --radius: 12px;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
.topbar { background: #141419; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1400px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; }
.brand-logo { font-size: 26px; }
.brand-name em { font-style: normal; font-size: 13px; font-weight: 400; color: var(--text-dim); margin-left: 4px; }
.topbar-tags { margin-left: auto; display: flex; gap: 8px; }
.tag { font-size: 12px; color: var(--text-dim); border: 1px solid var(--border); padding: 3px 10px; border-radius: 999px; }
.tag-free { color: var(--accent); border-color: rgba(255, 214, 10, .45); font-weight: 600; }

/* ---------- Hero ---------- */
.hero { max-width: 1400px; margin: 0 auto; padding: 28px 24px 6px; width: 100%; }
.hero h1 { font-size: 26px; font-weight: 700; letter-spacing: .5px; }
.hero p { color: var(--text-dim); margin-top: 6px; max-width: 780px; }
.hero b { color: var(--accent); }

/* ---------- 布局 ---------- */
.layout { max-width: 1400px; margin: 0 auto; padding: 18px 24px 40px; width: 100%; display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: start; }
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }

/* ---------- 设置卡片 ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 14px; color: rgba(255,255,255,.92); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); }
.switch-row b { display: block; font-size: 15px; }
.switch-row small { color: var(--text-dim); font-size: 12px; }

.switch { width: 44px; height: 24px; border-radius: 999px; background: #3a3a46; position: relative; cursor: pointer; flex-shrink: 0; transition: background .2s; }
.switch i { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .2s; }
.switch.on { background: var(--accent); }
.switch.on i { left: 23px; }

.hint-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.hint-row small { color: var(--text-dim); font-size: 12px; }

/* 风格选择 */
.style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.style-tile { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); cursor: pointer; font-size: 14px; transition: border-color .15s, color .15s; }
.style-tile:hover { border-color: #55555f; }
.style-tile.selected { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.sw { width: 34px; height: 24px; border-radius: 6px; flex-shrink: 0; }
.sw-mosaic {
  background-image:
    linear-gradient(45deg, #6b6b78 25%, transparent 25%, transparent 75%, #6b6b78 75%),
    linear-gradient(45deg, #6b6b78 25%, transparent 25%, transparent 75%, #6b6b78 75%);
  background-color: #3c3c48; background-size: 8px 8px; background-position: 0 0, 4px 4px;
}
.sw-blur { background: radial-gradient(circle at 35% 40%, #7a7a8a, #2c2c38 80%); }
.sw-sticker { display: flex; align-items: center; justify-content: center; background: #3c3c48; font-size: 16px; }
.sw-block { background: #000; border: 1px solid #444; }

.emoji-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.emoji-tile { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; font-size: 20px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); cursor: pointer; }
.emoji-tile.selected { border-color: var(--accent); background: rgba(255, 214, 10, .08); }

/* 滑杆 */
.slider-row { margin-bottom: 14px; }
.slider-row:last-child { margin-bottom: 0; }
.slider-row label { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.slider-row output { color: var(--accent); font-weight: 600; }
input[type=range] { width: 100%; accent-color: var(--accent); cursor: pointer; }

.card-tips ol { padding-left: 18px; color: var(--text-dim); font-size: 13px; }
.card-tips li { margin: 4px 0; }
.privacy { margin-top: 12px; font-size: 12px; color: #7ee0a0; background: rgba(126,224,160,.07); border: 1px solid rgba(126,224,160,.2); border-radius: 8px; padding: 8px 10px; }

/* ---------- 按钮 ---------- */
.btn { border: 1px solid var(--border); background: var(--panel-2); color: var(--text); border-radius: 8px; padding: 8px 16px; font-size: 14px; cursor: pointer; transition: filter .15s, border-color .15s; font-family: inherit; }
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-dark); font-weight: 700; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: rgba(255,91,91,.5); color: var(--danger); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-icon { padding: 6px 12px; }
.btn.big { padding: 10px 26px; font-size: 15px; }

/* ---------- 工作区 ---------- */
.workspace { min-height: 560px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; }
.view { flex: 1; display: flex; flex-direction: column; min-height: 480px; }

/* 上传区 */
.dropzone { flex: 1; min-height: 380px; border: 2px dashed #3d3d4a; border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: pointer; transition: border-color .2s, background .2s; text-align: center; padding: 30px; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(255,214,10,.04); }
.dz-icon { font-size: 52px; }
.dz-title { font-size: 18px; font-weight: 600; }
.dz-sub { color: var(--text-dim); font-size: 13px; }
.engine-status { margin-top: 14px; color: var(--text-dim); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.engine-status.ok { color: #7ee0a0; }
.engine-status.err { color: var(--danger); }
.spinner { width: 14px; height: 14px; border: 2px solid #4a4a58; border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 工具条 */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar-info { font-size: 14px; color: var(--text-dim); margin-right: auto; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 画布区域 */
.canvas-wrap { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; background: #0a0a0e; border-radius: 10px; overflow: hidden; min-height: 300px; }
.canvas-wrap canvas, .canvas-wrap video { max-width: 100%; max-height: 62vh; display: block; }
.canvas-wrap.draw-mode { cursor: crosshair; }
.overlay { position: absolute; pointer-events: auto; }
.edit-tip { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(0,0,0,.65); color: #ddd; font-size: 12px; padding: 4px 12px; border-radius: 999px; pointer-events: none; white-space: nowrap; }

.faces-strip { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.face-chip { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.face-chip .score { color: var(--text-dim); }
.face-chip button { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 14px; }

/* 视频控制 */
.video-controls { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.video-controls input[type=range] { flex: 1; }
.time-label { font-size: 12px; color: var(--text-dim); min-width: 96px; text-align: right; font-variant-numeric: tabular-nums; }
.vid-meta { margin-top: 8px; font-size: 12px; color: var(--text-dim); }

/* 进度 */
.progress-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.progress-head h3 { font-size: 17px; }
.progress-bar-wrap { height: 10px; background: #26262f; border-radius: 999px; overflow: hidden; margin-top: 14px; }
.progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, #ffd60a, #ffb703); transition: width .2s; border-radius: 999px; }
.progress-text { margin-top: 10px; color: var(--text-dim); font-size: 13px; text-align: center; }
.canvas-wrap.processing canvas { max-height: 52vh; }

/* 结果 */
.result-wrap { flex: 1; display: flex; align-items: center; justify-content: center; background: #0a0a0e; border-radius: 10px; overflow: hidden; min-height: 300px; }
.result-wrap img, .result-wrap video { max-width: 100%; max-height: 64vh; display: block; }

/* ---------- 页脚 ---------- */
.footer { border-top: 1px solid var(--border); padding: 16px 24px; text-align: center; color: #6c6c7a; font-size: 12px; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px); background: #2c2c36; color: #fff; border: 1px solid var(--border); padding: 10px 20px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 999; max-width: 80vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
