/* ==================================================================
   JamSpace — стили интерфейса
   Темы задаются через data-theme на <html>.
   ================================================================== */

:root {
  --bg: #F3F3F3;
  --canvas: #F3F3F3;
  --grid: #E3E3E3;
  --grid-strong: #D5D5D5;
  --surface: #FFFFFF;
  --surface-2: #F7F7F7;
  --surface-3: #EFEFEF;
  --border: #E4E4E4;
  --border-strong: #D4D4D4;
  --text: #1B1B1B;
  --text-2: #6B6B6B;
  --text-3: #767676;
  --accent: #0D99FF;
  --accent-soft: #E7F4FF;
  --accent-text: #FFFFFF;
  --danger: #E5484D;
  --success: #18A957;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 12px 32px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.10), 0 24px 64px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-lg: 18px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html[data-theme="midnight"] {
  --bg: #191A1D;
  --canvas: #191A1D;
  --grid: #26272B;
  --grid-strong: #33353A;
  --surface: #242529;
  --surface-2: #2B2C31;
  --surface-3: #34353B;
  --border: #35363C;
  --border-strong: #474950;
  --text: #F2F2F2;
  --text-2: #A8A8B0;
  --text-3: #8F8F97;
  --accent: #4DA6FF;
  --accent-soft: #1D3550;
  --accent-text: #0B1420;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.40);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);
}

html[data-theme="blueprint"] {
  --bg: #0F2233;
  --canvas: #0F2233;
  --grid: #17324A;
  --grid-strong: #21445F;
  --surface: #17324A;
  --surface-2: #1D3D59;
  --surface-3: #254A69;
  --border: #2A5273;
  --border-strong: #356585;
  --text: #ECF5FB;
  --text-2: #A7C3D6;
  --text-3: #82A7BF;
  --accent: #58C4DD;
  --accent-soft: #123C4D;
  --accent-text: #06222C;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);
}

html[data-theme="sand"] {
  --bg: #F4EDE4;
  --canvas: #F4EDE4;
  --grid: #E7DCCE;
  --grid-strong: #D9C9B6;
  --surface: #FFFBF5;
  --surface-2: #F9F1E7;
  --surface-3: #F1E5D6;
  --border: #E7DACA;
  --border-strong: #D6C3AC;
  --text: #2B2118;
  --text-2: #7A6857;
  --text-3: #867258;
  --accent: #E8590C;
  --accent-soft: #FDEBE0;
  --accent-text: #FFFFFF;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font-family: inherit; }
button { cursor: pointer; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

#app { position: fixed; inset: 0; overflow: hidden; }

#board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: default;
}

#board.tool-hand { cursor: grab; }
#board.tool-hand.dragging { cursor: grabbing; }
#board.tool-sticky, #board.tool-shape, #board.tool-text,
#board.tool-section, #board.tool-connector, #board.tool-code { cursor: crosshair; }
#board.tool-pen, #board.tool-highlighter { cursor: crosshair; }
#board.tool-comment { cursor: copy; }
#board.tool-eraser { cursor: cell; }
#board.tool-vote { cursor: pointer; }

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ic-fill { fill: currentColor; stroke: none; }
.hidden { display: none !important; }

/* ---------------- Верхняя панель ---------------- */

#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  pointer-events: none;
  z-index: 30;
}
#topbar > * { pointer-events: auto; }

.tb-left, .tb-right { display: flex; align-items: center; gap: 8px; min-width: 0; }

.logo-btn {
  width: 40px; height: 40px;
  border: none;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  display: grid; place-items: center;
  transition: transform .15s ease, box-shadow .15s ease;
}
.logo-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.logo-mark { font-size: 20px; line-height: 1; color: var(--accent); font-weight: 700; }

