/* Модальное окно */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    min-width: 400px;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #333;
}

.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 20px;
    font-family: inherit;
}

.input:focus {
    outline: none;
    border-color: #2196f3;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Модал предпросмотра ИИ */
#ai-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

#ai-preview-modal.hidden {
    display: none;
}

.ai-preview-content {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    width: calc(100vw - 40px);
    height: calc(100vh - 40px);
    max-width: none;
    max-height: none;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    margin: 20px auto;
}

.ai-preview-content h2 {
    margin-bottom: 15px;
    color: #333;
    flex-shrink: 0;
}

#preview-notes-container {
    flex: 1;
    width: 100%;
    overflow: hidden;
    background: var(--bg-canvas);
    border: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: 10px;
    position: relative;
    min-width: 1000px;
    min-height: 1000px;
}

.preview-connections-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.preview-note {
    position: absolute;
    width: 200px;
    min-height: 200px;
    max-height: 700px;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    font-size: 14px;
    background: white;
    border: 1px solid #ddd;
    overflow-y: auto;
}

.ai-preview-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 10px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

/* Медиа-запросы для мобильных устройств */
@media (max-width: 768px) {
    .ai-preview-content {
        width: calc(100vw - 40px);
        height: calc(100vh - 40px);
        margin: 20px auto;
        padding: 10px;
    }

    #preview-notes-container {
        min-width: 100%;
        min-height: 100%;
    }
}

.ai-preview-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

#ai-accept-btn {
    background: #4caf50;
    color: white;
}

#ai-accept-btn:hover {
    background: #45a049;
}

#ai-cancel-btn {
    background: #f44336;
    color: white;
}

#ai-cancel-btn:hover {
    background: #da190b;
}

/* Стили для модалки конфликтов слияния */
#merge-conflicts-modal .modal-content {
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    width: 90%;
}

#conflicts-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 20px 0;
}

.conflict-item {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
}

.conflict-item h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 16px;
}

.conflict-versions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    align-items: start;
}

.version {
    background: white;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #eee;
    text-align: center;
}

.version.base {
    border-left: 4px solid #ccc;
}

.version.source {
    border-left: 4px solid #f00;
}

.version.target {
    border-left: 4px solid #0f0;
}

.version strong {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #555;
}

.note-preview {
    min-height: 60px;
    max-height: 120px;
    overflow: hidden;
    padding: 8px;
    background: #fafafa;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 13px;
    line-height: 1.3;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.color-badge {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin: 0 5px;
    border: 1px solid #ddd;
}

.resolve-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-top: 8px;
    transition: all 0.2s;
    background: #ddd;
    color: #333;
}

.resolve-btn:hover {
    background: #ccc;
}

.resolve-btn.selected {
    background: #4caf50;
    color: white;
}

.resolve-btn.selected:hover {
    background: #45a049;
}

/* Markdown в preview */
.note-preview h3 {
    font-size: 14px;
    font-weight: bold;
    margin: 5px 0;
}

.note-preview strong {
    font-weight: bold;
}

#apply-merge-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}
/* Версионность: Основная панель */
.version-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end !important;
  flex-wrap: wrap;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  padding: 8px 16px;
  gap: 8px;
  position: fixed;
  /* Хедер имеет z-index:101; панель должна быть поверх canvas и не пропадать */
  top: 60px;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1200;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.version-controls .btn {
  padding: 6px 12px;
  border: 1px solid #dee2e6;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.version-controls .btn:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

.version-controls .btn:active {
  transform: translateY(1px);
}

/* Модалки версионности */
.version-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.version-modal.hidden {
  display: none;
}

.modal-header {
  padding: 16px;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  color: #333;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6c757d;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.close-btn:hover {
  background: #f8f9fa;
}

.modal-body {
  padding: 16px;
}

.modal-body label {
  display: block;
  margin-bottom: 4px;
  font-weight: 500;
  color: #333;
}

.modal-body input,
.modal-body textarea,
.modal-body select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  font-size: 14px;
  box-sizing: border-box;
}

.modal-body textarea {
  resize: vertical;
  min-height: 80px;
  max-height: 200px;
}

