/* SchemeOG Canvas Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    overflow: hidden;
    color: #000000;
}

#canvas {
    width: 100vw;
    height: 100vh;
    position: relative;
    background: #f5f5f5;
    overflow: hidden;
    /* Курсор управляется через JavaScript при нажатии пробела */
    cursor: default;
    /* Отключаем выделение текста при двойном клике */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Floating tools (слева внизу) */
.canvas-float-tools {
    position: fixed;
    left: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1001;
}

.canvas-float-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    border: 1.5px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6b7280;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.canvas-float-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #374151;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: scale(1.05);
}

.canvas-float-btn:active {
    transform: scale(0.95);
    background: #f3f4f6;
}

.canvas-float-btn svg {
    width: 20px;
    height: 20px;
}

/* Loader */
.canvas-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.canvas-loader.active {
    display: flex;
}

.loader-content {
    text-align: center;
    color: white;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader-text {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.loader-subtext {
    font-size: 14px;
    opacity: 0.8;
}

/* Schema Title (Top Left) */
.schema-title-header {
    position: fixed;
    top: 20px;
    left: 84px; /* 20px (отступ слева) + 44px (ширина кнопки схем) + 20px (gap) */
    background: white;
    height: 44px;
    padding: 0 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    border: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
}

/* Schemas Quick Access (отдельная кнопка слева) */
.schemas-quick-access {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    display: flex;
    align-items: center;
}

.schemas-toggle-btn {
    width: 44px;
    height: 44px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: white;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    outline: none;
}

/* .schemas-toggle-btn:hover {
    background: #f9fafb;
    border-color: #f97316;
    color: #f97316;
    box-shadow: 0 4px 16px rgba(249, 115, 22, 0.2);
} */

.schemas-toggle-btn:focus {
    outline: none;
}

.schemas-toggle-btn:active {
    transform: scale(0.95);
}

.schema-title-text {
    font-size: 18px;
    font-weight: 600;
    color: #000000;
    margin: 0;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    letter-spacing: -0.5px;
    /* Обрезка длинного названия с троеточием */
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schema-title-text:hover {
    background: #f5f5f5;
    color: #000000;
}

.schema-title-input {
    font-size: 18px;
    font-weight: 600;
    color: #000000;
    padding: 4px 8px;
    border: 2px solid #000000;
    border-radius: 6px;
    background: white;
    outline: none;
    letter-spacing: -0.5px;
    min-width: 200px;
}

.schema-title-input:focus {
    border-color: #000000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

/* Toolbar */
.toolbar {
    position: fixed;
    top: 20px;
    right: 80px;
    display: none;
    gap: 10px;
    background: white;
    padding: 10px 15px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 2000;
    border: 1px solid #e5e5e5;
}

.view-code-btn {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    background: #ffffff;
    color: #000000;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #e5e5e5;
}

.view-code-btn:hover {
    background: #f5f5f5;
    transform: translateY(-1px);
}

.view-code-btn:active {
    transform: translateY(0);
}

/* ========================================
   TOP TOOLBAR - Flexbox контейнер справа сверху
   ======================================== */
.top-toolbar {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1001;
}

/* Универсальная кнопка toolbar */
.toolbar-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: white;
    border: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
    color: #6b7280;
}

.toolbar-btn:hover {
    background: #f8f9fa;
    border-color: #d0d0d0;
    color: #374151;
}

.toolbar-btn:hover svg {
    stroke: #374151;
}

.toolbar-btn:active {
    transform: scale(0.95);
}

/* Account кнопка в toolbar */
.toolbar-account {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f3f4f6;
    border: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
}

.toolbar-account svg {
    width: 20px;
    height: 20px;
}

.toolbar-account:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

/* Lock toggle стили внутри toolbar */
.toolbar-btn.lock-toggle {
    position: relative;
    padding: 0;
}

.toolbar-btn.lock-toggle input {
    display: none;
}

.toolbar-btn.lock-toggle .lock-toggle-slider {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #6b7280;
}

.toolbar-btn.lock-toggle .lock-open {
    display: block;
}

.toolbar-btn.lock-toggle .lock-closed {
    display: none;
}

.toolbar-btn.lock-toggle input:checked + .lock-toggle-slider .lock-open {
    display: none;
}

.toolbar-btn.lock-toggle input:checked + .lock-toggle-slider .lock-closed {
    display: block;
}

.toolbar-btn.lock-toggle:has(input:checked) {
    background: #fef3c7;
    border-color: #f59e0b;
}

.toolbar-btn.lock-toggle:has(input:checked) .lock-toggle-slider {
    color: #d97706;
}

/* Legacy стили для обратной совместимости */
.schema-settings-btn,
.schema-share-btn,
.schema-copy-btn,
.schema-download-btn {
    display: none; /* Скрываем старые кнопки */
}

/* Lock Toggle Button (MCP mode) - legacy */
.schema-lock-toggle {
    display: none; /* Скрываем старую кнопку */
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 1001;
    transition: all 0.2s ease;
}

.schema-lock-toggle:hover {
    background: #f8f9fa;
    border-color: #d0d0d0;
}

.schema-lock-toggle input {
    display: none;
}

.schema-lock-toggle .lock-toggle-slider {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: color 0.2s ease;
}

.schema-lock-toggle .lock-open {
    display: block;
}

.schema-lock-toggle .lock-closed {
    display: none;
}

/* Locked state */
.schema-lock-toggle input:checked + .lock-toggle-slider {
    color: #d97706;
}

.schema-lock-toggle input:checked + .lock-toggle-slider .lock-open {
    display: none;
}

.schema-lock-toggle input:checked + .lock-toggle-slider .lock-closed {
    display: block;
}

/* When locked - show yellow background */
.schema-lock-toggle:has(input:checked) {
    background: #fef3c7;
    border-color: #fbbf24;
}

/* Locked mode - disable editing UI */
body.locked-mode .left-sidebar {
    opacity: 0.4;
    pointer-events: none;
}

body.locked-mode #canvas {
    cursor: default !important;
}

/* Visual indicator when locked */
body.locked-mode::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
    z-index: 99999;
}

.schema-copy-btn {
    position: fixed;
    top: 20px;
    right: 228px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: white;
    border: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 1001;
    transition: all 0.2s ease;
    color: #333;
}

.schema-copy-btn:hover {
    background: #fff7ed;
    border-color: #f97316;
}

.schema-copy-btn:hover svg {
    stroke: #f97316;
}

.schema-copy-btn:active {
    transform: scale(0.95);
}

.schema-paste-btn {
    position: fixed;
    top: 20px;
    right: 228px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: white;
    border: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 1001;
    transition: all 0.2s ease;
    color: #333;
}

.schema-paste-btn:hover {
    background: #fff7ed;
    border-color: #f97316;
}

.schema-paste-btn:hover svg {
    stroke: #f97316;
}

.schema-paste-btn:active {
    transform: scale(0.95);
}

.schema-download-btn {
    position: fixed;
    top: 20px;
    right: 176px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: white;
    border: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 1001;
    transition: all 0.2s ease;
    color: #333;
}

.schema-download-btn:hover {
    background: #f8f9fa;
    border-color: #d0d0d0;
}

.schema-download-btn:active {
    transform: scale(0.95);
}

.account-circle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: white;
    border: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 1001;
    transition: all 0.2s ease;
    font-size: 18px;
    user-select: none;
    color: #333;
}

