/* Image — zelfde rustige stijl als Go. Navy (#29384B / #E9EDF2) alleen voor de AI-actie. */
@font-face { font-family: "Instrument Sans"; font-weight: 400; font-display: swap; src: url(/fonts/instrument-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 500; font-display: swap; src: url(/fonts/instrument-sans-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 600; font-display: swap; src: url(/fonts/instrument-sans-latin-600-normal.woff2) format("woff2"); }

:root {
  --canvas: #ffffff;
  --sunken: #f2f2ef;
  --line: #e9e9e5;
  --line-strong: #dcdcd6;
  --ink: #1c1c1e;
  --ink-2: #3f3f46;
  --muted: #5d5d66;
  --faint: #8a8a93;
  --accent: #2e2e33;
  --ai: #29384B;
  --ai-hover: #1d2836;
  --ai-soft: #E9EDF2;
  --shadow-card: 0 1px 2px rgb(20 20 30 / 0.04), 0 4px 14px -8px rgb(20 20 30 / 0.09);
  --shadow-raised: 0 2px 6px rgb(20 20 30 / 0.05), 0 16px 40px -12px rgb(20 20 30 / 0.14);
  --radius: 6px;
  font-family: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--canvas); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; }

/* ---------- algemeen ---------- */
.card { background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.help { font-size: 12px; color: var(--faint); margin: 4px 0 0; }
.warn { font-size: 12px; color: #8a5a00; margin: 4px 0 0; }
.error { color: #a32020; font-size: 13px; margin: 0; }
.field { display: block; margin-bottom: 14px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--canvas);
  padding: 7px 10px; outline: none; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(46 46 51 / 0.08); }
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
select:disabled, input:disabled { background: var(--sunken); color: var(--faint); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-strong);
  background: var(--canvas); border-radius: var(--radius); padding: 7px 12px; cursor: pointer; font-weight: 500; white-space: nowrap;
  text-decoration: none; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--sunken); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--ai); border-color: var(--ai); color: #fff; }
.btn.primary:hover { background: var(--ai-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--sunken); color: var(--ink); }
.btn.wide { width: 100%; padding: 10px; }
.btn.small { padding: 4px 8px; font-size: 12px; }

/* ---------- login ---------- */
.login-body { min-height: 100dvh; display: grid; place-items: center; background: var(--sunken); padding: 16px; }
.login { width: min(360px, 100%); padding: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; margin-bottom: 22px; }
.login .error { margin-bottom: 12px; }

/* ---------- kop ---------- */
.top { display: flex; align-items: center; gap: 16px; padding: 12px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--canvas); z-index: 5; }
.top .brand { margin: 0; }
.top .spacer { flex: 1; }
.usage { font-size: 12px; color: var(--muted); }
.usage b { color: var(--ink); font-weight: 600; }

