:root {
  --red: #c8102e;
  --ink: #1f2328;
  --muted: #59636e;
  --line: #d0d7de;
  --bg: #f6f8fa;
  --panel: #ffffff;
  --focus: #0969da;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
}

[hidden] { display: none !important; }

.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: #fff; padding: 8px 12px; z-index: 10;
}
.skip:focus { left: 8px; top: 8px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.top { background: var(--red); color: #fff; padding: 20px 0 18px; }
.top h1 { margin: 0; font-size: 24px; letter-spacing: 1px; }
.top .sub { margin: 4px 0 0; opacity: .95; }

.banner { max-width: 960px; margin: 12px auto 0; padding: 10px 14px; border-radius: 6px; }
.banner-err { background: #ffebe9; border: 1px solid #ff8182; color: #82071e; }
.banner-warn { background: #fff8c5; border: 1px solid #d4a72c; color: #4d2d00; }

main { padding-top: 16px; padding-bottom: 24px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.panel h2 { margin: 0 0 12px; font-size: 17px; }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; min-height: 140px; padding: 20px;
  border: 2px dashed #8c959f; border-radius: 8px;
  background: #fafbfc; color: var(--ink); cursor: pointer;
  font: inherit; text-align: center;
}
.drop:hover, .drop.over { border-color: var(--red); background: #fff5f5; }
.drop-main { font-size: 16px; font-weight: 600; }
.drop-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.src { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.src img { width: 96px; height: 96px; object-fit: contain; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.src-meta { color: var(--muted); font-size: 13px; word-break: break-all; }

.tips { margin-top: 12px; color: var(--muted); font-size: 14px; }
.tips summary { cursor: pointer; color: var(--ink); }
.tips ul { margin: 8px 0 0; padding-left: 20px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field output { font-weight: 400; color: var(--muted); margin-left: 6px; }
.field select, .field input[type=number] {
  width: 100%; height: 36px; padding: 0 8px;
  border: 1px solid #8c959f; border-radius: 6px; background: #fff; font: inherit; color: var(--ink);
}
.field input[type=number], .field input[type=color] { margin-top: 6px; }
.field input[type=range] { width: 100%; accent-color: var(--red); }
.field input[type=color] { width: 100%; height: 36px; border: 1px solid #8c959f; border-radius: 6px; background: #fff; }

.bg-switch { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 10px; }
.bg-switch label { cursor: pointer; }

.stage {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 280px; padding: 16px;
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.stage canvas { width: min(100%, 420px); height: auto; aspect-ratio: 1 / 1; }
.bg-checker {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e6e6e6 25%, transparent 25%),
    linear-gradient(-45deg, #e6e6e6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e6e6e6 75%),
    linear-gradient(-45deg, transparent 75%, #e6e6e6 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.bg-white { background: #fff; }
.bg-gray { background: #8c8c8c; }
.bg-doc {
  background-color: #fff;
  background-image: repeating-linear-gradient(180deg, transparent 0 22px, #c9ced6 22px 24px);
}
.placeholder { color: var(--muted); margin: 0; }
.busy {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .7); font-weight: 600;
}

.status { min-height: 1.6em; margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.status.err { color: #82071e; }

.actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
button.primary, button.ghost {
  height: 40px; padding: 0 20px; border-radius: 6px; font: inherit; font-weight: 600; cursor: pointer;
}
button.primary { background: var(--red); color: #fff; border: 1px solid var(--red); }
button.ghost { background: #fff; color: var(--ink); border: 1px solid #8c959f; }
button:disabled { opacity: .5; cursor: not-allowed; }

.wx { margin-top: 12px; padding: 12px; border: 1px dashed #d4a72c; border-radius: 8px; background: #fffdf0; }
.wx p { margin: 0 0 8px; }
.wx img { display: block; width: min(100%, 320px); margin: 0 auto; }

.note ul { margin: 0; padding-left: 20px; }
.note li { margin-bottom: 6px; }

.foot { color: var(--muted); font-size: 13px; padding: 8px 0 24px; text-align: center; }

@media (max-width: 520px) {
  .top h1 { font-size: 20px; }
  .stage { min-height: 220px; }
  .actions button { flex: 1; }
}
