:root {
  --rood: #bb0909;
  --rood-hover: #910909;
  --inkt: #17171a;
  --inkt-zacht: #4f4f51;
  --inkt-licht: #6f6f71;
  --lijn: #d5d5d6;
  --mist: #f3f5f7;
  --mist-2: #e6eaf0;
  --wit: #fff;
  --focus: 0 0 0 3px rgba(187, 9, 9, .35);
  --zijbalk: 400px;
  font-family: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--inkt);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--mist); font-size: 15px; line-height: 1.45; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); }
a { color: var(--rood); }

/* ---------- losse pagina's (inloggen) ---------- */
body.los { display: grid; place-items: center; padding: 24px; min-height: 100%; }
.kaart { background: var(--wit); border: 1px solid var(--lijn); border-radius: 12px; padding: 32px; max-width: 440px; width: 100%; box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05); }
.kaart h1 { font-size: 22px; margin: 0 0 12px; letter-spacing: -.01em; }
.merk { margin: 0 0 20px; font-size: 13px; font-weight: 600; color: var(--rood); text-transform: uppercase; letter-spacing: .06em; }
.kaart label { display: block; font-weight: 600; margin: 16px 0 6px; }
.kaart input { width: 100%; padding: 10px 12px; border: 1px solid var(--lijn); border-radius: 8px; background: var(--wit); }
.kaart button, .knop { display: inline-flex; align-items: center; justify-content: center; gap: 6px; margin-top: 16px; padding: 10px 16px; border: 0; border-radius: 8px; background: var(--rood); color: var(--wit); font-weight: 600; cursor: pointer; }
.kaart button:hover, .knop:hover { background: var(--rood-hover); }
.kaart button:disabled, .knop:disabled { background: var(--inkt-licht); cursor: not-allowed; }
.zacht { color: var(--inkt-zacht); font-size: 14px; }
.melding { background: var(--mist); border-left: 3px solid var(--rood); padding: 10px 12px; border-radius: 4px; }

