:root {
  --bg: #1e1e1e;
  --fg: #ddd;
  --muted: #888;
  --accent: #3d9bff;
  --panel: #2a2a2a;
  --line: #3a3a3a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg);
  font: 13px/1.4 system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif; user-select: none; }

#stage { position: fixed; inset: 0; overflow: hidden; touch-action: none; }
#stage.grab { cursor: grab; }
#stage.panning { cursor: grabbing; }
#stage.drop { outline: 2px dashed var(--accent); outline-offset: -8px; }

#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#world .item { position: absolute; left: 0; top: 0; display: block; pointer-events: none; }

#overlay { position: absolute; inset: 0; pointer-events: none; }
#overlay .sel { position: absolute; outline: 1px solid var(--accent); }
#overlay .group { position: absolute; outline: 1px dashed var(--accent); }
#overlay .handle { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  background: #fff; border: 1px solid var(--accent); }
#overlay .marquee { position: absolute; border: 1px solid var(--accent); background: rgba(61,155,255,.12); }

#empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; color: var(--muted); pointer-events: none; text-align: center; padding: 16px; }
#empty .big { font-size: 18px; color: #aaa; margin: 0 0 8px; }
#empty[hidden] { display: none; }
kbd { background: #333; border: 1px solid #444; border-radius: 3px; padding: 0 4px; font: inherit; font-size: 12px; }

#toolbar { position: fixed; right: 12px; bottom: 12px; display: flex; gap: 4px; align-items: center;
  background: rgba(42,42,42,.85); border: 1px solid var(--line); border-radius: 8px; padding: 4px; opacity: .55; transition: opacity .15s; }
#toolbar:hover { opacity: 1; }
#toolbar button, #menu button { background: none; border: 0; color: var(--fg); font: inherit; cursor: pointer; }
#toolbar button { padding: 4px 8px; border-radius: 5px; }
#toolbar button:hover { background: #3a3a3a; }
#zoom { color: var(--muted); padding: 0 6px; min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; }

#menu { position: fixed; z-index: 10; min-width: 200px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
#menu button { display: flex; justify-content: space-between; gap: 24px; width: 100%; padding: 5px 10px; border-radius: 4px; text-align: left; }
#menu button:hover:not(:disabled) { background: var(--accent); color: #fff; }
#menu button:disabled { color: #666; cursor: default; }
#menu button span { color: var(--muted); }
#menu button:hover:not(:disabled) span { color: #fff; }
#menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px 24px; max-width: 460px; width: 100%; max-height: 90vh; overflow: auto; }
.modal h2 { margin: 0 0 12px; font-size: 16px; }
#login .panel { max-width: 320px; }
#login input { width: 100%; padding: 8px 10px; background: #1e1e1e; color: var(--fg); border: 1px solid var(--line); border-radius: 6px; font: inherit; user-select: text; }
#login input:focus { outline: none; border-color: var(--accent); }
#login .error { color: #ff7b72; margin: 8px 0 0; }
#login .actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 16px; }
#login button { background: #3a3a3a; color: var(--fg); border: 0; border-radius: 6px; padding: 6px 14px; font: inherit; cursor: pointer; }
#login button.primary { background: var(--accent); color: #fff; }
#help dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
#help dt { color: var(--muted); white-space: nowrap; }
#help dd { margin: 0; }

/* visitors see a read-only board; editors see editing controls */
body.viewer [data-edit], body:not(.viewer) [data-view] { display: none; }
body.viewer #stage { cursor: grab; }
#status { color: var(--muted); padding: 0 4px; font-size: 12px; }
#status:empty { display: none; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 6px; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }
body.viewer #stage.panning { cursor: grabbing; }
