:root {
  --bg-app: #f4f5f7;
  --bg-board: #fafbfc;
  --grid-dot-color: #cbd5e1;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: #eff6ff;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-sticky: 2px 4px 14px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
}

#app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* Top Navigation Bar */
.top-nav {
  min-height: 54px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 14px;
  z-index: 120;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.nav-left, .nav-center, .nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: #0f172a;
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 15px;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
  flex-shrink: 0;
}

.btn-boards {
  font-weight: 600;
  background: #f8fafc;
}

.count-pill {
  background: #e2e8f0;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

.board-title-input {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-main);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  outline: none;
  transition: all 0.2s;
  width: 175px;
  user-select: text;
  -webkit-user-select: text;
}

.board-title-input:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.board-title-input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Save Status & Explicit Save Button */
.save-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 14px;
  background: #f1f5f9;
  color: #475569;
  white-space: nowrap;
}

.save-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
}

.save-status.saved {
  background: #ecfdf5;
  color: #047857;
}
.save-status.saved .save-dot { background: #10b981; }

.save-status.saving {
  background: #eff6ff;
  color: #1d4ed8;
}
.save-status.saving .save-dot {
  background: #3b82f6;
  animation: pulseDot 0.9s infinite;
}

.save-status.dirty {
  background: #fffbeb;
  color: #b45309;
}
.save-status.dirty .save-dot { background: #f59e0b; }

.save-status.error {
  background: #fef2f2;
  color: #b91c1c;
}
.save-status.error .save-dot { background: #ef4444; }

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

.btn-save {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}
.btn-save:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

/* Search input */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  background: #f1f5f9;
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 5px 26px 5px 30px;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  width: 150px;
  transition: all 0.2s ease;
  user-select: text;
  -webkit-user-select: text;
}

.search-box input:focus {
  background: #fff;
  border-color: var(--primary);
  width: 210px;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.search-icon {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  font-size: 15px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

/* Nav Stats */
.nav-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  background: #f8fafc;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.stat-dot.todo { background: #94a3b8; }
.stat-dot.inprogress { background: #3b82f6; }
.stat-dot.done { background: #10b981; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #fff;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-icon-only {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn-danger {
  color: var(--danger);
}
.btn-danger:hover {
  background: #fef2f2;
  border-color: #fecaca;
}

.input-field {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.input-field:focus {
  border-color: var(--primary);
}

/* Boards Drawer */
.boards-drawer {
  position: absolute;
  top: 0;
  left: 0;
  width: 340px;
  max-width: 92vw;
  height: 100%;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(14px);
  border-right: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  transform: translateX(calc(-100% - 16px));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.boards-drawer.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.drawer-header h3 {
  font-size: 15px;
  font-weight: 700;
}

.drawer-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
}

.boards-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.board-list-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  background: #fff;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.board-list-item:hover {
  border-color: #93c5fd;
  background: #f8fafc;
}

.board-list-item.active {
  border-color: var(--primary);
  background: #eff6ff;
}

.board-item-info {
  min-width: 0;
  flex: 1;
}

.board-item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.board-item-actions {
  display: flex;
  gap: 4px;
}

.board-mini-btn {
  border: none;
  background: transparent;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: #64748b;
}

.board-mini-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.board-mini-btn.danger:hover {
  background: #fee2e2;
  color: var(--danger);
}

.drawer-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 8px;
  background: #f8fafc;
}

/* Left Floating Toolbar */
.toolbar-dock {
  position: absolute;
  left: 16px;
  top: 16px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 90;
}

.tool-btn {
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #475569;
  position: relative;
  transition: all 0.15s ease;
}

.tool-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.tool-btn.active {
  background: #eff6ff;
  color: var(--primary);
  box-shadow: inset 0 0 0 1.5px var(--primary);
}

.tool-btn svg {
  width: 19px;
  height: 19px;
  stroke-width: 2;
}

.tool-badge {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 9px;
  font-weight: 700;
  color: #94a3b8;
  pointer-events: none;
}

.tool-divider {
  height: 1px;
  background: var(--border-color);
  margin: 3px 2px;
}

.tool-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #1e293b;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease 0.25s;
  box-shadow: var(--shadow-md);
  z-index: 1000;
}

.tool-btn:hover::after {
  opacity: 1;
}

/* Pen options bar */
.pen-options-bar {
  position: absolute;
  left: 74px;
  top: 16px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 90;
}

.pen-colors, .pen-widths {
  display: flex;
  align-items: center;
  gap: 5px;
}

.pen-color-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.pen-color-btn.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--primary);
}

.pen-width-btn {
  border: 1px solid var(--border-color);
  background: #fff;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  color: #475569;
}
.pen-width-btn.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Mode hint pill */
.mode-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.88);
  color: #fff;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 20px;
  z-index: 95;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}

