/* comfyarts — Visual Deconstruction.

   Same catalogue language as Explore (explore.css supplies the tokens, type, buttons,
   header and footer). This file only lays out the tool: a ruled control strip, a
   framed drop area with crop marks, a queue of plates, and the settings column.

   The two animations that matter here are functional, not decoration:
     upload    a new card wipes in from its top edge, so a dropped batch visibly lands
     analysis  while a card is being read it is grey and a scan line travels down it;
               when the prompt arrives the picture "develops" back to full colour
   Both stop on their own. Nothing loops while the page is idle. */

.pg-decon .bh { border-bottom: 0; padding-bottom: clamp(22px, 3vw, 40px); }
.pg-decon .bh h1 { font-size: clamp(3rem, 9.4vw, 9.6rem); }

.dk-shell { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: clamp(18px, 2.4vw, 40px); align-items: start; }
.dk-wrap { min-width: 0; }

/* ── control strip ────────────────────────────────────────────────────────── */
.dk-bar { display: grid; grid-template-columns: auto minmax(180px, 1fr) auto auto; border: 1px solid var(--rule-2); border-radius: 2px; background: var(--bg-2); }
.dk-cell { display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 16px 20px; border-right: 1px solid var(--rule); min-width: 0; }
.dk-lab { font: 500 10.5px/1 var(--m); letter-spacing: .1em; text-transform: uppercase; color: var(--mute); white-space: nowrap; }
.dk-lab b { font-weight: 500; color: var(--dim); }
.dk-acts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; border-top: 1px solid var(--rule); }

/* Fast / Brain: a rectangular track with a square knob */
.dk-mode { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; outline-offset: 6px; }
.dk-mode .lab { font: 800 17px/1 var(--f); font-stretch: 72%; text-transform: uppercase; letter-spacing: .01em; transition: color .3s; }
.dk-mode .lab.fast { color: var(--paper); } .dk-mode .lab.pro { color: var(--mute); }
.dk-mode.pro .lab.fast { color: var(--mute); } .dk-mode.pro .lab.pro { color: var(--sig); }
.dk-sw { position: relative; width: 46px; height: 24px; border: 1px solid var(--rule-2); border-radius: 2px; background: none; flex: none; }
.dk-sw i { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: var(--paper); border-radius: 1px; transition: transform .5s var(--e), background .3s; }
.dk-mode.pro .dk-sw i { transform: translateX(22px); background: var(--sig); }
.dk-cost { margin-left: 4px; font: 500 12px/1 var(--m); color: var(--dim); white-space: nowrap; }

.dk-range { display: flex; align-items: center; gap: 14px; }
.dk-range input[type=range] { flex: 1; min-width: 80px; height: 24px; margin: 0; background: none; cursor: pointer; -webkit-appearance: none; appearance: none; }
.dk-range input[type=range]::-webkit-slider-runnable-track { height: 1px; background: var(--rule-2); }
.dk-range input[type=range]::-moz-range-track { height: 1px; background: var(--rule-2); }
.dk-range input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 22px; margin-top: -11px; border: 0; border-radius: 1px; background: var(--paper); transition: background .2s, transform .2s; }
.dk-range input[type=range]::-moz-range-thumb { width: 12px; height: 22px; border: 0; border-radius: 1px; background: var(--paper); }
.dk-range input[type=range]:hover::-webkit-slider-thumb { background: var(--sig); transform: scaleY(1.12); }
.dk-workers .n, .dk-sum { font: 500 15px/1 var(--m); color: var(--paper); white-space: nowrap; }
.dk-workers .n { min-width: 2ch; text-align: right; }