.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
  outline: none;
  border-color: #80bdff;
  box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

.commit-stats {
  margin: 8px 0;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 4px;
  font-size: 12px;
  color: #6c757d;
}

.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.warning {
  color: #dc3545;
  font-weight: 500;
  background: #f8d7da;
  padding: 8px;
  border-radius: 4px;
  border-left: 4px solid #dc3545;
  margin: 8px 0;
}

/* Конфликты слияния */
.conflict-item {
  border: 1px solid #dee2e6;
  border-radius: 4px;
  margin-bottom: 16px;
  padding: 16px;
}

.conflict-item h4 {
  margin: 0 0 12px 0;
  color: #333;
}

.conflict-versions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.version {
  border: 1px solid #dee2e6;
  padding: 8px;
  border-radius: 4px;
  position: relative;
}

.version.base { border-color: #ffc107; }
.version.source { border-color: #28a745; }
.version.target { border-color: #007bff; }

.version strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: #6c757d;
}

.note-preview {
  font-size: 12px;
  min-height: 40px;
  padding: 4px;
  background: #f8f9fa;
  border-radius: 2px;
  white-space: pre-wrap;
  max-height: 60px;
  overflow-y: auto;
}

.color-badge {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  margin: 4px 0;
  border: 1px solid #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.version input[type="radio"] {
  margin-right: 4px;
}

.version.selected {
  border-color: #28a745;
  box-shadow: 0 0 0 2px rgba(40,167,69,0.25);
}

.progress-bar {
  background: #e9ecef;
  border-radius: 4px;
  padding: 4px;
  margin: 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.progress-fill {
  flex: 1;
  height: 8px;
  background: #28a745;
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Timeline Styles */
.timeline-section {
  position: fixed;
  top: 110px;
  right: -400px;
  width: 400px;
  height: calc(100vh - 110px);
  background: white;
  border-left: 2px solid #333;
  box-shadow: -4px 0 12px rgba(0,0,0,0.15);
  overflow: hidden;
  z-index: 50;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}

.timeline-section.open {
  right: 0;
}

.timeline-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #fafafa;
}

.timeline-canvas {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
  cursor: grab;
  display: block;
}

.timeline-canvas:active {
  cursor: grabbing;
}

.timeline-controls {
  position: absolute;
  top: 40px;
  right: 10px;
  background: rgba(255,255,255,0.9);
  padding: 8px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  z-index: 10;
  display: flex;
  gap: 4px;
}

.timeline-controls button {
  padding: 4px 8px;
  border: 1px solid #ddd;
  background: white;
  cursor: pointer;
  border-radius: 3px;
  font-size: 12px;
}

.commit-details-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    backdrop-filter: blur(10px);
    max-height: 350px;
    overflow-y: auto;
    z-index: 10;
}

.commit-details-panel.hidden {
  display: none;
}

.commit-details-panel h4 {
  margin: 0 0 8px 0;
  color: #333;
}

.commit-details-panel p {
  margin: 4px 0;
  font-size: 12px;
  color: #6c757d;
}

.commit-details-panel .actions {
  display: flex;
  gap: 5px;
  margin-top: 10px;
}

.commit-details-panel button {
  flex: 1;
  padding: 6px 4px;
  border: 1px solid #ddd;
  background: white;
  cursor: pointer;
  border-radius: 3px;
  font-size: 11px;
  white-space: nowrap;
}

.commit-details-panel button.primary {
  background: #2196f3;
  color: white;
  border-color: #1e88e5;
}

.commit-details-panel button.danger {
  background: #f44336;
  color: white;
  border-color: #d32f2f;
}

.commit-details-panel button.success {
  background: #4caf50;
  color: white;
  border-color: #43a047;
}

/* Context Menu */
.commit-context-menu {
  position: fixed;
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  padding: 8px;
  z-index: 10000;
  min-width: 150px;
}

.commit-context-menu button {
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
}

.commit-context-menu .delete-btn {
  background: #f44336;
  color: white;
  margin-bottom: 4px;
}

.commit-context-menu .cancel-btn {
  background: transparent;
  color: #666;
}

/* Responsive */
@media (max-width: 768px) {
  .version-controls {
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 8px;
  }

  .version-controls .btn,
  .branch-selector {
    padding: 4px 8px;
    font-size: 12px;
    min-width: auto;
  }

  .modal-content {
    width: 95%;
    max-height: 90vh;
  }

  .conflict-versions {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .timeline-section {
    width: 100%;
    right: -100%;
  }
}

/* Commit Modal Styles */
.modal-commit {
   max-width: 500px;
}

.commit-form {
   display: flex;
   flex-direction: column;
   gap: 15px;
   margin: 20px 0;
}

.commit-form label {
   font-weight: bold;
   color: #333;
   margin-bottom: 5px;
}

.commit-form textarea {
   width: 100%;
   padding: 10px;
   border: 2px solid #ddd;
   border-radius: 4px;
   font-family: Arial, sans-serif;
   font-size: 14px;
   resize: vertical;
   min-height: 80px;
   box-sizing: border-box;
}

.commit-form textarea:focus {
   outline: none;
   border-color: #2196f3;
}

.char-count {
   font-size: 12px;
   color: #999;
   text-align: right;
}

.commit-branch-info {
   padding: 10px;
   background: #f5f5f5;
   border-radius: 4px;
   font-weight: bold;
   color: #4caf50;
}

.commit-stats-info {
   padding: 10px;
   background: #f9f9f9;
   border-left: 4px solid #2196f3;
   border-radius: 4px;
}

.stats-row {
   display: flex;
   justify-content: space-between;
   padding: 5px 0;
   font-size: 14px;
}

.stats-row span {
   color: #666;
}

.stats-row strong {
   color: #2196f3;
   font-weight: bold;
}

/* Unsaved changes indicator */
.unsaved-indicator {
   display: inline-block;
   width: 8px;
   height: 8px;
   background: #f44336;
   border-radius: 50%;
   margin-left: 4px;
   animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
   0%, 100% { opacity: 1; }
   50% { opacity: 0.5; }
}

/* Merge Modal Styles */
.modal-merge {
   max-width: 450px;
}

.merge-form {
   display: flex;
   flex-direction: column;
   gap: 15px;
   margin: 20px 0;
}

.merge-form label {
   font-weight: bold;
   color: #333;
   margin-bottom: 5px;
}

.merge-form select {
   padding: 10px;
   border: 2px solid #ddd;
   border-radius: 4px;
   font-size: 14px;
   background: white;
   box-sizing: border-box;
}

.merge-form select:focus {
   outline: none;
   border-color: #ff9800;
}

/* Conflict Resolution Modal */
.modal-conflicts {
   max-width: 700px;
   max-height: 80vh;
   overflow-y: auto;
}

.conflict-item.warning {
   border: 2px solid #ff9800;
   border-radius: 4px;
   padding: 15px;
   margin: 10px 0;
   background: #fffbf0;
}

.conflict-item.warning h4 {
   margin: 0 0 15px 0;
   color: #d68910;
}

.conflict-progress {
   margin: 15px 0;
   padding: 10px;
   background: #f9f9f9;
   border-radius: 4px;
}

.progress-text {
   font-size: 12px;
   color: #666;
   text-align: center;
}

/* New Branch Modal Styles */
.modal-branch {
   max-width: 450px;
}

.branch-form {
   display: flex;
   flex-direction: column;
   gap: 15px;
   margin: 20px 0;
}

.branch-form label {
   font-weight: bold;
   color: #333;
   margin-bottom: 5px;
}

.branch-form input[type="text"] {
   width: 100%;
   padding: 10px;
   border: 2px solid #ddd;
   border-radius: 4px;
   font-size: 14px;
   box-sizing: border-box;
}

.branch-form input[type="text"]:focus {
   outline: none;
   border-color: #4caf50;
}

.branch-form small {
   display: block;
   font-size: 12px;
   margin-top: 3px;
}

.branch-form input[type="radio"],
.branch-form input[type="checkbox"] {
   cursor: pointer;
   margin-right: 5px;
}

/* Toast Notifications */
.toast-container {
   position: fixed;
   bottom: 20px;
   right: 20px;
   z-index: 10000;
   display: flex;
   flex-direction: column;
   gap: 10px;
}

.toast {
   position: relative;
   margin: 10px 0;
   padding: 15px 20px;
   border-radius: 4px;
   color: white;
   font-size: 14px;
   box-shadow: 0 2px 8px rgba(0,0,0,0.2);
   min-width: 300px;
   max-width: 400px;
   animation: toastSlideIn 0.3s ease-out;
   transform-origin: bottom right;
}

@keyframes toastSlideIn {
   from {
       transform: translateX(100%);
       opacity: 0;
   }
   to {
       transform: translateX(0);
       opacity: 1;
   }
}

.toast-success {
   background: #4caf50;
   border-left: 4px solid #388e3c;
}

.toast-warning {
   background: #ff9800;
   border-left: 4px solid #f57c00;
}

.toast-error {
   background: #f44336;
   border-left: 4px solid #d32f2f;
}

.toast-info {
   background: #2196f3;
   border-left: 4px solid #1976d2;
}

.toast-close {
   position: absolute;
   top: 5px;
   right: 10px;
   background: none;
   border: none;
   color: white;
   font-size: 18px;
   cursor: pointer;
   opacity: 0.7;
}

.toast-close:hover {
   opacity: 1;
}

/* Branch Selector */
.branch-selector {
   padding: 8px 12px;
   border: 1px solid #ddd;
   border-radius: 4px;
   font-size: 14px;
   background: white;
   cursor: pointer;
   min-width: 150px;
}

.branch-selector:hover {
   border-color: #4CAF50;
}

.branch-selector:focus {
   outline: none;
   border-color: #4CAF50;
   box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

/* Кнопка "Сохранить Commit" - специальные стили */
.btn-save-commit {
  padding: 6px 12px;
  border: 1px solid #dee2e6;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-save-commit:enabled {
  background: #fff8e1;
  border-color: #fbc02d;
  color: #f57f17;
  font-weight: 500;
}

.btn-save-commit:enabled:hover {
  background: #ffeb3b;
  border-color: #fbc02d;
  box-shadow: 0 2px 4px rgba(245, 127, 23, 0.2);
}

.btn-save-commit:enabled:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(245, 127, 23, 0.2);
}

.btn-save-commit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: white;
  border-color: #dee2e6;
  color: #6c757d;
}

/* Resolve buttons in conflict modal */
.resolve-btn {
   width: 100%;
   padding: 8px;
   border: 1px solid #ddd;
   background: white;
   border-radius: 3px;
   cursor: pointer;
   font-size: 12px;
   transition: all 0.2s ease;
}

.resolve-btn:hover {
   background: #f0f0f0;
}

.resolve-btn.selected {
   background: #4caf50 !important;
   color: white !important;
   border-color: #4caf50 !important;
}
/* Минимальный сброс - остальное в styles/ */
#root {
  width: 100%;
  height: 100vh;
}
:root {
    --yellow: #ffeb3b;
    --pink: #f8bbd0;
    --blue: #b3e5fc;
    --green: #c8e6c9;
    --gray: #e0e0e0;
    --bg-canvas: #f5f5f5;
    --shadow: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.15);
    --scale: 1;
}
/* Сброс и базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-canvas);
    overflow: hidden;
}
/* Верхняя панель */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: white;
    box-shadow: var(--shadow);
    position: relative;
    z-index: 101; /* Увеличено, чтобы выпадающие меню перекрывали панель версий */
}

