:root {
  --bg: #fbf7f1;
  --card: #ffffff;
  --ink: #2b2620;
  --muted: #8a8076;
  --line: #ece4d8;
  --brand: #c2712f;
  --brand-d: #a85c20;
  --accent: #2f6f5e;
  --danger: #c0392b;
  --ok: #2f7d4f;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(120, 90, 50, 0.10);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: rgba(251,247,241,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand-ico { font-size: 22px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.credit-pill {
  background: #fff; border: 1px solid var(--line);
  padding: 5px 12px; border-radius: 999px; font-size: 13px; color: var(--brand-d);
}
.btn-ghost {
  background: #fff; border: 1px solid var(--line); color: var(--ink);
  padding: 8px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-d); }
.btn-mini { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; font-size: 14px; }
.btn-primary {
  display: inline-block; text-align: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-d));
  color: #fff; border: none; padding: 13px 22px; border-radius: 14px;
  font-size: 16px; font-weight: 700; box-shadow: var(--shadow);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-primary.block, .btn-ghost.block { display: block; width: 100%; margin: 10px 0; }

/* 布局 */
.wrap { max-width: 720px; margin: 0 auto; padding: 18px 16px 60px; }
.hero { text-align: center; margin: 14px 0 22px; }
.hero h1 { font-size: 26px; margin: 0 0 8px; letter-spacing: -0.5px; }
.hero .sub { color: var(--muted); margin: 0; font-size: 15px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 19px; }
.card h3 { margin: 18px 0 8px; font-size: 16px; }