/* Board Viewport & Infinite Dot Grid */
#viewport {
  flex: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
  background-color: var(--bg-board);
  background-image: radial-gradient(var(--grid-dot-color) 1.25px, transparent 1.25px);
  background-size: 24px 24px;
  cursor: default;
}

#viewport.panning {
  cursor: grab !important;
}

#viewport.panning:active {
  cursor: grabbing !important;
}

#viewport.drawing-mode {
  cursor: crosshair !important;
}

#viewport.create-mode {
  cursor: copy !important;
}

/* Canvas container that transforms infinitely */
#board {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  overflow: visible;
  z-index: 2;
}

/* Frames background layer */
#board-frames {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 5;
}

/* SVG Layers */
#svg-connectors,
#svg-drawings {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
  pointer-events: none;
}

#svg-drawings { z-index: 10; }
#svg-connectors { z-index: 15; }

.connector-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 18;
  cursor: pointer;
  pointer-events: stroke;
}

.connector-path {
  fill: none;
  stroke: #64748b;
  stroke-width: 2.5;
  stroke-linecap: round;
  pointer-events: none;
  transition: stroke 0.15s, stroke-width 0.15s;
}

.connector-group:hover .connector-path {
  stroke-width: 3.5;
}

.connector-group.selected .connector-path {
  stroke-width: 3.5;
  filter: drop-shadow(0 0 3px rgba(59, 130, 246, 0.45));
}

.connector-label-bg {
  fill: #ffffff;
  stroke: #cbd5e1;
  stroke-width: 1;
  rx: 6;
  ry: 6;
  cursor: pointer;
  pointer-events: all;
}

.connector-label-text {
  font-size: 11.5px;
  font-weight: 600;
  fill: #334155;
  text-anchor: middle;
  dominant-baseline: central;
  cursor: pointer;
  pointer-events: all;
}

.drawing-stroke {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

/* Elements container */
#board-elements {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  overflow: visible;
  z-index: 20;
}

/* Generic Board Item */
.board-item {
  position: absolute;
  pointer-events: auto;
  box-sizing: border-box;
  touch-action: none;
  transform-origin: center center;
  transition: box-shadow 0.15s ease;
}

.board-item.selected {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.board-item.connector-source {
  outline: 2.5px dashed var(--primary);
  outline-offset: 5px;
}

.board-item.search-dimmed {
  opacity: 0.2 !important;
}

.board-item.search-match {
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.45), var(--shadow-lg) !important;
}

/* Selection Marquee Box (in viewport space) */
#selection-marquee {
  position: absolute;
  border: 1.5px dashed var(--primary);
  background: rgba(59, 130, 246, 0.09);
  pointer-events: none;
  display: none;
  z-index: 100;
}

/* --- STICKY NOTE --- */
.board-sticky {
  width: 200px;
  min-height: 160px;
  padding: 14px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow-sticky);
  display: flex;
  flex-direction: column;
  cursor: move;
  background-color: #fef08a;
}

.board-sticky:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.sticky-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  opacity: 0.65;
  font-size: 11px;
}

.sticky-content {
  flex: 1;
  font-size: 14.5px;
  line-height: 1.45;
  color: #1e293b;
  outline: none;
  cursor: text;
  word-break: break-word;
  white-space: pre-wrap;
  user-select: text;
  -webkit-user-select: text;
  overflow-y: auto;
}

.sticky-content:empty::before {
  content: 'Заметка...';
  color: rgba(30, 41, 59, 0.4);
}

.sticky-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 11px;
  opacity: 0.65;
}

.sticky-author {
  outline: none;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
  min-width: 30px;
}

