/* ------------------------------------------------------------------
   All colour is defined once as custom properties and redefined for
   dark; body gets an explicit background so a dark UA default can
   never paint through.
   ------------------------------------------------------------------ */
:root{
  color-scheme: light dark;
  --bg:#f4f5f8;
  --panel:#ffffff;
  --panel-2:#eef0f4;
  --panel-3:#e6e9ef;
  --fg:#14161b;
  --fg-dim:#525a68;
  --fg-faint:#7b8494;
  --border:#d8dde5;
  --border-2:#c2c9d4;
  --accent:#2b5cff;
  --accent-fg:#ffffff;
  --accent-soft:#e7edff;
  --ok:#0d7a43;
  --ok-soft:#e3f5ea;
  --warn:#8a5300;
  --warn-soft:#fdf2dc;
  --err:#b81f1f;
  --err-soft:#fdeaea;
  --err-border:#e9b4b4;
  --ck:#d5d9e0;
  --ck-2:#f7f8fa;
  --code-bg:#12151b;
  --code-fg:#e4e8ef;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#0d0f13;
    --panel:#15181e;
    --panel-2:#1b1f26;
    --panel-3:#232833;
    --fg:#e8ebf0;
    --fg-dim:#a7b0be;
    --fg-faint:#7d8695;
    --border:#2a2f39;
    --border-2:#3a414e;
    --accent:#6f97ff;
    --accent-fg:#0b1220;
    --accent-soft:#1d2740;
    --ok:#5fd39a;
    --ok-soft:#14301f;
    --warn:#e0ab52;
    --warn-soft:#33260f;
    --err:#ff8a8a;
    --err-soft:#3a1c1c;
    --err-border:#5c2b2b;
    --ck:#2a3038;
    --ck-2:#1a1e24;
    --code-bg:#080a0d;
    --code-fg:#dfe4ec;
  }
}
*{ box-sizing:border-box; }
[hidden]{ display:none !important; }
html,body{ margin:0; padding:0; }
body{
  background:var(--bg);
  color:var(--fg);
  font:15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
       "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  overflow-x:hidden;          /* phone width: no horizontal page scroll */
  -webkit-text-size-adjust:100%;
}
.wrap{ max-width:1080px; margin:0 auto; padding:0 16px; }   /* 16px side gutter */
a{ color:var(--accent); }
h1,h2,h3{ line-height:1.3; }
h2{ font-size:15px; margin:0 0 10px; letter-spacing:.01em; }
h3{ font-size:13px; margin:18px 0 8px; color:var(--fg-dim); font-weight:600; }
code,kbd,.mono{ font-family:var(--mono); font-size:12.5px; }
.dim{ color:var(--fg-dim); font-weight:400; }
.tiny{ font-size:12px; }
:focus-visible{ outline:2px solid var(--accent); outline-offset:2px; border-radius:3px; }

/* ---------- top bar ---------- */
.top{
  position:sticky; top:0; z-index:20;
  background:var(--panel); border-bottom:1px solid var(--border);
}
.top-in{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; padding:9px 0; }
.brand{ display:flex; align-items:center; gap:8px; font-weight:700; font-size:14px; }
.logo{ color:var(--accent); font-family:var(--mono); }
.topmeta{ display:flex; gap:6px; flex-wrap:wrap; margin-left:auto; }
.chip{
  display:inline-flex; align-items:center; gap:5px;
  border:1px solid var(--border); background:var(--panel-2);
  border-radius:999px; padding:2px 9px; font-size:12px; color:var(--fg-dim);
  font-family:var(--mono); white-space:nowrap; text-decoration:none;
}
.chip b{ color:var(--fg); font-weight:600; }
.chip-err{ border-color:var(--err-border); background:var(--err-soft); color:var(--err); font-weight:600; }
.chip-err.pulse{ animation:pulse 1.1s ease-out 3; }
@keyframes pulse{ 0%,100%{ transform:none; } 50%{ transform:scale(1.09); } }

