/* ============================================================
   imgbed — Light Gallery
   单一强调色 emerald #0F8A5C（饱和度<80%）· 不纯黑 · 无 emoji
   ============================================================ */

:root {
  /* 表面 */
  --canvas: #fafafa;
  --surface: #ffffff;
  --surface-2: #f5f5f4;

  /* 文字 */
  --ink: #18181b;        /* zinc-900，主文字（不纯黑）*/
  --ink-2: #3f3f46;      /* zinc-700 */
  --muted: #71717a;      /* zinc-500，次文字 */
  --faint: #a1a1aa;      /* zinc-400 */

  /* 线条 */
  --line: #e7e7e9;
  --line-2: #ededee;

  /* 强调色（唯一）*/
  --accent: #0f8a5c;
  --accent-ink: #0b7149;
  --accent-soft: rgba(15, 138, 92, 0.09);

  /* 语义色（克制使用）*/
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.08);

  /* 圆角 / 阴影 */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --shadow-1: 0 1px 2px rgba(24, 24, 27, 0.04), 0 1px 1px rgba(24, 24, 27, 0.03);
  --shadow-2: 0 8px 24px -10px rgba(24, 24, 27, 0.16), 0 2px 6px -2px rgba(24, 24, 27, 0.06);

  /* 动效：接近 spring 的 ease-out */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI Variable", "Segoe UI", system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px;
}

.muted { color: var(--muted); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(250, 250, 250, 0.82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 62px;
}
.brand {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}
.brand-dot { color: var(--accent); }

.nav { display: flex; gap: 4px; }
.nav-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .18s var(--ease), background .18s var(--ease);
  min-height: 36px;
}
.nav-tab:hover { color: var(--ink); background: var(--surface-2); }
.nav-tab.is-active { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-1); }

/* Token chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .18s var(--ease), background .18s var(--ease);
  min-height: 34px;
}
.chip:hover { border-color: var(--line-2); background: var(--surface-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.dot-off { background: var(--faint); }
.dot-on { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Main / Views ---------- */
main.wrap { padding-top: 40px; padding-bottom: 80px; }
.view { animation: rise .4s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Dropzone ---------- */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: clamp(40px, 9vw, 76px) 24px;
  background: var(--surface);
  border: 1.5px dashed var(--line);
  border-radius: var(--r-xl);
  cursor: pointer;
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .2s var(--ease);
  outline: none;
}
.dropzone:hover { border-color: var(--accent); background: #fcfdfc; }
.dropzone:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.dropzone.is-drag { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.005); }
.dz-icon { color: var(--accent); opacity: .9; }
.dz-title {
  margin: 10px 0 0;
  font-size: clamp(16px, 2.4vw, 19px);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.dz-sub { margin: 0; color: var(--muted); font-size: 13.5px; }
.dz-hint { margin-top: 6px; font-size: 11.5px; color: var(--faint); letter-spacing: .02em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  min-height: 38px;
  transition: background .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease), transform .08s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #27272a; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--line-2); background: var(--surface-2); color: var(--ink); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-ink); }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.9);
  color: var(--ink-2);
  cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.iconbtn:hover { background: #fff; color: var(--ink); border-color: var(--line-2); }
.g-del:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

/* ---------- Results ---------- */
.results { display: flex; flex-direction: column; gap: 12px; margin-top: 28px; }
.result-card {
  display: flex;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-1);
  animation: rise .35s var(--ease) both;
}
.rc-thumb {
  flex: 0 0 auto;
  width: 92px;
  height: 92px;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.rc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 11px; }
.rc-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rc-name { font-weight: 600; font-size: 14.5px; color: var(--ink); word-break: break-all; }
.rc-meta { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }

.rc-links { display: flex; flex-direction: column; gap: 7px; }
.link-row { display: flex; align-items: center; gap: 8px; }
.link-row .lbl {
  flex: 0 0 64px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--faint);
}
.link-row .val {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: text;
}
.copybtn {
  flex: 0 0 auto;
  padding: 7px 12px;
  min-height: 32px;
  font-size: 12.5px;
}
.copybtn.copied { background: var(--accent); color: #fff; border-color: var(--accent); }
.rc-foot { margin-top: 2px; }
.rc-open { font-size: 12.5px; color: var(--accent); text-decoration: none; font-weight: 500; }
.rc-open:hover { color: var(--accent-ink); text-decoration: underline; }

/* ---------- Gallery ---------- */
.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-title { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.02em; }
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
}
.g-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.g-item:hover { box-shadow: var(--shadow-2); border-color: var(--line-2); }
.g-media { position: relative; aspect-ratio: 1 / 1; background: var(--surface-2); }
.g-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px;
  background: linear-gradient(180deg, rgba(24,24,27,0.42), rgba(24,24,27,0) 60%);
  opacity: 0;
  transition: opacity .2s var(--ease);
}
.g-item:hover .g-overlay,
.g-item:focus-within .g-overlay { opacity: 1; }
.g-name {
  font-size: 11.5px;
  color: var(--muted);
  padding: 8px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--mono);
}
.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--faint);
  padding: 64px 0;
  font-size: 14px;
}

/* ---------- 图片处理面板 ---------- */
.proc {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.proc-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; cursor: pointer; list-style: none; user-select: none;
}
.proc-head::-webkit-details-marker { display: none; }
.proc-chevron { color: var(--muted); transition: transform .2s var(--ease); }
.proc[open] .proc-chevron { transform: rotate(180deg); }
.proc-title { font-weight: 600; font-size: 14px; color: var(--ink); }
.proc-sub { font-size: 12.5px; color: var(--muted); }
.proc-body { padding: 4px 18px 14px; }