.account-circle svg {
    width: 20px;
    height: 20px;
}

.account-circle:hover {
    background: #f8f9fa;
    border-color: #d0d0d0;
}

.account-circle:active {
    transform: scale(0.95);
}

/* Account Dropdown */
.account-dropdown {
    position: fixed;
    top: 72px;
    right: 20px;
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    display: none;
    min-width: 200px;
    overflow: hidden;
}

.account-dropdown.show {
    display: block;
    animation: fadeIn 0.15s ease-out;
}

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

.account-dropdown-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #000000;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.account-dropdown-item:hover {
    background: #f9f9f9;
}

.account-dropdown-divider {
    height: 1px;
    background: #e5e5e5;
    margin: 0;
}

.account-dropdown-header {
    padding: 0;
    font-size: 13px;
    color: #737373;
    border-bottom: 1px solid #e5e5e5;
}

.account-dropdown-email {
    font-weight: 400;
    font-size: 14px;
    color: #000000;
    cursor: pointer;
    padding: 12px 16px;
    border-radius: 0;
    transition: background 0.2s;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.account-dropdown-email:hover {
    background: #f9f9f9;
}

/* Tooltips - единый стиль (чёрный фон, белый текст) */
.element-tooltip {
    position: fixed;
    background: #1f2937;
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    border: none;
    font-size: 12px;
    font-weight: 500;
    pointer-events: none;
    z-index: 10000;
    display: none;
    white-space: normal;
    max-width: 300px;
    word-wrap: break-word;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.element-tooltip.show,
.element-tooltip.visible {
    display: block;
}

/* ============================================= */
/* DESCRIPTION PANEL (slides from right) */
/* ============================================= */

.description-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100vh;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 2000000; /* Выше toolbar кнопок (999999) */
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.description-panel.visible {
    right: 0;
}

.description-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.description-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}

.description-panel-content {
    flex: 1;
    padding: 16px 20px;
    overflow-y: auto;
}

.description-panel-content textarea {
    width: 100%;
    height: 100%;
    min-height: 200px;
    padding: 12px;
    font-size: 14px;
    line-height: 1.6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    resize: none;
    background: #f9fafb;
    color: #374151;
    transition: border-color 0.2s, background 0.2s;
    margin: 0;
    box-sizing: border-box;
}

.description-panel-content textarea:focus {
    outline: none;
    border-color: #f97316;
    background: #fff;
}

/* SVG Canvas Elements */
#canvas svg {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* SVG Карточки, условия и ASCII */
.schemeog-card,
.schemeog-condition,
.schemeog-ascii {
    cursor: move;
    user-select: none;
    pointer-events: all;
}

.schemeog-card:hover rect,
.schemeog-condition:hover path,
.schemeog-ascii:hover rect {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.schemeog-card.dragging,
.schemeog-condition.dragging,
.schemeog-ascii.dragging {
    opacity: 0.8;
}

/* Выделенные элементы - БЕЗ ОБВОДКИ */
.schemeog-card.selected,
.schemeog-condition.selected,
.schemeog-ascii.selected {
    opacity: 1;
    cursor: move;
}

/* Подсветка элементов во время обводки рамкой выделения */
.schemeog-card.selection-hover rect:first-child,
.schemeog-condition.selection-hover path:first-child,
.schemeog-ascii.selection-hover rect:first-child {
    filter: drop-shadow(0 0 8px rgba(249, 115, 22, 0.6)) drop-shadow(0 0 3px rgba(249, 115, 22, 0.8));
    transition: filter 0.15s ease;
}

/* Анимация для выделенных элементов */
.selection-outline {
    animation: selection-pulse 2s ease-in-out infinite;
}

@keyframes selection-pulse {
    0%, 100% {
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
}

/* Режим read-only: курсор по умолчанию */
.read-only-mode .schemeog-card,
.read-only-mode .schemeog-condition,
.read-only-mode .schemeog-card.selected,
.read-only-mode .schemeog-condition.selected {
    cursor: default !important;
}

/* Legacy Card Styles (для старых версий) */
.card {
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    cursor: move;
    user-select: none;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Scheme Code Viewer */
.scheme-code-viewer {
    position: fixed;
    top: 0;
    right: 0;
    width: 500px;
    height: 100vh;
    background: white;
    border-left: 1px solid #e5e5e5;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    z-index: 2000;
    display: none;
    flex-direction: column;
}

.scheme-code-viewer.active {
    display: flex;
}

.code-header {
    padding: 20px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.code-content {
    flex: 1;
    overflow: auto;
    padding: 20px;
}

.code-block {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 0;
    margin: 8px 0;
    overflow: hidden;
    position: relative;
}

.code-block .code-lang {
    display: block;
    background: #333;
    color: #888;
    font-size: 11px;
    padding: 4px 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.code-block pre {
    margin: 0;
    padding: 12px 15px;
    overflow-x: auto;
}

.code-block pre code {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #d4d4d4;
    white-space: pre;
    display: block;
}

/* Inline code */
code.inline-code {
    background: #f0f0f0;
    color: #e53935;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 0.9em;
}

/* Markdown rendered content in descriptions */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
    margin: 12px 0 8px 0;
    line-height: 1.3;
}

.markdown-content h1 { font-size: 1.4em; }
.markdown-content h2 { font-size: 1.2em; }
.markdown-content h3 { font-size: 1.1em; }

.markdown-content p {
    margin: 6px 0;
    line-height: 1.5;
}

.markdown-content ul,
.markdown-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.markdown-content li {
    margin: 4px 0;
    line-height: 1.4;
}

.markdown-content hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 12px 0;
}

.markdown-content a {
    color: #f97316;
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

/* Tooltip markdown styles */
#tooltip-content .code-block {
    margin: 6px 0;
}

#tooltip-content .code-block pre {
    padding: 8px 12px;
}

#tooltip-content code.inline-code {
    font-size: 0.85em;
}

#tooltip-content p {
    margin: 4px 0;
}

/* Marked.js code block styles (when using marked.js library) */
pre {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 12px 15px;
    margin: 8px 0;
    overflow-x: auto;
}

pre code {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    color: #d4d4d4;
    background: transparent !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

/* Inline code from marked.js */
code {
    background: #f0f0f0;
    color: #e53935;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 0.9em;
}

/* Side panel and tooltip specific styles for code */
#tooltip-content pre,
#card-description pre,
#card-description-text pre,
.card-detail-panel pre {
    background: #1e1e1e;
    padding: 10px 12px;
    margin: 6px 0;
}

#tooltip-content code,
#card-description code,
#card-description-text code,
.card-detail-panel code {
    font-size: 0.85em;
}

.close-btn {
    padding: 8px 16px;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

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

/* Popups */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.popup-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.popup-header {
    margin-bottom: 20px;
}

.popup-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: #000000;
}

.popup-body {
    margin-bottom: 20px;
}

.popup-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Forms */
input[type="text"],
input[type="email"],
textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    background: #ffffff;
    color: #000000;
    outline: none;
    transition: all 0.2s ease;
    margin-bottom: 12px;
}

input:focus,
textarea:focus {
    border-color: #000000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

button {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border: 1.5px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    outline: none;
}

button:focus {
    outline: none;
}

/* Стили кнопок в стиле "Только обводки" (Вариант 3) */
.btn-primary, button.primary {
    background: transparent;
    color: #000000;
    border: 1.5px solid #000000;
}

.btn-primary:hover, button.primary:hover {
    background: #fafafa;
}

.btn-secondary, button.secondary {
    background: transparent;
    color: #6b7280;
    border: 1.5px solid #d1d5db;
}

.btn-secondary:hover, button.secondary:hover {
    background: #f9fafb;
}

.btn-danger, button.danger {
    background: transparent;
    color: #dc2626;
    border: 1.5px solid #dc2626;
}

.btn-danger:hover, button.danger:hover {
    background: #fef2f2;
}

/* Кнопка закрытия (X) */
.btn-close {
    background: transparent;
    color: #6b7280;
    border: none;
    padding: 0;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.btn-close-absolute {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

/* Utility classes */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

/* ================================================
   POPUP БЛОКИРОВКА UI - КРИТИЧЕСКИ ВАЖНО!
   Когда попап открыт, весь остальной UI блюрится
   и недоступен для клика
   ================================================ */

/* Overlay для всех попапов */
.popup-overlay,
.card-detail-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    animation: fadeInOverlay 0.2s ease-out;
}

/* Попап подтверждения удаления - ВЫШЕ всех остальных попапов */
#delete-confirm-popup {
    z-index: 1000000 !important;
}

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

/* Когда попап открыт */
.popup-overlay.show,
.card-detail-overlay.show {
    display: flex;
}

/* Блокировка UI элементов когда попап открыт */
body.popup-open #canvas,
body.popup-open .toolbar,
body.popup-open .top-toolbar,
body.popup-open .schema-title-header,
body.popup-open .account-dropdown {
    pointer-events: none;
    filter: blur(3px);
    opacity: 0.6;
    transition: filter 0.2s ease, opacity 0.2s ease;
}

/* Восстановление UI когда попап закрыт */
body:not(.popup-open) #canvas,
body:not(.popup-open) .toolbar,
body:not(.popup-open) .top-toolbar,
body:not(.popup-open) .schema-title-header,
body:not(.popup-open) .account-dropdown {
    pointer-events: auto;
    filter: none;
    opacity: 1;
    transition: filter 0.2s ease, opacity 0.2s ease;
}

/* Стили для card-detail-popup */
.card-detail-popup {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    position: relative;
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

/* Заголовок карточки детали */
.card-detail-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-shrink: 0;
    background: white;
    border-radius: 16px 16px 0 0;
}

.card-detail-title {
    font-size: 18px;
    font-weight: 600;
    color: #000000;
    margin-bottom: 4px;
}

.card-detail-subtitle {
    font-size: 11px;
    color: #737373;
}

.card-detail-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.card-detail-edit-btn,
.card-detail-save-btn,
.card-detail-cancel-btn,
.card-detail-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 24px;
    line-height: 1;
    padding: 0;
    color: #6b7280;
}

.card-detail-edit-btn:hover,
.card-detail-save-btn:hover,
.card-detail-cancel-btn:hover,
.card-detail-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.card-detail-content {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.card-tags-popup {
    margin-bottom: 12px;
}

.card-tags-popup h4 {
    font-size: 12px;
    font-weight: 600;
    color: #000000;
    margin-bottom: 6px;
}

.card-tag-popup {
    display: inline-block;
    padding: 2px 6px;
    margin: 2px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 400;
    border: 1px solid currentColor;
    background: transparent;
    opacity: 0.8;
}

.card-description {
    font-size: 15px;
    line-height: 1.6;
    color: #000000;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.card-description-textarea {
    width: 100%;
    min-height: 200px;
    padding: 12px;
    font-size: 15px;
    line-height: 1.6;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    resize: vertical;
    font-family: inherit;
}

.card-detail-title-input {
    width: 100%;
    font-size: 24px;
    font-weight: 600;
    padding: 4px 8px;
    border: 2px solid #000000;
    border-radius: 6px;
    margin-bottom: 8px;
}

/* ========================================
   iOS-STYLE SWITCH (Completed toggle)
   ======================================== */

/* Контейнер секции */
.completed-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.completed-label {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

/* iOS Switch */
.ios-switch {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
    flex-shrink: 0;
}

.ios-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ios-switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e9e9eb;
    border-radius: 31px;
    transition: background-color 0.3s ease;
}

.ios-switch-slider:before {
    position: absolute;
    content: "";
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Checked state - зелёный как на iPhone */
.ios-switch input:checked + .ios-switch-slider {
    background-color: #34c759;
}

.ios-switch input:checked + .ios-switch-slider:before {
    transform: translateX(20px);
}

/* Hover effect */
.ios-switch:hover .ios-switch-slider {
    background-color: #d1d1d6;
}

.ios-switch input:checked + .ios-switch-slider:hover {
    background-color: #2db84d;
}

/* Focus для accessibility */
.ios-switch input:focus + .ios-switch-slider {
    box-shadow: 0 0 0 2px rgba(52, 199, 89, 0.3);
}

/* Active press effect */
.ios-switch:active .ios-switch-slider:before {
    width: 31px;
}

.ios-switch input:checked:active + .ios-switch-slider:before {
    transform: translateX(16px);
}

/* ========================================
   СТИЛИ ДЛЯ УПРАВЛЕНИЯ ДОСТУПОМ К СХЕМАМ
   ======================================== */

/* Карточки типов доступа */
.access-option {
    display: block;
    cursor: pointer;
}

.access-radio {
    display: none;
}

.access-card {
    padding: 16px;
    border: 2px solid #e5e5e5;
    border-radius: 12px;
    transition: all 0.2s ease;
    background: white;
}

.access-card:hover {
    border-color: #cbd5e1;
    background: #f8f9fa;
}

.access-radio:checked + .access-card {
    border-color: #f97316;
    background: #fff7ed;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

/* Кнопка настроек доступа в списке схем */
.schema-access-btn {
    opacity: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    border: none;
    background: transparent;
    color: #6b7280;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.schema-access-btn:hover {
    background: #f3f4f6;
    color: #f97316;
}

.group:hover .schema-access-btn {
    opacity: 1;
}

/* Список приглашенных пользователей */
.invite-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: white;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
}

.invite-item-email {
    flex: 1;
    font-size: 14px;
    color: #374151;
}

.invite-item-status {
    font-size: 12px;
    color: #6b7280;
    margin-right: 12px;
}

.invite-item-remove {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.invite-item-remove:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* Анимация для показа блоков */
.show-with-fade {
    animation: fadeIn 0.3s ease;
}

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

/* Уведомление об успешном копировании */
.copy-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    background: #10b981;
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    animation: slideIn 0.3s ease, slideOut 0.3s ease 2.7s;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Редактирование тегов в попапе карточки - МИНИМАЛИСТИЧНЫЙ ДИЗАЙН */
.card-tags-edit {
    margin-bottom: 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
}

.card-tags-edit h4 {
    display: none; /* Скрываем заголовок, теги теперь в header */
}

.card-tags-edit-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 24px;
    margin-bottom: 8px;
    align-items: center;
}

.card-tag-editable {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid;
    transition: all 0.15s;
    line-height: 1.4;
    cursor: pointer;
    position: relative;
}

.card-tag-editable:hover {
    filter: brightness(1.1);
}

.card-tag-remove {
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.15s;
    margin-left: 2px;
}

.card-tag-remove:hover {
    opacity: 1;
}

.card-tag-add-btn {
    padding: 2px 8px;
    background: transparent;
    border: 1px dashed #d1d5db;
    border-radius: 3px;
    color: #9ca3af;
    font-size: 10px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.15s;
    opacity: 0.6;
    line-height: 1.4;
}

.card-tag-add-btn:hover {
    opacity: 1;
    border-color: #6b7280;
    color: #6b7280;
    background: rgba(107, 114, 128, 0.05);
}

.card-tag-dropdown {
    position: absolute;
    margin-top: 4px;
    padding: 8px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    max-height: 320px;
    overflow-y: auto;
    z-index: 1000;
    min-width: 220px;
}

.card-tag-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 12px;
}

.card-tag-dropdown-item:hover {
    background: #f9fafb;
}

.card-tag-dropdown-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    border: 1.5px solid;
    flex-shrink: 0;
}

/* Стили для попапа карточки - заголовок редактируется по двойному клику */
.card-detail-title-input {
    width: 100%;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    padding: 8px 12px;
    border: 2px solid transparent;
    border-radius: 6px;
    background: #f9fafb;
    transition: all 0.2s;
}

.card-detail-title-input:hover {
    background: #f3f4f6;
}

.card-detail-title-input:focus {
    outline: none;
    border-color: #f97316;
    background: white;
}

.card-description-edit {
    margin-top: 12px;
}

.card-description-edit h4 {
    margin: 0 0 6px 0;
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

.card-description-textarea {
    display: block !important;
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border: 2px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    color: #374151;
    background: #f9fafb;
    resize: vertical;
    transition: all 0.2s;
}

.card-description-textarea:hover {
    background: #f3f4f6;
}

.card-description-textarea:focus {
    outline: none;
    border-color: #f97316;
    background: white;
}

/* Markdown Preview */
.card-description-preview {
    margin-top: 16px;
    padding: 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.card-description-preview-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-description-preview-content {
    font-size: 14px;
    line-height: 1.6;
    color: #374151;
}

.card-description-preview-content h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 12px 0 8px 0;
    color: #111827;
}

.card-description-preview-content h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 10px 0 6px 0;
    color: #111827;
}

.card-description-preview-content h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 8px 0 4px 0;
    color: #111827;
}

