:root {
  --bg: #f7f2ea;
  --card: #fffdf9;
  --ink: #2d2622;
  --muted: #6f655d;
  --line: #e2d8ca;
  --accent: #9c4a3a;
  --accent-ink: #ffffff;
  --stage: #d9d2c6;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 17px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Georgia, 'Times New Roman', serif; line-height: 1.45; }
.top { padding: 22px 24px 6px; max-width: 1400px; margin: 0 auto; }
.top h1 { margin: 0; font-size: 1.7rem; font-weight: normal; letter-spacing: 0.01em; }
.top p { margin: 2px 0 0; color: var(--muted); }
.layout { display: grid; grid-template-columns: minmax(320px, 430px) 1fr; gap: 22px; padding: 16px 24px 48px; max-width: 1400px; margin: 0 auto; align-items: start; }
.controls { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.card h2 { margin: 0 0 10px; font-size: 1.12rem; font-weight: normal; display: flex; align-items: center; gap: 10px; }
.card h2 small { color: var(--muted); font-size: 0.85rem; }
.card h3 { font-size: 1rem; font-weight: normal; margin: 18px 0 6px; border-top: 1px solid var(--line); padding-top: 14px; }
.num { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); align-items: center; justify-content: center; font-size: 0.85rem; font-family: system-ui, sans-serif; flex: none; }
details.card summary { cursor: pointer; list-style: none; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary h2 { margin: 0; }
details.card summary h2::after { content: '+'; margin-left: auto; color: var(--muted); font-size: 1.3rem; }
details.card[open] summary h2::after { content: '\2212'; }
details.card[open] summary { margin-bottom: 12px; }
label { display: block; font-size: 0.92rem; color: var(--muted); font-family: system-ui, -apple-system, sans-serif; }
input, select, button { font: inherit; font-family: system-ui, -apple-system, sans-serif; color: var(--ink); }
input[type=number], input[type=text], select { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 1rem; }
.inline { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.inline input { width: 110px; flex: none; }
input[type=color] { width: 54px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-top: 4px; display: block; cursor: pointer; }
.row { margin-bottom: 12px; }
.row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row.check { display: flex; align-items: center; gap: 12px; }
.row.check label, .checkline { color: var(--ink); font-size: 0.98rem; display: flex; align-items: center; gap: 8px; }
.row.check input[type=color] { margin: 0; height: 30px; width: 44px; }
.checkline { align-self: end; padding-bottom: 10px; }
input[type=checkbox] { width: 19px; height: 19px; accent-color: var(--accent); flex: none; }
.hint { font-family: system-ui, -apple-system, sans-serif; font-size: 0.86rem; color: var(--muted); margin: 6px 0 0; }
.hint.warn { color: #9a3412; font-weight: 600; }
.hint:empty { display: none; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; cursor: pointer; background: #fff; }
.drop.over { border-color: var(--accent); background: #fbf1ec; }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop strong { display: block; color: var(--accent); font-size: 1.05rem; font-weight: 600; }
.drop span { font-size: 0.88rem; }
.samples { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-family: system-ui, sans-serif; font-size: 0.9rem; color: var(--muted); flex-wrap: wrap; }
.samples button, .play button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 0.9rem; }
.samples button:hover, .play button:hover { border-color: var(--accent); }
button.primary { width: 100%; padding: 13px; border: 0; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 1.08rem; font-weight: 600; cursor: pointer; }
button.primary:hover { filter: brightness(1.08); }
button.link { background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 8px 0 0; font-size: 0.9rem; }
button.link:empty { display: none; }
.colors, .steps { list-style: none; margin: 8px 0 0; padding: 0; }
.colors li { display: grid; grid-template-columns: auto auto 1fr auto auto; gap: 8px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); font-family: system-ui, sans-serif; font-size: 0.92rem; }
.colors li.off .cname { text-decoration: line-through; color: var(--muted); }
.colors input[type=color] { margin: 0; width: 40px; height: 32px; }
.colors .cname small { display: block; color: var(--muted); font-size: 0.78rem; }
.colors .angle { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 0.8rem; }
.colors .angle input { width: 62px; margin: 0; padding: 5px 6px; font-size: 0.9rem; }
.colors .move { display: flex; flex-direction: column; gap: 2px; }
.colors .move button { border: 1px solid var(--line); background: #fff; border-radius: 5px; width: 28px; height: 19px; line-height: 1; font-size: 0.62rem; cursor: pointer; padding: 0; }
.colors .move button:disabled { opacity: 0.3; cursor: default; }
.steps li { display: grid; grid-template-columns: 24px 22px 1fr; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); font-family: system-ui, sans-serif; font-size: 0.9rem; align-items: start; }
.steps .sw, .colors .sw { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.25); margin-top: 1px; }
.steps small { display: block; color: var(--muted); }
.preview { position: sticky; top: 14px; min-width: 0; }
.tabs { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.tab { border: 1px solid var(--line); background: var(--card); padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 0.9rem; }
.tab.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.busy { margin-left: auto; font-family: system-ui, sans-serif; font-size: 0.88rem; color: var(--accent); }
.stage { background: var(--stage); border-radius: 14px; border: 1px solid var(--line); height: min(72vh, 760px); min-height: 340px; position: relative; overflow: hidden; }
.stage canvas { width: 100%; height: 100%; display: block; }
.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); margin: 0; font-size: 1.1rem; }
.play { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.play input[type=range] { flex: 1; accent-color: var(--accent); }
.stats { font-family: system-ui, sans-serif; font-size: 0.9rem; color: var(--muted); margin: 8px 2px 0; }
body:not(.has-art) .needs-art { display: none; }
body.no-patch .patch-only { display: none; }
body.no-border .border-only { display: none; }
body:not(.bg-fill) .bg-only { display: none; }
@media (max-width: 860px) {
  html { font-size: 16px; }
  .layout { grid-template-columns: 1fr; padding: 12px 16px 40px; }
  .preview { position: static; order: -1; }
  .stage { height: 56vh; }
  .top { padding: 16px 16px 2px; }
}
@media print {
  body { background: #fff; }
  .top p, .preview, .card:not(:last-child), details, #download, #download-alt, #print, .row { display: none !important; }
  .card { border: 0; padding: 0; }
  .layout { display: block; padding: 0; }
}