/* ---------- indeling ---------- */
.layout { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 24px; padding: 24px; max-width: 1680px; margin: 0 auto; }
.panel { padding: 18px; align-self: start; position: sticky; top: 76px; max-height: calc(100dvh - 100px); overflow: auto; }
.panel h2, .section-title { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); margin: 0 0 10px; }
.model-desc { font-size: 12px; color: var(--faint); margin: 4px 0 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
details.adv { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; }
details.adv summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 12px; list-style: none; }
details.adv summary::before { content: "▸ "; }
details.adv[open] summary::before { content: "▾ "; }
.size-custom { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; margin-top: 6px; }
.size-custom span { color: var(--faint); }
.submit-row { position: sticky; bottom: -18px; background: var(--canvas); padding: 12px 0 0; margin-top: 4px; }
.estimate { font-size: 12px; color: var(--faint); text-align: center; margin-top: 6px; min-height: 18px; }
.file-opt { display: flex; gap: 8px; align-items: center; }
.file-opt .name { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* referenties */
.drop { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 10px; background: var(--sunken); transition: border-color .12s, background .12s; }
.drop.over { border-color: var(--ai); background: var(--ai-soft); }
.drop .hint { font-size: 12px; color: var(--muted); text-align: center; padding: 8px 4px; cursor: pointer; }
.refs { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.refs:empty { display: none; }
.refs .ref { position: relative; aspect-ratio: 1; border-radius: 4px; overflow: hidden; background: #fff; border: 1px solid var(--line); }
.refs .ref img { width: 100%; height: 100%; object-fit: cover; }
.refs .ref .x { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgb(0 0 0 / .6); color: #fff; cursor: pointer; font-size: 13px; line-height: 20px; padding: 0; }
.refs .ref .no { position: absolute; left: 3px; bottom: 2px; font-size: 10px; color: #fff; background: rgb(0 0 0 / .5); border-radius: 3px; padding: 0 4px; }
.mode { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* ---------- resultaat ---------- */
.stage { padding: 0; overflow: hidden; display: flex; flex-direction: column; min-height: 560px; }
.stage-view { flex: 1; display: grid; place-items: center; background: var(--sunken); position: relative; min-height: 480px;
  background-image: linear-gradient(45deg, #ecece8 25%, transparent 25%), linear-gradient(-45deg, #ecece8 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ecece8 75%), linear-gradient(-45deg, transparent 75%, #ecece8 75%);
  background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0; }
.stage-view img.main { max-width: 100%; max-height: 70dvh; object-fit: contain; cursor: zoom-in; box-shadow: var(--shadow-raised); }
.stage-view img.partial { filter: blur(3px) saturate(.9); transition: filter .4s; cursor: default; }
.empty { color: var(--faint); text-align: center; padding: 40px; }
.stage-bar { border-top: 1px solid var(--line); padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stage-bar .meta { flex: 1; min-width: 200px; font-size: 12px; color: var(--muted); }
.stage-bar .meta .p { color: var(--ink); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.variants { display: flex; gap: 6px; padding: 10px 16px 0; }
.variants img { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; border: 2px solid transparent; cursor: pointer; }
.variants img.on { border-color: var(--ai); }

.progress { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); width: min(420px, 85%); background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-raised); padding: 12px 14px; }
.progress .row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 8px; gap: 12px; }
.progress .row .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 4px; background: var(--sunken); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ai); width: 0; transition: width .9s linear; border-radius: 2px; }
.bar.indet i { width: 30%; animation: indet 1.4s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%) } 100% { transform: translateX(340%) } }
.steps { display: flex; gap: 6px; margin-top: 8px; font-size: 11px; color: var(--faint); flex-wrap: wrap; }
.steps span.on { color: var(--ai); font-weight: 600; }
.steps span.done { color: var(--ink-2); }
.err-box { max-width: 520px; margin: 24px; padding: 14px 16px; background: #fff; border: 1px solid #ecc; border-radius: var(--radius); color: #a32020; }

/* ---------- geschiedenis ---------- */
.history { padding: 0 24px 40px; max-width: 1680px; margin: 0 auto; }
.hist { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.hcard { padding: 0; overflow: hidden; cursor: pointer; position: relative; transition: box-shadow .12s, border-color .12s; }
.hcard:hover { box-shadow: var(--shadow-raised); }
.hcard.on { border-color: var(--ai); }
.hcard .th { aspect-ratio: 1; background: var(--sunken); display: grid; place-items: center; overflow: hidden; }
.hcard .th img { width: 100%; height: 100%; object-fit: cover; }
.hcard .th .state { font-size: 12px; color: var(--faint); padding: 8px; text-align: center; }
.hcard .info { padding: 8px 10px; font-size: 12px; }
.hcard .info .p { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hcard .info .m { color: var(--faint); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hcard .del { position: absolute; top: 6px; right: 6px; opacity: 0; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgb(255 255 255 / .9); cursor: pointer; color: var(--muted); }
.hcard:hover .del { opacity: 1; }
.hcard .count { position: absolute; top: 6px; left: 6px; font-size: 11px; background: rgb(0 0 0 / .55); color: #fff; border-radius: 3px; padding: 0 5px; }
.spin { width: 18px; height: 18px; border: 2px solid var(--line-strong); border-top-color: var(--ai); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 6px; }
@keyframes spin { to { transform: rotate(360deg) } }

/* ---------- volledige weergave ---------- */
.lightbox { position: fixed; inset: 0; background: rgb(18 18 20 / .94); z-index: 50; display: flex; flex-direction: column; }
.lb-top { display: flex; gap: 8px; align-items: center; padding: 10px 14px; color: #ddd; font-size: 13px; }
.lb-top .spacer { flex: 1; }
.lb-top .btn { background: transparent; color: #eee; border-color: #444; }
.lb-top .btn:hover { background: #2a2a2e; }
.lb-view { flex: 1; overflow: hidden; position: relative; cursor: grab; display: grid; place-items: center; }
.lb-view.fit img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-view.real { display: block; overflow: auto; }
.lb-view.real img { max-width: none; max-height: none; margin: 0 auto; }
.lb-view.dragging { cursor: grabbing; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .panel { position: static; max-height: none; }
  .top { padding: 10px 12px; }
  .history { padding: 0 12px 24px; }
  .stage-view { min-height: 320px; }
}