.card-description-preview-content p {
    margin: 8px 0;
}

.card-description-preview-content ul,
.card-description-preview-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.card-description-preview-content li {
    margin: 4px 0;
}

.card-description-preview-content code {
    background: #e5e7eb;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 13px;
}

.card-description-preview-content pre {
    background: #1f2937;
    color: #e5e7eb;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 12px 0;
}

.card-description-preview-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.card-description-preview-content strong {
    font-weight: 600;
    color: #111827;
}

.card-description-preview-content em {
    font-style: italic;
}

.card-description-preview-content a {
    color: #f97316;
    text-decoration: underline;
}

.card-description-preview-content a:hover {
    color: #ea580c;
}

/* Убираем старые кнопки редактирования */
.card-detail-edit-btn,
.card-detail-save-btn,
.card-detail-cancel-btn {
    display: none !important;
}

/* Заголовок карточки - обычный текст, редактируется по двойному клику */
.card-detail-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: text;
    transition: background 0.2s;
    margin: 0;
}

.card-detail-title:hover {
    background: #f9fafb;
}

/* Скрываем input по умолчанию */
.hidden {
    display: none !important;
}

/* Когда input активен */
.card-detail-title-input:not(.hidden) {
    display: block !important;
}

/* Левая панель инструментов */
.left-sidebar {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: white;
    border-radius: 0 12px 12px 0;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.sidebar-btn {
    width: 44px;
    height: 44px;
    border: 1.5px solid #e5e7eb;
    border-radius: 50%;
    background: white;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    outline: none;
}

.sidebar-btn:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #374151;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.sidebar-btn:focus {
    outline: none;
}