.board-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-radius: 12px;
  padding: 0 12px;
  height: 40px;
  box-shadow: var(--shadow-sm);
  max-width: min(44vw, 460px);
}
.board-name {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  outline: none;
  min-width: 60px;
  max-width: 300px;
  width: 22ch;
  padding: 4px 0;
}
.board-name:focus { box-shadow: inset 0 -1.5px 0 var(--accent); }
.save-status { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.save-status.saving { color: var(--text-2); }
.save-status.offline { color: var(--danger); }

.presence { display: flex; align-items: center; padding-left: 8px; }
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  margin-left: -8px;
  display: grid; place-items: center;
  color: white;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  transition: transform .12s ease;
  background: var(--accent);
}
.avatar:hover { transform: translateY(-2px); z-index: 2; }
.avatar.me { cursor: default; }
.avatar .status-dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--success); border: 2px solid var(--surface);
}
.avatar-more { background: var(--surface-3); color: var(--text-2); }

.btn {
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: background .12s ease, box-shadow .12s ease, transform .12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.06); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-danger { background: var(--danger); color: white; }

.icon-btn {
  width: 38px; height: 38px;
  border: none;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
  transition: background .12s ease, color .12s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; box-shadow: none; background: transparent; }
.icon-btn.sm:hover { background: var(--surface-3); }

/* ---------------- Нижний тулбар ---------------- */

.toolbar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 40;
  max-width: calc(100vw - 24px);
  overflow-x: auto;
  scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { display: none; }
.tool-group { display: flex; align-items: center; gap: 2px; }
.tool-divider { width: 1px; height: 26px; background: var(--border); margin: 0 5px; flex: none; }

.tool-btn {
  width: 38px; height: 38px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  display: grid;
  place-items: center;
  position: relative;
  transition: background .12s ease, color .12s ease, transform .12s ease;
  flex: none;
}
.tool-btn:hover { background: var(--surface-3); color: var(--text); }
.tool-btn.active { background: var(--accent); color: var(--accent-text); }
.tool-btn.active:hover { background: var(--accent); }
.tool-btn:active { transform: scale(.94); }
.tool-btn .kbd-badge {
  position: absolute; right: 2px; bottom: 1px;
  font-size: 8px; font-weight: 700; opacity: .55;
}
.tool-more { width: auto; padding: 0 10px; gap: 6px; display: flex; }
.tool-more-label { font-size: 12px; font-weight: 600; }
.tool-more.active { background: var(--accent); color: var(--accent-text); }

/* ---------------- Зум ---------------- */

.zoombar {
  position: absolute;
  right: 16px; bottom: 22px;
  display: flex; align-items: center;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  height: 38px;
  padding: 3px;
  z-index: 35;
}
.zoom-btn, .zoom-value {
  border: none;
  background: transparent;
  color: var(--text-2);
  height: 32px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 14px;
}
.zoom-btn { width: 30px; }
.zoom-value { min-width: 54px; font-size: 12px; font-weight: 600; color: var(--text); }
.zoom-btn:hover, .zoom-value:hover { background: var(--surface-3); }
.zoom-btn .ic { width: 16px; height: 16px; }

/* ---------------- Панель ---------------- */

.panel {
  position: absolute;
  top: 64px; left: 12px;
  width: 348px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 148px);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 38;
  overflow: hidden;
  animation: panelIn .16s ease;
}
@keyframes panelIn { from { opacity: 0; transform: translateY(-6px) scale(.99); } }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 10px;
}
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.panel-head .icon-btn { width: 30px; height: 30px; box-shadow: none; background: transparent; }
.panel-body { overflow-y: auto; padding: 0 16px 16px; }
.panel-body::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }

.section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-3);
  margin: 16px 0 8px;
}
.section-label:first-child { margin-top: 4px; }

/* Палитра стикеров */
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.swatch {
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1.5px solid rgba(0,0,0,.08);
  position: relative;
  transition: transform .1s ease;
}
.swatch:hover { transform: scale(1.06); }
.swatch.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

/* Эмодзи */
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emoji-btn {
  aspect-ratio: 1;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 22px;
  display: grid; place-items: center;
  transition: background .1s ease, transform .1s ease;
}
.emoji-btn:hover { background: var(--surface-3); transform: scale(1.12); }

