:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1b1f24;
  --muted: #667085;
  --border: #e3e6ea;
  --accent: #ea6b16;
  --accent-text: #ffffff;
  --accent-soft: #fdeee3;
  --danger: #c62828;
  --ok: #2e7d32;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
/* Donker: volgt het systeem, tenzij de beheerder een vast thema kiest (data-theme op <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121417;
    --panel: #1b1e23;
    --text: #e8eaed;
    --muted: #9aa3ae;
    --border: #2c3138;
    --accent: #f07c2e;
    --accent-soft: #3a2618;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #121417;
  --panel: #1b1e23;
  --text: #e8eaed;
  --muted: #9aa3ae;
  --border: #2c3138;
  --accent: #f07c2e;
  --accent-soft: #3a2618;
  --shadow: none;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: .2em 0 .4em; line-height: 1.25; }
h2 { font-size: 1.2rem; margin: 1.8em 0 .6em; }
h3 { font-size: 1rem; margin: 1.2em 0 .4em; }
img { max-width: 100%; display: block; }
.wrap { max-width: var(--wrap, 1240px); margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.icon { width: 1.1em; height: 1.1em; vertical-align: -.18em; flex: none; }
.icon.big { width: 48px; height: 48px; }
.icon.huge { width: 96px; height: 96px; }

/* topbar */
.topbar { background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; color: var(--text); }
.brand .icon { color: var(--accent); width: 26px; height: 26px; }
.search { flex: 1; max-width: 520px; }
.search input { width: 100%; }
.nav { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.menu { position: relative; }
.menu summary { cursor: pointer; list-style: none; padding: 6px 10px; border-radius: calc(var(--radius) * .8); border: 1px solid var(--border); }
.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .15); min-width: 190px; padding: 6px; display: grid; }
.menu-list a, .menu-list button { padding: 8px 10px; border-radius: 6px; color: var(--text); text-align: left; }
.menu-list a:hover, .menu-list button:hover { background: var(--bg); text-decoration: none; }

/* forms */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border);
  border-radius: calc(var(--radius) * .8); padding: 8px 10px; width: 100%;
}
input[type=checkbox] { width: auto; }
input[type=file] { padding: 6px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: grid; gap: 4px; font-weight: 500; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0; display: grid; gap: 12px; background: var(--panel); }
legend { font-weight: 600; padding: 0 6px; }
.stack { display: grid; gap: 12px; }
.form-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.inline-form input:not([type=checkbox]) { flex: 1 1 200px; width: auto; }
.error { background: #fdecea; color: var(--danger); padding: 10px 12px; border-radius: calc(var(--radius) * .8); }
.ok { background: #e8f5e9; color: var(--ok); padding: 10px 12px; border-radius: calc(var(--radius) * .8); }
.notice { border: 1px solid var(--border); border-left: 4px solid var(--accent); background: var(--panel); padding: 10px 14px; border-radius: calc(var(--radius) * .8); margin-bottom: 16px; }
.notice ul { margin: 6px 0 0; padding-left: 20px; overflow-wrap: anywhere; }
.zip-drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 12px 14px; }
.zip-drop:hover, .zip-drop:focus-within { border-color: var(--accent); }
.confirm-dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: 18px 20px; max-width: min(420px, calc(100% - 32px)); }
.confirm-dialog::backdrop { background: rgb(0 0 0 / .4); }
.confirm-dialog p { margin: 0 0 14px; }
.confirm-dialog .form-actions { justify-content: flex-end; }
.live-toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px); box-shadow: 0 4px 16px rgb(0 0 0 / .18); }
[aria-busy=true] [data-live] { cursor: progress; }
.danger-zone { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); }
.existing { display: grid; gap: 4px; }

.btn, button.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: calc(var(--radius) * .8);
  border: 1px solid var(--border); background: var(--panel); color: var(--text); font: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-small { padding: 4px 9px; font-size: .85rem; }