.sidebar-btn:active {
    transform: scale(0.95);
    background: #f3f4f6;
}

/* Тултипы для кнопок сайдбара */
.sidebar-btn[data-tooltip] {
    position: relative;
}

.sidebar-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 8px;
    background: #1f2937;
    color: white;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease-in-out;
    z-index: 10000;
}

.sidebar-btn[data-tooltip]:hover::after {
    opacity: 1;
}

/* Тултипы для кнопок сайдбара с i18n */
.sidebar-btn[data-tooltip-i18n] {
    position: relative;
}

.sidebar-btn[data-tooltip-i18n]::after {
    content: attr(title);
    position: absolute;
    left: calc(100% + 8px) !important;
    top: 50% !important;
    bottom: auto !important;
    transform: translateY(-50%) !important;
    padding: 4px 8px !important;
    background: #1f2937;
    color: white;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease-in-out;
    z-index: 10000;
    height: auto !important;
}

.sidebar-btn[data-tooltip-i18n]:hover::after {
    opacity: 1;
}

/* Schemas Quick Access Dropdown */
.schemas-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 300px;
    max-width: 400px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 1001;
    max-height: 500px;
    display: flex;
    flex-direction: column;
}

.schemas-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.schemas-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    font-size: 14px;
    color: #111827;
    background: #f9fafb;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Кнопка "+" в хедере дропдауна — стиль как у "All" */