/* ---------- panels ---------- */
main{ padding-bottom:64px; }
.panel{
  background:var(--panel); border:1px solid var(--border); border-radius:10px;
  padding:14px; margin:14px 0;
}
.panel.console.has-error{ border-color:var(--err-border); }
.panel.console.has-error h2{ color:var(--err); }
.row{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.row-tight{ display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
.sep{ height:1px; background:var(--border); margin:12px 0; }

/* ---------- buttons ---------- */
button,.btn{
  font:inherit; font-size:13px;
  background:var(--panel-2); color:var(--fg);
  border:1px solid var(--border-2); border-radius:7px;
  padding:6px 12px; cursor:pointer; text-decoration:none;
  display:inline-flex; align-items:center; gap:6px;
}
button:hover:not(:disabled),.btn:hover{ background:var(--panel-3); }
button:disabled,.btn[aria-disabled="true"]{ opacity:.45; cursor:not-allowed; }
button[aria-pressed="true"]{ background:var(--accent-soft); border-color:var(--accent); color:var(--fg); }
.btn-primary{
  background:var(--accent); border-color:var(--accent); color:var(--accent-fg);
  font-weight:600; padding:9px 18px; font-size:14px;
}
.btn-primary:hover:not(:disabled){ filter:brightness(1.08); background:var(--accent); }
.btn-sm{ padding:3px 9px; font-size:12px; }
.btn-danger{ border-color:var(--err-border); color:var(--err); }

/* ---------- input & spec dual-column layout ---------- */
.input-spec-panel{
  grid-area:spec;
  min-width:0;
}
.input-spec-grid{
  display:grid;
  grid-template-columns:minmax(300px, 360px) 1fr;
  gap:18px;
  align-items:stretch;
}
@media (max-width: 860px){
  .input-spec-grid{ grid-template-columns:1fr; gap:14px; }
}

.input-spec-left{
  display:flex; flex-direction:column; gap:10px;
  min-width:0;
  height:100%;
}
.input-spec-right{
  display:flex; flex-direction:column; gap:12px;
  min-width:0;
}

/* ---------- drop zone ---------- */
.drop{
  display:block; border:2px dashed var(--border-2); border-radius:10px;
  padding:26px 16px; text-align:center; cursor:pointer;
  background:var(--panel-2); color:var(--fg-dim);
  transition:border-color .15s ease, background .15s ease;
}
.drop.over{ border-color:var(--accent); background:var(--accent-soft); color:var(--fg); }
.drop-main{ font-size:14px; font-weight:600; color:var(--fg); margin-bottom:4px; display:block; }
.sr-only{
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}

/* ---------- upload ready card (置顶大预览) ---------- */
.upload-card{
  border:1px solid var(--border); border-radius:10px; background:var(--panel-2);
  padding:12px; display:flex; flex-direction:column; gap:10px;
  height:100%; box-sizing:border-box;
}
.upload-card-preview{
  width:100%; flex:1 1 240px; min-height:220px; border-radius:8px; overflow:hidden;
  border:1px solid var(--border-2);
  display:flex; align-items:center; justify-content:center;
  background-color:var(--ck-2);
  background-image:
    linear-gradient(45deg, var(--ck) 25%, transparent 25%, transparent 75%, var(--ck) 75%),
    linear-gradient(45deg, var(--ck) 25%, transparent 25%, transparent 75%, var(--ck) 75%);
  background-size:16px 16px;
  background-position:0 0, 8px 8px;
}
.upload-card-preview img{
  max-width:100%; max-height:100%; object-fit:contain;
  image-rendering:pixelated; image-rendering:crisp-edges;
}
.upload-card-meta{
  display:flex; flex-direction:column; gap:8px; font-size:12.5px;
}
.upload-card-header{
  display:flex; justify-content:space-between; align-items:center; gap:8px;
}
.upload-card-filename{
  font-size:11px; color:var(--fg-dim); font-family:var(--mono);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:170px;
}
.upload-stats-grid{
  display:grid; grid-template-columns:1fr 1fr; gap:6px;
}
.stat-item{
  background:var(--panel-3); border:1px solid var(--border); border-radius:6px;
  padding:5px 8px; display:flex; flex-direction:column; gap:1px;
}
.stat-label{ font-size:10px; color:var(--fg-dim); }
.stat-value{
  font-family:var(--mono); font-size:11.5px; font-weight:700; color:var(--fg);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.upload-card-actions{
  display:flex; gap:8px; align-items:center; margin-top:2px;
}

/* ---------- scale pills (输入尺寸预调) ---------- */
.spec-section .spec-label-row{
  display:flex; align-items:baseline; gap:8px; margin-bottom:8px; flex-wrap:wrap;
}
.scale-pills{
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  gap:8px;
}
@media (max-width: 520px){
  .scale-pills{ grid-template-columns:repeat(2, 1fr); }
}
.scale-pill{
  border:1px solid var(--border); background:var(--panel-2); color:var(--fg);
  border-radius:6px; padding:6px 8px; cursor:pointer; font-size:12px;
  display:inline-flex; flex-direction:column; align-items:center; gap:2px;
  text-align:center; transition:all .15s ease; width:100%; box-sizing:border-box;
}
.scale-pill:hover:not(:disabled){ background:var(--panel-3); }
.scale-pill.active{
  border-color:var(--accent); background:var(--accent-soft); font-weight:600;
  box-shadow:0 0 0 1px var(--accent);
}
.scale-pill:disabled{ opacity:.4; cursor:not-allowed; }
.scale-pill .p-name{ font-family:var(--mono); font-size:12px; font-weight:700; }
.scale-pill .p-dim{ font-size:11px; color:var(--fg-dim); font-family:var(--mono); }
.scale-pill.active .p-dim{ color:var(--fg); }

/* ---------- form bits ---------- */
fieldset{ border:0; padding:0; margin:0 0 4px; }
legend{ font-size:13px; font-weight:600; color:var(--fg-dim); padding:0 0 6px; }
.sizes{ display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:8px; }
.sizes label{
  display:flex; gap:8px; align-items:flex-start;
  border:1px solid var(--border); border-radius:8px; padding:9px 10px;
  background:var(--panel-2); cursor:pointer;
  transition:border-color .15s ease, background .15s ease;
  min-width:0;
  height:100%;
  min-height:86px;
  box-sizing:border-box;
}
.sizes label:has(input:checked){ border-color:var(--accent); background:var(--accent-soft); }
.sizes input{ margin:3px 0 0; accent-color:var(--accent); flex-shrink:0; }
.sizes .size-content{ display:flex; flex-direction:column; min-width:0; flex:1; height:100%; }
.sizes .n{ font-family:var(--mono); font-weight:700; font-size:12.5px; color:var(--fg); line-height:1.3; }
.sizes .t{
  font-size:11px; color:var(--fg-dim); line-height:1.35; margin-top:2px;
  min-height:2.7em;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
}
.sizes .size-out{
  display:inline-block; margin-top:auto; font-family:var(--mono); font-size:11px;
  color:var(--accent); font-weight:700;
  background:rgba(43,92,255,.08); border-radius:4px; padding:2px 6px;
  width:fit-content; line-height:1.2;
}
@media (prefers-color-scheme: dark){
  .sizes .size-out{ background:rgba(111,151,255,.15); }
}

.size-tip-card{
  display:flex; flex-direction:column; justify-content:center; gap:4px;
  border:1px dashed var(--border-2); border-radius:8px; padding:9px 10px;
  background:var(--panel-2); opacity:.85; height:100%; min-height:86px; box-sizing:border-box;
}
.size-tip-card .tip-badge{ font-family:var(--mono); font-size:11px; font-weight:700; color:var(--fg-dim); }
.size-tip-card .tip-text{ font-size:10.5px; color:var(--fg-dim); line-height:1.35; }

/* ---------- spec summary bar (推导条) ---------- */
.spec-summary{
  margin-top:14px; background:var(--panel-2); border:1px solid var(--border);
  border-radius:8px; padding:9px 12px; font-size:12.5px;
}
.summary-line{
  display:flex; align-items:center; gap:8px; flex-wrap:wrap; font-family:var(--mono);
}
.summary-node{ display:inline-flex; align-items:baseline; gap:4px; }
.summary-node b{ color:var(--fg); }
.summary-node.highlight b{ color:var(--accent); font-size:13.5px; font-weight:800; }
.summary-arrow{ color:var(--fg-faint); font-size:12px; }
input[type=number],textarea{
  font:inherit; font-size:13px; font-family:var(--mono);
  background:var(--panel-2); color:var(--fg);
  border:1px solid var(--border-2); border-radius:7px; padding:6px 8px;
}
textarea{ width:100%; min-height:64px; resize:vertical; line-height:1.5; }
input[type=number]{ width:88px; }
input[type=checkbox]{ accent-color:var(--accent); width:16px; height:16px; }

.presets{ display:grid; grid-template-columns:repeat(auto-fill,minmax(168px,1fr)); gap:8px; }
.preset{
  display:block; text-align:left; padding:9px 10px; width:100%;
  border:1px solid var(--border); background:var(--panel-2); border-radius:8px;
}
.preset[aria-pressed="true"]{ border-color:var(--accent); background:var(--accent-soft); }
.preset .ph{ display:flex; align-items:center; gap:6px; flex-wrap:wrap; font-size:13px; font-weight:600; }
.preset .pn{ font-family:var(--mono); font-size:11px; color:var(--fg-dim); font-weight:400; }
.sw{ display:flex; flex-wrap:wrap; gap:2px; margin:7px 0 5px; }
.sw i{ width:12px; height:12px; border-radius:2px; border:1px solid rgba(128,128,128,.45); }
.preset .note{ font-size:11px; color:var(--fg-dim); display:block; }
.badge-ok{
  font-size:10px; font-family:var(--mono); border:1px solid var(--ok);
  color:var(--ok); background:var(--ok-soft); border-radius:4px; padding:0 4px;
}
.caution{
  margin-top:8px; border:1px solid var(--warn); background:var(--warn-soft); color:var(--warn);
  border-radius:8px; padding:8px 10px; font-size:12.5px;
}
.pixelonly{
  border:1px solid var(--accent); background:var(--accent-soft); border-radius:9px;
  padding:10px 12px; margin:12px 0; display:flex; gap:10px; align-items:flex-start;
}
.pixelonly .lbl{ font-weight:700; font-size:13.5px; }
.pixelonly .desc{ font-size:12px; color:var(--fg-dim); }

/* ---------- progress ---------- */
.stepper{ display:flex; flex-wrap:wrap; gap:6px; }
.st{
  display:inline-flex; align-items:center; gap:6px; font-size:12px;
  border:1px solid var(--border); background:var(--panel-2); color:var(--fg-dim);
  border-radius:999px; padding:3px 10px;
}
.st .mk{ font-family:var(--mono); width:1em; text-align:center; }
.st.done{ border-color:var(--ok); color:var(--ok); background:var(--ok-soft); }
.st.current{ border-color:var(--accent); color:var(--fg); background:var(--accent-soft); font-weight:600; }
.st.pending{ opacity:.6; }
.st.skipped{ opacity:.45; text-decoration:line-through; }
.st.failed{ border-color:var(--err); color:var(--err); background:var(--err-soft); font-weight:700; }
.st .el{ font-family:var(--mono); font-size:10.5px; opacity:.85; }
.statusline{
  display:flex; gap:8px; align-items:center; flex-wrap:wrap;
  font-size:13px; margin-top:10px;
}
.dot{ width:9px; height:9px; border-radius:50%; background:var(--fg-faint); flex:none; }
.dot.open{ background:var(--ok); animation:idle 1.6s ease-in-out infinite; }
.dot.warn{ background:var(--warn); }
.dot.err{ background:var(--err); }
.dot.busy{ background:var(--accent); }
@keyframes idle{ 0%,100%{ opacity:1 } 50%{ opacity:.35 } }
.indet{ height:6px; border-radius:3px; background:var(--panel-2); overflow:hidden; margin-top:10px; border:1px solid var(--border); }
.indet i{ display:block; height:100%; width:38%;
  background:linear-gradient(90deg,transparent,var(--accent),transparent);
  animation:slide 1.7s linear infinite; }
@keyframes slide{ from{ transform:translateX(-110%) } to{ transform:translateX(300%) } }
.indet-lbl{ font-size:11.5px; color:var(--fg-dim); margin-top:5px; font-family:var(--mono); }
.upbar{ display:flex; align-items:center; gap:8px; font-size:12px; color:var(--fg-dim); margin-top:8px; }
.upbar .track{ flex:1; min-width:80px; height:5px; background:var(--panel-2); border-radius:3px; overflow:hidden; border:1px solid var(--border); }
.upbar .fill{ height:100%; background:var(--accent); width:0; }

/* ---------- result ---------- */
.stage{
  border:1px solid var(--border); border-radius:9px; overflow:auto;
  height:clamp(240px, 46vh, 520px);           /* reserved box: no layout shift */
  display:flex; align-items:center; justify-content:center;
  background-color:var(--ck-2);
  background-image:
    linear-gradient(45deg, var(--ck) 25%, transparent 25%, transparent 75%, var(--ck) 75%),
    linear-gradient(45deg, var(--ck) 25%, transparent 25%, transparent 75%, var(--ck) 75%);
  background-size:16px 16px;
  background-position:0 0, 8px 8px;
}
.stage-fit{
  overflow:hidden;
  padding:8px;
}
.stage-pixel-fit{
  overflow:hidden;
  padding:8px;
}
.stage img{
  display:block; max-width:none; flex:none;
  image-rendering:pixelated;   /* NEAREST: smooth scaling would re-introduce anti-aliasing */
  image-rendering:crisp-edges;
}
.stage-fit img{
  max-width:100%; max-height:100%; width:auto; height:auto;
  object-fit:contain;
  image-rendering:auto;
}
.stage-pixel-fit img{ max-width:100%; max-height:100%; }
.stage-empty{ color:var(--fg-faint); font-size:12.5px; text-align:center; padding:16px; }
.ai-row{ display:grid; grid-template-columns:1fr; gap:12px; margin-bottom:12px; }
.ai-row > *{ min-width:0; }
.final-row{ display:grid; grid-template-columns:minmax(0,1fr) 148px; gap:12px; align-items:start; }
.final-main{ min-width:0; }
.final-controls{ min-width:0; border:1px solid var(--border); border-radius:9px; padding:10px; background:var(--panel-2); }
.final-controls .cap{ margin-bottom:8px; }
.final-controls #zooms{ display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.final-controls #zooms button{ min-width:0; }
/* A 1fr track defaults to min-width:auto, so every result card must opt into
   shrinking. The AI row has two columns on desktop; the final image keeps its
   own larger stage and puts its zoom controls beside it. */
@media (min-width:820px){ .ai-row.has-two{ grid-template-columns:1fr 1fr; } }
@media (max-width:700px){
  .final-row{ grid-template-columns:1fr; }
  .final-controls{ order:2; }
  .final-controls #zooms{ grid-template-columns:repeat(4,1fr); }
}
.cap{ font-size:12px; color:var(--fg-dim); margin:0 0 6px; }
.pal-echo{ display:flex; flex-wrap:wrap; gap:4px; margin:6px 0; }
.pal-echo span{ display:inline-flex; align-items:center; gap:5px; font-family:var(--mono); font-size:11px;
  border:1px solid var(--border); border-radius:5px; padding:1px 6px; background:var(--panel-2); }
.pal-echo i{ width:11px; height:11px; border-radius:2px; border:1px solid rgba(128,128,128,.45); }
.kv{ font-family:var(--mono); font-size:12px; color:var(--fg-dim); }

/* ---------- error console ---------- */
.errblock{
  border:1px solid var(--err-border); border-left:4px solid var(--err);
  border-radius:8px; padding:10px 12px; margin:0 0 12px; background:var(--panel);
}
.errhead{ display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:8px; }
.kind{
  font-family:var(--mono); font-size:11.5px; font-weight:700; letter-spacing:.02em;
  border-radius:5px; padding:2px 8px; border:1px solid;
  background:var(--warn-soft); color:var(--warn); border-color:var(--warn);
}
.kind.sev-err{ background:var(--err-soft); color:var(--err); border-color:var(--err); }
.kind.sev-info{ background:var(--accent-soft); color:var(--accent); border-color:var(--accent); }
.kind.sev-ok{ background:var(--ok-soft); color:var(--ok); border-color:var(--ok); }
.meta-chip{
  font-family:var(--mono); font-size:11px; color:var(--fg-dim);
  border:1px solid var(--border); border-radius:5px; padding:1px 7px; background:var(--panel-2);
}
pre.blk{
  font-family:var(--mono); white-space:pre-wrap; overflow-wrap:anywhere;
  margin:0 0 8px; padding:9px 10px; border-radius:7px;
  background:var(--code-bg); color:var(--code-fg); font-size:12.5px; line-height:1.5;
}
pre.blk.msg{ font-size:13.5px; border-left:3px solid var(--err); }
.lbl2{ font-size:11px; color:var(--fg-dim); font-family:var(--mono); margin:8px 0 3px; }
details{ margin:6px 0 8px; }
summary{ cursor:pointer; font-size:12.5px; color:var(--fg-dim); }
.timeline{ display:flex; flex-direction:column; gap:3px; }
.tl-row{
  display:flex; gap:8px; flex-wrap:wrap; align-items:baseline;
  font-family:var(--mono); font-size:11.5px; color:var(--fg-dim);
  border-left:3px solid var(--border); padding:2px 0 2px 8px;
}
.tl-row .t{ color:var(--fg-faint); }
.tl-row .p{ color:var(--fg); font-weight:600; }
.tl-row .d{ color:var(--fg-faint); overflow-wrap:anywhere; }
.tl-row.ok{ border-left-color:var(--ok); }
.tl-row.info{ border-left-color:var(--accent); }
.tl-row.err{ border-left-color:var(--err); background:var(--err-soft); color:var(--err); }
.tl-row.err .p{ color:var(--err); }
.tl-row.note{ border-left-color:var(--warn); }
.empty{ color:var(--fg-faint); font-size:12.5px; margin:6px 0; }
.hintline{ margin:6px 0 0; font-size:12.5px; color:var(--fg-dim); }
.warnline{ font-size:12.5px; color:var(--warn); background:var(--warn-soft); border:1px solid var(--warn); border-radius:7px; padding:7px 9px; margin:8px 0 0; }

/* ---------- pixel workbench redesign ----------
   A compact masthead keeps the tool identity visible without competing with
   the mosaic workspace below. The existing IDs and runtime DOM contract stay
   untouched. */
:root{
  color-scheme:dark;
  --bg:#09131d;
  --panel:#101e2a;
  --panel-2:#172a39;
  --panel-3:#20394b;
  --fg:#e7f0f8;
  --fg-dim:#9eb2c3;
  --fg-faint:#6f8799;
  --border:#294456;
  --border-2:#45667b;
  --accent:#86d2ff;
  --accent-fg:#071722;
  --accent-soft:#173b52;
  --ok:#75d6bd;
  --ok-soft:#123d3d;
  --warn:#e9bd72;
  --warn-soft:#3b301d;
  --err:#ff929f;
  --err-soft:#422532;
  --err-border:#784250;
  --ck:#304b5b;
  --ck-2:#152734;
  --code-bg:#071019;
  --code-fg:#dceeff;
  --ink:#071019;
  --ink-soft:#0e2230;
  --hero-fg:#eaf5ff;
  --hero-dim:#9db4c7;
  --grid-line:rgba(134,210,255,.15);
  --shadow:0 16px 38px rgba(0,0,0,.32);
}
html,body{ background:var(--bg); }
body{
  font-size:14px;
  line-height:1.5;
  letter-spacing:-.005em;
}
.wrap{ max-width:1240px; padding-left:24px; padding-right:24px; }
.top{
  background:var(--bg);
  background:color-mix(in srgb,var(--bg) 94%,transparent);
  border-bottom:1px solid var(--border);
  backdrop-filter:blur(14px);
}
.top-in{ min-height:64px; padding:12px 0; }
.brand{ gap:10px; font-family:var(--mono); font-size:13px; letter-spacing:.04em; text-transform:uppercase; }
.logo{
  display:inline-grid; place-items:center; width:31px; height:31px;
  background:var(--accent); color:var(--accent-fg); border:1px solid var(--accent);
  font-size:18px; line-height:1; transform:rotate(-4deg);
}
.brand-sub{ color:var(--fg-faint); font-size:10px; letter-spacing:.12em; }
.topmeta{ gap:7px; }
.chip{ border-radius:4px; padding:4px 8px; background:var(--panel); border-color:var(--border); }
.chip b{ font-weight:700; }

main{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  grid-template-areas:
    "hero hero hero"
    "spec spec generation"
    "palette palette generation"
    "palette palette console"
    "result result result"
    "footer footer footer";
  gap:18px;
  padding-top:28px;
  padding-bottom:72px;
}
.hero{
  grid-area:hero;
  min-height:104px;
  display:grid;
  grid-template-columns:minmax(0,.78fr) minmax(320px,1fr);
  position:relative;
  overflow:hidden;
  background:var(--ink);
  color:var(--hero-fg);
  border:1px solid var(--ink);
  border-radius:14px;
  box-shadow:var(--shadow);
}
.hero-copy{
  padding:16px 28px; position:relative; z-index:1;
  display:flex; align-items:center; gap:18px;
}
.eyebrow,.hero-label,.hero-corner{
  font:11px/1.2 var(--mono); letter-spacing:.14em; text-transform:uppercase;
}
.eyebrow{ color:var(--accent); margin-bottom:0; white-space:nowrap; }
.hero h1{
  margin:0; max-width:none; white-space:nowrap;
  font:700 clamp(24px,3vw,36px)/.95 var(--mono);
  letter-spacing:-.075em; text-transform:uppercase;
}
.hero h1 em{ color:var(--accent); font-style:normal; }
.hero-visual{
  position:relative; min-height:104px; overflow:hidden;
  background-color:var(--ink-soft);
  background-image:
    linear-gradient(var(--grid-line) 1px,transparent 1px),
    linear-gradient(90deg,var(--grid-line) 1px,transparent 1px);
  background-size:24px 24px;
  border-left:1px solid var(--border);
}
.hero-visual:before,.hero-visual:after{
  content:""; position:absolute; border:1px solid rgba(134,210,255,.38);
}
.hero-visual:before{ inset:12px 16px; }
.hero-visual:after{ width:34px; height:34px; right:44px; top:30px; background:var(--accent); border:0; box-shadow:none; }
.hero-glyph{ display:none; }
.hero-label{ position:absolute; left:14px; bottom:8px; color:var(--hero-dim); font-size:8px; }
.hero-corner{ position:absolute; right:15px; bottom:8px; color:var(--accent); font-size:8px; }
.panel{
  margin:0; padding:18px; background:var(--panel); border:1px solid var(--border);
  border-radius:15px; box-shadow:0 4px 18px rgba(0,19,32,.18);
}
.input-spec-panel{ grid-area:spec; }
.palette-panel{ grid-area:palette; }
.generate-panel{ grid-area:generation; }
.result-panel{ grid-area:result; padding:20px; }
.console{ grid-area:console; min-height:100%; }
.footer-note{ grid-area:footer; }
.panel > h2{
  display:flex; flex-direction:column; gap:3px; margin:0 0 14px;
  font:700 17px/1.2 var(--mono); letter-spacing:-.035em;
}
.panel > h2 .dim{ display:block; font-size:12px; line-height:1.4; letter-spacing:0; }
h3{ margin-top:20px; font-family:var(--mono); letter-spacing:-.02em; }
.row{ gap:8px; }
.row-tight{ gap:6px; }
.sep{ margin:16px 0; background:var(--border); }
button,.btn{ border-radius:7px; border-color:var(--border-2); padding:7px 11px; }
button:hover:not(:disabled),.btn:hover{ background:var(--panel-3); }
.btn-primary{
  min-height:44px; justify-content:center; border-color:var(--accent); background:var(--accent);
  color:var(--accent-fg); font:700 13px var(--mono); letter-spacing:.02em;
  box-shadow:4px 4px 0 var(--ink);
}
.btn-primary:hover:not(:disabled){ background:var(--accent); filter:brightness(1.04); transform:translate(-1px,-1px); }
.drop{
  min-height:240px; height:100%; flex:1; display:flex; flex-direction:column; justify-content:center; align-items:center; gap:10px;
  padding:28px 20px; border:1px dashed var(--border-2); border-radius:10px;
  text-align:center; background:var(--panel-2); position:relative; overflow:hidden;
  box-sizing:border-box; cursor:pointer;
}
.drop:before{ content:"DROP / PASTE"; position:absolute; top:11px; right:13px; color:var(--fg-faint); font:10px var(--mono); letter-spacing:.1em; }
.drop-main{ max-width:280px; font:700 15px/1.35 var(--mono); letter-spacing:-.02em; }
.drop .tiny{ max-width:280px; line-height:1.45; }
.drop.over{ border-color:var(--accent); background:var(--accent-soft); }
.thumb{ padding-top:12px; border-top:1px solid var(--border); }
.thumb img{ width:64px; height:64px; border-radius:5px; }
fieldset{ margin-bottom:0; }
legend{ margin-bottom:8px; padding:0; font:700 11px/1.3 var(--mono); text-transform:uppercase; letter-spacing:.04em; }

.presets{ grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
.palette-panel .presets{ grid-template-columns:repeat(auto-fill,minmax(145px,1fr)); }
.palette-mode{
  margin-bottom:10px; padding:9px; border:1px solid var(--border-2);
  border-radius:10px; background:var(--ink-soft);
}
.palette-mode .preset{
  display:grid; grid-template-columns:minmax(120px,.42fr) minmax(0,1fr); align-items:center;
  gap:10px; width:100%; height:54px; min-height:54px;
  padding:7px; border-color:transparent; background:transparent;
}
.palette-mode .preset[aria-pressed="true"]{ border-color:var(--accent); background:var(--accent-soft); }
.palette-mode .preset .ph{ min-height:0; }
.palette-mode .preset .note{ max-height:none; }
.auto-options{
  display:flex; align-items:center; gap:8px; min-width:0; padding:8px 7px 1px;
  border-top:1px solid var(--border); color:var(--fg-dim);
}
.preset{ height:84px; min-height:0; padding:8px; border-radius:8px; overflow:hidden; }
.preset .ph{ min-height:24px; align-content:flex-start; font-size:12px; gap:4px; line-height:1.2; }
.preset .pn{ font-size:10px; }
.preset .note{ max-height:44px; overflow:hidden; font-size:10px; line-height:1.3; }
.sw{ min-height:10px; gap:1px; margin:6px 0 4px; }
.sw i{ width:9px; height:9px; }
.pixelonly{
  margin:0 0 16px; padding:12px; border:1px solid var(--accent); border-radius:10px;
  background:var(--accent-soft); box-shadow:inset 4px 0 var(--accent);
}
.pixelonly .desc{ font-size:11.5px; line-height:1.45; }
.generate-panel .row:has(#generate){ align-items:stretch; }
.generate-panel .row:has(#generate) button{ flex:1; min-height:38px; justify-content:center; }
.generate-panel #generate{ flex:1; }
.generate-panel #clear-file{ align-self:center; }
.generate-panel #repixelize{ width:100%; justify-content:center; }
.stepper{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px; }
.st{ min-width:0; padding:5px 7px; border-radius:5px; font:10px/1.2 var(--mono); }
.st .el{ font-size:9px; }
.statusline{ margin-top:14px; padding:10px; background:var(--panel-2); border-radius:8px; font-size:12px; }
.indet{ margin-top:10px; }
.indet-lbl{ font-size:10px; line-height:1.35; }
.upbar{ margin-top:10px; }
.progress-panel .row[style]{ margin-top:14px !important; }
.progress-panel .row[style] .tiny{ flex:1; min-width:180px; font-size:10px; line-height:1.3; }
.generate-panel .progress-panel{ margin-top:18px; padding-top:18px; border-top:1px solid var(--border); }
.generate-panel .progress-panel h3{ margin:0 0 12px; color:var(--fg); font-size:15px; }
.stage{
  height:clamp(360px,52vh,620px); border:1px solid var(--border-2); border-radius:9px;
  background-color:var(--ck-2); background-image:
    linear-gradient(45deg,var(--ck) 25%,transparent 25%,transparent 75%,var(--ck) 75%),
    linear-gradient(45deg,var(--ck) 25%,transparent 25%,transparent 75%,var(--ck) 75%);
  background-size:22px 22px; background-position:0 0,11px 11px;
  box-shadow:inset 0 0 0 8px rgba(0,0,0,.08);
}
.stage-empty{ max-width:250px; font:12px/1.4 var(--mono); color:var(--fg-dim); }
.result-panel .ai-row{
  display:grid; grid-template-columns:repeat(3,minmax(0,1fr)) 120px;
  gap:12px; margin:0; align-items:stretch;
}
.result-panel .ai-row.has-two{ grid-template-columns:repeat(3,minmax(0,1fr)) 120px; }
.result-card{
  min-width:0; padding:10px; border:1px solid var(--border); border-radius:10px;
  background:var(--panel-2); display:flex; flex-direction:column;
}
.result-card .cap{ min-height:30px; margin-bottom:7px; }
.result-card .stage{
  width:100%; height:auto; aspect-ratio:1 / 1; min-height:0;
  border-color:var(--border-2); box-shadow:none;
}
.result-card .stage-empty{ max-width:210px; text-align:center; }
.zoom-card{
  min-width:0; padding:10px; border:1px solid var(--border); border-radius:10px;
  background:var(--panel-2); display:flex; flex-direction:column;
}
.zoom-card .cap{ min-height:30px; margin-bottom:7px; }
.zoom-stack{ display:flex; flex-direction:column; gap:6px; flex:1; }
.zoom-stack button{
  width:100%; min-height:32px; padding:4px 6px; justify-content:center;
  font:11.5px var(--mono); text-align:center;
}
.zoom-card #zoom-info{
  margin-top:auto; padding-top:8px; font-size:10px; line-height:1.3; color:var(--fg-dim);
}
.is-disabled,.btn[aria-disabled="true"]{ opacity:.4; cursor:not-allowed; pointer-events:none; }
.row-tight > button,.row-tight > .btn,.row-tight > a.btn{ min-height:30px; }
.result-panel #downloads{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); }
.result-panel #downloads .btn{ min-width:0; justify-content:center; text-align:center; }
.result-panel .copy-actions{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); }
.result-panel .copy-actions #copy-target{ grid-column:1/-1; }
.result-panel .resource-actions{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
.errblock .row-tight button,.errblock .row-tight .btn{ flex:1; min-width:120px; justify-content:center; }
.cap{ font:11px/1.35 var(--mono); color:var(--fg-dim); text-transform:uppercase; letter-spacing:.025em; }
.result-panel > h3{ margin-top:22px; }
.result-panel > p.tiny{ max-width:720px; line-height:1.45; }
.console{ overflow:hidden; }
.console > h2{ margin-bottom:14px; }
.console #console{
  max-height:420px;
  overflow-y:auto;
  overscroll-behavior:contain;
  padding-right:4px;
  margin-bottom:12px;
  scrollbar-width:thin;
  scrollbar-color:var(--border-2) transparent;
}
.console .timeline{
  max-height:220px;
  overflow:auto;
  overscroll-behavior:contain;
  padding-right:4px;
  scrollbar-width:thin;
  scrollbar-color:var(--border-2) transparent;
}
.errblock{ border-radius:8px; background:var(--panel-2); }
.footer-note{ margin:0; padding:0 4px; line-height:1.5; }
@media (max-width:1040px){
  main{
    grid-template-columns:minmax(270px,330px) minmax(0,1fr);
    grid-template-areas:
      "hero hero"
      "spec spec"
      "palette palette"
      "generation console"
      "result result"
      "footer footer";
  }
  .result-panel{ position:static; }
  .result-panel .ai-row{ grid-template-columns:repeat(3,minmax(0,1fr)); }
  .zoom-card{ grid-column:1 / -1; }
  .zoom-stack{ flex-direction:row; flex-wrap:wrap; }
  .zoom-stack button{ flex:1; min-width:80px; }
  .hero{ grid-template-columns:1fr .8fr; }
  .hero-copy{ padding:16px 22px; gap:14px; }
  .hero h1{ font-size:clamp(23px,4.3vw,34px); }
}
@media (max-width:700px){
  main{
    grid-template-columns:minmax(0,1fr);
    grid-template-areas:"hero" "spec" "palette" "generation" "result" "console" "footer";
  }
  .hero{ display:block; min-height:166px; }
  .hero-copy{ display:flex; padding:20px; min-height:78px; }
  .hero h1{ white-space:normal; }
  .hero-visual{ min-height:88px; border-left:0; border-top:1px solid var(--border); }
  .result-panel .ai-row{ grid-template-columns:1fr; }
  .result-panel .ai-row.has-two{ grid-template-columns:1fr; }
  .result-panel{ position:static; }
}
@media (max-width:600px){
  .wrap{ padding-left:14px; padding-right:14px; }
  main{ gap:12px; padding-top:16px; }
  .topmeta{ width:100%; margin-left:0; }
  .top-in{ align-items:flex-start; }
  .hero-copy{ padding:18px; }
  .hero h1{ font-size:30px; }
  .hero-visual:after{ right:48px; top:30px; }
  .hero-label,.hero-corner{ bottom:13px; }
  .panel,.result-panel{ padding:15px; }
  .sizes{ grid-template-columns:repeat(2,minmax(0,1fr)); }
  .stage{ height:clamp(300px,68vh,520px); }
  .result-card .stage{ height:auto; }
}
@media (max-width:400px){
  .sizes{ grid-template-columns:1fr; }
}
@media (prefers-reduced-motion:reduce){
  *,*:before,*:after{ animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important; scroll-behavior:auto !important; }
}
