:root {
  --accent: #6965db;
  --accent-hover: #5753c9;
  --accent-soft: #eeedfc;
  --bg: #f6f6f9;
  --surface: #ffffff;
  --text: #1e1e24;
  --muted: #6b6b78;
  --border: #e4e4ea;
  --danger: #e03131;
  --shadow: 0 1px 2px rgba(20, 20, 40, 0.06), 0 4px 16px rgba(20, 20, 40, 0.06);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
[hidden] { display: none !important; }

/* ---------- buttons & inputs ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; white-space: nowrap; font-weight: 500;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f1f1f5; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0, 0, 0, 0.05); }
.btn.small { height: 30px; padding: 0 10px; font-size: 14px; }
.btn.icon { width: 32px; height: 32px; padding: 0; }
.btn:disabled { opacity: .5; cursor: default; }

.input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--text); }
.logo-mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--accent);
  display: grid; place-items: center; color: #fff; font-size: 15px;
}

/* ---------- modal / menu / toast ---------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 20, 30, 0.35);
  display: grid; place-items: center; z-index: 1000; padding: 16px;
}
.modal {
  width: 100%; max-width: 420px; background: var(--surface); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2); padding: 22px;
}
.modal h2 { margin: 0 0 6px; font-size: 19px; }
.modal p { margin: 0 0 14px; color: var(--muted); line-height: 1.45; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.modal .field + .field { margin-top: 14px; }
.modal label.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; line-height: 1.4; }
.modal label.check input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; }
.link-row { display: flex; gap: 8px; }
.link-row .input { font-size: 13px; }

.menu {
  position: fixed; z-index: 1100; min-width: 200px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.menu button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none;
  border-radius: 6px; cursor: pointer;
}
.menu button:hover { background: #f1f1f5; }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 1200; display: grid; gap: 8px; }
.toast {
  background: #1e1e24; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: var(--shadow); animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

.avatar {
  width: 22px; height: 22px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 600;
  display: inline-grid; place-items: center; flex: none; border: 2px solid #fff;
}

/* ---------- login ---------- */

.center-page { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card {
  width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px;
  box-shadow: var(--shadow); padding: 28px;
}
.card h1 { font-size: 20px; margin: 18px 0 6px; }
.card p { color: var(--muted); margin: 0 0 18px; }
.card .btn { width: 100%; margin-top: 12px; height: 40px; }
.form-error { color: var(--danger); font-size: 14px; margin-top: 10px; min-height: 1em; }

/* ---------- dashboard ---------- */

.topbar {
  height: 60px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.container { max-width: 1120px; margin: 0 auto; padding: 28px 24px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.space-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s;
}
.space-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.space-cover {
  height: 92px; position: relative; display: block;
  background-image: radial-gradient(rgba(0,0,0,.12) 1px, transparent 1px);
  background-size: 14px 14px;
}
.space-cover .shape { position: absolute; border-radius: 8px; opacity: .9; }
.space-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.space-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.space-title a { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.space-meta { color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.space-meta .online { color: #2f9e44; }
.space-actions { display: flex; gap: 8px; margin-top: 8px; }
.space-actions .btn { flex: 1; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #f1f1f5; color: var(--muted); }
.empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
  border: 2px dashed var(--border); border-radius: var(--radius);
}
.empty h2 { color: var(--text); font-size: 18px; margin: 0 0 8px; }

/* ---------- space page ---------- */

.space-layout { display: flex; height: 100%; overflow: hidden; }
.sidebar {
  width: 260px; flex: none; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border); z-index: 20;
  transition: margin-left .18s ease;
}
.space-layout.collapsed .sidebar { margin-left: -260px; }
.sb-head { padding: 14px 12px 10px 14px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.sb-head .titles { flex: 1; min-width: 0; }
.sb-head .space-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-head .sub { font-size: 12px; color: var(--muted); }
.sb-section { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 16px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.board-list { list-style: none; margin: 0; padding: 0 8px; overflow-y: auto; flex: 1; }
.board-item {
  display: flex; align-items: center; gap: 8px; padding: 0 6px 0 10px; height: 38px;
  border-radius: 8px; cursor: pointer; user-select: none;
}
.board-item:hover { background: #f4f4f7; }
.board-item.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.board-item.drag-over { box-shadow: inset 0 2px 0 var(--accent); }
.board-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-item .people { display: flex; }
.board-item .people .avatar { width: 20px; height: 20px; font-size: 10px; margin-left: -6px; }
.board-item .more { opacity: 0; }
.board-item:hover .more, .board-item.active .more { opacity: 1; }
.sb-foot { border-top: 1px solid var(--border); padding: 12px; display: grid; gap: 8px; }
.sb-foot > .btn { width: 100%; }
.me-row { display: flex; align-items: center; gap: 8px; padding: 4px 2px; }
.me-row .avatar { width: 28px; height: 28px; font-size: 12px; }
.me-row .who { flex: 1; min-width: 0; }
.me-row .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.me-row .who span { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #adb5bd; display: inline-block; }
.dot.online { background: #2f9e44; }
.dot.offline { background: var(--danger); }

.board-host { flex: 1; position: relative; min-width: 0; }
.board-host .excalidraw { --color-primary: var(--accent); }
.board-loading, .board-message {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px;
}
.board-message h2 { color: var(--text); margin: 0 0 8px; }
.sb-toggle {
  position: absolute; left: 12px; bottom: 16px; z-index: 30;
  box-shadow: var(--shadow); background: var(--surface);
}
.space-layout:not(.collapsed) .sb-toggle { display: none; }
.readonly-pill {
  position: absolute; top: 70px; left: 50%; transform: translateX(-50%); z-index: 5;
  background: #fff3bf; color: #7a5b00; padding: 4px 12px; border-radius: 99px; font-size: 13px; pointer-events: none;
}

@media (max-width: 760px) {
  .sidebar { position: absolute; top: 0; bottom: 0; left: 0; box-shadow: var(--shadow); }
  .container { padding: 20px 16px 40px; }
  .topbar { padding: 0 16px; }
}

/* ---------- board: dotted background ---------- */

.board-wrap { position: absolute; inset: 0; --board-bg: #f1f1f4; --board-dot: #c4c4cf; }
.board-wrap.theme-dark { --board-bg: #18181c; --board-dot: #3b3b46; }
.board-dots {
  position: absolute; inset: 0; pointer-events: none;
  background-color: var(--board-bg);
  background-image: radial-gradient(circle, var(--board-dot) 1.1px, transparent 1.5px);
  background-size: 24px 24px;
}
.board-wrap .excalidraw { background: transparent; }

/* ---------- board: left toolbar (replaces the editor's top toolbar) ---------- */

.board-wrap .excalidraw:not(.excalidraw--mobile) .shapes-section { display: none; }
.board-wrap .excalidraw:not(.excalidraw--mobile) .App-menu__left { margin-left: 58px; }
.board-wrap:has(.excalidraw--mobile) .lt-core { display: none; }

.left-toolbar {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%); z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px;
  max-height: calc(100% - 140px); overflow: visible;
  background: var(--island-bg-color, #fff); border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 2px 10px rgba(0,0,0,.08);
}
.lt-btn {
  position: relative; width: 38px; height: 38px; border: 0; border-radius: 8px; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: var(--icon-fill-color, #1b1b1f);
}
.lt-btn:hover { background: var(--button-hover-bg, #f1f1f5); }
.lt-btn.active { background: var(--accent-soft); color: var(--accent-hover); }
.theme-dark .lt-btn.active { background: #3a3760; color: #c9c7ff; }
.lt-sep { width: 24px; height: 1px; background: var(--default-border-color, #e4e4ea); margin: 4px 0; }
.lt-group { position: relative; }
.lt-pop {
  position: absolute; left: 50px; top: -6px; z-index: 10; padding: 6px;
  background: var(--island-bg-color, #fff); border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 6px 20px rgba(0,0,0,.14);
}
.lt-row { display: flex; gap: 2px; align-items: center; }
.lt-vsep { width: 1px; height: 24px; margin: 0 4px; background: var(--default-border-color, #e4e4ea); }
.lt-colors { display: grid; grid-template-columns: repeat(3, 32px); gap: 6px; padding: 8px; }
.lt-emojis { display: grid; grid-template-columns: repeat(3, 44px); gap: 2px; }
.lt-emoji { width: 44px; height: 44px; border: 0; border-radius: 8px; background: none; cursor: pointer; display: grid; place-items: center; }
.lt-emoji:hover { background: var(--button-hover-bg, #f1f1f5); }
.board-wrap.rpanning, .board-wrap.rpanning * { cursor: grabbing !important; }

.et-swatch { position: absolute; right: 5px; bottom: 5px; width: 8px; height: 8px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.et-count {
  position: absolute; top: 1px; right: 0; min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 10px; line-height: 15px; font-weight: 700;
}
.et-color { width: 32px; height: 32px; border-radius: 6px; border: 1px solid rgba(0,0,0,.1); cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.et-color:hover { transform: scale(1.08); }

/* frame formats list (toolbar popover and the bar above a selected frame) */
.fmt-list { display: grid; min-width: 190px; color: var(--text-primary-color, #1e1e24); }
.fmt-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border: 0; border-radius: 7px;
  background: none; cursor: pointer; text-align: left; font: inherit; font-size: 14px; color: inherit;
}
.fmt-item:hover { background: var(--button-hover-bg, #f1f1f5); }
.fmt-item.active { background: var(--accent-soft); }
.fmt-label { flex: 1; }
.fmt-size { color: var(--muted); font-size: 12px; }

/* ---------- board: frames ---------- */

.frame-fills { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.frame-fill { position: absolute; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.05), 0 1px 4px rgba(0,0,0,.06); }
.theme-dark .frame-fill { background: #232329; box-shadow: 0 0 0 1px rgba(255,255,255,.06); }
/* the same colour shift the editor applies to element colours in the dark theme */
.theme-dark .frame-fill.tinted { filter: invert(93%) hue-rotate(180deg); }
.frame-bar {
  position: absolute; z-index: 5; transform: translateX(-50%); pointer-events: auto;
  display: flex; gap: 2px;
  background: var(--island-bg-color, #fff); border-radius: 10px; padding: 4px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.12);
}
.fb-format {
  display: flex; align-items: center; gap: 10px; padding: 3px 8px; border: 0; border-radius: 7px;
  background: none; cursor: pointer; font: inherit; color: inherit;
}
.fb-format:hover { background: var(--button-hover-bg, #f1f1f5); }
.fb-text { display: grid; text-align: left; }
.fb-caption { font-size: 10px; color: var(--muted); line-height: 1.1; }
.fb-value { font-size: 13px; font-weight: 600; line-height: 1.3; }
.fb-caret { color: var(--muted); font-size: 11px; }
.fb-icon { padding: 3px 9px; color: var(--icon-fill-color, #1b1b1f); }
.export-formats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.export-format {
  display: grid; gap: 2px; padding: 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer; text-align: left;
}
.export-format span { font-size: 12px; color: var(--muted); line-height: 1.3; }
.export-format:hover { border-color: var(--accent); }
.export-format.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal .field-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.fb-swatch { width: 18px; height: 18px; border-radius: 5px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.fb-colors { left: auto; right: 0; display: grid; grid-template-columns: repeat(5, 30px); gap: 6px; padding: 8px; }
.fb-colors .et-color { width: 30px; height: 30px; }
.et-color.active { box-shadow: 0 0 0 2px var(--island-bg-color, #fff), 0 0 0 4px var(--accent); }
.fb-pop {
  position: absolute; top: calc(100% + 6px); left: 0; padding: 6px; border-radius: 10px;
  background: var(--island-bg-color, #fff); box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 6px 20px rgba(0,0,0,.14);
}

/* ---------- board: placing layer & comments ---------- */

.board-overlay { position: absolute; inset: 0; pointer-events: none; }
.place-layer { position: absolute; inset: 0; pointer-events: auto; z-index: 3; cursor: crosshair; }
.place-comment { cursor: copy; }
.place-lasso { touch-action: none; }
.lasso-path { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.lasso-path polygon { fill: rgba(105, 101, 219, .08); stroke: var(--accent, #6965db); stroke-width: 1.5; stroke-dasharray: 5 4; stroke-linejoin: round; }
.place-hint {
  position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%);
  background: #1e1e24; color: #fff; padding: 6px 12px; border-radius: 99px; font-size: 13px; pointer-events: none;
}
.cm-pin {
  position: absolute; z-index: 3; pointer-events: auto; transform: translate(-4px, -100%);
  padding: 2px; border: 2px solid; border-radius: 16px 16px 16px 2px; background: #fff; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.18); display: flex; align-items: center; gap: 2px; touch-action: none;
}
.cm-pin:hover, .cm-pin.open { box-shadow: 0 0 0 3px var(--accent-soft), 0 2px 6px rgba(0,0,0,.18); }
.cm-pin-avatar { width: 24px; height: 24px; border-radius: 50%; color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.cm-pin-count { font-size: 11px; font-weight: 700; padding: 0 5px 0 2px; color: #444; }
.cm-draft-pin {
  position: absolute; z-index: 3; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.cm-popover {
  position: absolute; z-index: 5; width: 300px; pointer-events: auto;
  background: #fff; color: var(--text); border-radius: 12px; padding: 10px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 10px 30px rgba(0,0,0,.18); font-size: 14px;
}
.cm-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; margin: -2px 0 6px 4px; }
.cm-head > span:last-child { display: flex; gap: 2px; }
.cm-thread { max-height: 280px; overflow-y: auto; display: grid; gap: 10px; padding: 4px; }
.cm-item { display: flex; gap: 8px; }
.cm-item .avatar { width: 26px; height: 26px; border: 0; }
.cm-body { flex: 1; min-width: 0; }
.cm-meta { display: flex; align-items: baseline; gap: 6px; font-size: 13px; }
.cm-role { font-size: 11px; color: var(--accent); }
.cm-time { color: var(--muted); font-size: 12px; }
.cm-del { margin-left: auto; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; }
.cm-del:hover { color: var(--danger); }
.cm-text { white-space: pre-wrap; word-wrap: break-word; line-height: 1.4; margin-top: 2px; }
.cm-form { margin-top: 8px; }
.cm-input {
  width: 100%; resize: vertical; min-height: 44px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; font: inherit; outline: none;
}
.cm-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cm-form-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }

/* ---------- board: participants (replaces the editor's user list and Library button) ---------- */

.board-wrap .UserList__wrapper,
.board-wrap .UserList-Wrapper,
.board-wrap .default-sidebar-trigger { display: none !important; }

.people { position: relative; }
.people-btn {
  display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px 0 8px; border: 0; border-radius: 10px;
  background: var(--island-bg-color, #fff); color: var(--text-primary-color, #1e1e24); cursor: pointer; font: inherit;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.08);
}
.people-btn:hover, .people-btn.open { background: var(--button-hover-bg, #f1f1f5); }
.people-stack { display: flex; }
.people-stack .avatar { width: 26px; height: 26px; font-size: 11px; margin-left: -8px; }
.people-stack .avatar:first-child { margin-left: 0; }
.people-count { font-weight: 600; font-size: 14px; }
.people-caret { color: var(--muted); font-size: 11px; }
.people-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 280px; padding: 8px;
  background: var(--island-bg-color, #fff); color: var(--text-primary-color, #1e1e24); border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 10px 30px rgba(0,0,0,.16);
  max-height: 60vh; overflow-y: auto;
}
.people-title { font-size: 12px; color: var(--muted); padding: 4px 6px 8px; }
.people-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 8px; }
.people-row:hover { background: var(--button-hover-bg, #f6f6f9); }
.people-row .avatar { width: 28px; height: 28px; font-size: 11px; border: 0; }
.people-name { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.people-name b { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-name small { font-size: 11px; color: var(--accent); }
.people-summon { width: 100%; margin-top: 6px; }

/* ---------- board version history ---------- */
.versions { display: grid; gap: 4px; max-height: 50vh; overflow-y: auto; margin: 0 -6px; }
.version-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 6px; border-radius: 8px; }
.version-row:hover { background: #f4f4f7; }
.version-row b { display: block; font-weight: 600; }
.version-row span { font-size: 13px; color: var(--muted); }
