:root {
  --ink: #0c0d0a;
  --ink-2: #131511;
  --panel: #16180f;
  --rule: #262a1f;
  --rule-hi: #3b422f;
  --text: #e9eae1;
  --muted: #8a9179;
  --signal: #c8f24b;
  --signal-dim: #7d9430;
  --warn: #ff6a3d;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Archivo', 'Helvetica Neue', sans-serif;
  --ease: cubic-bezier(.2, 0, 0, 1);
}

* { box-sizing: border-box; }

/* Moet de display-regels hieronder overrulen, anders blijft een verborgen
   veld gewoon staan. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  background-image:
    linear-gradient(rgba(200, 242, 75, .028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(200, 242, 75, .028) 1px, transparent 1px),
    radial-gradient(120% 80% at 78% -10%, rgba(200, 242, 75, .07), transparent 60%);
  background-size: 64px 64px, 64px 64px, 100% 100%;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  overflow-x: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: .05;
  pointer-events: none;
  z-index: 100;
  mix-blend-mode: overlay;
}

.rail {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 34px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 22px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 10px;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--signal-dim);
  border-right: 1px solid var(--rule);
  background: rgba(12, 13, 10, .6);
  z-index: 20;
}

/* ---------- masthead ---------- */

.masthead {
  margin-left: 34px;
  padding: 30px 32px 20px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

h1 { margin: 0; display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }

.h-sub {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--muted);
}

.h-main {
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(2.4rem, 7vw, 4.6rem);
  line-height: .85;
  letter-spacing: -.045em;
  color: var(--text);
}

.conn {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--muted);
  padding-bottom: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border: 1px solid var(--rule-hi);
  border-radius: 50%;
  flex: none;
}
.dot[data-state="on"] { background: var(--signal); border-color: var(--signal); box-shadow: 0 0 12px rgba(200, 242, 75, .55); }
.dot[data-state="bad"] { background: var(--warn); border-color: var(--warn); }
.dot[data-state="busy"] { background: var(--signal); border-color: var(--signal); animation: blink 1s steps(2) infinite; }

@keyframes blink { 50% { opacity: .2; } }

/* ---------- layout ---------- */

.shell {
  margin-left: 34px;
  display: grid;
  grid-template-columns: minmax(320px, 400px) 1fr;
  align-items: start;
  min-height: calc(100vh - 120px);
}

.panel {
  border-right: 1px solid var(--rule);
  padding: 0 0 40px;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-hi) transparent;
}

.block {
  padding: 22px 26px;
  border-bottom: 1px solid var(--rule);
}

.label {
  margin: 0 0 14px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--signal-dim);
  display: flex;
  align-items: center;
  gap: 10px;
}

summary.label { cursor: pointer; list-style: none; margin-bottom: 0; }
summary.label::-webkit-details-marker { display: none; }
summary.label::after {
  content: '+';
  margin-left: auto;
  font-size: 14px;
  color: var(--muted);
}
details[open] > summary.label::after { content: '−'; }
details[open] > summary.label { margin-bottom: 16px; }

.count {
  margin-left: auto;
  font-size: 11px;
  letter-spacing: 0;
  color: var(--text);
  background: rgba(200, 242, 75, .1);
  border: 1px solid var(--rule-hi);
  padding: 0 7px;
  font-variant-numeric: tabular-nums;
}

/* ---------- form ---------- */

.field { display: block; margin-bottom: 12px; }
.field > span {
  display: block;
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}

input, textarea, select, button { font: inherit; color: inherit; }

input[type="url"], input[type="text"], input[type="password"],
input[type="number"], input:not([type]), textarea, select {
  width: 100%;
  background: var(--ink-2);
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 8px 10px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  transition: border-color .16s var(--ease), background .16s var(--ease);
}

textarea { resize: vertical; line-height: 1.6; min-height: 76px; }

input:hover, textarea:hover, select:hover { border-color: var(--rule-hi); }

input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible {
  outline: none;
  border-color: var(--signal);
  box-shadow: inset 0 0 0 1px var(--signal);
}
button:focus-visible { box-shadow: 0 0 0 2px var(--ink), 0 0 0 3px var(--signal); }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 15px, calc(100% - 9px) 15px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.span2 { grid-column: 1 / -1; }

.grid2.shared { padding-bottom: 4px; border-bottom: 1px dashed var(--rule); margin-bottom: 16px; }

/* ---------- tabbladen ---------- */

.tabs { display: flex; gap: 0; margin-bottom: 16px; border: 1px solid var(--rule); }
.tabs button {
  flex: 1;
  background: transparent;
  border: none;
  border-right: 1px solid var(--rule);
  color: var(--muted);
  padding: 8px 6px;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .16s var(--ease), background .16s var(--ease);
}
.tabs button:last-child { border-right: none; }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { background: rgba(200, 242, 75, .12); color: var(--signal); }
.tabs button:focus-visible { outline: none; box-shadow: inset 0 0 0 1px var(--signal); }

