:root {
  color-scheme: light;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
  --canvas: #f5f5f7;
  --surface: #fff;
  --recessed: #f5f5f7;
  --ink: #1d1d1f;
  --muted: #65656b;
  --line: rgb(0 0 0 / .06);
  --control-line: rgb(0 0 0 / .14);
  --selected: rgb(0 0 0 / .075);
  --accent: #0071e3;
  --accent-hover: #0065cc;
  --accent-ink: #fff;
  --motion: .2s cubic-bezier(.16, 1, .3, 1);
  color: var(--ink);
  background: var(--canvas);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #161618;
  --surface: #1e1e20;
  --recessed: #242426;
  --ink: #f5f5f7;
  --muted: #ababaf;
  --line: rgb(255 255 255 / .08);
  --control-line: rgb(255 255 255 / .19);
  --selected: rgb(255 255 255 / .10);
  --accent: #5aaaf9;
  --accent-hover: #7bbaff;
  --accent-ink: #101820;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; transition: background-color var(--motion), color var(--motion); }
main { width: min(896px, calc(100% - 32px)); margin: clamp(32px, 7vw, 80px) auto; }
h1 { font-size: clamp(2.25rem, 5vw, 4rem); font-weight: 600; line-height: 1.12; letter-spacing: -.045em; margin: 16px 0 8px; }
p { color: var(--muted); margin: 0; }
a { color: var(--ink); text-underline-offset: .2em; }
.panel { display: grid; gap: 24px; margin-block-start: 32px; border: 1px solid var(--line); border-radius: 24px; padding: clamp(16px, 4vw, 32px); background: var(--surface); }
label { min-width: 0; font-size: 14px; font-weight: 500; display: grid; gap: 8px; }
label:has(output) { grid-template-columns: 1fr auto; }
label input[type=range] { grid-column: 1 / -1; accent-color: var(--accent); }
input, select, textarea { min-width: 0; width: 100%; color: inherit; background: var(--recessed); border: 1px solid var(--control-line); border-radius: 8px; font: inherit; padding: 8px 12px; }
input[type=color] { width: 64px; height: 38px; padding: 3px; cursor: pointer; }
.of-url-note { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.of-divider { text-align: center; font-size: 12px; color: var(--muted); margin: 16px 0 4px; }
.of-badge { font-size: 11px; line-height: 1; padding: 3px 8px; border-radius: 999px; margin-inline-start: 8px; border: 1px solid var(--control-line); color: var(--muted); white-space: nowrap; vertical-align: 1px; }
.of-badge.direct { border-color: var(--accent); color: var(--accent); }
#steps { font-size: 13px; color: var(--muted); line-height: 1.6; }
input[type=file] { cursor: pointer; }
textarea { resize: vertical; font: 14px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; }
button, .button { display: inline-flex; justify-content: center; align-items: center; background: var(--accent); color: var(--accent-ink); border: 1px solid transparent; border-radius: 8px; min-height: 44px; font: inherit; font-size: 14px; font-weight: 500; padding: 8px 16px; text-decoration: none; cursor: pointer; transition: background-color var(--motion), transform var(--motion); }
button:not(:disabled):hover, .button:hover { background: var(--accent-hover); }
button:not(:disabled):active, .button:active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: wait; }
.secondary { color: var(--ink); background: var(--recessed); }
.secondary:not(:disabled):hover, a.secondary:hover { background: var(--selected); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; }
#status:empty { display: none; }
#preview { display: block; max-width: 100%; max-height: 320px; width: auto; height: auto; object-fit: contain; border-radius: 8px; margin-block-end: 16px; }
#video { max-width: 100%; }
#board { max-width: 100%; height: auto; touch-action: none; cursor: crosshair; }
#wave { display: block; max-width: 100%; height: auto; border-radius: 12px; touch-action: none; cursor: crosshair; }
input[type=checkbox] { width: auto; justify-self: start; }
.seg { display: inline-flex; gap: 4px; background: var(--recessed); border: 1px solid var(--control-line); border-radius: 10px; padding: 4px; }
.seg button { background: transparent; color: var(--ink); border: 0; min-height: 36px; border-radius: 7px; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, .18); }
.diff { font: 13px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.diff div { padding: 2px 12px; white-space: pre; }
.diff .add { background: rgba(30, 170, 80, .16); }
.diff .del { background: rgba(228, 32, 40, .13); }
.diff .same { color: var(--muted); }
.tiles { display: grid; gap: 8px; }
.tiles figure { margin: 0; display: grid; gap: 6px; justify-items: center; }
.tiles img { max-width: 100%; border-radius: 8px; }
#qr { display: block; margin: 0 auto; max-width: min(320px, 100%); height: auto; border-radius: 12px; }
.file-list { margin: 0; padding-inline-start: 20px; display: grid; gap: 4px; font-size: 14px; }
#timer { font-variant-numeric: tabular-nums; font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 640px) { .fields { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } :active { transform: none !important; } }

/* Discreet brand line on every standalone app (Chan, 2026-11-27). */
.brand-line { text-align: center; color: var(--muted); font-size: 12.5px; letter-spacing: .14em; padding: 20px 0 28px; margin: 0; }
.save-img { display: block; max-width: 260px; width: 100%; margin: 14px auto 0; }
.save-img[hidden] { display: none; }
/* Mode sections inside a panel (random-pick list/numbers modes): keep the
   panel's grid rhythm inside the section, and let [hidden] win over grid. */
.mode-sec { display: grid; gap: 24px; }
.mode-sec[hidden] { display: none; }
.num-results { display: flex; flex-wrap: wrap; gap: 12px; }
.num-results div { font-size: 40px; font-weight: 700; line-height: 1.1; padding: 14px 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--recessed); }