.schemas-header-plus-btn {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.schemas-header-plus-btn:hover {
    background: white;
    border-color: #9ca3af;
    color: #374151;
}

.schemas-view-all-btn {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.schemas-view-all-btn:hover {
    background: white;
    border-color: #9ca3af;
    color: #374151;
}

.schemas-create-btn {
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    color: #6b7280;
    border: none;
    border-top: 1px solid #e5e7eb;
    border-radius: 0;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}

.schemas-create-btn:hover {
    background: #f9fafb;
    color: #374151;
}

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

.schemas-dropdown-content {
    overflow-y: auto;
    max-height: 350px;
    padding: 8px 0;
}

.schemas-dropdown-loading {
    padding: 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

.schemas-dropdown-empty {
    padding: 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

.schemas-dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #374151;
    font-size: 14px;
}

.schemas-dropdown-item:hover {
    background: #f3f4f6;
}

.schemas-dropdown-item.active {
    background: #fff7ed;
    color: #ea580c;
    font-weight: 500;
}

.schemas-dropdown-item.active .schema-name-btn {
    color: #ea580c;
    font-weight: 500;
}

/* Schema info container - название + проект */
.schema-info-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    cursor: pointer;
}

.schema-info-container:hover .schema-name-text {
    color: #ea580c;
}

.schema-name-text {
    font-size: 14px;
    color: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schema-project-text {
    font-size: 11px;
    color: #9ca3af;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schemas-dropdown-item.active .schema-name-text {
    color: #ea580c;
    font-weight: 500;
}

/* Schema name button - основное название (legacy) */
.schema-name-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    text-align: left;
    color: inherit;
    font-size: 14px;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schema-name-btn:hover {
    color: #ea580c;
}

/* Schema rename button - карандаш */
.schema-rename-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.schemas-dropdown-item:hover .schema-rename-btn {
    opacity: 1;
}

.schema-rename-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

/* Project headers in schemas dropdown */
.schemas-dropdown-project-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 4px;
    margin-top: 4px;
}

.schemas-dropdown-project-header:first-child {
    margin-top: 0;
    padding-top: 4px;
}

.schemas-dropdown-project-header .project-name {
    font-size: 11px;
    font-weight: 500;
    color: #6b7280;
}

.schemas-dropdown-project-header .project-count {
    font-size: 10px;
    color: #9ca3af;
}

/* Rename input mode */
.schema-rename-input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #f97316;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

/* Tooltips для топбара (schema-settings, share, download) */
[data-tooltip-i18n] {
    position: relative;
}

[data-tooltip-i18n]::after {
    content: attr(title);
    position: absolute;
    bottom: -32px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: #1f2937;
    color: white;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease-in-out;
    z-index: 10000;
}

[data-tooltip-i18n]:hover::after {
    opacity: 1;
}

/* Override for sidebar buttons - position tooltip to the right */
.sidebar-btn[data-tooltip-i18n]::after {
    left: calc(100% + 8px);
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    padding: 4px 8px;
    height: auto;
}

/* ========================================
   SCHEMA FILTERS & OWNER ICONS
   ======================================== */

/* Кнопки фильтров схем */
/* Минималистичные кнопки фильтров */
.schema-filter-btn {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.15s ease;
}

.schema-filter-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.schema-filter-btn.active {
    background: #f3f4f6;
    color: #111827;
    font-weight: 600;
}

/* ========================================
   ROLE BADGES
   ======================================== */

/* Бейджики ролей для схем */
/* Минималистичные бейджи ролей */
.role-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.role-badge.editor {
    background: #fff7ed;
    color: #f97316;
    border: 1px solid #fed7aa;
}

.role-badge.viewer {
    background: #f9fafb;
    color: #6b7280;
    border: 1px solid #e5e7eb;
}

/* ========================================
   CONNECTION ENDPOINTS (Синие точки на связях)
   ======================================== */

/* Гарантируем, что синие точки на связях всегда интерактивны */
.connection-endpoint {
    pointer-events: all !important;
    cursor: grab !important;
    z-index: 1000 !important;
}

.connection-endpoint:active {
    cursor: grabbing !important;
}

.connection-endpoint circle {
    pointer-events: all !important;
    cursor: inherit !important;
}

/* При наведении увеличиваем точку для лучшей видимости */
.connection-endpoint:hover circle {
    r: 6;
    stroke-width: 2.5;
    filter: drop-shadow(0 0 2px rgba(249, 115, 22, 0.5));
}

/* Анимация при драге */
.connection-endpoint.dragging circle {
    r: 7;
    stroke-width: 2.5;
    fill: #f97316;
    filter: drop-shadow(0 0 4px rgba(249, 115, 22, 0.8));
}

/* ==========================================
   Custom Select Dropdown Styles
   ========================================== */

.custom-select {
    position: relative;
    display: inline-block;
}

.custom-select-trigger {
    padding: 10px 32px 10px 12px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 140px;
}

.custom-select-trigger:hover {
    border-color: #9ca3af;
}

.custom-select.open .custom-select-trigger {
    border-color: #000000;
}

.custom-select-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    transition: transform 0.2s;
}

.custom-select.open .custom-select-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 10000;
    min-width: 100%;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s;
}

