:root {
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --ink: #111827;
  --ink-2: #4b5563;
  --ink-3: #9ca3af;
  --line: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --danger: #dc2626;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* 类选择器上的 display 会盖掉浏览器默认的 [hidden]，这里统一压回去 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px calc(48px + env(safe-area-inset-bottom)); }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 4px 16px;
}
.topbar h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -0.2px; }
.topbar .sub { margin: 2px 0 0; font-size: 13px; color: var(--ink-3); }

/* ---------- card ---------- */
.card {
  margin-bottom: 16px;
  padding: 18px 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 700;
}
.card-head .num {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-head .opt { font-size: 13px; font-weight: 400; color: var(--ink-3); }

/* ---------- field ---------- */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}
.field .tip { margin: 6px 0 0; font-size: 12.5px; color: var(--ink-3); }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-family: inherit;
  line-height: 1.6;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
textarea { resize: vertical; min-height: 120px; }
textarea.tall { min-height: 160px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 13px 18px;
  border: none;
  border-radius: 11px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, opacity 0.15s;
  text-decoration: none;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-block { width: 100%; padding: 15px; font-size: 17px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-ghost { background: #eef0f3; color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: #e3e6ea; }
.btn-danger-ghost { background: #fef2f2; color: var(--danger); }
.btn-sm { padding: 8px 13px; font-size: 14px; border-radius: 9px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- dropzone ---------- */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 26px 16px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  background: #fafbfc;
  color: var(--ink-2);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: #f5f8ff; }
.dropzone .big { font-size: 26px; }
.dropzone .main { font-size: 15px; font-weight: 600; }
.dropzone .sub { font-size: 12.5px; color: var(--ink-3); }

/* ---------- thumbs ---------- */
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.thumb {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #f2f3f5;
  border: 1px solid var(--line);
}
.thumb .preview { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: #000; }
.thumb .order {
  position: absolute;
  top: 6px;
  left: 6px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb .del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb .moves {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: rgba(0, 0, 0, 0.55);
}
.thumb .moves button {
  flex: 1;
  padding: 5px 0;
  border: none;
  background: none;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
.thumb .moves button:disabled { opacity: 0.3; cursor: default; }
.thumb .state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink-2);
  font-size: 12.5px;
  text-align: center;
  padding: 8px;
}
.thumb .state.bad { background: rgba(254, 226, 226, 0.92); color: var(--danger); }

/* ---------- result ---------- */
.result { text-align: center; }
.qr-frame {
  display: inline-block;
  padding: 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
}
.qr-frame canvas { display: block; width: 216px; height: 216px; image-rendering: pixelated; }
.link-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfc;
  text-align: left;
}
.link-row code { flex: 1; font-size: 13px; word-break: break-all; color: var(--ink-2); }

/* ---------- history ---------- */
.item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: none; }
.item .info { flex: 1; min-width: 0; }
.item .name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.item .acts { display: flex; gap: 6px; flex: none; }

.empty { padding: 26px 0; text-align: center; color: var(--ink-3); font-size: 14px; }

/* ---------- gate ---------- */
.gate { max-width: 380px; margin: 12vh auto; padding: 30px 24px; background: var(--card); border-radius: 18px; box-shadow: 0 6px 24px rgba(0,0,0,.08); }
.gate h1 { margin: 0 0 4px; font-size: 22px; text-align: center; }
.gate p { margin: 0 0 20px; font-size: 13.5px; color: var(--ink-3); text-align: center; }
.gate .err { margin: 10px 0 0; font-size: 13.5px; color: var(--danger); text-align: center; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 9%;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.88);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 14.5px;
  z-index: 200;
  max-width: 82vw;
  text-align: center;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.hidden { display: none !important; }
