/* ============================================================
   水印橡皮擦 · 样式表
   ============================================================ */

:root {
  --bg:            #f4f6f9;
  --surface:       #ffffff;
  --surface-2:     #fafbfc;
  --border:        #e4e8ee;
  --border-strong: #d3d9e2;
  --text:          #1b2230;
  --text-2:        #5b6675;
  --text-3:        #8b95a3;
  --accent:        #3d6bf5;
  --accent-hover:  #2f59dc;
  --accent-soft:   #eaf0ff;
  --danger:        #e0464b;
  --shadow-sm:     0 1px 2px rgba(16, 24, 40, .06);
  --shadow-md:     0 4px 16px rgba(16, 24, 40, .08);
  --shadow-lg:     0 12px 40px rgba(16, 24, 40, .14);
  --radius:        10px;
  --topbar-h:      56px;
  --toolbar-w:     78px;
  --panel-w:       288px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button { font-family: inherit; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  flex: 0 0 var(--topbar-h);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 9px; }

.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #4d7cff, #2f4fe0);
  box-shadow: 0 2px 8px rgba(61, 107, 245, .35);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-text { font-size: 15px; font-weight: 650; letter-spacing: .2px; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: #bcc5d2; }
.btn:active:not(:disabled) { background: #eef1f5; }
.btn:disabled { opacity: .42; cursor: not-allowed; }

.btn.icon { width: 32px; padding: 0; justify-content: center; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.primary:active:not(:disabled) { background: #2649c4; }
.btn.lg { height: 40px; padding: 0 22px; font-size: 14px; }

.ico { width: 16px; height: 16px; flex: none; }

.sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }

.export-group {
  display: flex;
  align-items: center;
  border-radius: 8px;
  overflow: hidden;
}
.select {
  height: 32px;
  border: 1px solid var(--border-strong);
  border-right: none;
  border-radius: 8px 0 0 8px;
  padding: 0 6px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.export-group .btn.primary { border-radius: 0 8px 8px 0; }

/* ---------------- 主体布局 ---------------- */
.workspace {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

/* 左侧工具条 */
.toolbar {
  flex: 0 0 var(--toolbar-w);
  width: var(--toolbar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 20;
}
.tool {
  width: 60px;
  padding: 8px 0 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tool svg { width: 21px; height: 21px; }
.tool-label { font-size: 11px; }
.tool:hover { background: var(--surface-2); color: var(--text); }
.tool.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* ---------------- 画布区 ---------------- */
.stage {
  flex: 1 1 auto;
  position: relative;
  min-width: 0;
  overflow: hidden;
  background:
    linear-gradient(45deg, #eceef2 25%, transparent 25%, transparent 75%, #eceef2 75%) 0 0 / 20px 20px,
    linear-gradient(45deg, #eceef2 25%, transparent 25%, transparent 75%, #eceef2 75%) 10px 10px / 20px 20px,
    #f7f8fa;
}

/* 空状态拖拽区 */
.dropzone {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 12;
}
.dropzone.hidden { display: none; }
.dropzone-inner {
  max-width: 460px;
  text-align: center;
  padding: 44px 40px;
  background: rgba(255, 255, 255, .92);
  border: 1.5px dashed var(--border-strong);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(2px);
  transition: border-color .18s, background .18s;
}
.dropzone.dragover .dropzone-inner {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dz-icon {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
}
.dz-icon svg { width: 28px; height: 28px; }
.dropzone h2 { margin: 0 0 6px; font-size: 17px; font-weight: 650; }
.dropzone p  { margin: 0 0 20px; color: var(--text-2); }
.dz-tips {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-3);
  font-size: 12px;
}
.dz-tips .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-3); }

/* 画布容器 */
.canvas-wrap {
  position: absolute;
  inset: 0 0 34px 0;
  overflow: hidden;
  display: none;
  cursor: crosshair;
}
.canvas-wrap.ready { display: block; }
.canvas-wrap.t-pan { cursor: grab; }
.canvas-wrap.t-pan.dragging { cursor: grabbing; }
.canvas-wrap.t-restore { cursor: cell; }
.canvas-wrap.busy { cursor: progress; }

#cvBase, #cvMaskOverlay {
  position: absolute;
  top: 0; left: 0;
  display: block;
  transform-origin: 0 0;
}
#cvBase { box-shadow: var(--shadow-lg); }
/* 透明区域的棋盘格（便于观察 PNG 透明通道） */
#cvBase.checker {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #dfe3e9 25%, transparent 25%, transparent 75%, #dfe3e9 75%),
    linear-gradient(45deg, #dfe3e9 25%, transparent 25%, transparent 75%, #dfe3e9 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}
#cvMaskOverlay {
  pointer-events: none;
  opacity: .58;
}
#cvMaskOverlay.hidden { display: none; }

/* 画笔光标 */
.brush-cursor {
  position: absolute;
  border: 1.5px solid rgba(20, 26, 40, .75);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .85) inset,
              0 0 0 1px rgba(255, 255, 255, .7);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  display: none;
  z-index: 5;
}
.brush-cursor.show { display: block; }

/* 处理中 */
.processing {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(244, 246, 249, .72);
  backdrop-filter: blur(2px);
  z-index: 25;
}
.processing.show { display: grid; }
.proc-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 状态栏 */
.statusbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  z-index: 15;
}
.flex-spacer { flex: 1 1 auto; }
.statusbar .hint { color: var(--text-3); }
.sep-v { width: 1px; height: 16px; background: var(--border); }
.zoom-ctl { display: flex; align-items: center; gap: 4px; }
#stZoom { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.zbtn {
  min-width: 22px; height: 22px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.zbtn:hover { background: var(--surface-2); color: var(--text); }
.zbtn.wide { padding: 0 8px; font-size: 12px; }

/* ---------------- 右侧面板 ---------------- */
.panel {
  flex: 0 0 var(--panel-w);
  width: var(--panel-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 4px 0 24px;
  z-index: 20;
}
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: #dde2ea; border-radius: 4px; }

.p-block {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.p-block:last-child { border-bottom: none; }
.p-title {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-3);
}

.field + .field { margin-top: 18px; }
.field-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.field-head label { font-size: 13px; color: var(--text); }
.field-head .num {
  margin-left: auto;
  width: 62px;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  text-align: right;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.field-head .unit { color: var(--text-3); font-size: 12px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #e3e8ef;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
  cursor: pointer;
}

.tip {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--text-3);
}
kbd {
  display: inline-block;
  min-width: 16px;
  padding: 1px 4px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 10.5px;
  color: var(--text-2);
  text-align: center;
}

/* 算法选择卡片 */
.radio-list { display: flex; flex-direction: column; gap: 8px; }
.radio-card {
  display: flex;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.radio-card:hover { background: var(--surface-2); }
.radio-card input { margin: 2px 0 0; accent-color: var(--accent); }
.radio-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.rc-body { display: flex; flex-direction: column; gap: 3px; }
.rc-title { font-size: 13px; font-weight: 600; }
.rc-title em {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-style: normal;
  font-weight: 500;
  vertical-align: 1px;
}
.rc-desc { font-size: 11.5px; color: var(--text-2); line-height: 1.45; }

/* 开关 */
.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 13px;
  cursor: pointer;
}
.switch-row input { display: none; }
.switch {
  margin-left: auto;
  position: relative;
  width: 34px; height: 19px;
  border-radius: 10px;
  background: #d5dbe4;
  transition: background .18s;
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform .18s;
}
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(15px); }

/* 图片信息 */
.meta { margin: 0; display: flex; flex-direction: column; gap: 7px; }
.meta > div { display: flex; align-items: baseline; gap: 10px; }
.meta dt { color: var(--text-3); font-size: 12px; }
.meta dd {
  margin: 0 0 0 auto;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* 说明 */
.tips-block .steps {
  margin: 0 0 10px;
  padding-left: 18px;
  color: var(--text-2);
  font-size: 12px;
}
.tips-block .steps li { margin-bottom: 4px; }
.note {
  margin: 0;
  padding: 8px 10px;
  border-radius: 7px;
  background: #fff8e8;
  border: 1px solid #f4e2b8;
  color: #8a6d1f;
  font-size: 11.5px;
  line-height: 1.5;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  :root { --panel-w: 250px; --toolbar-w: 66px; }
  .tool { width: 54px; }
}
@media (max-width: 860px) {
  .panel { display: none; }
  .brand-text { display: none; }
}

/* ============================================================
   页脚 · 广告位 · Cookie 同意条
   ============================================================ */

.site-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 16px;
  min-height: 106px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 25;
}
.foot-brand {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.foot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
}
.foot-links a {
  color: var(--text-2);
  text-decoration: none;
}
.foot-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.foot-copy {
  width: 100%;
  color: var(--text-3);
  font-size: 11px;
}

/* 广告位容器：预留固定高度，防止广告加载时页面跳动（CLS） */
.ad-slot { flex: 0 0 auto; }
.ad-slot .adsbygoogle { display: block; }

.ad-vertical {
  margin: 14px 18px 4px;
  min-height: 600px;
  max-width: 160px;
  /* 居中放在右栏，避免与 300px 栏宽造成布局错位 */
  margin-left: auto;
  margin-right: auto;
}
.ad-banner {
  width: 728px;
  max-width: 100%;
  min-height: 90px;
  margin-left: auto;
}
.ad-sidebar {
  margin: 14px 18px 4px;
  min-height: 250px;
}
.ad-page {
  width: 728px;
  max-width: 100%;
  min-height: 90px;
  margin: 28px auto 0;
}

/* 未配置 AdSense 时的占位框（拿到广告代码后自动消失） */
.ad-slot.ad-placeholder {
  display: grid;
  place-items: center;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-3);
  font-size: 11px;
  letter-spacing: .6px;
}

/* Cookie 同意条 */
.cookie-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 13px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 24px rgba(16, 24, 40, .10);
  font-size: 12.5px;
  color: var(--text-2);
}
.cookie-bar p { margin: 0; flex: 1 1 320px; line-height: 1.6; }
.cookie-bar a { color: var(--accent); text-decoration: none; }
.cookie-bar a:hover { text-decoration: underline; }
.cookie-actions { display: flex; gap: 8px; }

@media (max-width: 1080px) {
  .site-foot { flex-wrap: wrap; min-height: 0; gap: 12px; }
  .ad-banner { width: 100%; margin-left: 0; min-height: 100px; }
}