/* Фигуры */
.shape-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.shape-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 10px 6px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  color: var(--text-2);
  font-size: 10px;
}
.shape-card:hover { border-color: var(--accent); color: var(--text); }
.shape-card .ic { width: 24px; height: 24px; }

/* Список */
.list { display: flex; flex-direction: column; gap: 6px; }
.list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--surface-2);
  font-size: 13px;
}
.list-item:hover { border-color: var(--border-strong); }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; }
.list-item .li-sub { font-size: 11px; color: var(--text-2); margin-top: 1px; }

/* Чат */
.chat-log { display: flex; flex-direction: column; gap: 8px; min-height: 120px; max-height: 44vh; overflow-y: auto; padding-right: 2px; }
.chat-msg { display: flex; gap: 8px; align-items: flex-start; }
.chat-avatar { width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff; font-size: 10px; font-weight: 700; }
.chat-bubble { background: var(--surface-2); border-radius: 10px; padding: 7px 10px; font-size: 12.5px; line-height: 1.4; word-break: break-word; }
.chat-name { font-size: 10.5px; color: var(--text-3); margin-bottom: 2px; font-weight: 600; }
.chat-form { display: flex; gap: 6px; margin-top: 10px; }
.chat-form input, .field {
  flex: 1; min-width: 0;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 10px;
  font-size: 13px;
  outline: none;
}
.chat-form input:focus, .field:focus { border-color: var(--accent); }

/* Настройки */
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.field-row:last-child { border-bottom: none; }
.field-label { font-size: 13px; }
.field-hint { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.field-row .field { max-width: 160px; flex: none; }

.toggle {
  width: 40px; height: 23px;
  border-radius: 20px;
  border: none;
  background: var(--surface-3);
  position: relative;
  transition: background .15s ease;
  flex: none;
}
.toggle::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 17px; height: 17px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .15s ease;
}
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(17px); }

.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-card {
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
  text-align: left;
  color: var(--text);
  padding: 0;
}
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.theme-preview { height: 52px; position: relative; display: flex; align-items: flex-end; padding: 8px; gap: 4px; }
.theme-preview span { width: 18px; height: 18px; border-radius: 4px; }
.theme-card b { display: block; padding: 8px 10px; font-size: 12px; }

/* Сочетания клавиш */
.shortcut-list { display: flex; flex-direction: column; gap: 2px; }
.shortcut-row { display: flex; align-items: center; justify-content: space-between; padding: 7px 8px; border-radius: 8px; font-size: 12.5px; }
.shortcut-row:nth-child(odd) { background: var(--surface-2); }
kbd {
  font-family: var(--font);
  font-size: 10.5px;
  font-weight: 600;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 2px 6px;
  color: var(--text-2);
  white-space: nowrap;
}

/* ---------------- Панель свойств выделения ---------------- */

.selection-toolbar {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 32;
  transform: translate(-50%, -100%);
  max-width: calc(100vw - 24px);
  overflow-x: auto;
  scrollbar-width: none;
}
.selection-toolbar::-webkit-scrollbar { display: none; }
.st-divider { width: 1px; height: 22px; background: var(--border); margin: 0 2px; flex: none; }
.st-btn {
  width: 32px; height: 32px;
  border: none; background: transparent; color: var(--text-2);
  border-radius: 8px; display: grid; place-items: center; flex: none;
}
.st-btn:hover { background: var(--surface-3); color: var(--text); }
.st-btn.active { background: var(--accent-soft); color: var(--accent); }
.st-btn .ic { width: 17px; height: 17px; }
.st-colors { display: flex; gap: 4px; }
.st-color { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0,0,0,.12); flex: none; }
.st-color.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--accent); }
.st-label { font-size: 11px; color: var(--text-3); padding: 0 2px; white-space: nowrap; }
.st-input {
  width: 48px; height: 30px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface-2); color: var(--text); text-align: center; font-size: 12px; outline: none;
}

/* ---------------- Курсоры ---------------- */

