:root {
  --bg: #070608;
  --fg: #f3ece6;
  --card: #120e11;
  --muted: #a89890;
  --line: rgba(212, 180, 140, 0.32);
  --ice: #8f3044;
  --gold: #d4b48a;
  --rose: #e7a8b8;
  --soft: #1c1619;
  --danger: #e07070;
  --radius: 2px;
  color-scheme: dark;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  background-color: var(--bg);
  color: var(--fg);
}
html, body {
  background-color: #070608;
  background-image:
    linear-gradient(180deg, rgba(7, 6, 8, 0.62), rgba(7, 6, 8, 0.84)),
    url("art/prison-bg.png");
  background-size: cover;
  background-position: center top;
  background-attachment: fixed;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body, body * {
  -webkit-user-select: none;
  user-select: none;
}
input, textarea, .legend-list, .legend-list *, footer, footer * {
  -webkit-user-select: text;
  user-select: text;
}
img, canvas {
  -webkit-user-drag: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

.shell { position: relative; z-index: 1; max-width: 72rem; margin: 0 auto; padding: 0.85rem 1rem 2rem; display: grid; gap: 1rem; }
.float-butterfly {
  position: fixed;
  right: -1.5rem;
  bottom: -1.2rem;
  width: min(34vw, 240px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.92;
}
.mast {
  position: relative;
  overflow: hidden;
  width: 100%;
  margin: 0;
  min-height: 7.5rem;
  padding: 1rem 42% 0.9rem 1rem;
  border: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(7, 6, 8, 0.9) 0%, rgba(7, 6, 8, 0.72) 58%, rgba(7, 6, 8, 0.28) 100%),
    url("art/blossom-bars.png") right center / auto 145% no-repeat;
  color: var(--fg);
  display: grid;
  gap: 0.2rem;
  justify-items: start;
  text-align: left;
}
.mast:hover .quote-line { color: white; }
.mast-kicker { font-size: 0.68rem; letter-spacing: 0.42em; color: var(--rose); }
.quote-line { font-family: "Songti SC", "Yu Mincho", "Source Han Serif SC", Palatino, serif; font-size: clamp(1rem, 2.4vw, 1.25rem); line-height: 1.65; letter-spacing: 0.04em; }
.quote-who { font-size: 0.72rem; letter-spacing: 0.18em; color: var(--gold); }
.top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: flex-end; }
.brand { display: flex; gap: 0.75rem; align-items: flex-start; }
.brand svg { width: 2.75rem; height: 2.75rem; flex: none; }
.kicker { margin: 0; font-family: "Songti SC", "Yu Mincho", Palatino, serif; letter-spacing: 0.28em; font-size: 0.72rem; color: var(--gold); }
h1 { margin: 0.15rem 0 0; font-family: "Songti SC", "Yu Mincho", "Source Han Serif SC", Palatino, serif; font-size: clamp(1.8rem, 4vw, 2.5rem); font-weight: 560; line-height: 1.15; color: var(--fg); }
.lede { margin: 0.35rem 0 0; max-width: 38rem; color: var(--muted); font-size: 0.92rem; line-height: 1.6; }

.layout { display: grid; gap: 1rem; align-items: start; }
.controls { order: 2; display: grid; gap: 0.85rem; padding: 1rem; border: 1px solid var(--line); border-radius: 2px; background: var(--card); }
.stage-col { order: 1; display: grid; gap: 0.75rem; min-width: 0; }
@media (min-width: 1024px) {
  .layout { grid-template-columns: 320px minmax(0, 1fr); }
  .controls { order: 1; }
  .stage-col { order: 2; }
}

.section { display: grid; gap: 0.65rem; }
.section-label { margin: 0; font-size: 11px; letter-spacing: 0.18em; color: var(--gold); }
.drop {
  border: 1px dashed var(--line);
  background: #0c0a0c;
  border-radius: 2px;
  padding: 1.1rem 0.75rem;
  text-align: center;
}
.drop.over { border-color: var(--rose); background: #241318; }
.drop strong { display: block; font-size: 0.92rem; }
.hint, .fine { color: var(--muted); font-size: 0.78rem; line-height: 1.5; }
.file-name { margin: 0.4rem 0 0; font-size: 0.78rem; color: var(--rose); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; gap: 0.5rem; }
.row > * { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.field { display: grid; gap: 0.35rem; }
label.lbl { font-size: 0.82rem; }
input[type="number"], input[type="text"], select {
  width: 100%;
  border: 1px solid var(--line);
  background: #0c0a0c;
  border-radius: 2px;
  padding: 0.45rem 0.55rem;
}
input[type="color"] { width: 3.2rem; height: 2rem; padding: 0.15rem; border: 1px solid var(--line); border-radius: 2px; background: #0c0a0c; }
.mono { font-family: ui-monospace, Consolas, "Sarasa Mono SC", monospace; }

.btn, .seg button {
  border: 1px solid var(--line);
  background: #0c0a0c;
  border-radius: 2px;
  padding: 0.45rem 0.7rem;
  font-size: 0.86rem;
}
.btn.primary { background: var(--ice); color: #f8ecee; border-color: transparent; }
.btn.on { background: #2a1620; border-color: var(--rose); }
.btn.soft { background: var(--soft); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.icon { width: 2.2rem; flex: none; padding: 0; }
.seg { display: flex; width: 100%; }
.seg button { flex: 1; border-radius: 0; }
.seg button:first-child { border-radius: 2px 0 0 2px; }
.seg button:last-child { border-radius: 0 2px 2px 0; }
.seg button + button { margin-left: -1px; }
.seg button.on { background: #2a1620; border-color: var(--rose); color: var(--rose); position: relative; z-index: 1; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; font-size: 0.88rem; }
.switch input { width: 2.4rem; height: 1.35rem; accent-color: var(--ice); }
.switch:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
.dim { opacity: 0.5; pointer-events: none; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
.error { color: var(--danger); font-size: 0.86rem; margin: 0; }

.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.badge { border: 1px solid var(--line); background: #0c0a0c; border-radius: 999px; padding: 0.15rem 0.55rem; font-size: 0.75rem; color: var(--muted); }
.badge.solid { background: #2a1620; color: var(--rose); }

.stage-row { display: grid; gap: 0.5rem; }
.stage-row.side { grid-template-columns: 1fr; }
@media (min-width: 640px) { .stage-row.side { grid-template-columns: 1fr 1fr; } }
.pane, .wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #0c0a0c;
  min-height: 280px;
  height: min(78vw, 520px);
}
@media (min-width: 1024px) { .pane, .wrap { height: min(70vh, 760px); } }
.pane img { width: 100%; height: 100%; object-fit: contain; display: block; }
.wrap { touch-action: none; }
.wrap canvas { width: 100%; height: 100%; display: block; }
.wrap.cross { cursor: crosshair; }
.wrap.grab { cursor: grab; }
.wrap.grab:active { cursor: grabbing; }
.chip { position: absolute; top: 0.5rem; left: 0.5rem; background: rgba(7, 6, 8, 0.82); border: 1px solid var(--line); border-radius: 999px; padding: 0.1rem 0.5rem; font-size: 0.75rem; pointer-events: none; }
.zoombar { position: absolute; right: 0.5rem; bottom: 0.5rem; display: flex; gap: 0.25rem; }
.veil { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(7, 6, 8, 0.78); padding: 1.5rem; text-align: center; }
.veil[hidden] { display: none; }
.veil p { margin: 0; max-width: 22rem; font-size: 0.92rem; line-height: 1.6; }
.tip { position: absolute; z-index: 2; pointer-events: none; max-width: 14rem; background: #1a1216; color: var(--fg); border: 1px solid var(--line); border-radius: 2px; padding: 0.4rem 0.55rem; font-size: 0.75rem; }
.tip p { margin: 0; }
.tip .sub { opacity: 0.8; }

.card-note, .pick {
  border: 1px dashed var(--line);
  border-radius: 2px;
  padding: 0.55rem 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.pick { border-style: solid; background: var(--card); color: var(--fg); display: flex; gap: 0.75rem; }
.swatch { width: 2.5rem; height: 2.5rem; border-radius: 2px; border: 1px solid var(--line); flex: none; }
.pick p { margin: 0; }
.pick .sub { color: var(--muted); font-size: 0.8rem; }

.legend { border: 1px solid var(--line); border-radius: 2px; background: var(--card); padding: 1rem; }
.legend-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; align-items: flex-end; margin-bottom: 0.75rem; }
.legend h2 { margin: 0; font-family: "Songti SC", "Yu Mincho", Palatino, serif; font-size: 1.25rem; font-weight: 560; }
.legend-list { max-height: min(28rem, 70vh); overflow: auto; display: grid; gap: 0.4rem; padding-right: 0.25rem; }
.mat {
  width: 100%;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  text-align: left;
  border: 1px solid transparent;
  background: #0c0a0c;
  border-radius: 2px;
  padding: 0.45rem 0.6rem;
}
.mat.on { border-color: var(--rose); background: #2a1620; }
.mat:hover { background: var(--soft); }
.mat .name { font-size: 0.88rem; font-weight: 600; }
.mat .sub { color: var(--muted); font-weight: 400; font-size: 0.78rem; }
.count { text-align: right; font-variant-numeric: tabular-nums; }
.count b { display: block; font-size: 0.9rem; }
.empty { background: var(--soft); border-radius: 2px; text-align: center; padding: 1.4rem 0.8rem; color: var(--muted); font-size: 0.9rem; }

footer { color: var(--muted); font-size: 0.75rem; line-height: 1.55; padding-bottom: 1rem; }
footer p { margin: 0; }
dialog { border: 1px solid var(--line); border-radius: 2px; max-width: 34rem; width: calc(100% - 2rem); padding: 1.1rem 1.15rem 1.2rem; background: var(--card); color: var(--fg); }
dialog::backdrop { background: rgba(0, 0, 0, 0.72); }
dialog h2 { margin: 0 0 0.35rem; font-family: "Songti SC", "Yu Mincho", Palatino, serif; font-size: 1.25rem; }
dialog p { margin: 0.45rem 0; font-size: 0.9rem; line-height: 1.6; }
dialog form { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