#workflowJson { font-size: 11.5px; line-height: 1.45; min-height: 150px; white-space: pre; }

.wf-report {
  margin: 0 0 12px;
  font-size: 10.5px;
  line-height: 1.65;
  color: var(--muted);
  border-left: 2px solid var(--rule-hi);
  padding: 8px 0 8px 10px;
}
.wf-report:empty { display: none; }
.wf-report b { color: var(--text); font-weight: 500; }
.wf-report .ok { color: var(--signal); }
.wf-report .no { color: var(--warn); }
.wf-report ul { margin: 4px 0 0; padding-left: 14px; }
.wf-report code { background: var(--ink-2); border: 1px solid var(--rule); padding: 0 3px; }

.presets { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; }
.presets button {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted);
  padding: 4px 8px;
  font-size: 10.5px;
  cursor: pointer;
  transition: all .16s var(--ease);
}
.presets button:hover { border-color: var(--signal); color: var(--signal); }

.note {
  margin: 10px 0 0;
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--muted);
}
.note code { background: var(--ink-2); border: 1px solid var(--rule); padding: 0 4px; }
.note.bad { color: var(--warn); }
.note.good { color: var(--signal); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--rule-hi);
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  cursor: pointer;
  /* De vulling schuift van onderaf omhoog — een background-image laag, zodat
     de tekst er altijd bovenop blijft staan. */
  background-image: linear-gradient(var(--signal), var(--signal));
  background-repeat: no-repeat;
  background-position: 50% 100%;
  background-size: 100% 0%;
  transition: background-size .26s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}
.btn:hover:not(:disabled), .btn:focus-visible:not(:disabled) {
  color: var(--ink);
  border-color: var(--signal);
  background-size: 100% 100%;
}
.btn:disabled { opacity: .35; cursor: not-allowed; }

.btn-ghost { width: 100%; }
.btn-small { padding: 6px 12px; font-size: 10px; width: auto; }
.btn-small.btn-ghost { width: auto; margin-top: 14px; }

.actions { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; padding: 22px 26px 0; }
.btn-go {
  background-color: var(--signal);
  background-image: linear-gradient(var(--text), var(--text));
  border-color: var(--signal);
  color: var(--ink);
  font-weight: 700;
}
.btn-go:hover:not(:disabled), .btn-go:focus-visible:not(:disabled) { color: var(--ink); border-color: var(--text); }
.btn-stop { background-image: linear-gradient(var(--warn), var(--warn)); }
.btn-stop:hover:not(:disabled), .btn-stop:focus-visible:not(:disabled) { border-color: var(--warn); color: var(--ink); }
.actions + .note { padding: 0 26px; }

/* ---------- contact sheet ---------- */

.sheet { padding: 0 0 60px; min-width: 0; }

.sheet-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--rule);
  background: rgba(12, 13, 10, .88);
  backdrop-filter: blur(8px);
  flex-wrap: wrap;
}

.stats { display: flex; gap: 20px; flex-wrap: wrap; font-size: 11px; letter-spacing: .08em; color: var(--muted); }
.stat b, .stat i { font-style: normal; font-variant-numeric: tabular-nums; }
.stat b { color: var(--signal); font-weight: 700; }
#sFailed:not(:empty) { color: var(--warn); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1px;
  background: var(--rule);
  border-bottom: 1px solid var(--rule);
}

.empty {
  grid-column: 1 / -1;
  background: var(--ink);
  margin: 0;
  padding: 80px 26px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.empty b { color: var(--signal); font-weight: 500; }

.slot {
  background: var(--ink);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.frame {
  position: relative;
  aspect-ratio: var(--ar, 832 / 1216);
  border: 1px solid var(--rule);
  background:
    repeating-linear-gradient(45deg, rgba(200, 242, 75, .022) 0 2px, transparent 2px 8px),
    var(--ink-2);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.frame .idx {
  font-family: var(--sans);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: -.05em;
  color: rgba(233, 234, 225, .07);
  font-variant-numeric: tabular-nums;
}

.frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  clip-path: inset(0 0 100% 0);
  transition: clip-path .7s var(--ease);
}
.slot[data-status="done"] .frame img { clip-path: inset(0 0 0 0); }

/* scanlijn tijdens het renderen */
.slot[data-status="running"] .frame::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--signal);
  box-shadow: 0 0 14px 2px rgba(200, 242, 75, .55);
  animation: scan 2.4s var(--ease) infinite;
}
@keyframes scan { 0% { top: -2%; } 100% { top: 102%; } }

.slot[data-status="running"] .frame { border-color: var(--signal-dim); }
.slot[data-status="error"] .frame { border-color: var(--warn); }
.slot[data-status="done"] .frame { border-color: var(--rule-hi); }