.header-left {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.board-name {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

/* Кнопки */
.btn-primary, .btn-secondary, .btn-danger {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: #2196f3;
    color: white;
}

.btn-primary:hover {
    background: #1976d2;
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #bdbdbd;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

.board-selector {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    min-width: 200px;
}

.sort-mode-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    background: white;
    min-width: 180px;
}

.sort-mode-select:focus {
    outline: none;
    border-color: #2196f3;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: 10px;
}

.zoom-btn {
    padding: 5px 10px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

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

.zoom-indicator {
    font-size: 12px;
    color: #666;
    min-width: 40px;
    text-align: center;
}

/* Версионность - стили перенесены в versioning.css */

.branch-selector {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.branch-selector:hover {
    border-color: #4CAF50;
}

.branch-info {
    font-size: 12px;
    color: #666;
}

.btn {
    padding: 8px 16px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background: white;
    color: #333;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    color: #333;
}

.btn:hover {
    background: #45a049;
}

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

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    color: #666;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: #f0f0f0;
    color: #333;
}
/* Canvas */
.canvas-container {
    position: relative;
    width: 100vw;
    height: calc(100vh - 60px);
    overflow: auto;
    background:
        linear-gradient(90deg, rgba(200,200,200,0.1) 1px, transparent 1px),
        linear-gradient(rgba(200,200,200,0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    cursor: grab;
    transition: width 0.3s ease;
}

.canvas-container.timeline-open {
    width: calc(100vw - 400px);
}

.canvas-container:active {
    cursor: grabbing;
}

.connections-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transform: scale(var(--scale));
    transform-origin: 0 0;
}

.notes-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-width: 10000px;
    min-height: 10000px;
    transform: scale(var(--scale));
    transform-origin: top left;
    z-index: 2;
}

/* Анимация связей */
.connection-line {
    transition: stroke 0.2s, stroke-width 0.2s;
}

.connection-line.highlighted {
    stroke: #2196f3 !important;
    stroke-width: 3 !important;
}

/* Lasso */
.lasso {
    position: absolute;
    top: 0;
    left: 0;
    border: 2px dashed #2196f3;
    background-color: rgba(33, 150, 243, 0.1);
    pointer-events: none;
    z-index: 5;
}

/* Pyramid layout styles for canvas */
.pyramid-level {
    display: flex;
    justify-content: center;
    gap: 100px;
}

.staggered {
    position: relative;
}

.staggered.odd {
    top: -25px;
}

.staggered.even {
    top: 25px;
}
/* Плавающая кнопка добавления */
.fab {
    position: fixed;
    bottom: 30px;
    right: 130px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #2196f3;
    color: white;
    font-size: 32px;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-hover);
    transition: all 0.2s;
    /* Поверх timeline (z-index: 1000) и других панелей */
    z-index: 1500;
}

/* При открытом timeline сдвигаем кнопку левее,
   чтобы она оставалась в видимой области canvas */
.canvas-container.timeline-open .fab {
    right: calc(130px + 400px);
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(33,150,243,0.4);
}

/* Стикеры */
.note {
    position: absolute;
    width: 200px;
    height: auto !important; /* Автоматическая высота, перебиваем инлайн */
    min-height: 200px !important;
    /* max-height: 700px; Убираем ограничение высоты */
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: move;
    transition: box-shadow 0.2s;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: visible !important; /* Убираем скролл полностью */
}

.note::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

.note:hover {
    box-shadow: var(--shadow-hover);
    z-index: 20;
}

.note.dragging {
    opacity: 0.8;
    z-index: 30;
}

.note-text {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 14px;
    line-height: 1.4;
    outline: none;
    font-family: inherit;
    min-height: 60px;
    overflow: visible !important; /* Убираем скролл */
    height: auto; /* Автоматическая высота */
}

.note-text::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

.note-tags {
    border: none;
    background: rgba(0,0,0,0.05);
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 12px;
    outline: none;
    font-family: inherit;
}

.note-tags::placeholder {
    color: #999;
}

.note-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.note-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.note-btn:hover {
    opacity: 1;
}

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nw-resize;
    background: linear-gradient(-45deg, transparent 0%, transparent 40%, rgba(0,0,0,0.1) 40%, rgba(0,0,0,0.1) 60%, transparent 60%, transparent 100%);
    border-radius: 0 0 8px 0;
}

/* Цветовая палитра */
.color-picker {
    position: fixed;
    display: grid;
    grid-template-columns: repeat(7, 30px);
    gap: 8px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-hover);
    z-index: 1100;
}