.proc-row {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 0; border-top: 1px solid var(--line);
}
.proc-row:first-of-type { border-top: 0; }
.proc-main { flex: 1; min-width: 0; }
.proc-label { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 7px; }
.proc-ctrl {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  font-size: 13px; color: var(--muted); transition: opacity .18s var(--ease);
}
.proc-row:has(input[type=checkbox]:not(:checked)) .proc-ctrl { opacity: .45; }
.proc-note { font-size: 11.5px; color: var(--faint); }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: 0 0 auto; margin-top: 2px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #d4d4d8; border-radius: 999px; transition: background .18s var(--ease); }
.switch span::before {
  content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .18s var(--ease);
  box-shadow: 0 1px 2px rgba(24,24,27,.25);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 4px var(--accent-soft); }

/* 输入控件 */
.num, .sel, .wm-text {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 10px; outline: none;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.num { width: 80px; height: 34px; }
.wm-size { width: 64px; }
.sel { height: 34px; padding-right: 28px; }
.wm-text { flex: 1; min-width: 150px; }
.num:focus, .sel:focus, .wm-text:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.num-out { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 12.5px; min-width: 26px; text-align: right; }
.wm-color {
  width: 36px; height: 34px; padding: 3px; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--surface); cursor: pointer;
}

/* range slider */
.rng { -webkit-appearance: none; appearance: none; width: 108px; height: 4px; background: #e4e4e7; border-radius: 999px; outline: none; cursor: pointer; }
.rng::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff; cursor: pointer; box-shadow: 0 1px 3px rgba(24,24,27,.25);
}
.rng::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
  border: 2px solid #fff; cursor: pointer;
}

/* ---------- Inputs / Modal ---------- */
.input {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  outline: none;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.modal {
  border: 0;
  border-radius: var(--r-lg);
  padding: 0;
  background: var(--surface);
  box-shadow: var(--shadow-2);
  width: min(420px, calc(100vw - 32px));
  color: var(--ink);
}
.modal::backdrop { background: rgba(24, 24, 27, 0.42); backdrop-filter: blur(2px); }
.modal-form { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.modal-title { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.modal-desc { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.modal-desc code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ---------- Footer ---------- */
.site-foot { border-top: 1px solid var(--line); margin-top: 40px; }
.foot-inner { padding: 20px 24px; }
.foot-inner .muted { font-size: 12.5px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
  z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

/* ---------- AI 抠图视图 ---------- */
.small { font-size: 12px; }
.ai-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.ai-panel { display: flex; flex-direction: column; gap: 16px; }

.ai-drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 28px 20px; background: var(--surface); border: 1.5px dashed var(--line);
  border-radius: var(--r-lg); cursor: pointer; color: var(--muted); outline: none;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.ai-drop:hover, .ai-drop:focus-visible { border-color: var(--accent); }
.ai-drop.is-drag { border-color: var(--accent); background: var(--accent-soft); }
.ai-drop svg { color: var(--accent); }
.ai-drop-title { margin: 6px 0 0; font-weight: 600; color: var(--ink); font-size: 14px; }
.ai-drop-sub { margin: 0; font-size: 12px; color: var(--muted); }

.ai-progress { display: flex; flex-direction: column; gap: 8px; }
.ai-bar { height: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.ai-bar span { display: block; height: 100%; width: 0%; background: var(--accent); transition: width .25s var(--ease); }

.ai-opts { display: flex; flex-direction: column; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-1); }
.ai-field { display: flex; flex-direction: column; gap: 8px; }
.ai-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }

/* 分段控件 */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; align-self: flex-start; }
.seg-btn { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 500; padding: 7px 14px; border-radius: 7px; cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease); }
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* 色板 */
.ai-swatches { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: var(--c, #fff); cursor: pointer; padding: 0; transition: border-color .15s var(--ease), transform .1s var(--ease); }
.swatch:hover { border-color: var(--ink-2); }
.swatch.is-active { border-color: var(--accent); transform: scale(1.08); }
.swatch-picker { position: relative; overflow: hidden; display: inline-flex; background: conic-gradient(#ef4444, #eab308, #22c55e, #06b6d4, #3b82f6, #a855f7, #ef4444); }
.swatch-picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; border: 0; padding: 0; width: 100%; height: 100%; }

.ai-prompt { width: 100%; }
.ai-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ai-engine { width: auto; }

/* 预览 */
.ai-preview { display: flex; flex-direction: column; gap: 10px; }
.ai-prev-head { display: flex; align-items: baseline; justify-content: space-between; }
.ai-prev-label { font-weight: 600; font-size: 14px; }
.ai-prev { border: 1px solid var(--line); border-radius: var(--r-lg); min-height: 320px; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 14px; }
.ai-prev img, .ai-prev canvas { max-width: 100%; max-height: 60vh; border-radius: 8px; display: block; }
.ai-prev-empty { font-size: 13px; }

/* 棋盘格（透明指示） */
.checker {
  background-color: #fafafa;
  background-image:
    linear-gradient(45deg, #e7e7ea 25%, transparent 25%),
    linear-gradient(-45deg, #e7e7ea 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e7e7ea 75%),
    linear-gradient(-45deg, transparent 75%, #e7e7ea 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

/* ---------- 响应式 ---------- */
@media (max-width: 880px) {
  .ai-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .header-inner { gap: 10px; height: 56px; }
  .brand { font-size: 17px; }
  .nav-tab { padding: 7px 11px; font-size: 13px; }
  #tokenLabel { display: none; }
  .chip { padding: 8px; }
  .result-card { flex-direction: column; gap: 14px; }
  .rc-thumb { width: 100%; height: 180px; }
  .link-row .lbl { flex: 0 0 52px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