.dk-btn { position: relative; flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 9px; height: 56px; padding: 0 22px; border: 0; border-right: 1px solid var(--rule); border-radius: 0; background: none; color: var(--paper); cursor: pointer; overflow: hidden; isolation: isolate; font: 700 13px/1 var(--f); letter-spacing: .09em; text-transform: uppercase; white-space: nowrap; transition: color .3s; }
.dk-btn::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--paper); transform: translateY(101%); transition: transform .5s var(--e); }
.dk-btn:hover:not(:disabled) { color: #0B0A09; }
.dk-btn:hover:not(:disabled)::before { transform: none; }
.dk-btn.primary { flex: 2 1 220px; border-right: 0; background: var(--paper); color: #0B0A09; }
.dk-btn.primary::before { background: var(--sig); }
.dk-btn:disabled { cursor: not-allowed; color: var(--mute); background: none; }
.dk-btn.primary:disabled { background: var(--bg-3); color: var(--mute); }
.dk-btn[hidden] { display: none; }
.pg-spin { width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: dkspin .7s linear infinite; }
@keyframes dkspin { to { transform: rotate(360deg); } }

/* ── drop area ────────────────────────────────────────────────────────────── */
.dk-dz { position: relative; margin-top: clamp(14px, 1.6vw, 24px); min-height: clamp(280px, 38vw, 480px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 40px 20px; text-align: center; cursor: pointer; border: 1px dashed var(--rule-2); border-radius: 2px; transition: background .4s, border-color .3s; }
.dk-dz[hidden] { display: none; }
/* crop marks: four corners drawn with one element, pulled inward on hover / drag */
.dk-crop { position: absolute; inset: 18px; pointer-events: none; transition: inset .7s var(--e), opacity .3s;
  background:
    linear-gradient(var(--paper), var(--paper)) 0 0 / 26px 1px no-repeat, linear-gradient(var(--paper), var(--paper)) 0 0 / 1px 26px no-repeat,
    linear-gradient(var(--paper), var(--paper)) 100% 0 / 26px 1px no-repeat, linear-gradient(var(--paper), var(--paper)) 100% 0 / 1px 26px no-repeat,
    linear-gradient(var(--paper), var(--paper)) 0 100% / 26px 1px no-repeat, linear-gradient(var(--paper), var(--paper)) 0 100% / 1px 26px no-repeat,
    linear-gradient(var(--paper), var(--paper)) 100% 100% / 26px 1px no-repeat, linear-gradient(var(--paper), var(--paper)) 100% 100% / 1px 26px no-repeat; }
.dk-dz:hover .dk-crop { inset: 34px; }
.dk-dz.over { background: var(--bg-2); border-color: var(--sig); border-style: solid; }
.dk-dz.over .dk-crop { inset: 56px; }
.dk-dz .ic { color: var(--dim); transition: transform .7s var(--e), color .3s; }
.dk-dz:hover .ic, .dk-dz.over .ic { transform: translateY(-6px); color: var(--paper); }
.dk-dz h2 { margin: 0; font: 800 clamp(2.2rem, 6vw, 5.4rem)/.88 var(--f); font-stretch: 62%; text-transform: uppercase; }
.dk-dz.over h2 { color: var(--sig); }
.dk-dz p { margin: 0; font: 500 12px/1.6 var(--m); letter-spacing: .04em; color: var(--mute); }
.dk-dz .browse { margin-top: 10px; padding-bottom: 5px; border-bottom: 1px solid var(--paper); font: 600 13px/1 var(--f); letter-spacing: .08em; text-transform: uppercase; }

/* ── queue ────────────────────────────────────────────────────────────────── */
.dk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: clamp(10px, 1.2vw, 18px); margin-top: clamp(14px, 1.6vw, 24px); }
.dk-grid:empty { display: none; }
.dk-card { position: relative; display: flex; flex-direction: column; background: var(--bg-2); border: 1px solid var(--rule); border-radius: 2px; overflow: hidden; animation: dkin .9s var(--e) both; }
@keyframes dkin { from { clip-path: inset(0 0 100% 0); transform: translateY(18px); } to { clip-path: inset(0); transform: none; } }
.dk-card.err { border-color: rgba(255, 74, 28, .55); }
.dk-card .shot { position: relative; background: #000; overflow: hidden; }
.dk-card .shot img { display: block; width: 100%; height: 220px; object-fit: cover; cursor: zoom-in; transition: filter 1.6s ease, transform 1.4s var(--e); }
.dk-card:hover .shot img { transform: scale(1.03); }
/* queued and being read: grey. Done: develops to colour. */
.dk-card:has(.dk-badge:not(.done):not(.err)) .shot img { filter: grayscale(1) contrast(1.15) brightness(.75); }
.dk-card:has(.dk-badge.run) .shot::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--sig); box-shadow: 0 0 0 1px rgba(255, 74, 28, .25), 0 -40px 60px 30px rgba(255, 74, 28, .08); animation: dkscan 1.9s cubic-bezier(.45, 0, .55, 1) infinite alternate; }
@keyframes dkscan { from { transform: translateY(0); } to { transform: translateY(218px); } }
.dk-badge { position: absolute; left: 0; top: 0; display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 10px; background: var(--bg); font: 500 10.5px/1 var(--m); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.dk-badge .dot { width: 6px; height: 6px; background: currentColor; }
.dk-badge.run { color: var(--sig); } .dk-badge.done { color: var(--paper); } .dk-badge.err { color: var(--sig); }
.dk-badge.run .dot { animation: dkblink 1s steps(2, end) infinite; }
@keyframes dkblink { 50% { opacity: .2; } }
.dk-x { position: absolute; right: 0; top: 0; width: 26px; height: 26px; display: grid; place-items: center; border: 0; background: var(--bg); color: var(--dim); cursor: pointer; transition: background .2s, color .2s; }
.dk-x:hover { background: var(--sig); color: #0B0A09; }
.dk-body { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; flex: 1; }
.dk-name { font: 500 11px/1.4 var(--m); letter-spacing: .04em; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dk-prompt { max-height: 240px; overflow-y: auto; padding-right: 6px; color: var(--paper); font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; scrollbar-width: thin; scrollbar-color: var(--rule-2) transparent; animation: dkwrite 1.1s var(--e) both; }
@keyframes dkwrite { from { clip-path: inset(0 0 100% 0); opacity: 0; } to { clip-path: inset(0); opacity: 1; } }
.dk-errmsg { font: 500 12.5px/1.5 var(--m); color: var(--sig); }
.dk-foot { display: flex; align-items: center; gap: 14px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--rule); }
.dk-foot .meta { margin-right: auto; font: 500 11px/1 var(--m); letter-spacing: .06em; text-transform: uppercase; color: var(--mute); }
.dk-mini { display: inline-flex; align-items: center; gap: 6px; padding: 0 0 4px; border: 0; border-bottom: 1px solid var(--rule-2); border-radius: 0; background: none; color: var(--paper); cursor: pointer; text-decoration: none; font: 600 12px/1 var(--f); letter-spacing: .08em; text-transform: uppercase; transition: border-color .2s, color .2s; }
.dk-mini:hover { border-color: var(--paper); }
.dk-mini.done { color: var(--sig); border-color: var(--sig); }

/* ── settings column ──────────────────────────────────────────────────────── */
.sh-side { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow-y: auto; border: 1px solid var(--rule-2); border-radius: 2px; background: var(--bg-2); scrollbar-width: thin; scrollbar-color: var(--rule-2) transparent; }
.sh-bulk, .sh-head, .sh-body { padding: 18px 20px; border-bottom: 1px solid var(--rule); }
.sh-side > :last-child { border-bottom: 0; }
.sh-side h2 { margin: 0 0 8px; font: 800 22px/.95 var(--f); font-stretch: 68%; text-transform: uppercase; }
.sh-side p { margin: 0 0 12px; color: var(--dim); font-size: 13px; line-height: 1.5; }
.sh-side label, .sh-top b, .sh-prevtop b { display: block; margin: 14px 0 7px; font: 500 10.5px/1.2 var(--m); letter-spacing: .1em; text-transform: uppercase; color: var(--mute); }
.sh-bulk > label:first-child { margin-top: 0; }
.sh-side input[type=text], .sh-side select, .sh-side textarea { display: block; width: 100%; padding: 11px 12px; border: 1px solid var(--rule-2); border-radius: 2px; background: var(--bg); color: var(--paper); font: 500 14px/1.4 var(--f); outline: 0; transition: border-color .2s; }
.sh-side select { appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%), linear-gradient(135deg, var(--dim) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.sh-side select option { background: #12100F; }
.sh-side input[type=text]:focus, .sh-side select:focus, .sh-side textarea:focus { border-color: var(--paper); }
.sh-side textarea { min-height: 96px; resize: vertical; font: 400 12.5px/1.55 var(--m); }
.sh-options { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; }
.sh-options label { display: flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; color: var(--dim); }
.sh-options input { width: 14px; height: 14px; margin: 0; accent-color: #FF4A1C; }
.sh-reset { margin-top: 12px; padding: 0 0 4px; border: 0; border-bottom: 1px solid var(--rule-2); background: none; color: var(--dim); cursor: pointer; font: 600 11.5px/1 var(--f); letter-spacing: .08em; text-transform: uppercase; transition: color .2s, border-color .2s; }
.sh-reset:hover { color: var(--paper); border-color: var(--paper); }
.sh-head { display: flex; align-items: flex-start; gap: 14px; }
.sh-head .t { flex: 1; min-width: 0; } .sh-head p { margin: 0; }
.tgl { position: relative; flex: none; width: 46px; height: 24px; padding: 0; border: 1px solid var(--rule-2); border-radius: 2px; background: none; cursor: pointer; }
.tgl .k { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: var(--mute); border-radius: 1px; transition: transform .5s var(--e), background .3s; }
.tgl[aria-checked="true"] .k { transform: translateX(22px); background: var(--sig); }
.sh-body { transition: opacity .3s; }
.sh-side.off .sh-body { opacity: .32; pointer-events: none; }
.sh-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sh-top b { margin-top: 0; }
.sh-step, .sh-prevtop span { font: 500 11px/1 var(--m); color: var(--dim); }
.sh-devs { display: grid; margin-bottom: 4px; border-top: 1px solid var(--rule); }
.sh-dev-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 2px; border: 0; border-bottom: 1px solid var(--rule); background: none; color: var(--paper); text-align: left; cursor: pointer; transition: padding .45s var(--e), background .3s; }
.sh-dev-row:hover { padding-left: 10px; }
.sh-dev-row .dot { flex: none; width: 10px; height: 10px; border: 1px solid var(--mute); transition: background .2s, border-color .2s; }
.sh-dev-row.on .dot { background: var(--sig); border-color: var(--sig); }
.sh-dev-row .nm { flex: 1; min-width: 0; }
.sh-dev-row .nm b { display: block; font: 700 14px/1.2 var(--f); }
.sh-dev-row .nm span { display: block; margin-top: 3px; font: 400 10.5px/1.3 var(--m); color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh-prevtop { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 14px; }

/* ── lightbox + toast ─────────────────────────────────────────────────────── */
.dk-lb { position: fixed; inset: 0; z-index: 400; display: none; align-items: center; justify-content: center; padding: 4vmin; background: rgba(11, 10, 9, .94); cursor: zoom-out; }
.dk-lb.on { display: flex; animation: dkfade .3s both; }
.dk-lb img { max-width: 100%; max-height: 100%; padding: 8px; background: var(--paper); animation: dkpop .6s var(--e) both; }
@keyframes dkfade { from { opacity: 0; } } @keyframes dkpop { from { transform: scale(.94); opacity: 0; } }
.dk-toast { position: fixed; left: 50%; bottom: 24px; z-index: 500; max-width: min(92vw, 560px); padding: 13px 18px; background: var(--paper); color: #0B0A09; font: 600 13.5px/1.4 var(--f); opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: opacity .3s, transform .6s var(--e); }
.dk-toast.show { opacity: 1; transform: translate(-50%, 0); }
.dk-toast.err { background: var(--sig); }

/* ── how it works ─────────────────────────────────────────────────────────── */
.dk-how { padding-top: clamp(64px, 9vw, 140px); }
.dk-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--rule-2); }
.dk-steps li { padding: clamp(18px, 2vw, 30px); border-right: 1px solid var(--rule); min-height: 240px; display: flex; flex-direction: column; }
.dk-steps li:last-child { border-right: 0; }
.dk-steps .mi-no { color: var(--sig); }
.dk-steps h3 { margin: auto 0 10px; font: 800 clamp(1.5rem, 2.2vw, 2.2rem)/.92 var(--f); font-stretch: 64%; text-transform: uppercase; }
.dk-steps p { margin: 0; color: var(--dim); font-size: 14.5px; line-height: 1.5; }

@media (max-width: 1180px) {
  .dk-shell { grid-template-columns: minmax(0, 1fr); }
  .sh-side { position: static; max-height: none; }
  .dk-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dk-steps li:nth-child(2) { border-right: 0; } .dk-steps li:nth-child(-n+2) { border-bottom: 1px solid var(--rule); }
}
@media (max-width: 760px) {
  .dk-bar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dk-cell { border-bottom: 1px solid var(--rule); padding: 14px 16px; }
  .dk-cell:nth-child(2n) { border-right: 0; }
  .dk-cell:first-child, .dk-workers { grid-column: 1 / -1; border-right: 0; }
  .dk-acts { border-top: 0; }
  .dk-btn { flex: 1 1 50%; padding: 0 12px; }
  .dk-btn.primary { flex: 1 1 100%; border-top: 1px solid var(--rule); }
  .dk-card .shot img { height: 200px; }
  .dk-steps { grid-template-columns: minmax(0, 1fr); }
  .dk-steps li { border-right: 0; border-bottom: 1px solid var(--rule); min-height: 0; gap: 14px; }
  .dk-steps h3 { margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .dk-card, .dk-prompt, .dk-lb.on, .dk-lb img { animation: none !important; }
  .dk-card:has(.dk-badge.run) .shot::after { animation: none; top: 50%; }
}