/* 上传 */
.dropzone {
  position: relative; border: 2px dashed var(--line); border-radius: 14px;
  min-height: 200px; display: flex; align-items: center; justify-content: center;
  background: #fdfbf7; cursor: pointer; overflow: hidden; transition: border-color .2s;
}
.dropzone.drag { border-color: var(--brand); background: #fff6ec; }
.dz-inner { text-align: center; padding: 20px; }
.dz-ico { font-size: 34px; }
.dz-text { margin-top: 8px; font-weight: 600; }
.dz-hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.preview-img { max-width: 100%; max-height: 360px; display: block; margin: 0 auto; }
.clear-img {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px;
  border-radius: 50%; border: none; background: rgba(0,0,0,0.55); color: #fff; font-size: 18px;
}

/* 模式 */
.modes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 16px 0; }
.mode {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: #fbf7f0; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; text-align: left;
}
.mode .mode-ico { font-size: 20px; }
.mode .mode-name { font-weight: 700; font-size: 15px; }
.mode .mode-cost { font-size: 12px; color: var(--muted); }
.mode.active { border-color: var(--brand); background: #fff6ec; box-shadow: 0 0 0 3px rgba(194,113,47,0.12); }

/* 验证码 */
.captcha-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; }
.captcha-img { height: 44px; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; background: #f1f5f9; }
.captcha-input { flex: 1; min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; letter-spacing: 3px; text-transform: uppercase; }

/* 进度 / 提示 */
.progress { margin-top: 14px; }
.progress-bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--accent)); transition: width .4s; }
.progress-text { font-size: 13px; color: var(--muted); margin-top: 6px; text-align: center; }
.alert { margin-top: 14px; padding: 11px 14px; border-radius: 10px; font-size: 14px; background: #fdecea; color: var(--danger); border: 1px solid #f5c6c0; }
.alert.ok { background: #eafaf0; color: var(--ok); border-color: #bfe9cd; }

/* 结果对比 */
.compare { position: relative; width: 100%; aspect-ratio: 1/1; border-radius: 12px; overflow: hidden; user-select: none; touch-action: none; background: #eee; }
.cmp { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cmp.after { clip-path: inset(0 0 0 50%); }
.slider-handle { position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; background: #fff; box-shadow: 0 0 6px rgba(0,0,0,.4); transform: translateX(-50%); cursor: ew-resize; }
.slider-handle::after { content: "⇄"; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 34px; height: 34px; border-radius: 50%; background: #fff; color: var(--brand-d); display: flex; align-items: center; justify-content: center; font-size: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.cmp-label { position: absolute; bottom: 8px; background: rgba(0,0,0,.5); color: #fff; font-size: 12px; padding: 3px 9px; border-radius: 999px; }
.cmp-label.left { left: 8px; }
.cmp-label.right { right: 8px; }
.result-actions { display: flex; gap: 10px; margin-top: 14px; }
.result-actions .btn-primary { flex: 1; text-decoration: none; }
.result-meta { color: var(--muted); font-size: 13px; margin-top: 10px; }

/* 说明 */
.tips ul { margin: 6px 0; padding-left: 20px; font-size: 14px; color: #4a443c; }
.tips .note { color: var(--muted); font-size: 13px; }

/* 弹窗 / 抽屉 */
.modal, .drawer { position: fixed; inset: 0; z-index: 50; display: flex; }
.modal { background: rgba(0,0,0,0.45); align-items: center; justify-content: center; padding: 16px; }
.drawer { justify-content: flex-end; background: rgba(0,0,0,0.35); }
.modal-card, .drawer-card {
  background: #fff; border-radius: 18px; padding: 22px; width: 100%; max-width: 420px;
  max-height: 90vh; overflow-y: auto; position: relative; animation: pop .18s ease;
}
.drawer-card { max-width: 420px; border-radius: 18px 0 0 18px; height: 100%; max-height: 100%; animation: slide .22s ease; }
.drawer-card.wide { max-width: 560px; }
@keyframes pop { from { transform: scale(.96); opacity: .6; } to { transform: scale(1); opacity: 1; } }
@keyframes slide { from { transform: translateX(40px); opacity: .6; } to { transform: translateX(0); opacity: 1; } }
.modal-close { position: absolute; top: 12px; right: 14px; width: 32px; height: 32px; border: none; background: #f3eee6; border-radius: 50%; font-size: 20px; color: var(--muted); }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { flex: 1; background: #f3eee6; border: none; padding: 10px; border-radius: 10px; font-weight: 700; color: var(--muted); }
.tab.active { background: var(--brand); color: #fff; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input { padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 16px; }
.acct-balance { font-size: 22px; margin: 10px 0; color: var(--brand-d); }
.history-list { max-height: 320px; overflow-y: auto; }
.history-list .row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.history-list .empty { color: var(--muted); padding: 14px 0; text-align: center; }
.recharge-note { background: #fff6ec; border: 1px solid #f3d9bf; border-radius: 12px; padding: 12px; font-size: 14px; color: #8a5a22; }
.plans { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 14px 0; }
.plan { background: #fbf7f0; border: 1px solid var(--line); border-radius: 12px; padding: 14px 8px; text-align: center; }
.plan b { display: block; font-size: 14px; }
.plan span { font-size: 13px; color: var(--muted); }
.recharge-tip { color: var(--muted); font-size: 13px; }

/* 管理 */
.admin-stats { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; margin: 8px 0 4px; }
.stat { background: #fbf7f0; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat b { display: block; font-size: 22px; color: var(--brand-d); }
.stat span { font-size: 12px; color: var(--muted); }
.table-wrap { overflow-x: auto; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.user-table .ops { display: flex; gap: 6px; }
.user-table .ops button { font-size: 12px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.tag-admin { background: #fdeccb; color: #8a5a22; padding: 2px 8px; border-radius: 999px; font-size: 11px; }
.tag-user { background: #eef3f0; color: var(--accent); padding: 2px 8px; border-radius: 999px; font-size: 11px; }
.st-ok { color: var(--ok); }
.st-fail { color: var(--danger); }
.st-no { color: var(--muted); }

/* toast */
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: #2b2620; color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; z-index: 99; box-shadow: 0 6px 20px rgba(0,0,0,.3); }

/* 平板及以上 */
@media (min-width: 768px) {
  .hero h1 { font-size: 32px; }
  .modes { grid-template-columns: repeat(4, 1fr); }
  .modal-card { max-width: 440px; }
}
