:root {
  --bg: #0c0c0e;
  --panel: #151518;
  --line: #ffffff1f;
  --text: #f3f3f4;
  --muted: #9a9aa3;
  --red: #e32219;
  --ok: #7dffa8;
  --err: #ff6b6b;
  --shadow: 0 18px 40px #00000080;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input, textarea, select { font: inherit; color: inherit; }
body { min-height: 100vh; }
.page { max-width: 1180px; margin: 0 auto; padding: 24px 20px 48px; display: grid; gap: 20px; }
header h1 { margin: 0 0 6px; font-size: 22px; font-weight: 650; }
header p { margin: 0; color: var(--muted); max-width: 46em; }
.layout { display: grid; grid-template-columns: minmax(280px, 1.1fr) minmax(300px, 0.9fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.stage {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.stage-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 12px; }
.stage-head span { color: var(--muted); font-size: 12px; }
.board-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  background: #10121c;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.board-wrap.r34 { aspect-ratio: 3/4; }
.board-wrap.r169 { aspect-ratio: 16/9; max-width: 100%; }
.board-wrap.r11 { aspect-ratio: 1/1; }
#cover {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: default;
}
.overlay { position: absolute; inset: 0; pointer-events: none; }
.box {
  position: absolute;
  pointer-events: auto;
  border: 1px dashed rgba(255,255,255,.75);
  cursor: move;
  touch-action: none;
}
.handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--red);
  border: 2px solid #fff;
  border-radius: 50%;
  box-sizing: border-box;
}
.handle.rs { right: -7px; bottom: -7px; cursor: nwse-resize; }
.handle.rt {
  left: 50%;
  top: -28px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  background: #fff;
  cursor: grab;
}
.handle.rt::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 10px;
  width: 1px;
  height: 16px;
  background: #fff;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0; font-size: 13px; letter-spacing: .08em; color: var(--muted); font-weight: 650; }
label.field, .field { display: grid; gap: 6px; }
label.field > span, .field > span { color: var(--muted); font-size: 12px; }
textarea, input[type="text"], input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c0c0e;
  padding: 8px 10px;
}
textarea { min-height: 70px; resize: vertical; }
textarea:focus, input:focus, button:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
input[type="range"] { width: 100%; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #1c1c20;
  border-radius: 8px;
  padding: 8px 12px;
  min-height: 36px;
  cursor: pointer;
}
.btn:hover { border-color: #ffffff55; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 650; }
.btn.primary:disabled { opacity: .5; cursor: default; }
.file { position: relative; overflow: hidden; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.meta[data-over="1"], .err { color: var(--err); }
.err { font-size: 12px; min-height: 1.2em; }
.ok { color: var(--ok); font-size: 12px; }
.styles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.style {
  appearance: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10121c;
  cursor: pointer;
  text-align: center;
}
.style canvas { width: 100%; aspect-ratio: 16/9; height: auto; display: block; border-radius: 4px; background: #10121c; }
.style span { font-size: 11px; line-height: 1.3; }
.style[aria-pressed="true"] { border-color: #fff; box-shadow: 0 0 0 1px #fff; }
.sliders { display: grid; gap: 10px; }
.sliders label { display: grid; gap: 4px; }
.sliders b { font-weight: 600; color: var(--text); }
.ratios { display: flex; gap: 6px; }
.ratios .btn[aria-pressed="true"] { border-color: #fff; }
.status { color: var(--muted); font-size: 12px; }

.note { margin: 0; font-size: 12px; color: var(--muted); }
.fonts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.font {
  appearance: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10121c;
  cursor: pointer;
  text-align: center;
  position: relative;
}
.font canvas { width: 100%; aspect-ratio: 16/9; height: auto; display: block; border-radius: 4px; background: #10121c; }
.font span { font-size: 11px; line-height: 1.3; }
.font[aria-pressed="true"] { border-color: #fff; box-shadow: 0 0 0 1px #fff; }
.font .tag {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 9px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  background: var(--red);
  color: #fff;
}
.current {
  padding: 8px 10px;
  border-radius: 8px;
  background: #0c0c0e;
  border: 1px solid var(--line);
  font-size: 13px;
}
.current b { font-weight: 650; }
.btn.accent { background: #2a2a32; border-color: #ffffff55; }
.btn.accent:hover { border-color: #fff; }
@media (max-width: 760px) {
  .fonts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