/* ---------- portaal ---------- */
.portaal { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.kopbalk { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 52px; background: var(--wit); border-bottom: 1px solid var(--lijn); }
.kopbalk h1 { font-size: 16px; margin: 0; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.kopbalk .merkje { color: var(--rood); font-weight: 700; }
.kopbalk .ruimte { flex: 1; }
.kopbalk .wie { color: var(--inkt-zacht); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.licht { background: none; border: 1px solid var(--lijn); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.licht:hover { background: var(--mist); }
.tabs { display: none; }

.werkvlak { display: grid; grid-template-columns: minmax(0, 1fr) var(--zijbalk); min-height: 0; }
.blad { position: relative; min-width: 0; min-height: 0; background: #dfe3e8; }
.blad iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.vernieuwd { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 2; display: flex; align-items: center; gap: 10px; background: var(--inkt); color: var(--wit); padding: 8px 8px 8px 14px; border-radius: 999px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.vernieuwd button { background: var(--wit); color: var(--inkt); border: 0; border-radius: 999px; padding: 4px 12px; font-weight: 600; cursor: pointer; }
.vernieuwd[hidden] { display: none; }

/* ---------- chat ---------- */
.chat { display: grid; grid-template-rows: auto 1fr auto auto; min-height: 0; min-width: 0; background: var(--wit); border-left: 1px solid var(--lijn); }
.chat-kop { padding: 12px 16px 10px; border-bottom: 1px solid var(--lijn); }
.chat-kop h2 { font-size: 15px; margin: 0; }
.chat-kop p { margin: 2px 0 0; font-size: 13px; color: var(--inkt-zacht); }
.berichten { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; overscroll-behavior: contain; }
.leeg { color: var(--inkt-zacht); font-size: 14px; background: var(--mist); border-radius: 10px; padding: 14px; }
.leeg p { margin: 0; }
.leeg ul { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.leeg button { display: block; width: 100%; background: var(--wit); border: 1px solid var(--lijn); border-radius: 8px; padding: 8px 10px; color: var(--inkt); cursor: pointer; text-align: left; font-size: 14px; }
.leeg button:hover { border-color: var(--rood); color: var(--rood); }
.msg { max-width: 92%; display: flex; flex-direction: column; gap: 3px; }
.msg .van { font-size: 12px; color: var(--inkt-licht); }
.msg .tekst { padding: 9px 12px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.eigen { align-self: flex-end; align-items: flex-end; }
.msg.eigen .tekst { background: var(--inkt); color: var(--wit); border-bottom-right-radius: 4px; }
.msg.ander .tekst { background: var(--mist-2); border-bottom-left-radius: 4px; }
.msg.agent .tekst { background: var(--mist); border: 1px solid var(--mist-2); border-bottom-left-radius: 4px; white-space: normal; }
.msg.agent .van { color: var(--rood); font-weight: 600; }
.msg .stand { font-size: 12px; color: var(--inkt-licht); }
.msg .stand.fout { color: var(--rood); }
.tekst p { margin: 0 0 8px; }
.tekst p:last-child, .tekst ul:last-child, .tekst ol:last-child { margin-bottom: 0; }
.tekst ul, .tekst ol { margin: 0 0 8px; padding-left: 20px; }
.tekst li > p { margin: 0 0 2px; }
.tekst .kop { font-weight: 700; margin: 4px 0 6px; }
.tekst code, .tekst pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: rgba(0,0,0,.05); border-radius: 4px; }
.tekst code { padding: 1px 4px; }
.tekst pre { padding: 8px; overflow-x: auto; white-space: pre; margin: 0 0 8px; }
.tekst blockquote { margin: 0 0 8px; padding-left: 10px; border-left: 3px solid var(--lijn); color: var(--inkt-zacht); }

.status { padding: 8px 16px; font-size: 13px; color: var(--inkt-zacht); border-top: 1px solid var(--lijn); display: flex; align-items: center; gap: 8px; min-height: 36px; }
.status .punt { width: 8px; height: 8px; border-radius: 50%; background: var(--inkt-licht); flex: none; }
.status.bezig .punt { background: var(--rood); animation: puls 1.4s ease-in-out infinite; }
@keyframes puls { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .status.bezig .punt { animation: none; } .berichten { scroll-behavior: auto; } }

.invoer { padding: 10px 12px 12px; border-top: 1px solid var(--lijn); }
.invoer form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.invoer textarea { resize: none; min-height: 44px; max-height: 180px; padding: 10px 12px; border: 1px solid var(--lijn); border-radius: 10px; background: var(--wit); line-height: 1.4; }
.invoer button { height: 44px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--rood); color: var(--wit); font-weight: 600; cursor: pointer; }
.invoer button:hover { background: var(--rood-hover); }
.invoer button:disabled { background: var(--inkt-licht); cursor: default; }
.invoer .uitleg { margin: 6px 2px 0; font-size: 12px; color: var(--inkt-licht); }
.invoer .fout { margin: 6px 2px 0; font-size: 13px; color: var(--rood); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 1100px) { :root { --zijbalk: 340px; } }
@media (max-width: 760px) {
  .kopbalk { gap: 8px; padding: 0 10px; }
  .kopbalk .wie, .kopbalk .merkje { display: none; }
  .kopbalk h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .tabs { display: flex; gap: 4px; }
  .tabs button { border: 1px solid var(--lijn); background: var(--wit); border-radius: 8px; padding: 6px 12px; font-size: 14px; cursor: pointer; }
  .tabs button[aria-selected="true"] { background: var(--inkt); color: var(--wit); border-color: var(--inkt); }
  .werkvlak { grid-template-columns: minmax(0, 1fr); }
  .werkvlak[data-tab="model"] .chat { display: none; }
  .werkvlak[data-tab="chat"] .blad { display: none; }
  .chat { border-left: 0; }
}
