:root {
  --bg: #121316;
  --panel: #191b1f;
  --panel-2: #20232a;
  --line: #2c3038;
  --text: #e8e6e3;
  --muted: #8d939e;
  --accent: #6ea8ff;
  --accent-ink: #0d1726;
  --danger: #ef6f6c;
  --ok: #62c58a;
  --board: #1b1d21;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; font-weight: 600; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
a { color: var(--accent); }

button, .button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .button:hover { border-color: #3d424d; }
button:disabled { opacity: .45; cursor: default; }
button.primary, .button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
button.on { background: #3a2a2a; border-color: var(--danger); }
button.link { background: none; border: 0; padding: 2px 4px; color: var(--muted); }
button.link:hover { color: var(--text); }
input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.badge { background: var(--danger); color: #fff; border-radius: 99px; padding: 0 6px; font-size: 12px; }

/* ---------- Inloggen ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  display: flex; flex-direction: column; gap: 14px;
}
.card h1 { font-size: 26px; }
.card .sub { margin: -6px 0 4px; color: var(--muted); }
.card label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.card input { color: var(--text); }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 250px 1fr; height: 100%; }
.side {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 16px;
  display: flex; flex-direction: column; gap: 22px;
  min-height: 0; overflow-y: auto;
}
.brand { font-size: 20px; font-weight: 700; }
.side section { display: flex; flex-direction: column; gap: 10px; }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.people li { display: flex; align-items: center; gap: 8px; }
.people .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.in-voice { box-shadow: 0 0 0 3px #62c58a33; }
.tag { font-size: 13px; }
.dot.off { background: none; border: 1.5px solid var(--muted); }
.people .offline { color: var(--muted); }
.people .offline-head { font-size: 12px; color: var(--muted); margin-top: 6px; text-transform: uppercase; letter-spacing: .06em; }
.voice .row { flex-wrap: wrap; }
.voice .row button { flex: 1; }
.side-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; color: var(--muted); font-size: 14px; }
.side-foot #me-name { width: 100%; color: var(--text); font-weight: 600; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabs { display: flex; gap: 4px; padding: 10px 14px 0; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-radius: 8px 8px 0 0; background: none; color: var(--muted); padding: 9px 14px; position: relative; }
.tabs button.active { background: var(--panel); color: var(--text); }
.tabs button.unread::after { content: ""; position: absolute; top: 7px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }

/* ---------- Chat ---------- */
.messages { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: min(720px, 92%); }
.msg .meta { display: flex; gap: 8px; align-items: baseline; font-size: 13px; color: var(--muted); }
.msg .meta strong { color: var(--text); font-size: 14px; }
.msg.mine .meta strong { color: var(--accent); }
.msg .del { visibility: hidden; font-size: 12px; }
.msg:hover .del { visibility: visible; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .image img { display: block; max-width: min(420px, 100%); max-height: 320px; border-radius: 8px; margin-top: 4px; border: 1px solid var(--line); }
.msg .file {
  display: inline-flex; gap: 10px; align-items: center; margin-top: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
  color: var(--text); text-decoration: none;
}
.msg .file .size, .gone { color: var(--muted); font-size: 13px; }
.typing { margin: 0; padding: 0 18px; height: 20px; font-size: 13px; color: var(--muted); }
.composer { display: flex; gap: 8px; padding: 10px 14px 14px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; max-height: 160px; }
.attach { cursor: pointer; font-size: 20px; padding: 6px; }
.drop {
  position: absolute; inset: 10px; border: 2px dashed var(--accent); border-radius: 14px;
  background: #121316dd; display: grid; place-items: center; font-size: 18px; pointer-events: none;
}

/* ---------- GIFs ---------- */
.gif-btn { font-size: 12px; font-weight: 700; letter-spacing: .04em; padding: 6px 8px; }
.composer .gif-btn { align-self: center; }
.msg img.gif { display: block; max-width: min(320px, 100%); height: auto; border-radius: 8px; margin-top: 4px; }
.gif-dialog #gif-search { flex: 1; }
.gif-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px;
  height: min(60vh, 520px); overflow-y: auto; align-content: start;
}
.gif-tile { padding: 0; border: 0; border-radius: 6px; overflow: hidden; background: var(--panel-2); height: 120px; }
.gif-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gif-tile:hover { outline: 2px solid var(--accent); }
.giphy-credit { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- Bestanden / tabellen ---------- */
#pane-files { overflow-y: auto; padding: 18px; gap: 14px; }
.files-head { display: flex; justify-content: space-between; align-items: center; }
.files-head h2 { font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--text); }
table.files { width: 100%; border-collapse: collapse; }
.files th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.files td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.files td:first-child { overflow-wrap: anywhere; }
.files td.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.files tr.pending td { background: #6ea8ff12; }

/* ---------- Whiteboard ---------- */
.board-pane { flex-direction: row; }
.board-side {
  width: 210px; flex: none; border-right: 1px solid var(--line); padding: 12px;
  display: flex; flex-direction: column; gap: 10px; overflow-y: auto;
}
.board-list, .frame-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.board-list li { display: flex; align-items: center; gap: 4px; border-radius: 8px; padding: 2px 4px; }
.board-list li.active { background: var(--panel-2); }
.board-list .board-name { flex: 1; min-width: 0; justify-content: flex-start; background: none; border: 0; padding: 5px 4px; overflow: hidden; text-overflow: ellipsis; }
.board-list li.active .board-name { font-weight: 600; }
.board-actions { display: none; }
.board-list li:hover .board-actions { display: flex; }
.board-actions .link { padding: 2px 3px; font-size: 13px; }
.viewers { display: flex; gap: 2px; }
.viewer { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #111; }
.frame-list .link { display: flex; gap: 8px; align-items: center; color: var(--text); padding: 4px; width: 100%; justify-content: flex-start; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.board-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.toolbar .group { display: flex; gap: 4px; align-items: center; }
.toolbar button { min-width: 34px; padding: 6px 8px; }
.toolbar button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.toolbar select { padding: 6px 6px; }
.toolbar .zoom { min-width: 58px; font-variant-numeric: tabular-nums; }
.toolbar .check { display: flex; gap: 5px; align-items: center; font-size: 14px; color: var(--muted); }
.swatch-input { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); cursor: pointer; }
.swatch-input input { width: 30px; height: 30px; padding: 2px; }
.board-select { display: none; max-width: 160px; }

.board-viewport {
  flex: 1; min-height: 0; position: relative; overflow: hidden; touch-action: none; user-select: none;
  background-color: var(--board);
  background-image: radial-gradient(circle, #ffffff14 1px, transparent 1.2px);
  cursor: default;
}
.board-viewport[data-tool="hand"], .board-viewport.space { cursor: grab; }
.board-viewport.panning { cursor: grabbing; }
.board-viewport[data-tool="pen"], .board-viewport[data-tool="line"], .board-viewport[data-tool="arrow"],
.board-viewport[data-tool="rect"], .board-viewport[data-tool="ellipse"], .board-viewport[data-tool="frame"] { cursor: crosshair; }
.board-viewport[data-tool="text"] { cursor: text; }
.board-viewport[data-tool="sticky"] { cursor: copy; }
.board-viewport[data-tool="eraser"] { cursor: cell; }
.board-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; --inv: 1; }
.item { position: absolute; }
.item svg { display: block; overflow: visible; }
.item-pen, .item-line, .item-arrow { pointer-events: none; }
.item .hit { stroke: transparent; fill: none; pointer-events: stroke; stroke-linecap: round; stroke-linejoin: round; }
.item .hit-fill { pointer-events: all; }
.item-text .tb, .item-sticky .tb { padding: 4px 6px; line-height: 1.3; overflow-wrap: anywhere; white-space: pre-wrap; }
.item-sticky { box-shadow: 0 4px 14px #0007; border-radius: 2px; overflow: hidden; }
.item-sticky .tb { padding: 14px; height: 100%; overflow: hidden; }
.tb .bullet { display: flex; gap: .45em; }
.tb .bullet .bullet-mark { flex: none; }
.item.editing .tb { visibility: hidden; }
.item-image img { width: 100%; height: 100%; display: block; border-radius: 2px; pointer-events: auto; -webkit-user-drag: none; }
.item-frame { border: 2px solid; border-radius: 6px; pointer-events: none; }
.item-frame .frame-title {
  position: absolute; left: -2px; bottom: 100%; padding-bottom: 6px; font: 600 18px system-ui, sans-serif;
  white-space: nowrap; pointer-events: auto; cursor: pointer;
}
.item-frame .edge { position: absolute; pointer-events: auto; }
.item-frame .edge.t, .item-frame .edge.b { left: -8px; right: -8px; height: 14px; }
.item-frame .edge.l, .item-frame .edge.r { top: -8px; bottom: -8px; width: 14px; }
.item-frame .edge.t { top: -8px; } .item-frame .edge.b { bottom: -8px; }
.item-frame .edge.l { left: -8px; } .item-frame .edge.r { right: -8px; }
.item.selected { outline: calc(1px * var(--inv)) solid #6ea8ff88; }
.remote-draft { opacity: .65; pointer-events: none !important; }
.remote-draft * { pointer-events: none !important; }
#board-drafts { pointer-events: none; }
#board-drafts * { pointer-events: none !important; }

.board-sel { position: absolute; outline: calc(1.5px * var(--inv)) solid var(--accent); pointer-events: none; z-index: 99998; }
.handle {
  position: absolute; width: calc(12px * var(--inv)); height: calc(12px * var(--inv));
  background: #fff; border: calc(1.5px * var(--inv)) solid var(--accent); border-radius: calc(3px * var(--inv));
  transform: translate(-50%, -50%); pointer-events: auto;
}
.handle[data-h="nw"] { left: 0; top: 0; cursor: nwse-resize; }
.handle[data-h="ne"] { left: 100%; top: 0; cursor: nesw-resize; }
.handle[data-h="sw"] { left: 0; top: 100%; cursor: nesw-resize; }
.handle[data-h="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.marquee { position: absolute; border: 1px solid var(--accent); background: #6ea8ff1f; pointer-events: none; }

.board-editor {
  position: absolute; background: #00000030; border: 0; resize: none; overflow: hidden;
  outline: calc(1.5px * var(--inv)) dashed var(--accent); padding: 4px 6px; line-height: 1.3; margin: 0;
  white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.4em;
}
.board-editor.sticky-editor { padding: 14px; overflow: auto; }

#board-cursors { position: absolute; left: 0; top: 0; z-index: 99999; pointer-events: none; }
.cursor { position: absolute; transform: scale(var(--inv)); transform-origin: 0 0; transition: left .08s linear, top .08s linear, opacity .4s; display: flex; align-items: flex-start; }
.cursor .label { color: #111; font: 600 12px system-ui, sans-serif; padding: 1px 7px; border-radius: 6px; margin: 14px 0 0 -4px; white-space: nowrap; }
.cursor.idle { opacity: .25; }

/* ---------- Scherm ---------- */
.screens { flex: 1; min-height: 0; display: grid; gap: 10px; padding: 10px; grid-auto-rows: 1fr; }
.screens[data-count="2"], .screens[data-count="3"] { grid-template-columns: 1fr 1fr; }
.screen { margin: 0; position: relative; background: #000; border-radius: 8px; overflow: hidden; min-height: 0; }
.screen video { width: 100%; height: 100%; object-fit: contain; display: block; }
.screen figcaption { position: absolute; left: 8px; bottom: 8px; background: #000a; padding: 2px 8px; border-radius: 6px; font-size: 13px; }
.screen .full { position: absolute; right: 8px; bottom: 8px; padding: 2px 8px; background: #000a; }

/* ---------- Dialogen en meldingen ---------- */
dialog {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; padding: 22px;
  width: min(420px, calc(100% - 32px));
}
dialog.wide { width: min(860px, calc(100% - 32px)); }
dialog::backdrop { background: #000a; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
dialog h2 { font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--text); }
#admin-new input { flex: 1; min-width: 140px; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 10; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; max-width: 340px; box-shadow: 0 6px 24px #0008; }

/* ---------- Telefoon ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 16px; gap: 10px; flex-direction: row; flex-wrap: wrap; align-items: center; overflow: visible; }
  .brand { font-size: 17px; }
  .side section { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .side h2 { display: none; }
  .people { flex-direction: row; flex-wrap: wrap; gap: 4px 12px; }
  .people .offline, .people .offline-head { display: none; }
  .side-foot { margin: 0; width: 100%; }
  .side-foot #me-name { width: auto; }
  .tabs { padding: 6px 8px 0; overflow-x: auto; }
  .files thead { display: none; }
  .files tr { display: grid; grid-template-columns: 1fr auto; }
  .files td:nth-child(3), .files td:nth-child(4) { display: none; }
  .files td.actions { grid-column: 1 / -1; justify-content: flex-start; }
  .screens[data-count="2"], .screens[data-count="3"] { grid-template-columns: 1fr; }
  .board-side { display: none; }
  .board-select { display: block; }
}