/* Colors */
.color-yellow { background-color: #fef08a !important; color: #422006 !important; }
.color-green { background-color: #bbf7d0 !important; color: #064e3b !important; }
.color-blue { background-color: #bae6fd !important; color: #0c4a6e !important; }
.color-pink { background-color: #fbcfe8 !important; color: #701a75 !important; }
.color-orange { background-color: #fed7aa !important; color: #7c2d12 !important; }
.color-purple { background-color: #e9d5ff !important; color: #4c1d95 !important; }
.color-dark { background-color: #1e293b !important; color: #f8fafc !important; }
.color-dark .sticky-content { color: #f8fafc !important; }
.color-dark .sticky-content:empty::before { color: rgba(248, 250, 252, 0.45); }
.color-dark .sticky-header, .color-dark .sticky-footer { color: #cbd5e1 !important; }

/* Frame & Card Accent Colors */
.board-frame.color-yellow { background: rgba(254, 240, 138, 0.16) !important; border-color: #eab308 !important; }
.board-frame.color-green { background: rgba(187, 247, 208, 0.18) !important; border-color: #22c55e !important; }
.board-frame.color-blue { background: rgba(186, 230, 253, 0.2) !important; border-color: #3b82f6 !important; }
.board-frame.color-pink { background: rgba(251, 207, 232, 0.18) !important; border-color: #ec4899 !important; }
.board-frame.color-orange { background: rgba(254, 215, 170, 0.18) !important; border-color: #f97316 !important; }
.board-frame.color-purple { background: rgba(233, 213, 255, 0.2) !important; border-color: #a855f7 !important; }
.board-frame.color-dark { background: rgba(30, 41, 59, 0.08) !important; border-color: #334155 !important; }

.board-card.color-yellow { border-top: 4px solid #eab308 !important; background: #fff !important; color: var(--text-main) !important; }
.board-card.color-green { border-top: 4px solid #10b981 !important; background: #fff !important; color: var(--text-main) !important; }
.board-card.color-blue { border-top: 4px solid #3b82f6 !important; background: #fff !important; color: var(--text-main) !important; }
.board-card.color-pink { border-top: 4px solid #ec4899 !important; background: #fff !important; color: var(--text-main) !important; }
.board-card.color-orange { border-top: 4px solid #f97316 !important; background: #fff !important; color: var(--text-main) !important; }
.board-card.color-purple { border-top: 4px solid #a855f7 !important; background: #fff !important; color: var(--text-main) !important; }
.board-card.color-dark { border-top: 4px solid #1e293b !important; background: #fff !important; color: var(--text-main) !important; }

/* --- TASK CARD --- */
.board-card {
  width: 260px;
  min-height: 150px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: move;
}

.board-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: #cbd5e1;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-status-badge {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.card-status-badge.status-todo { background: #f1f5f9; color: #475569; }
.card-status-badge.status-inprogress { background: #eff6ff; color: #2563eb; }
.card-status-badge.status-done { background: #ecfdf5; color: #059669; }
.card-status-badge.status-review { background: #fef3c7; color: #d97706; }

.card-priority {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
}
.priority-high { background: #ef4444; box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2); }
.priority-med { background: #f59e0b; box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2); }
.priority-low { background: #10b981; box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2); }

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  outline: none;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
  word-break: break-word;
  white-space: pre-wrap;
}
.card-title:empty::before {
  content: 'Название задачи...';
  color: #94a3b8;
}

.card-desc {
  font-size: 12.5px;
  color: #64748b;
  line-height: 1.4;
  outline: none;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
  min-height: 24px;
  word-break: break-word;
  white-space: pre-wrap;
}
.card-desc:empty::before {
  content: 'Детали задачи...';
  color: #cbd5e1;
}

/* Card Checklist */
.card-checklist {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}

.checklist-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #334155;
}

.checklist-row input[type="checkbox"] {
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.checklist-text {
  flex: 1;
  outline: none;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
  word-break: break-word;
}

.checklist-row.done .checklist-text {
  text-decoration: line-through;
  color: #94a3b8;
}

.checklist-del {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  opacity: 0;
}
.checklist-row:hover .checklist-del {
  opacity: 1;
}
.checklist-del:hover {
  color: var(--danger);
}

.card-add-subtask {
  align-self: flex-start;
  background: none;
  border: none;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  padding: 2px 0;
}
.card-add-subtask:hover {
  color: var(--primary);
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #94a3b8;
  border-top: 1px solid #f1f5f9;
  padding-top: 7px;
  margin-top: auto;
  gap: 8px;
}

.card-assignee {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.card-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #475569;
  flex-shrink: 0;
}

.card-assignee-name, .card-date {
  outline: none;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}

/* --- FRAME / SECTION --- */
.board-frame {
  position: absolute;
  border: 2px dashed #94a3b8;
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.45);
  box-sizing: border-box;
  cursor: move;
}

.board-frame:hover {
  border-color: #64748b;
  background: rgba(248, 250, 252, 0.65);
}

.frame-header {
  position: absolute;
  top: -30px;
  left: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  padding: 4px 12px;
  border-radius: 6px 6px 0 0;
  border: 1px solid #cbd5e1;
  border-bottom: none;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.02);
}

.frame-title {
  outline: none;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
  min-width: 40px;
}

/* --- TEXT ELEMENT --- */
.board-text {
  min-width: 80px;
  min-height: 36px;
  padding: 6px 10px;
  font-size: 20px;
  font-weight: 600;
  color: #0f172a;
  cursor: move;
  border-radius: 6px;
  background: transparent !important;
}

.board-text-inner {
  outline: none;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 24px;
}

.board-text-inner:empty::before {
  content: 'Текст...';
  color: #94a3b8;
}

.board-text.size-h1 { font-size: 32px; font-weight: 800; }
.board-text.size-h2 { font-size: 24px; font-weight: 700; }
.board-text.size-body { font-size: 15px; font-weight: 400; }

.board-text.color-yellow .board-text-inner { color: #a16207; }
.board-text.color-green .board-text-inner { color: #15803d; }
.board-text.color-blue .board-text-inner { color: #1d4ed8; }
.board-text.color-pink .board-text-inner { color: #be185d; }
.board-text.color-orange .board-text-inner { color: #c2410c; }
.board-text.color-purple .board-text-inner { color: #7e22ce; }
.board-text.color-dark .board-text-inner { color: #0f172a; }

/* Connection Port Handles on Elements */
.connect-port {
  position: absolute;
  width: 15px;
  height: 15px;
  background: #ffffff;
  border: 2.5px solid var(--primary);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  cursor: crosshair;
  transition: opacity 0.15s, transform 0.15s, background-color 0.15s, border-color 0.15s;
  z-index: 50;
}

/* Увеличенная невидимая зона попадания 35x35px вокруг каждого круга */
.connect-port::before {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
}

.board-item:hover .connect-port,
.board-item.selected .connect-port,
.connector-mode .connect-port,
.connecting-mode .connect-port {
  opacity: 1;
}

.connect-port:hover {
  transform: translate(-50%, -50%) scale(1.3);
  background: var(--primary);
}

.connect-port.snap-target {
  opacity: 1 !important;
  transform: translate(-50%, -50%) scale(1.45);
  background: #10b981;
  border-color: #ffffff;
  box-shadow: 0 0 0 3px #10b981;
}

.port-top { top: 0; left: 50%; }
.port-bottom { top: 100%; left: 50%; }
.port-left { top: 50%; left: 0; }
.port-right { top: 50%; left: 100%; }

/* Resizer Handle */
.resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  background: transparent;
}

.resize-handle::after {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 6px;
  height: 6px;
  border-right: 2px solid #94a3b8;
  border-bottom: 2px solid #94a3b8;
}

/* Floating Action Context Menu */
#floating-context-menu {
  position: absolute;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 5px 8px;
  display: none;
  align-items: center;
  gap: 4px;
  z-index: 1000;
}

.context-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.context-btn {
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 12px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.context-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.context-btn.active {
  background: var(--primary-light);
  color: var(--primary);
}

.context-divider {
  width: 1px;
  height: 18px;
  background: #e2e8f0;
  margin: 0 2px;
}

.color-dots-group {
  display: flex;
  gap: 4px;
  align-items: center;
}

.color-dot-pick {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.14);
  transition: transform 0.1s;
}

.color-dot-pick:hover {
  transform: scale(1.2);
}

/* Minimap */
.minimap-wrapper {
  position: absolute;
  left: 16px;
  bottom: 18px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
  z-index: 88;
}

#minimap-canvas {
  display: block;
  cursor: pointer;
  border-radius: 6px;
  background: #f8fafc;
}

/* Bottom Navigation Controls */
.bottom-dock {
  position: absolute;
  bottom: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 90;
}

.zoom-toggle-minimap {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-md);
}

.zoom-widget {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  padding: 3px;
  gap: 2px;
}

.zoom-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
}

.zoom-btn:hover {
  background: #f1f5f9;
}

.zoom-text {
  font-size: 12px;
  font-weight: 600;
  min-width: 44px;
  text-align: center;
  cursor: pointer;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 580px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
  transform: translateY(20px);
  transition: transform 0.2s ease;
}

.modal-overlay.open .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #334155;
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.template-card {
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-card:hover {
  border-color: var(--primary);
  background: #eff6ff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.template-icon { font-size: 24px; }
.template-name { font-size: 14px; font-weight: 700; color: #1e293b; }
.template-desc { font-size: 11.5px; color: #64748b; line-height: 1.4; }

.hotkey-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
}

.kbd {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: monospace;
  font-weight: 600;
  color: #334155;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.2s ease, fadeOut 0.25s ease 2.6s forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@media (max-width: 1100px) {
  .logo-text { display: none; }
  .nav-stats { display: none; }
  .btn-save .btn-label { display: none; }
}

@media (max-width: 760px) {
  .minimap-wrapper { display: none; }
  .board-title-input { width: 120px; }
  .search-box input { width: 110px; }
}