.custom-select.open .custom-select-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-select-option {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #000000;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.custom-select-option:first-child {
    border-radius: 6px 6px 0 0;
}

.custom-select-option:last-child {
    border-radius: 0 0 6px 6px;
}

.custom-select-option:hover {
    background: #f5f5f5;
}

.custom-select-option.selected {
    background: #fafafa;
}

/* ===============================
   ASCII CARD STYLES
   =============================== */

/* ASCII карточка - основной контейнер */
/* cursor: move наследуется из общего стиля .schemeog-ascii выше */

.schemeog-ascii rect {
    transition: stroke-width 0.15s ease;
}

.schemeog-ascii:hover rect {
    stroke-width: 2.5;
}

/* ASCII текст - моноширинный шрифт */
.schemeog-ascii text {
    font-family: 'Courier New', 'Consolas', 'Monaco', 'Liberation Mono', 'Lucida Console', monospace;
    /* Улучшение рендеринга текста */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ASCII placeholder для пустого контента */
.schemeog-ascii text[font-style="italic"] {
    opacity: 0.7;
}

/* ASCII ошибка - визуальный стиль */
.schemeog-ascii-error rect {
    animation: ascii-error-pulse 2s ease-in-out infinite;
}

@keyframes ascii-error-pulse {
    0%, 100% {
        stroke-opacity: 1;
    }
    50% {
        stroke-opacity: 0.6;
    }
}

/* ASCII при низком zoom - улучшенная читаемость */
.schemeog-ascii.zoom-low text {
    font-weight: 500;
}

/* ASCII при высоком zoom - более тонкий шрифт */
.schemeog-ascii.zoom-high text {
    font-weight: 400;
}

/* Выделенная ASCII карточка */
.schemeog-ascii.selected rect {
    stroke-width: 3;
    filter: drop-shadow(0 2px 8px rgba(156, 39, 176, 0.3));
}

/* ====================================
   Schemas Sidebar (выдвижная панель)
   ==================================== */

/* Overlay (затемнение фона) */
.schemas-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.schemas-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Sidebar панель */
.schemas-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100vh;
    background: #ffffff;
    z-index: 2000;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.schemas-sidebar.active {
    transform: translateX(0);
}

/* Header */
.schemas-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #fafafa;
}