.meta { display: flex; align-items: center; gap: 8px; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; }
.meta .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.meta .st { margin-left: auto; color: var(--muted); }
.slot[data-status="running"] .st { color: var(--signal); }
.slot[data-status="done"] .st { color: var(--signal-dim); }
.slot[data-status="error"] .st { color: var(--warn); }

.ptext {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.slot .err { color: var(--warn); -webkit-line-clamp: 4; line-clamp: 4; }

.slot-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.slot-actions a, .slot-actions button {
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: none;
  border-bottom: 1px solid var(--rule-hi);
  padding: 1px 0;
  cursor: pointer;
  transition: color .16s var(--ease), border-color .16s var(--ease);
}
.slot-actions a:hover, .slot-actions button:hover { color: var(--signal); border-color: var(--signal); }
.slot-actions .seed {
  margin-left: auto;
  border: none;
  cursor: default;
  font-variant-numeric: tabular-nums;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.slot-actions .seed:hover { color: var(--muted); }

/* ---------- lightbox ---------- */

body.lb-open { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  grid-template-rows: 52px 1fr auto auto;
  grid-template-areas:
    'top   top   top'
    'prev  stage next'
    'meta  meta  meta'
    'strip strip strip';
  background: rgba(8, 9, 7, .97);
  backdrop-filter: blur(10px);
  animation: lbIn .22s var(--ease);
}
.lightbox[hidden] { display: none; }

@keyframes lbIn { from { opacity: 0; } to { opacity: 1; } }

.lb-top {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--rule);
}

.lb-counter {
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.lb-counter b { color: var(--signal); font-weight: 700; }

.lb-close {
  background: none;
  border: 1px solid var(--rule-hi);
  color: var(--muted);
  padding: 5px 12px;
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .16s var(--ease), border-color .16s var(--ease);
}
.lb-close:hover, .lb-close:focus-visible { color: var(--signal); border-color: var(--signal); outline: none; }

.lb-stage {
  grid-area: stage;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 18px 0;
  overflow: hidden;
}
.lb-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: 1px solid var(--rule);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .9);
  animation: lbImg .3s var(--ease);
}
@keyframes lbImg { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }

.lb-nav {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  transition: color .16s var(--ease);
}
.lb-prev { grid-area: prev; }
.lb-next { grid-area: next; }
.lb-nav:hover, .lb-nav:focus-visible { color: var(--signal); outline: none; }
.lb-nav:disabled { opacity: .18; cursor: default; }

.lb-meta {
  grid-area: meta;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 12px 18px;
  border-top: 1px solid var(--rule);
  flex-wrap: wrap;
}
.lb-prompt {
  margin: 0;
  flex: 1 1 320px;
  min-width: 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text);
  word-break: break-word;
}
.lb-facts { display: flex; align-items: center; gap: 14px; flex: none; }
.lb-seed, .lb-download {
  background: none;
  border: none;
  border-bottom: 1px solid var(--rule-hi);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-decoration: none;
  padding: 1px 0;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: color .16s var(--ease), border-color .16s var(--ease);
}
.lb-seed:hover, .lb-download:hover, .lb-seed:focus-visible, .lb-download:focus-visible {
  color: var(--signal); border-color: var(--signal); outline: none;
}

.lb-strip {
  grid-area: strip;
  display: flex;
  gap: 6px;
  padding: 10px 18px 14px;
  overflow-x: auto;
  border-top: 1px solid var(--rule);
  scrollbar-width: thin;
  scrollbar-color: var(--rule-hi) transparent;
}
.lb-strip button {
  flex: none;
  width: 46px;
  height: 62px;
  padding: 0;
  border: 1px solid var(--rule);
  background: var(--ink-2);
  cursor: pointer;
  overflow: hidden;
  opacity: .45;
  transition: opacity .16s var(--ease), border-color .16s var(--ease);
}
.lb-strip button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb-strip button:hover { opacity: .8; }
.lb-strip button[aria-current="true"] { opacity: 1; border-color: var(--signal); }
.lb-strip button:focus-visible { outline: none; border-color: var(--signal); opacity: 1; }

/* klikbaar frame in het contactvel */
.slot[data-status="done"] .frame { cursor: zoom-in; }
.slot[data-status="done"] .frame:focus-visible { outline: none; border-color: var(--signal); box-shadow: 0 0 0 1px var(--signal); }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .rail { display: none; }
  .masthead, .shell { margin-left: 0; }
  .masthead { padding: 22px 18px 16px; }
  .shell { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--rule); }
  .block, .actions, .actions + .note { padding-left: 18px; padding-right: 18px; }
  .sheet-bar { padding: 12px 18px; position: static; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

  .lightbox { grid-template-columns: 40px 1fr 40px; }
  .lb-nav { font-size: 26px; }
  .lb-meta { padding: 10px 14px; gap: 10px; }
  .lb-strip { padding: 8px 14px 12px; }
  .lb-strip button { width: 38px; height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .slot .frame img { clip-path: inset(0 0 0 0); }
}
