:root {
  --bg: #f3f3f1;
  --card: #ffffff;
  --text: #17171a;
  --muted: #6b6b70;
  --line: #e2e2df;
  --brand: #f5b000;
  --brand-ink: #111;
  --danger: #c62828;
  --ok: #2e7d32;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --card: #1c1c1f;
    --text: #f1f1f1;
    --muted: #9a9aa0;
    --line: #2e2e33;
  }
}
* { box-sizing: border-box; }
/* Niets mag de pagina breder maken dan het scherm (clip houdt de sticky bovenbalk werkend) */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: hidden; }
body { overflow-x: hidden; }
@supports (overflow: clip) { html, body { overflow-x: clip; } }
img, canvas, video, iframe, table, pre { max-width: 100%; }
pre { white-space: pre-wrap; }
body {
  margin: 0; width: 100%; position: relative;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2 { margin: 0 0 6px; line-height: 1.2; }
h2 { font-size: 1.15rem; display: flex; align-items: center; gap: 10px; }
.muted { color: var(--muted); margin: 0 0 12px; }
.small { font-size: .85rem; }
.error { color: var(--danger); }

.step {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand); color: var(--brand-ink);
  font-size: .85rem; font-weight: 700;
}

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px; background: #111; color: #fff;
}
.topbar-logo { height: 34px; }
.topbar-link { margin-left: auto; color: #bbb; font-size: .9rem; text-decoration: none; padding: 6px 4px; }
.topbar-link.out { margin-left: 4px; text-decoration: underline; }
a.topbar-link[href="#instellingen"] { font-size: 1.15rem; line-height: 1; }
.tabs { display: flex; gap: 4px; margin-left: 8px; }
.tabs a { color: #bbb; text-decoration: none; font-weight: 600; font-size: .9rem; padding: 6px 10px; border-radius: 8px; }
.tabs a.on { background: var(--brand); color: var(--brand-ink); }
@media (max-width: 520px) {
  .wrap { padding: 12px; }
  .card { padding: 14px; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .stat { padding: 8px 10px; }
  .stat b { font-size: 1.15rem; }
  .stat span { font-size: .72rem; }
}

/* menubalk onderin op mobiel; bovenin dan alleen logo en titel */
.bottomnav { display: none; }
@media (max-width: 720px) {
  .tabs, .topbar-link { display: none; }
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(88px + env(safe-area-inset-bottom)); }
  .bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; width: 100%;
    transform: translateZ(0);
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
    background: var(--card); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 16px rgba(0,0,0,.06);
  }
  .bottomnav a {
    display: grid; justify-items: center; gap: 2px;
    color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600;
    padding: 4px 0; -webkit-tap-highlight-color: transparent;
  }
  .bottomnav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .bottomnav a.on { color: var(--text); }
  .bottomnav a.on svg { stroke-width: 2.3; }
  .bottomnav a.on::after { content: ""; width: 18px; height: 3px; border-radius: 2px; background: var(--brand); }
  .bottomnav .fab { margin-top: -26px; }
  .bottomnav .fab-circle {
    display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%;
    background: var(--brand); color: var(--brand-ink); box-shadow: 0 4px 12px rgba(0,0,0,.18);
  }
  .bottomnav .fab-circle svg { stroke-width: 2.6; }
  .bottomnav .fab.on::after { display: none; }
}

/* overzicht */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 12px 0; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 1.4rem; line-height: 1.1; }
.stat span { font-size: .8rem; color: var(--muted); }
.list-filters { margin-bottom: 8px; }
.list-filters input { flex: 1; min-width: 180px; width: auto; }
.list-filters .seg { flex-wrap: wrap; }
.list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.item { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.item img, .item .noimg { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; background: var(--bg); }
.item .noimg { display: grid; place-items: center; font-size: .7rem; color: var(--muted); text-align: center; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-meta { font-size: .82rem; color: var(--muted); margin: 2px 0 6px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.item-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.item-actions a { text-decoration: none; }
.e-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-bottom: 14px; }
.e-img { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.e-img img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--bg); }
.e-img .row { gap: 4px; padding: 4px; justify-content: center; }
.e-img .btn.small { min-height: 32px; min-width: 32px; padding: 4px 6px; }
.e-img.main { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.badge.draft { background: #fff1c2; color: #6b4e00; }
.badge.live { background: var(--ok); color: #fff; }
.badge.sold { background: var(--danger); color: #fff; }
.badge.studio { background: #111; color: var(--brand); }

.wrap { max-width: 880px; margin: 0 auto; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.wrap > *, .grid2 > *, label { min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; overflow-wrap: anywhere; }
.preview > div { overflow-x: auto; }
.preview img, .preview table { max-width: 100%; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; display: grid; gap: 12px; text-align: center; }
.login-logo { width: 160px; margin: 0 auto; }

label { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; font-size: .9rem; font-weight: 600; margin-bottom: 10px; }
/* 16px voorkomt dat iPhones inzoomen bij het aantikken van een veld */
input, select, textarea {
  font: inherit; font-size: 16px; font-weight: 400; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 12px; }
.row.end .muted { margin: 0 auto 0 0; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 10px 16px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: .85rem; }
.file-btn { margin: 0; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; border: 0; background: transparent; color: var(--text); padding: 10px 14px; cursor: pointer; }
.seg button.on { background: var(--text); color: var(--card); }

.photos { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-top: 12px; }
.photo { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; min-width: 0; }
[hidden] { display: none !important; }
.photo-canvas { position: relative; background: #ddd; aspect-ratio: 1 / 1; }
.photo-canvas canvas, .photo-canvas img { width: 100%; height: 100%; display: block; object-fit: contain; }
.photo-busy {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(0,0,0,.45); color: #fff; font-weight: 600; text-align: center; padding: 12px;
}
.photo-tools { padding: 10px 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.photo-tools .row { gap: 8px; }
.photo-tools select { width: auto; flex: 1; padding: 8px 10px; }
.slider select { width: 100%; min-width: 0; }
.slider { display: grid; grid-template-columns: 90px minmax(0, 1fr); align-items: center; gap: 8px; font-size: .85rem; font-weight: 500; margin: 0; }
.slider input { padding: 0; accent-color: var(--brand); background: none; border: 0; }
.badge { font-size: .75rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--line); }
.badge.ok { background: var(--ok); color: #fff; }
.v-pos { font-weight: 700; margin-right: 2px; }
.v-up, .v-down { min-width: 40px; font-size: 1rem; }
.filename { font-size: .8rem; color: var(--muted); word-break: break-all; }

.count { font-weight: 400; color: var(--muted); font-size: .8rem; }
.count.over { color: var(--danger); }
.preview { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; }
.preview summary { cursor: pointer; font-weight: 600; }
.result { margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--bg); }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: #111; color: #fff; padding: 10px 16px; border-radius: 10px;
  max-width: calc(100% - 32px); z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}

/* retoucheren */
.editor {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column;
  background: #111; color: #eee;
}
.ed-bar { padding: 10px 16px 4px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; background: #1b1b1e; }
.ed-bar .btn { background: #2a2a2e; color: #eee; border-color: #3a3a40; }
.ed-bar .seg { border-color: #3a3a40; }
.ed-bar .seg button { color: #eee; }
.ed-bar .seg button.on { background: var(--brand); color: #111; }
.ed-bar .slider { color: #ccc; }
.ed-hint { margin: 0; font-size: .8rem; color: #999; }
.ed-stage { flex: 1; overflow: auto; position: relative; touch-action: none; }
.ed-inner { position: relative; margin: 0 auto; }
.ed-inner canvas { display: block; width: 100%; height: auto; touch-action: none; }
.ed-cursor {
  position: absolute; display: none; pointer-events: none;
  border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 1px #000;
}
.ed-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #1b1b1e;
}
.ed-foot .btn:not(.primary) { background: #2a2a2e; color: #eee; border-color: #3a3a40; }

/* kenteken / RDW */
.row.nowrap { flex-wrap: nowrap; }
.row.nowrap input { flex: 1; min-width: 0; }
.rdw { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: var(--bg); border-left: 4px solid var(--brand); font-size: .9rem; }
.rdw strong { display: block; margin-bottom: 2px; }
.rdw .warn { color: var(--danger); font-weight: 600; }
.rdw.err { border-left-color: var(--danger); }