#cursors { position: absolute; inset: 0; pointer-events: none; z-index: 25; overflow: hidden; }
.remote-cursor {
  position: absolute;
  left: 0; top: 0;
  transition: transform .09s linear;
  will-change: transform;
  pointer-events: none;
}
.remote-cursor svg { display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.18)); }
.cursor-label {
  position: absolute;
  left: 13px; top: 15px;
  padding: 3px 8px;
  border-radius: 7px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.cursor-bubble {
  position: absolute;
  left: 16px; top: 36px;
  max-width: 220px;
  background: var(--text);
  color: var(--surface);
  padding: 5px 9px;
  border-radius: 9px;
  font-size: 11.5px;
  line-height: 1.35;
  box-shadow: var(--shadow-md);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------------- Реакции ---------------- */

#reactions { position: absolute; inset: 0; pointer-events: none; z-index: 26; overflow: hidden; }
.reaction-float {
  position: absolute;
  font-size: 30px;
  animation: floatUp 2.2s ease-out forwards;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.15));
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
  12% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--drift, 20px)), -220px) scale(.9) rotate(var(--rot, 12deg)); }
}

/* ---------------- Модальные окна ---------------- */

.modal-overlay {
  position: absolute; inset: 0;
  background: rgba(15, 18, 22, .32);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  z-index: 60;
  animation: fadeIn .15s ease;
  padding: 20px;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: min(560px, 100%);
  max-height: min(84vh, 720px);
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalIn .18s cubic-bezier(.2,.8,.3,1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px; }
.modal-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.modal-head .icon-btn { box-shadow: none; background: transparent; width: 32px; height: 32px; }
.modal-body { padding: 6px 20px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); }

/* Command palette */
.palette-input-wrap { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.palette-input-wrap .ic { color: var(--text-3); }
.palette-input { flex: 1; border: none; background: transparent; outline: none; font-size: 16px; color: var(--text); }
.palette-list { max-height: 380px; overflow-y: auto; padding: 8px; }
.palette-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px; font-size: 13.5px; color: var(--text);
  width: 100%; border: none; background: transparent; text-align: left;
}
.palette-item .ic { width: 18px; height: 18px; color: var(--text-2); }
.palette-item .pi-hint { margin-left: auto; font-size: 11px; color: var(--text-3); }
.palette-item.active, .palette-item:hover { background: var(--accent-soft); color: var(--text); }
.palette-empty { padding: 24px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ---------------- Контекстное меню ---------------- */

.context-menu {
  position: absolute;
  min-width: 220px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 70;
  animation: fadeIn .1s ease;
}
.cm-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; border: none; background: transparent;
  padding: 8px 9px; border-radius: 8px;
  font-size: 12.5px; color: var(--text); text-align: left;
}
.cm-item:hover { background: var(--surface-3); }
.cm-item .ic { width: 16px; height: 16px; color: var(--text-2); }
.cm-item .cm-hint { margin-left: auto; color: var(--text-3); font-size: 10.5px; }
.cm-item.danger { color: var(--danger); }
.cm-item.danger .ic { color: var(--danger); }
.cm-sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* ---------------- Тосты ---------------- */

.toasts { position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 80; pointer-events: none; }
.toast {
  background: var(--text);
  color: var(--surface);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn .2s ease;
  max-width: 80vw;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s ease, transform .2s ease; }

/* ---------------- Таймер / голосование / follow ---------------- */

.timer-widget, .vote-widget, .follow-banner {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 64px;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 14px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  z-index: 34;
  font-size: 13px;
  font-weight: 600;
}
.timer-widget .ic { color: var(--text-2); }
#timer-display { font-variant-numeric: tabular-nums; font-size: 15px; letter-spacing: .02em; }
.vote-widget { top: 108px; }
.vote-emoji { font-size: 20px; }
.follow-banner { top: 108px; background: var(--accent); color: var(--accent-text); }
.follow-banner .btn { background: rgba(255,255,255,.2); color: inherit; box-shadow: none; }

