:root{--ink:#253128;--muted:#687068;--paper:#fffdf7;--green:#2f654c;--gold:#b58a3a;--line:#d8d0bc}*{box-sizing:border-box}
body{margin:0;background:#ece8de;color:var(--ink);font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif}.app{max-width:1160px;margin:auto;padding:14px}
.header,.stage,.tools{background:var(--paper);border:1px solid var(--line);border-radius:18px}.header{padding:15px 16px;margin-bottom:12px}h1{margin:0 0 5px;font-size:clamp(24px,4vw,38px)}.intro{margin:0;color:var(--muted);font-size:clamp(14px,2.1vw,18px)}
.tabs{display:flex;gap:8px;overflow-x:auto;padding-top:11px}.tabs button,.tool,.nav,.action{font:inherit;min-height:44px;border:1px solid var(--line);border-radius:11px;background:#fff;color:var(--ink);padding:9px 12px;font-weight:700;cursor:pointer;white-space:nowrap}.tabs button[aria-current=page]{background:var(--green);color:#fff;border-color:var(--green)}
.grid{display:grid;grid-template-columns:minmax(0,1fr) 255px;gap:12px;align-items:start}.stage,.tools{padding:12px}.page-title{font-size:21px;font-weight:800}.page-tip{color:var(--muted);margin:2px 0 10px;font-size:14px}.sheet{position:relative;width:100%;max-width:720px;margin:auto;overflow:hidden;border:1px solid #ddd;border-radius:10px;background:#fff;min-height:300px}.sheet img{display:block;width:100%;height:auto;user-select:none;-webkit-user-drag:none}.load-error{display:none;padding:28px;color:#8b0000;font-weight:700}.load-error.show{display:block}
#draw{position:absolute;inset:0;width:100%;height:100%;touch-action:none;cursor:crosshair}.navrow{display:flex;justify-content:space-between;gap:10px;margin-top:10px}.tools h2{font-size:17px;margin:0 0 10px}.row{display:flex;gap:8px;flex-wrap:wrap}.tool.active{background:var(--green);color:#fff;border-color:var(--green)}.tool-label{margin:12px 0 4px;font-weight:700;font-size:14px}.palette{display:grid;grid-template-columns:repeat(5,44px);gap:8px;margin:10px 0}.swatch{width:44px;height:44px;border-radius:50%;border:3px solid #fff;outline:1px solid #999;padding:0}.swatch.active{outline:4px solid var(--gold)}.size-label{display:flex;justify-content:space-between;font-weight:700;font-size:14px}input[type=range]{width:100%;min-height:36px}.actions{display:grid;gap:8px;margin-top:10px}.action.primary{background:var(--green);color:#fff;border-color:var(--green)}.status{min-height:22px;margin-top:8px;color:var(--muted);font-size:14px}.help{font-size:12px;color:var(--muted);line-height:1.4}
@media(max-width:820px){.grid{grid-template-columns:1fr}.palette{grid-template-columns:repeat(7,40px)}.swatch{width:40px;height:40px}}
@media print{body{background:#fff}.header,.tools,.navrow,.page-title,.page-tip{display:none!important}.app,.stage{padding:0;margin:0;border:0}.sheet{max-width:none;border:0;border-radius:0}}
.swatch.c1{background:#222222}.swatch.c2{background:#d62828}.swatch.c3{background:#f77f00}.swatch.c4{background:#f4cf2c}.swatch.c5{background:#2f9e44}.swatch.c6{background:#2383c4}.swatch.c7{background:#7048c8}.swatch.c8{background:#e64980}.swatch.c9{background:#8b5a2b}.swatch.c10{background:#ffffff}

/* Keep the palette within narrow tool panels and show keyboard focus. */
.palette{grid-template-columns:repeat(auto-fit,44px)}
.swatch{width:44px;height:44px}
button:focus-visible,input:focus-visible{outline:3px solid #2383c4;outline-offset:5px}
