:root {
  --blauw: #05599F;
  --blauw-diep: #033F73;
  --blauw-zacht: #EAF2FB;
  --groen: #0E9F38;
  --oranje: #FD8A19;
  --oranje-diep: #E8770A;
  --inkt: #17232E;
  --tekst: #2B3A48;
  --grijs: #6B7A89;
  --lijn: #E1E7EE;
  --rand: #D3DCE6;
  --veld: #FBFCFD;
  --vlak: #F1F4F8;
  --let-op: #B4570A;
  --radius: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  font-family: "Roboto Banner", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--tekst);
  background: var(--vlak);
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.card { border: 1px solid var(--lijn); border-radius: var(--radius); background: #fff; }

.eyebrow {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--grijs);
}

/* Bovenbalk */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  color: #fff;
  background: linear-gradient(100deg, #033F73 0%, #05599F 60%, #0A6FC2 100%);
  box-shadow: 0 6px 20px rgba(3, 40, 80, 0.18);
}
.topbar-inner { display: flex; align-items: center; gap: 16px; max-width: 1600px; height: 64px; margin: 0 auto; padding: 0 28px; }
.topbar-logo { width: 64px; height: auto; }
.topbar-divider { width: 1px; height: 28px; background: rgba(255, 255, 255, 0.3); }
.topbar-title { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-title span { font-weight: 300; opacity: 0.85; }
.topbar-link {
  margin-left: auto;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.15s;
}
.topbar-link:hover { background: rgba(255, 255, 255, 0.22); }

/* Studio: templates, voorbeeld en historie links; instellingen rechts (blijft in beeld) */
.studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  grid-template-rows: auto auto 1fr;
  grid-template-areas: "templates panel" "stage panel" "history panel";
  gap: 16px 24px;
  align-items: start;
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 28px 56px;
}