/* ---------------- Пустое состояние ---------------- */

.empty-state {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  pointer-events: none;
  z-index: 20;
  padding: 24px;
}
.empty-card {
  pointer-events: auto;
  width: min(560px, 100%);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: modalIn .25s ease;
}
.empty-eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.empty-card h1 { margin: 0 0 10px; font-size: clamp(22px, 3vw, 30px); letter-spacing: -.02em; line-height: 1.15; }
.empty-card p { margin: 0 auto 18px; color: var(--text-2); font-size: 13.5px; line-height: 1.55; max-width: 420px; }
.empty-hint { font-size: 11.5px; color: var(--text-3); }

/* ---------------- Курсорный чат ---------------- */

.cursor-chat {
  position: absolute;
  z-index: 50;
  transform: translate(12px, 18px);
  background: var(--text);
  border-radius: 10px;
  padding: 4px;
  box-shadow: var(--shadow-md);
  width: 220px;
}
.cursor-chat input {
  width: 100%; border: none; background: transparent; color: var(--surface);
  padding: 6px 8px; font-size: 12px; outline: none;
}
.cursor-chat input::placeholder { color: color-mix(in srgb, var(--surface) 55%, transparent); }

.follow-indicator {
  position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%);
  background: var(--text); color: var(--surface);
  font-size: 11.5px; padding: 5px 12px; border-radius: 20px; z-index: 33;
  display: flex; align-items: center; gap: 6px;
}

/* ---------------- Текст-редактор ---------------- */

#text-editor-layer { position: absolute; inset: 0; pointer-events: none; z-index: 45; }
.text-editor {
  position: absolute;
  pointer-events: auto;
  border: none;
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  padding: 0;
  margin: 0;
  resize: none;
  overflow: hidden;
  background: transparent;
  transform-origin: 0 0;
  line-height: 1.3;
  white-space: pre-wrap;
  word-break: break-word;
  caret-color: var(--accent);
}

/* ---------------- Комментарии ---------------- */

.comment-pin {
  position: absolute;
  width: 30px; height: 30px;
  border-radius: 50% 50% 50% 4px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  box-shadow: var(--shadow-md);
  z-index: 22;
  cursor: pointer;
  transform: translate(-2px, -28px);
  transition: transform .12s ease;
}
.comment-pin:hover { transform: translate(-2px, -30px) scale(1.06); }
.comment-pin.resolved { background: var(--surface-3); color: var(--text-2); }
.comment-popover {
  position: absolute;
  width: 300px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 55;
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: 380px;
}
.cp-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 700; }
.cp-body { padding: 10px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; }
.cp-msg { font-size: 12.5px; line-height: 1.45; }
.cp-meta { font-size: 10.5px; color: var(--text-3); margin-bottom: 2px; }
.cp-form { display: flex; gap: 6px; padding: 8px 10px 10px; border-top: 1px solid var(--border); }
.cp-form input { flex: 1; height: 33px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 8px; padding: 0 9px; outline: none; font-size: 12px; }
.cp-form input:focus { border-color: var(--accent); }

/* ---------------- Адаптивность ---------------- */

@media (max-width: 860px) {
  .hide-sm { display: none; }
  .board-title-wrap { max-width: 38vw; }
  .board-name { width: 14ch; }
  #present-btn { width: 38px; padding: 0; justify-content: center; }
  .tool-more-label { display: none; }
  .tool-more { width: 38px; padding: 0; }
  .panel { width: 320px; }
  .zoombar { bottom: 74px; right: 12px; }
  .toasts { bottom: 130px; }
}

@media (max-width: 520px) {
  .save-status { display: none; }
  .presence .avatar:nth-child(n+3) { display: none; }
  .empty-card { padding: 20px; }
  .toolbar { bottom: 10px; padding: 5px; }
  .tool-btn { width: 36px; height: 36px; }
  .panel { top: 60px; left: 8px; width: calc(100vw - 16px); max-height: calc(100vh - 130px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