.color-picker.hidden {
    display: none;
}

.color-option {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.color-option:hover {
    border-color: #333;
    transform: scale(1.1);
}

/* Стикеры с главными тегами получают особую рамку */
.note.has-main-tag {
    border: 2px solid #ff9800;
    box-shadow: 0 2px 8px rgba(255,152,0,0.2);
}

.note.has-main-tag:hover {
    box-shadow: 0 4px 12px rgba(255,152,0,0.3);
}

/* Markdown styles for notes */
.note-text h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: bold;
    color: #333;
    line-height: 1.3;
}

.note-text strong {
    font-weight: bold;
}

.note-text br {
    display: block;
    margin-bottom: 0.5em;
}

/* Contenteditable div styles */
.note-text {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    line-height: 1.4;
    outline: none;
    font-family: inherit;
    min-height: 60px;
    height: auto;
    overflow: visible;
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 0;
    margin: 0;
    cursor: text;
}

.note-text:empty::before {
    content: attr(placeholder);
    color: #999;
    pointer-events: none;
}

.note.selected {
  border: 2px solid #2196f3;
  box-shadow: 0 2px 8px rgba(33,150,243,0.2), 0 0 0 2px rgba(33,150,243,0.3);
  transform: scale(1.02);
}

.note.selected:hover {
  box-shadow: 0 4px 12px rgba(33,150,243,0.3), 0 0 0 2px rgba(33,150,243,0.4);
}

