/* ==========================================
   图片工具箱 · sntfct —— 沿用主页黑白灰设计系统
   （功能类名 /#id 与 main.js 保持一致，勿改）
   ========================================== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #ffffff; --bg-card: #fafafa; --bg-soft: #f2f2f2;
  --text-1: #171717; --text-2: #525252; --text-3: #737373; --text-4: #a3a3a3;
  --line: rgba(0,0,0,.08); --line-2: rgba(0,0,0,.15);
  --accent: #171717;
  --checker: repeating-conic-gradient(#f0f0f0 0% 25%, #ffffff 0% 50%) 50% / 16px 16px;
}
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-1);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(0,0,0,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,.035) 1px, transparent 1px);
  background-size: 80px 80px;
  background-position: -1px -1px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
::selection { background: var(--text-1); color: #fff; }
img, canvas { display: block; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 顶栏 ---------- */
.nav {
  position: sticky; top: 0; z-index: 60;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  display: flex; align-items: center; gap: 14px;
}
.nav .back {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 10px; border-radius: 8px;
  font-size: 13px; color: var(--text-2);
  text-decoration: none; transition: all .2s;
}
.nav .back:hover { background: var(--bg-soft); color: var(--text-1); }
.nav .back svg { width: 14px; height: 14px; }
.nav .brand { flex: 1; font-size: 14px; letter-spacing: 1.5px; font-weight: 600; }
.nav .brand span { color: var(--text-3); font-weight: 400; margin-left: 6px; font-size: 12px; }

/* ---------- 布局 ---------- */
.wrap { max-width: 820px; margin: 0 auto; padding: 0 18px 64px; }
.hero { padding: 40px 0 26px; text-align: center; }
.hero .label { font-size: 11px; letter-spacing: 4px; color: var(--text-4); }
.hero h1 { font-size: 28px; font-weight: 800; letter-spacing: 1px; margin: 12px 0 10px; }
.hero p { font-size: 13px; line-height: 1.9; color: var(--text-3); }

.sec-title {
  display: flex; align-items: baseline; gap: 10px;
  font-size: 12px; font-weight: 500; letter-spacing: 3px;
  color: var(--text-4); text-transform: uppercase;
  margin: 34px 0 12px;
}
.sec-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.sec-title em { font-style: normal; letter-spacing: 0; text-transform: none; font-size: 11px; color: var(--text-4); }
.meta { font-size: 11px; letter-spacing: 0; text-transform: none; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------- 上传区 ---------- */
#dropzone {
  border: 2px dashed var(--line-2);
  border-radius: 16px;
  background: var(--bg-card);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .1s;
  outline: none;
}
#dropzone:hover, #dropzone:focus, #dropzone.drag {
  border-color: var(--text-1);
  background: var(--bg-soft);
}
#dropzone.drag { transform: scale(1.01); }
.dz-icon { font-size: 34px; }
.dz-main { margin-top: 10px; font-size: 15px; }
.dz-main b { color: var(--text-1); }
.dz-sub { margin-top: 6px; font-size: 12px; color: var(--text-4); }

/* ---------- 工作区 ---------- */
#workspace { margin-top: 8px; }
.origin-box {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  justify-content: center;
}
.origin-box img {
  max-width: 100%;
  max-height: 260px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--checker);
}

#grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  text-align: center;
  transition: transform .15s, border-color .15s, box-shadow .15s, background .15s;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--text-1);
  background: var(--bg);
  box-shadow: 0 6px 18px rgba(0,0,0,.07);
}
.card .c-preview {
  height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.card .c-preview canvas,
.card .c-preview img {
  max-width: 100%;
  max-height: 132px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--checker);
}
.card .c-loading { color: var(--text-4); font-size: 20px; }
.card .c-name { margin-top: 9px; font-size: 13px; color: var(--text-2); }
.card .c-icon { font-size: 14px; }

/* ---------- 提示 ---------- */
#hint {
  margin-top: 18px;
  padding: 10px 12px;
  background: #fff8e6;
  border: 1px solid #f0d489;
  border-radius: 10px;
  color: #8a6d1a;
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
}

