:root {
  --accent: #4262ff;
  --bg: #f4f5f8;
  --panel: #ffffff;
  --ink: #1d1f24;
  --muted: #6b7180;
  --line: #e3e5ea;
  --shadow: 0 4px 16px rgba(20, 24, 40, .10), 0 1px 3px rgba(20, 24, 40, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; }

/* ---------- Canvas ---------- */
#board { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none;
  background-color: var(--bg); background-image: radial-gradient(#c8ccd6 1.2px, transparent 1.2px); }
#board.tool-hand, #board.space { cursor: grab; }
#board.panning { cursor: grabbing; }
#board.tool-note, #board.tool-rect, #board.tool-ellipse, #board.tool-arrow, #board.tool-pen { cursor: crosshair; }
#board.tool-text { cursor: text; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }

.obj { position: absolute; left: 0; top: 0; }
.obj .text { width: 100%; height: 100%; outline: none; white-space: pre-wrap; overflow-wrap: anywhere;
  overflow: hidden; line-height: 1.3; cursor: inherit; }
.obj .text[contenteditable="true"] { user-select: text; -webkit-user-select: text; cursor: text; }

.obj.note { padding: 18px 16px 22px; box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 6px 14px rgba(0,0,0,.10); font-size: 20px; }
.obj.note .text, .obj.rect .text, .obj.ellipse .text {
  display: flex; flex-direction: column; justify-content: center; text-align: center; }
.obj.note .author { position: absolute; left: 10px; bottom: 6px; font-size: 11px; opacity: .55; pointer-events: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% - 20px); }
.obj.rect, .obj.ellipse { padding: 12px; border: 2.5px solid rgba(0,0,0,.65); font-size: 18px; }
.obj.rect { border-radius: 6px; }
.obj.ellipse { border-radius: 50%; padding: 18%; }
.obj.text { font-size: 24px; }
.obj.text .text { height: auto; min-height: 100%; overflow: visible; }
.obj.text .text:empty::before { content: "Text eingeben…"; opacity: .35; }

.obj.path, .obj.arrow { pointer-events: none; }
.obj svg.ink { position: absolute; left: 0; top: 0; overflow: visible; width: 1px; height: 1px; }
.obj svg.ink path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.obj svg.ink path.hit { stroke: transparent; stroke-width: 16; pointer-events: stroke; }

.obj.selected { outline: 2px solid var(--accent); outline-offset: 3px; }
.handle { display: none; position: absolute; right: -10px; bottom: -10px; width: 13px; height: 13px; background: #fff;
  border: 2px solid var(--accent); border-radius: 3px; cursor: nwse-resize; pointer-events: auto; z-index: 2; }
.obj.selected .handle { display: block; }

/* Auswahl anderer Personen */
.obj.remote-sel::after { content: ""; position: absolute; inset: -7px; border: 2px solid var(--rsel); border-radius: 4px; pointer-events: none; }
.obj.remote-sel::before { content: attr(data-rname); position: absolute; left: -7px; top: -28px; background: var(--rsel); color: #fff;
  font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 4px; white-space: nowrap; pointer-events: none; z-index: 3; }

#marquee { position: fixed; border: 1.5px solid var(--accent); background: rgba(66, 98, 255, .08); pointer-events: none; z-index: 5; }

/* ---------- Live-Cursor ---------- */
#cursors { position: fixed; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
.cursor { position: absolute; left: 0; top: 0; transition: transform 70ms linear; will-change: transform; }
.cursor svg { width: 22px; height: 22px; display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); }
.cursor .label { position: absolute; left: 16px; top: 18px; color: #fff; font-size: 12px; font-weight: 600; padding: 3px 8px;
  border-radius: 6px; white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.ping { position: absolute; width: 0; height: 0; }
.ping::before, .ping::after { content: ""; position: absolute; left: -40px; top: -40px; width: 80px; height: 80px; border-radius: 50%;
  border: 3px solid var(--c); animation: ping 1.2s ease-out 2 forwards; }
.ping::after { animation-delay: .3s; }
@keyframes ping { from { transform: scale(.1); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }

/* ---------- UI-Panels ---------- */
#topbar, #presence, #toolbar, #palette, #zoombar { position: fixed; z-index: 30; background: var(--panel); box-shadow: var(--shadow); border-radius: 12px; }
#topbar { top: 14px; left: 14px; display: flex; align-items: center; gap: 12px; padding: 7px 8px 7px 14px; }
.brand { font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 6px; }
.logo { color: var(--accent); }
.board-name { color: var(--muted); font-size: 13px; padding-left: 12px; border-left: 1px solid var(--line); max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { font-size: 12px; padding-right: 6px; }
.status.on { color: #22c55e; } .status.off { color: #ef4444; }

.pill { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 13px; font-weight: 600; }
.pill.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill.primary:hover { filter: brightness(1.08); }
.pill.wide { width: 100%; padding: 11px; font-size: 15px; margin-top: 8px; }

#presence { top: 14px; right: 14px; display: flex; align-items: center; padding: 6px 10px 6px 6px; gap: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center;
  border: 2px solid #fff; margin-left: -6px; cursor: pointer; position: relative; }
.avatar:first-child { margin-left: 0; }
.avatar.me { outline: 2px solid var(--line); }
.avatar:hover::after { content: attr(data-name); position: absolute; top: 38px; right: 0; background: var(--ink); color: #fff; font-size: 12px;
  font-weight: 500; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
.presence-count { margin-left: 10px; font-size: 13px; color: var(--muted); }

#toolbar { left: 14px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; padding: 6px; gap: 2px; }
#toolbar button { width: 40px; height: 40px; border: 0; background: none; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
#toolbar button:hover { background: #f0f2f6; }
#toolbar button.active { background: #e6eaff; color: var(--accent); }
#toolbar button:disabled { opacity: .3; cursor: default; background: none; }
#toolbar svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#toolbar hr { width: 26px; border: 0; border-top: 1px solid var(--line); margin: 4px auto; }

#palette { left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; gap: 6px; padding: 8px 10px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(0,0,0,.12); cursor: pointer; padding: 0; }
.swatch.active { outline: 2.5px solid var(--accent); outline-offset: 2px; }

#zoombar { right: 14px; bottom: 16px; display: flex; padding: 4px; }
#zoombar button { border: 0; background: none; min-width: 34px; height: 32px; border-radius: 7px; cursor: pointer; font-size: 16px; }
#zoombar button:hover { background: #f0f2f6; }
#zoomLabel { font-size: 12px !important; min-width: 52px !important; font-variant-numeric: tabular-nums; }

#hint { position: fixed; left: 14px; bottom: 20px; font-size: 12px; color: var(--muted); z-index: 10; pointer-events: none; max-width: 30vw; }

#toast { position: fixed; left: 50%; top: 18px; transform: translate(-50%, -80px); background: var(--ink); color: #fff; padding: 9px 16px;
  border-radius: 10px; font-size: 13px; z-index: 50; transition: transform .25s ease; pointer-events: none; }
#toast.show { transform: translate(-50%, 0); }

/* ---------- Beitreten ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: rgba(244, 245, 248, .7); backdrop-filter: blur(6px); }
.modal[hidden] { display: none; }
.card { background: #fff; padding: 30px; border-radius: 16px; box-shadow: 0 20px 60px rgba(20,24,40,.18); width: min(380px, calc(100vw - 32px)); }
.card h1 { margin: 8px 0 4px; font-size: 22px; }
.logo.big { font-size: 28px; }
.muted { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.card label, .card .label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.card input { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font-size: 15px; border: 1.5px solid var(--line); border-radius: 9px; outline: none; }
.card input:focus { border-color: var(--accent); }
.card .label { margin-bottom: 8px; }
#colorPick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

@media (max-width: 700px) {
  .board-name { display: none; }
  #palette { bottom: 64px; max-width: calc(100vw - 32px); overflow-x: auto; }
}

/* =================== Video: Sequenzen =================== */
.obj.seq { background: #1e2128; color: #e8eaf0; border-radius: 12px; font-size: 13px;
  box-shadow: 0 2px 4px rgba(0,0,0,.12), 0 12px 32px rgba(0,0,0,.22); }
.seq-head { position: absolute; left: 12px; right: 12px; top: 0; height: 36px; display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.seq-title { font-weight: 700; }
.seq-meta { color: #9aa0ad; font-size: 12px; }
.seq-by { color: #7ee2a8; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.seq-btn { margin-left: auto; }
.seq-preview { position: absolute; left: 12px; top: 36px; width: 400px; height: 225px; background: #000; border-radius: 6px; overflow: hidden; }
.seq-preview video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.seq-overlay { position: absolute; inset: 0; display: grid; place-items: center; color: #cfd3dc; font-size: 14px; pointer-events: none; }
.seq-overlay:empty { display: none; }
.seq-controls { position: absolute; left: 12px; top: 261px; width: 400px; height: 40px; display: flex; align-items: center; gap: 6px; }
.seq-controls button, .seq-btn { background: #2f3440; border: 0; color: #fff; height: 28px; min-width: 32px; padding: 0 10px; border-radius: 6px;
  cursor: pointer; font-size: 13px; }
.seq-controls button:hover, .seq-btn:hover { background: #3c4352; }
.seq-controls .playbtn { background: var(--accent); min-width: 44px; }
.seq-controls .playbtn:hover { background: #5873ff; }
.seq-time { flex: 1; color: #cfd3dc; font-size: 12px; font-variant-numeric: tabular-nums; padding-left: 4px; }
.seq-ruler { position: absolute; left: 12px; top: 301px; height: 18px; cursor: ew-resize; border-radius: 3px 3px 0 0;
  background: repeating-linear-gradient(90deg, #4a5060 0 1px, transparent 1px 14px) bottom / 100% 6px no-repeat, #262a33; }
.seq-strip { position: absolute; left: 12px; top: 319px; height: 64px; cursor: ew-resize; background: #262a33; border-radius: 0 0 4px 4px; }
.clip { position: absolute; top: 0; height: 64px; box-sizing: border-box; background: #3b4252; border: 2px solid #535c72;
  border-radius: 5px; overflow: hidden; cursor: grab; }
.clip.csel { border-color: #ffd60a; }
.clip .tile { position: absolute; top: 0; height: 100%; background-repeat: no-repeat; pointer-events: none; }
.clip .cname { position: absolute; left: 5px; right: 5px; bottom: 3px; font-size: 10.5px; color: #fff; text-shadow: 0 1px 2px #000, 0 0 4px #000;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.clip .trim { position: absolute; top: 0; bottom: 0; width: 9px; cursor: ew-resize; z-index: 2; }
.clip .trim.l { left: 0; } .clip .trim.r { right: 0; }
.clip:hover .trim, .clip.csel .trim { background: rgba(255, 214, 10, .6); }
.seq-playhead { position: absolute; left: 12px; top: 301px; width: 2px; height: 82px; margin-left: -1px; background: #ff4d4f; pointer-events: none; z-index: 3; }
.seq-playhead::before { content: ""; position: absolute; top: 0; left: -5px; border: 6px solid transparent; border-top-color: #ff4d4f; }
.seq-insert { display: none; position: absolute; left: 12px; top: 311px; width: 4px; height: 80px; margin-left: -2px; background: #ffd60a;
  border-radius: 2px; z-index: 4; box-shadow: 0 0 12px #ffd60a; pointer-events: none; }
.seq-insert.on { display: block; }
.clip-ghost { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; background: #3b4252; color: #fff; border: 2px solid #ffd60a;
  border-radius: 6px; padding: 8px 10px; font-size: 12px; white-space: nowrap; box-shadow: 0 8px 20px rgba(0,0,0,.3); }

#board.dropping::after { content: "🎬  Videos hier ablegen"; position: fixed; inset: 14px; border: 3px dashed var(--accent); border-radius: 16px;
  display: grid; place-items: center; font-size: 22px; font-weight: 700; color: var(--accent); background: rgba(66, 98, 255, .07); pointer-events: none; z-index: 60; }
#uploads { position: fixed; right: 14px; bottom: 64px; z-index: 30; display: flex; flex-direction: column; gap: 6px; }
.up { background: #fff; box-shadow: var(--shadow); border-radius: 10px; padding: 8px 12px; width: 260px; font-size: 12px; }
.up .n { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up .bar { height: 4px; background: #e6e8ee; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.up i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
#muteBtn.off { color: var(--muted); }
#hint { max-width: 40vw; line-height: 1.5; }
@media (max-width: 1100px) { #hint { display: none; } }