.schemas-sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.schemas-sidebar-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: all 0.15s ease;
}

.schemas-sidebar-close:hover {
    background: #f3f4f6;
    color: #374151;
}

/* Поиск */
.schemas-sidebar-search {
    position: relative;
    padding: 8px 12px;
    border-bottom: 1px solid #f3f4f6;
}

.schemas-sidebar-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.schemas-sidebar-search input:focus {
    border-color: #f97316;
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.1);
}

.schemas-sidebar-search input::placeholder {
    color: #9ca3af;
}

/* Убираем иконку поиска — не нужна */
.schemas-sidebar-search svg {
    display: none;
}

/* Кнопка создания — внизу sidebar */
.schemas-sidebar-create {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0 12px 12px;
    padding: 8px 12px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.schemas-sidebar-create:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

.schemas-sidebar-create:active {
    transform: scale(0.98);
}

.schemas-sidebar-create svg {
    width: 14px;
    height: 14px;
}

/* Контент (список схем) */
.schemas-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.schemas-sidebar-loading {
    padding: 40px 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

.schemas-sidebar-empty {
    padding: 40px 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

/* Группа проекта */
.schemas-sidebar-project {
    margin-bottom: 4px;
}

.schemas-sidebar-project-header {
    padding: 6px 12px 2px;
    font-size: 10px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Элемент схемы — компактный, без иконки */
.schemas-sidebar-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s ease;
    border: none;
    border-left: 2px solid transparent;
    background: none;
    width: 100%;
    text-align: left;
}

.schemas-sidebar-item:hover {
    background: #f9fafb;
}

.schemas-sidebar-item.active {
    border-left-color: #f97316;
}

.schemas-sidebar-item-name {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.schemas-sidebar-item-date {
    font-size: 10px;
    color: #c0c0c0;
    flex-shrink: 0;
    margin-left: 8px;
}

/* Keyboard hint */
.schemas-sidebar-hint {
    padding: 12px 16px;
    border-top: 1px solid #f3f4f6;
    font-size: 11px;
    color: #9ca3af;
    text-align: center;
}

.schemas-sidebar-hint kbd {
    display: inline-block;
    padding: 2px 6px;
    background: #f3f4f6;
    border-radius: 4px;
    font-family: inherit;
    font-size: 11px;
}

/* Mobile responsive */
@media (max-width: 400px) {
    .schemas-sidebar {
        width: 100%;
    }
}