.btn.liked { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn.liked .icon { fill: currentColor; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.linklike.danger { color: var(--danger); }
form { margin: 0; }

/* browse */
.browse { display: grid; grid-template-columns: 220px 1fr; gap: 28px; margin-top: 24px; }
.sidebar { display: grid; align-content: start; gap: 2px; }
.sidebar h4 { margin: 0 0 6px; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sidebar h4:not(:first-child) { margin-top: 18px; }
.sidebar > a { color: var(--text); padding: 5px 10px; border-radius: 6px; display: flex; justify-content: space-between; gap: 8px; }
.sidebar > a:hover { background: var(--panel); text-decoration: none; }
.sidebar > a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.sort select { width: auto; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--panel); border: 1px solid var(--border); padding: 2px 9px; border-radius: 999px; font-size: .82rem; color: var(--text); }
.tag:hover { border-color: var(--accent); text-decoration: none; }

/* Hooguit --cols kaarten per rij (instelbaar bij Beheer → Layout), minder op smalle schermen. */
.grid { display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(max(180px, calc((100% - (var(--cols, 5) - 1) * 16px) / var(--cols, 5))), 1fr)); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  color: var(--text); display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.card-img { aspect-ratio: 4 / 3; background: var(--bg); }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.placeholder { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); background: var(--bg); }
.placeholder.tall { aspect-ratio: 4 / 3; border-radius: var(--radius); border: 1px solid var(--border); }
.card-body { padding: 10px 12px 12px; }
.card-body h3 { margin: 0 0 2px; font-size: .98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-wrap { display: grid; gap: 4px; }
.stats { display: flex; gap: 14px; color: var(--muted); flex-wrap: wrap; }
.stats span { display: inline-flex; align-items: center; gap: 4px; }
.card .stats { margin-top: 6px; }
.big-stats { margin: 10px 0 20px; gap: 24px; }
.empty { color: var(--muted); padding: 30px; text-align: center; background: var(--panel); border: 1px dashed var(--border); border-radius: var(--radius); }
.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin: 24px 0; }

/* model */
.model { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 28px; margin-top: 24px; }
.model-media { display: grid; gap: 14px; align-content: start; }
.model-side { align-self: start; }
.model-main { grid-column: 1; }
.lead { font-size: 1.05rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.gallery { display: grid; gap: 8px; }
#gallery-main { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); }
.thumbs { display: flex; gap: 8px; overflow-x: auto; }
.thumb { padding: 0; border: 2px solid transparent; border-radius: calc(var(--radius) * .8); overflow: hidden; width: 76px; height: 57px; flex: none; cursor: pointer; background: none; }
.thumb.active { border-color: var(--accent); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.viewer { position: relative; aspect-ratio: 4 / 3; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(circle at 50% 35%, var(--panel), var(--bg)); }
.viewer-canvas, .viewer-canvas canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.viewer-overlay { position: absolute; inset: 0; display: grid; place-items: center; }
.viewer.loaded .viewer-overlay { display: none; }
.viewer-status { position: absolute; left: 10px; bottom: 8px; pointer-events: none; }
.viewer[hidden] { display: none; }
.viewer.pdf { aspect-ratio: auto; height: min(85vh, 1000px); background: var(--panel); }
.viewer-pdf { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.viewer.pdf .viewer-canvas, .viewer.pdf .viewer-status { display: none; }
.collect { margin: 10px 0; }
.collect summary { list-style: none; }
.collect summary::-webkit-details-marker { display: none; }
.collect form { margin-top: 10px; max-width: 320px; }
.kv { border-collapse: collapse; width: 100%; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.kv th, .kv td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--border); }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: 0; }
.kv th { color: var(--muted); font-weight: 500; width: 40%; }
.prose p { margin: 0 0 .8em; overflow-wrap: anywhere; }
.files { list-style: none; padding: 0; margin: 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.files li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.files li:last-child { border-bottom: 0; }
.files li.viewable { cursor: pointer; transition: background .15s; }
.files li.viewable:hover { background: var(--accent-soft); }
.files li.viewable.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.file-ext { font-size: .7rem; font-weight: 700; background: var(--accent-soft); color: var(--accent); padding: 2px 6px; border-radius: 4px; min-width: 44px; text-align: center; }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.more-list.collapsed .extra { display: none; }
.more-list.collapsed .files li:nth-last-child(1 of :not(.extra)) { border-bottom: 0; }
.more-btn { display: block; margin: 6px 0 0; padding: 4px 2px; background: none; border: 0; color: var(--accent); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; }
.more-btn:hover { text-decoration: underline; }
.makes { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.make { margin: 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.make img { aspect-ratio: 1; object-fit: cover; width: 100%; }
.make figcaption { padding: 6px 10px 8px; font-size: .85rem; }
.comments { display: grid; gap: 10px; margin-bottom: 12px; }
.comment { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.comment-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 4px; }
.comment-head form { margin-left: auto; }

/* profile / auth / admin */
.profile-head { display: flex; gap: 18px; align-items: center; margin: 28px 0 10px; }
.avatar { width: 72px; height: 72px; border-radius: 50%; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-size: 2rem; font-weight: 700; flex: none; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 10px 0 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.auth { max-width: 440px; margin: 40px auto; }
.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); }
.table th, .table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table td form { display: inline; margin-right: 10px; }
.admin-edit td { vertical-align: middle; }
.admin-edit input { padding: 5px 8px; }
.admin-edit input.narrow { width: 80px; }
.admin-edit select { padding: 5px 8px; }
.category-table tr.subcategory td:first-child { padding-left: 32px; position: relative; }
.category-table tr.subcategory td:first-child::before { content: '↳'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.sidebar a.subcategory { padding-left: 24px; font-size: .92em; }

/* printers */
.printers { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-bottom: 20px; }
.printer-card { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); }
.printer-actions { display: grid; gap: 4px; justify-items: end; align-content: start; }
.printer-form { max-width: 520px; }
.back-link { margin: 0 0 16px; }
.footer { color: var(--muted); font-size: .85rem; padding: 40px 16px 30px; text-align: center; }

@media (max-width: 860px) {
  .browse { grid-template-columns: 1fr; }
  .sidebar { display: flex; flex-wrap: wrap; gap: 6px; }
  .sidebar h4 { width: 100%; }
  .sidebar > a { border: 1px solid var(--border); background: var(--panel); }
  .model { grid-template-columns: 1fr; }
  .model-main { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .nav .btn span { display: none; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .table { display: block; overflow-x: auto; }
}

/* uploadformulier: printinstellingen */
.printer-details { display: grid; gap: 12px; padding: 12px; border-left: 3px solid var(--accent); background: var(--bg); border-radius: 0 8px 8px 0; }
.printer-details[hidden], label[data-subcategory][hidden] { display: none; }
.field { display: grid; gap: 4px; }
.field-label { font-weight: 500; }
.time-pick { display: flex; align-items: center; gap: 8px; }
.time-pick select { width: auto; min-width: 72px; }
.suffix-input { display: flex; align-items: center; gap: 8px; }
.suffix-input input { width: 110px; }

/* tags als blokjes */
.tag-input { display: block; }
.tag-input.tag-input-active { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; cursor: text;
  background: var(--panel); border: 1px solid var(--border); border-radius: calc(var(--radius) * .8); font-weight: 400; }
.tag-input.tag-input-active:focus-within { outline: 2px solid var(--accent); outline-offset: -1px; }
.tag-input-active input[type=text] { flex: 1 1 120px; width: auto; border: 0; padding: 4px 2px; background: transparent; outline: none; }
.tag-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 999px;
  background: var(--accent); color: var(--accent-text); font-size: .9em; }
.tag-chip button { background: none; border: 0; color: inherit; cursor: pointer; font: inherit; line-height: 1; padding: 0 6px; border-radius: 999px; }
.tag-chip button:hover { background: rgba(0, 0, 0, .2); }

/* beheer */
.admin-tabs { margin-bottom: 22px; }
.jump-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.jump-links a { padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: .85em; color: var(--muted); }
.jump-links a:hover { color: var(--text); border-color: var(--accent); text-decoration: none; }
.color-pick { display: flex; align-items: center; gap: 10px; }
.color-pick input[type=color] { width: 56px; height: 38px; padding: 3px; cursor: pointer; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--border); cursor: pointer; padding: 0; }
.swatch:hover { box-shadow: 0 0 0 2px var(--text); }
.design-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; background: var(--panel);
  border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- uploadoverlay met 3D-printer ---------- */
.upload-overlay { border: 0; padding: 0; background: transparent; max-width: none; max-height: none; overflow: visible; color: var(--text); }
.upload-overlay::backdrop { background: rgb(8 10 14 / .55); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: up-fade .25s ease-out; }
.upload-card { width: min(340px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--border); border-radius: calc(var(--radius) * 1.6);
  padding: 22px 24px 18px; text-align: center; box-shadow: 0 24px 60px rgb(0 0 0 / .35); animation: up-pop .35s cubic-bezier(.2, .9, .3, 1.2); }
.upload-card h2 { font-size: 1.05rem; margin: 6px 0 12px; }
.upload-card [hidden] { display: none; }
.upload-meta { margin: 8px 0 12px; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.upload-meta strong { color: var(--text); margin-right: 4px; }
.upload-bar { height: 6px; border-radius: 99px; background: var(--accent-soft); overflow: hidden; }
.upload-bar span { display: block; height: 100%; width: 0; border-radius: inherit; transition: width .3s ease-out;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #fff)); }
.is-processing .upload-bar span { width: 100% !important; background-size: 200% 100%; animation: up-shimmer 1.2s linear infinite;
  background-image: linear-gradient(90deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 50%, #fff) 50%, var(--accent) 100%); }

.printer { width: 230px; height: auto; display: block; margin: 4px auto 0; overflow: visible; }
.upload-card { background-image: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%); }
.printer .frame { fill: color-mix(in srgb, var(--text) 22%, var(--panel)); }
.printer .bed { fill: color-mix(in srgb, var(--text) 45%, var(--panel)); }
.printer .rail { fill: color-mix(in srgb, var(--text) 35%, var(--panel)); }
.printer .carriage { fill: color-mix(in srgb, var(--text) 70%, var(--panel)); }
.printer .fan { fill: var(--panel); opacity: .35; }
.printer .nozzle { fill: #c9a227; }
.printer .hot { fill: var(--accent); filter: drop-shadow(0 0 3px var(--accent)); animation: up-glow .5s ease-in-out infinite alternate; }
.printer .ghost { fill: color-mix(in srgb, var(--accent) 7%, transparent); stroke: color-mix(in srgb, var(--accent) 55%, var(--panel)); stroke-width: 1; stroke-dasharray: 3 3; }
.printer .print { filter: drop-shadow(0 0 4px color-mix(in srgb, var(--accent) 45%, transparent)); }
.printer .layer-fill { fill: var(--accent); }
.printer .layer-line { fill: rgb(0 0 0 / .18); }
.printer .spool-ring { fill: none; stroke: var(--accent); stroke-width: 5; opacity: .85; }
.printer .spool-spoke { stroke: color-mix(in srgb, var(--text) 22%, var(--panel)); stroke-width: 2; }
.printer .spool-spin { animation: up-spin 2.4s linear infinite; }
.printer .gantry { transition: transform .35s ease-out; }
.printer .head { animation: up-head 1.1s ease-in-out infinite alternate; }
.is-processing .printer .head { animation-duration: .6s; }
.is-done .printer .print { animation: up-done .6s ease-out; }

@keyframes up-head { from { transform: translateX(78px); } to { transform: translateX(122px); } }
@keyframes up-spin { to { transform: rotate(360deg); } }
@keyframes up-glow { from { opacity: .45; } to { opacity: 1; } }
@keyframes up-shimmer { to { background-position: -200% 0; } }
@keyframes up-fade { from { opacity: 0; } }
@keyframes up-pop { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes up-done { 50% { filter: brightness(1.35); } }
.zip-all { margin: 4px 0 18px; }