/* ---------- 说明 ---------- */
.tips { margin-top: 42px; }
.tips h2 {
  font-size: 12px; letter-spacing: 3px; color: var(--text-4); font-weight: 500;
  text-transform: uppercase; display: flex; align-items: center; gap: 12px;
}
.tips h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.tips ol { margin-top: 14px; padding-left: 0; list-style: none; counter-reset: tip; }
.tips li {
  position: relative; padding: 11px 0 11px 32px;
  border-bottom: 1px solid var(--line);
  font-size: 13px; line-height: 1.85; color: var(--text-2);
}
.tips li:last-child { border-bottom: 0; }
.tips li::before {
  counter-increment: tip; content: counter(tip);
  position: absolute; left: 0; top: 12px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg-soft); color: var(--text-2);
  font-size: 11px; font-weight: 700; line-height: 20px; text-align: center;
}
.tips li b { color: var(--text-1); }

/* ---------- 弹层 ---------- */
#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,.45);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 20px;
}
.lb-card {
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.22);
  max-width: min(860px, 94vw);
  max-height: 92vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.lb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.lb-head h3 { font-size: 15px; font-weight: 700; letter-spacing: .5px; }
#lb-close {
  background: none;
  border: 1px solid transparent;
  color: var(--text-3);
  font-size: 16px;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 8px;
  transition: all .15s;
}
#lb-close:hover { background: var(--bg-soft); border-color: var(--line); color: var(--text-1); }

#lb-speed-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px 0;
  font-size: 13px;
  flex-wrap: wrap;
}
#lb-speed-row label { color: var(--text-2); white-space: nowrap; }
#lb-speed { flex: 1; min-width: 140px; accent-color: var(--text-1); }
#lb-speed-val {
  color: var(--text-1);
  font-weight: 700;
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.speed-warn {
  display: block;
  flex-basis: 100%;
  margin-top: 4px;
  color: #8a6d1a;
  font-size: 12px;
}
.speed-warn:empty { display: none; }
#lb-speed-warn:not(:empty) {
  background: #fff8e6;
  border: 1px solid #f0d489;
  border-radius: 8px;
  padding: 8px 10px;
}

.lb-img-wrap {
  padding: 18px;
  display: flex;
  justify-content: center;
  overflow: auto;
}
.lb-img-wrap img {
  max-width: 100%;
  max-height: 62vh;
  border-radius: 10px;
  object-fit: contain;
  border: 1px solid var(--line);
  background: var(--checker);
}
.lb-actions { padding: 0 18px 18px; text-align: center; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-2);
  background: var(--bg);
  border-radius: 10px;
  padding: 11px 26px;
  font-size: 14px; color: var(--text-1);
  text-decoration: none;
  transition: background .15s, opacity .15s, transform .1s;
}
.btn:hover { background: var(--bg-soft); }
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--text-1); color: #fff; border-color: var(--text-1); font-weight: 600; }
.btn.primary:hover { background: #000; }

footer {
  border-top: 1px solid var(--line);
  padding: 26px 18px calc(26px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 12px; color: var(--text-4);
}
footer a { color: var(--text-3); text-decoration: none; }
footer a:hover { color: var(--text-1); }

.hide { display: none !important; }

@media (max-width: 620px) {
  .nav { padding: calc(6px + env(safe-area-inset-top)) 14px 6px; gap: 8px; }
  .nav .back { padding: 4px 6px; font-size: 12px; }
  .nav .back svg { width: 12px; height: 12px; }
  .nav .brand { font-size: 13px; letter-spacing: 1px; }
  .nav .brand span { font-size: 11px; margin-left: 4px; }
  .hero { padding-top: 18px; }
  .hero h1 { font-size: 22px; }
  #dropzone { padding: 30px 16px; }
  .dz-icon { font-size: 28px; }
  .dz-main { font-size: 14px; }
  #grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
  .card .c-preview { height: 104px; }
  .card .c-preview canvas, .card .c-preview img { max-height: 104px; }
  .card .c-name { font-size: 12px; }
  .lb-actions .btn { width: 100%; }
}
@media (max-width: 360px) {
  .nav .brand span { display: none; }
}