/* Групповое выделение - более яркая рамка */
.note.group-selected {
  border: 3px solid #1976d2;
  box-shadow: 0 2px 12px rgba(25,118,210,0.3), 0 0 0 3px rgba(25,118,210,0.2);
}

.note.group-selected:hover {
  box-shadow: 0 4px 16px rgba(25,118,210,0.4), 0 0 0 3px rgba(25,118,210,0.3);
}
/* Sidebar for tree/cluster view */
.sidebar {
    position: fixed;
    left: 0;
    top: 60px;
    width: 300px;
    height: calc(100vh - 60px);
    background: white;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 150;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.sidebar:not(.hidden) {
    transform: translateX(0);
}

.sidebar-header {
    padding: 15px;
    background: #f5f5f5;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.close-sidebar-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-sidebar-btn:hover {
    color: #333;
}

.sidebar-content {
    flex: 1;
    padding: 10px;
    overflow: hidden;
}

.sidebar-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-content ul.horizontal-level {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    list-style: none;
    padding: 0;
    margin: 0 0 0 10px;
    width: 100%;
}

.sidebar-content ul.horizontal-level > li {
    flex: 1 1 calc(33% - 5px);
    min-width: 80px;
}

.sidebar-content li {
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 12px;
    line-height: 1.2;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-wrap: break-word;
}

.sidebar-content li:hover {
    background: #f9f9f9;
}

.sidebar-content .tree-node {
    position: relative;
    padding-left: 10px;
}

.sidebar-content .level-0 { margin-left: 0px; }
.sidebar-content .level-1 { margin-left: 20px; }
.sidebar-content .level-2 { margin-left: 40px; }
.sidebar-content .level-3 { margin-left: 60px; }
.sidebar-content .level-4 { margin-left: 80px; }
.sidebar-content .level-5 { margin-left: 100px; }

.sidebar-content .tree-node::before {
    content: '├──';
    position: absolute;
    left: 0;
    color: #999;
}

.sidebar-content .tree-leaf {
    font-style: italic;
    color: #666;
}

.sidebar-content .main-tags,
.sidebar-content small {
    font-size: 10px;
    display: inline-block;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tree sidebar styles for compact display */
.tree-sidebar {
    padding: 10px;
}

.tree-sidebar .tree-group {
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.tree-sidebar .tree-node {
    list-style: none;
    padding: 4px 0;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 12px;
    line-height: 1.3;
}

.tree-sidebar .tree-node:hover {
    background: #f9f9f9;
}

.tree-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0 0 0 0;
}

.tree-sidebar ul.collapsed {
    display: none;
}

.tree-sidebar .collapsed-item {
    font-style: italic;
    color: #999;
    padding: 2px 0;
}

.tree-sidebar .toggle-btn {
    background: none;
    border: none;
    font-size: 12px;
    cursor: pointer;
    color: #2196f3;
    margin-left: 5px;
    padding: 0;
    line-height: 1;
    float: right;
}

.tree-sidebar .main-tags {
    font-size: 10px;
    color: #ff9800;
    font-weight: bold;
}

.tree-sidebar small {
    font-size: 10px;
    color: #666;
    display: block;
}

/* Optional: horizontal levels if needed, but for nested tree, indent is sufficient */
.tree-level {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.level-indent {
    margin-left: 20px;
}

/* Sidebar pyramid reflection */
.pyramid-sidebar .tree-group {
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.pyramid-node.main-node {
    text-align: center;
    font-weight: bold;
    margin: 8px auto;
    padding: 4px;
}

.pyramid-node .centered {
    display: block;
    text-align: center;
}

.pyramid-node .stagger-icon {
    font-size: 10px;
    margin-right: 2px;
}

.pyramid-node .shared-tags {
    font-size: 10px;
    color: #666;
    margin-left: 4px;
}

.pyramid-sidebar ul.horizontal-level {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    list-style: none;
    padding: 0;
    margin: 2px 0;
}

.pyramid-sidebar ul.compact-level {
    margin: 2px 0;
    padding-left: 10px;
}

.pyramid-sidebar ul.collapsed {
    display: none;
}

.pyramid-sidebar .collapsed-item {
    font-style: italic;
    color: #999;
    padding: 2px 0;
}

.pyramid-sidebar .toggle-btn {
    background: none;
    border: none;
    font-size: 12px;
    cursor: pointer;
    color: #2196f3;
    margin-left: 5px;
    padding: 0;
    line-height: 1;
}
/* ИИ Чат */
.ai-chat {
    position: fixed;
    right: 20px;
    bottom: 110px;
    width: 300px;
    height: 80%;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-hover);
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}

.ai-chat.hidden {
    display: none;
}

.ai-chat.collapsed {
    height: 60px;
    width: 60px;
    border-radius: 50%;
    right: 130px;
    bottom: 100px;
}

.ai-chat.collapsed .ai-messages,
.ai-chat.collapsed .ai-input-container,
.ai-chat.collapsed .ai-header span {
    display: none;
}

.ai-chat.collapsed .ai-header {
    justify-content: center;
    background: #2196f3;
    border-radius: 50%;
    width: 60px;
    height: 60px;
}

.ai-chat.collapsed .ai-collapse {
    margin: 0;
    font-size: 24px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat.collapsed .ai-collapse::before {
    content: '🤖';
    font-size: 24px;
}

.ai-header {
    padding: 10px 15px;
    background: #2196f3;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
    font-weight: 500;
}

.ai-collapse {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    margin-right: 5px;
}

.ai-collapse:hover {
    opacity: 1;
}

.ai-detach {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.ai-detach:hover {
    opacity: 1;
}

.ai-messages {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    background: #f9f9f9;
    font-size: 14px;
    line-height: 1.4;
}

.ai-message {
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.ai-message.user {
    background: #e3f2fd;
    margin-left: 20px;
    text-align: right;
}

.ai-message.ai {
    background: #f3e5f5;
    margin-right: 20px;
}

.ai-input-container {
    padding: 10px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    background: white;
}

.ai-input-container textarea {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    background: #f9f9f9;
    transition: border-color 0.2s, background 0.2s;
}

.ai-input-container textarea:focus {
    outline: none;
    border-color: #2196f3;
    background: white;
}

.ai-input-container textarea::placeholder {
    color: #999;
}

.ai-input-container button {
    padding: 10px 16px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}

.ai-input-container button:hover:not(:disabled) {
    background: #1976d2;
}

.ai-input-container button:active:not(:disabled) {
    transform: scale(0.98);
}

.ai-input-container button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.ai-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
}

.ai-input:focus {
    outline: none;
    border-color: #2196f3;
}

.ai-send-btn {
    padding: 8px 12px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.ai-send-btn:hover:not(:disabled) {
    background: #1976d2;
}

.ai-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Typing indicator for AI chat */
.ai-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: #f3e5f5;
    border-radius: 6px;
    margin-right: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.ai-typing-dots {
    display: flex;
    gap: 2px;
}

.ai-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite ease-in-out;
}

.ai-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.ai-typing-text {
    font-size: 14px;
    color: #666;
    margin-right: 10px;
}