.templates-card { grid-area: templates; padding: 16px; }
.templates { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.template {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 6px 9px;
  border: 1px solid var(--lijn);
  border-radius: 12px;
  font: inherit;
  text-align: left;
  color: inherit;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.template:hover { border-color: #B7CDE3; }
.template:focus-visible { outline: 3px solid rgba(5, 89, 159, 0.35); outline-offset: 2px; }
.template[aria-checked="true"] { border-color: var(--blauw); background: var(--blauw-zacht); box-shadow: inset 0 0 0 1px var(--blauw); }
.template canvas { display: block; width: 100%; height: auto; aspect-ratio: 3 / 1; border-radius: 8px; background: var(--vlak); }
.template-name { padding: 0 4px; font-size: 13px; font-weight: 700; color: var(--inkt); }

.stage {
  grid-area: stage;
  padding: 24px;
  border: 1px solid var(--lijn);
  border-radius: var(--radius);
  background-color: #F7F9FC;
  background-image: radial-gradient(#D6DEE8 1px, transparent 1px);
  background-size: 18px 18px;
}
.stage.dragging { outline: 2px dashed var(--blauw); outline-offset: -10px; }
.artboard { overflow: hidden; border-radius: 6px; box-shadow: 0 1px 2px rgba(15, 40, 70, 0.08), 0 18px 40px rgba(15, 40, 70, 0.18); }
.artboard canvas { display: block; width: 100%; height: auto; }
.artboard canvas.draggable { cursor: grab; touch-action: none; }
.artboard canvas.draggable:active { cursor: grabbing; }
.stage-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; font-size: 13px; color: var(--grijs); }
.chip { padding: 3px 10px; border: 1px solid var(--lijn); border-radius: 999px; font-weight: 500; color: var(--tekst); background: #fff; }

.warnings { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.warnings:empty { display: none; }
.warnings li { padding: 9px 12px; border: 1px solid #FBD3AC; border-radius: 10px; font-size: 13.5px; color: var(--let-op); background: #FFF5EB; }

/* Instellingen: velden scrollen binnen het paneel, downloaden blijft onderaan in beeld */
.panel { grid-area: panel; position: sticky; top: 88px; display: flex; flex-direction: column; max-height: calc(100vh - 112px); overflow: hidden; }
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #C9D4E0 transparent; }
.panel-section { display: flex; flex-direction: column; gap: 14px; padding: 20px 22px; }
.panel-footer { gap: 10px; border-top: 1px solid var(--lijn); box-shadow: 0 -10px 18px -14px rgba(15, 40, 70, 0.35); }
.panel-section + .panel-section { border-top: 1px solid var(--lijn); }
.panel-section .eyebrow { margin: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lang-switch { display: inline-flex; padding: 3px; border: 1px solid var(--lijn); border-radius: 999px; background: var(--vlak); }
.lang {
  min-width: 46px;
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--grijs);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.lang:hover { color: var(--inkt); }
.lang:focus-visible { outline: 3px solid rgba(5, 89, 159, 0.35); outline-offset: 1px; }
.lang[aria-pressed="true"] { color: #fff; background: var(--blauw); box-shadow: 0 1px 3px rgba(15, 40, 70, 0.25); }
.lang-note { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 10px 12px; border: 1px solid #CFE0F2; border-radius: 10px; font-size: 13px; color: var(--blauw-diep); background: var(--blauw-zacht); }
.lang-note p { flex: 1 1 220px; margin: 0; }
.lang-note .btn-link { align-self: baseline; margin: 0; padding: 0; font-size: 13px; }
.fields[inert] { opacity: 0.55; }
.fields { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { display: flex; align-items: baseline; gap: 4px; font-size: 13px; font-weight: 700; color: var(--inkt); }
.opt { font-weight: 400; color: var(--grijs); }
.field-hint { margin: 0; font-size: 12.5px; color: var(--grijs); }
.field-warning { margin: 0; font-size: 12.5px; color: var(--let-op); }

input:not([type="file"]):not([type="range"]) {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--rand);
  border-radius: 10px;
  font: inherit;
  font-size: 15px;
  color: var(--inkt);
  background: var(--veld);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input:not([type="file"]):not([type="range"]):hover { border-color: #BFCCDA; }
input:not([type="file"]):not([type="range"]):focus { outline: none; border-color: var(--blauw); background: #fff; box-shadow: 0 0 0 3px rgba(5, 89, 159, 0.14); }
.has-warning input:not([type="file"]):not([type="range"]),
.has-warning .rich { border-color: #F0A35E; }

/* Tekstveld met B-knop in de hoek, zoals in Word */
.rich {
  position: relative;
  border: 1px solid var(--rand);
  border-radius: 10px;
  background: var(--veld);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.rich:hover { border-color: #BFCCDA; }
.rich:focus-within { border-color: var(--blauw); background: #fff; box-shadow: 0 0 0 3px rgba(5, 89, 159, 0.14); }
.rich-toolbar { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.tool {
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--lijn);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  color: var(--tekst);
  background: #fff;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.tool:hover { border-color: #B7CDE3; background: var(--blauw-zacht); }
.tool:focus-visible { outline: 3px solid rgba(5, 89, 159, 0.35); outline-offset: 1px; }
.tool[aria-pressed="true"] { border-color: var(--blauw); color: #fff; background: var(--blauw); }
.tool-bold { font-weight: 700; }
.tool-green { font-weight: 700; color: var(--groen); }
.tool-green[aria-pressed="true"] { border-color: var(--groen); background: var(--groen); }
.rich-editor {
  min-height: 72px;
  padding: 10px 50px 10px 12px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--inkt);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  outline: none;
}
.rich:has(.tool-green) .rich-editor { padding-right: 116px; }
.base-bold { font-weight: 700; }
.base-light { font-weight: 300; }
.w-bold { font-weight: 700; }
.w-normal { font-weight: 300; }
.w-green { color: var(--groen); }

/* Foto */
.photo-pick {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1.5px dashed #C3D1DF;
  border-radius: 12px;
  background: var(--veld);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.photo-pick:hover { border-color: var(--blauw); background: var(--blauw-zacht); }
.photo-pick:focus-within { outline: 3px solid rgba(5, 89, 159, 0.3); outline-offset: 2px; }
.photo-thumb {
  display: grid;
  flex: none;
  place-items: center;
  width: 72px;
  height: 48px;
  overflow: hidden;
  border-radius: 8px;
  color: #5B7089;
  background: #E4ECF4;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.photo-text strong { font-size: 14px; color: var(--inkt); }
.photo-text span { overflow: hidden; font-size: 12.5px; color: var(--grijs); text-overflow: ellipsis; white-space: nowrap; }
.zoom-value { margin-left: auto; font-weight: 500; color: var(--grijs); }

.slider { --pct: 0%; width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer; appearance: none; -webkit-appearance: none; }
.slider:focus { outline: none; }
.slider::-webkit-slider-runnable-track { height: 4px; border-radius: 999px; background: linear-gradient(to right, var(--blauw) var(--pct), #D9E2EC var(--pct)); }
.slider::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border: 2px solid var(--blauw);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 40, 70, 0.25);
  -webkit-appearance: none;
}
.slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(5, 89, 159, 0.2); }
.slider::-moz-range-track { height: 4px; border-radius: 999px; background: #D9E2EC; }
.slider::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--blauw); }
.slider::-moz-range-thumb { width: 14px; height: 14px; border: 2px solid var(--blauw); border-radius: 50%; background: #fff; }

/* Knoppen */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 20px;
  border: 0;
  border-radius: 11px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgba(5, 89, 159, 0.35); outline-offset: 2px; }
.btn-primary { width: 100%; color: #fff; background: var(--oranje); box-shadow: 0 6px 16px rgba(253, 138, 25, 0.3); }
.btn-primary:hover { background: var(--oranje-diep); }
.btn-secondary { border: 1px solid #C7D6E6; color: var(--blauw); background: #fff; }
.btn-secondary:hover { background: var(--blauw-zacht); }
.btn-link {
  align-self: center;
  margin-top: -6px;
  padding: 2px 6px;
  border: 0;
  font: inherit;
  font-size: 13.5px;
  color: var(--blauw);
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  cursor: pointer;
}
.btn-link:hover { color: var(--blauw-diep); }
.message { margin: 0; font-size: 13.5px; text-align: center; color: var(--blauw-diep); }
.message:empty { display: none; }

/* Historie */
.history { grid-area: history; padding-top: 12px; }
.history-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 16px; }
.history-head h2 { margin: 0; font-size: 20px; font-weight: 700; color: var(--inkt); }
.history-status { margin: 0; font-size: 14px; color: var(--grijs); }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.history-grid:empty { display: none; }
.history-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--lijn);
  border-radius: 14px;
  background: #fff;
  transition: box-shadow 0.15s, transform 0.15s;
}
.history-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(15, 40, 70, 0.12); }
.history-thumb { position: relative; display: block; }
.history-thumb img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 1; object-fit: contain; background: var(--vlak); }
.history-thumb::after {
  content: "Openen";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: rgba(3, 40, 80, 0.45);
  opacity: 0;
  transition: opacity 0.15s;
}
.history-thumb:hover::after,
.history-thumb:focus-visible::after { opacity: 1; }
.history-body { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px 14px; }
.history-text { flex: 1; min-width: 0; }
.history-text h3 {
  display: -webkit-box;
  overflow: hidden;
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--inkt);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.history-meta { margin: 0; font-size: 12.5px; color: var(--grijs); }
.history-download {
  flex: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--blauw);
  text-decoration: none;
  background: var(--blauw-zacht);
  transition: background 0.15s;
}
.history-download:hover { background: #D6E7F8; }
.more { display: flex; margin: 20px auto 0; }

@media (max-width: 1100px) {
  .studio { grid-template-columns: 1fr; grid-template-rows: none; grid-template-areas: "templates" "stage" "panel" "history"; }
  .panel { position: static; max-height: none; }
  .panel-scroll { overflow: visible; }
}

@media (max-width: 640px) {
  .topbar-inner,
  .studio { padding-left: 14px; padding-right: 14px; }
  .topbar-divider,
  .topbar-title span { display: none; }
  .topbar-link { padding: 6px 10px; font-size: 13px; }
  .templates { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { padding: 14px; }
}