/* long-stitch （接龙） */
.drop { border: 1.5px dashed var(--line); border-radius: 16px; padding: 20px; text-align: center; }
.drop.drag { border-color: var(--ink); }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.stitch-list { display: grid; gap: 8px; }
.stitch-item { display: flex; align-items: center; gap: 10px; }
.stitch-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.stitch-meta { flex: 1; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stitch-seam { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); padding-inline-start: 54px; }
.stitch-seam input[type="range"] { flex: 1; }
.stitch-preview { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 12px; }

/* image-ascii （字画） */
.ascii-preview { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 9px; line-height: 1; letter-spacing: 0; white-space: pre; overflow: auto; max-height: 480px; margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #0a0f0a; color: #33ff66; }
.ascii-preview:empty { display: none; }

/* shot-mount （裱图） */
.sm-stage { display: block; max-width: 100%; height: auto; margin-inline: auto; border-radius: 12px; }
.sm-checker { background: repeating-conic-gradient(#d8d8de 0% 25%, #f4f4f6 0% 50%) 0 0 / 24px 24px; }
:root[data-theme="dark"] .sm-checker { background: repeating-conic-gradient(#333338 0% 25%, #1e1e20 0% 50%) 0 0 / 24px 24px; }
.sm-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sm-swatch { width: 52px; height: 36px; min-height: 36px; padding: 0; border-radius: 9px; border: 1px solid var(--control-line); cursor: pointer; overflow: hidden; }
.sm-swatch canvas { display: block; width: 100%; height: 100%; }
.sm-swatch[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }
.sm-g1 { background: linear-gradient(135deg, #667eea, #764ba2); }
.sm-g2 { background: linear-gradient(135deg, #ff9a9e, #fecfef); }
.sm-g3 { background: linear-gradient(135deg, #43cea2, #185a9d); }
.sm-g4 { background: linear-gradient(135deg, #f83600, #f9d423); }
.sm-g5 { background: linear-gradient(135deg, #232526, #414345); }
.sm-g6 { background: linear-gradient(135deg, #e0eafc, #cfdef3); }
.sm-g7 { background: linear-gradient(135deg, #fddb92, #d1fdff); }
.sm-g8 { background: linear-gradient(135deg, #5ee7df, #b490ca); }
.sm-g9 { background: linear-gradient(135deg, #2b5876, #4e4376); }
.sm-g10 { background: linear-gradient(135deg, #fa709a, #fee140); }
.pc-stage { display: block; max-width: 100%; height: auto; margin-inline: auto; border-radius: 12px; touch-action: none; }
.pc-stage.has-sel { cursor: grab; }
.pc-stage.dragging { cursor: grabbing; }
.pc-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.pc-thumb { position: relative; width: 64px; height: 64px; padding: 0; border-radius: 10px; border: 1px solid var(--line); overflow: hidden; background: var(--recessed); cursor: pointer; }
.pc-thumb canvas { display: block; width: 100%; height: 100%; }
.pc-thumb .pc-num { position: absolute; left: 4px; bottom: 3px; font-size: 11px; line-height: 1; padding: 2px 5px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; }
.pc-thumb[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 1px; }
.pc-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.pc-swatch { width: 40px; height: 28px; min-height: 28px; padding: 0; border-radius: 8px; border: 1px solid var(--control-line); cursor: pointer; }
.pc-swatch[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }
.pc-c1 { background: #ffffff; }
.pc-c2 { background: #f5f0e8; }
.pc-c3 { background: #111111; }
.pc-c4 { background: #1c2b4a; }
.pc-c5 { background: #f7d9e0; }
.pc-c6 { background: #dcefe2; }
.pc-c7 { background: #ffe9c9; }
.pc-c8 { background: #dfe9f5; }
.progress { height: 8px; border-radius: 99px; background: var(--recessed); overflow: hidden; }
.progress > div { height: 100%; width: 0%; background: var(--accent); border-radius: 99px; transition: width .2s; }

/* GaiCun (image-resizer) list rows */
.rs-list li { display: flex; align-items: center; gap: 10px; }
.rs-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; flex: none; border: 1px solid var(--line); }
#status.error { color: #c0392b; }

/* 藏言专属规则（原 index.html 内联 <style>，生产 CSP 禁内联样式，移至此文件） */
.cy-input { font-size: 20px; letter-spacing: .2em; text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 36px; }
#lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
#lines li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
#lines li:last-child { border-bottom: 0; padding-bottom: 0; }
.cy-line { font-family: "Noto Serif CJK SC", "Songti SC", "STSong", serif; font-size: 26px; letter-spacing: .08em; }
.cy-first { color: #a4262c; font-weight: 600; }
.cy-src { font-size: 13px; color: var(--muted); }
.cy-swap { grid-row: span 2; min-height: 36px; padding: 4px 12px; }
.checks { display: grid; gap: 4px; font-size: 14px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 16px; }
#card { display: block; width: min(420px, 100%); height: auto; margin-inline: auto; border-radius: 12px; border: 1px solid var(--line); }
.cy-note { font-size: 14px; color: var(--muted); line-height: 1.7; }
.cy-note p { margin: 0 0 8px; }
.cy-note p:last-child { margin: 0; }
