:root {
    --bg-app: #1e1e1e;
    --bg-sidebar: #252525;
    --bg-sidebar-hover: #323232;
    --bg-sidebar-active: #3a3a3a;
    --bg-content: #1a1a1a;
    --bg-tab: #2a2a2a;
    --bg-tab-active: #1e1e1e;
    --bg-node: #2d2d2d;
    --bg-node-hover: #353535;
    --bg-statusbar: #1b1b1b;
    --text-primary: #dcdcdc;
    --text-secondary: #b0b0b0;
    --text-muted: #7a7a7a;
    --text-faint: #5a5a5a;
    --accent: #7f6df2;
    --accent-hover: #9b8df5;
    --accent-soft: rgba(127, 109, 242, 0.15);
    --border: #3a3a3a;
    --border-light: #333333;
    --dot-color: #333;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    --node-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    --node-shadow-hover: 0 6px 28px rgba(0, 0, 0, 0.6), 0 0 0 2px var(--accent);
    --radius: 8px;
    --radius-node: 12px;
    --transition: 0.15s ease;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    background: var(--bg-app);
    color: var(--text-primary);
    user-select: none;
    -webkit-user-select: none;
    -webkit-font-smoothing: antialiased;
}

/* ===== APP SHELL ===== */
.app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* ===== TITLE BAR ===== */
.titlebar {
    display: flex;
    align-items: center;
    height: 36px;
    min-height: 36px;
    background: #1b1b1b;
    border-bottom: 1px solid var(--border);
    padding: 0 12px;
    gap: 8px;
    z-index: 100;
    -webkit-app-region: drag;
}
.titlebar__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    -webkit-app-region: no-drag;
    cursor: pointer;
    transition: var(--transition);
}
.titlebar__dot--red {
    background: #ff5f57;
}
.titlebar__dot--yellow {
    background: #febc2e;
}
.titlebar__dot--green {
    background: #28c840;
}
.titlebar__dot:hover {
    filter: brightness(1.3);
}
.titlebar__title {
    flex: 1;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

/* ===== MAIN AREA ===== */
.main-area {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}
/* 
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
    margin-left: -260px;
    transition: margin-left 0.25s ease, opacity 0.25s ease; 
}
.sidebar.collapsed {
    margin-left: -260px;
    opacity: 0;
    pointer-events: none;
}
.sidebar__header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.sidebar__header-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.2px;
}
.sidebar__header-actions {
    display: flex;
    gap: 4px;
}
.sidebar__btn {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.sidebar__btn:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}
.sidebar__search {
    margin: 8px 12px;
    padding: 7px 10px;
    background: var(--bg-sidebar-hover);
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: var(--font);
    outline: none;
    transition: var(--transition);
    flex-shrink: 0;
}
.sidebar__search:focus {
    border-color: var(--accent);
    background: #2a2a2a;
}
.sidebar__search::placeholder {
    color: var(--text-faint);
}
.sidebar__tree {
    flex: 1;
    overflow-y: auto;
    padding: 8px 6px;
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
}
.sidebar__tree::-webkit-scrollbar {
    width: 5px;
}
.sidebar__tree::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar__tree::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 10px;
}

 File tree items 
.tree-folder {
    margin-bottom: 2px;
}
.tree-folder__header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: var(--transition);
    font-weight: 500;
}
.tree-folder__header:hover {
    background: var(--bg-sidebar-hover);
}
.tree-folder__icon {
    font-size: 11px;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}
.tree-folder.open>.tree-folder__header .tree-folder__icon {
    transform: rotate(90deg);
}
.tree-folder__children {
    padding-left: 20px;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    opacity: 0;
}
.tree-folder.open>.tree-folder__children {
    max-height: 300px;
    opacity: 1;
}
.tree-file {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12.5px;
    color: var(--text-secondary);
    transition: var(--transition);
    margin: 1px 0;
    position: relative;
}
.tree-file:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-primary);
}
.tree-file.active {
    background: var(--bg-sidebar-active);
    color: var(--text-primary);
    font-weight: 500;
}
.tree-file.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}
.tree-file__icon {
    font-size: 14px;
    flex-shrink: 0;
}
.tree-file__name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
} */

/* ===== CONTENT ===== */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-content);
    position: relative;
}

/* ===== TABS BAR ===== */
.tabs-bar {
    display: flex;
    align-items: stretch;
    height: 38px;
    min-height: 38px;
    background: var(--bg-tab);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
    gap: 0;
    flex-shrink: 0;
}
.tabs-bar::-webkit-scrollbar {
    display: none;
}
.tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 16px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    border-right: 1px solid var(--border-light);
    background: transparent;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
    min-width: 0;
    flex-shrink: 0;
    font-family: var(--font);
}
.tab:hover {
    background: #2f2f2f;
    color: var(--text-secondary);
}
.tab.active {
    background: var(--bg-tab-active);
    color: var(--text-primary);
    border-bottom: 2px solid var(--accent);
    margin-bottom: -1px;
    font-weight: 500;
}
.tab__icon {
    font-size: 13px;
}
.tab__close {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
    margin-left: 2px;
}
.tab__close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* ===== CANVAS CONTAINER ===== */
.canvas-outer {
    flex: 1;
    position: relative;
    overflow: hidden;
    cursor: grab;
    background: #181818;
    background-image: radial-gradient(circle, var(--dot-color) 1px, transparent 1px);
    background-size: 28px 28px;
}
.canvas-outer:active {
    cursor: grabbing;
}
.canvas-outer.dragging-node {
    cursor: default;
}
.canvas-outer.panning {
    cursor: grabbing;
}

.canvas-viewport {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
    transition: none;
    pointer-events: none;
}
.canvas-viewport>* {
    pointer-events: auto;
}

/* SVG lines */
.canvas-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: visible;
}
.canvas-lines line {
    stroke: #555;
    stroke-width: 2;
    stroke-linecap: round;
    transition: stroke 0.2s ease;
    vector-effect: non-scaling-stroke;
}
.canvas-lines line.highlight {
    stroke: var(--accent);
    stroke-width: 2.5;
}

/* Arrow markers */
.canvas-lines defs marker polygon {
    fill: #555;
    transition: fill 0.2s ease;
}
.canvas-lines line.highlight+polygon {
    fill: var(--accent);
}

/* ===== NODES ===== */
.node {
    position: absolute;
    width: 240px;
    background: var(--bg-node);
    border: 2px solid #444;
    border-radius: var(--radius-node);
    padding: 16px 18px;
    cursor: grab;
    z-index: 10;
    box-shadow: var(--node-shadow);
    transition: border-color 0.2s ease, box-shadow 0.25s ease, background 0.2s ease;
    pointer-events: auto;
    color: var(--text-primary);
}
.node:hover {
    border-color: #666;
    background: var(--bg-node-hover);
    box-shadow: var(--node-shadow-hover);
    z-index: 20;
}
.node:active {
    cursor: grabbing;
}
.node--selected {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-soft), var(--node-shadow) !important;
    z-index: 15;
}
.node__title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #fff;
    letter-spacing: 0.1px;
}
.node__body {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-secondary);
    word-break: break-word;
}
.node__body a {
    color: var(--accent);
    text-decoration: none;
    pointer-events: auto;
    cursor: pointer;
}
.node__body a:hover {
    text-decoration: underline;
    color: var(--accent-hover);
}

/* ===== CANVAS CONTROLS ===== */
.canvas-controls {
    position: absolute;
    bottom: 16px;
    right: 16px;
    display: flex;
    gap: 6px;
    z-index: 50;
    pointer-events: auto;
}
.canvas-controls button {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-node);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    font-family: var(--font);
}
.canvas-controls button:hover {
    background: #3d3d3d;
    border-color: #555;
}
.canvas-controls button:active {
    background: #4a4a4a;
    transform: scale(0.94);
}
.canvas-controls__zoom-label {
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    background: var(--bg-node);
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    min-width: 52px;
    justify-content: center;
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
}

/* ===== STATUSBAR ===== */
.statusbar {
    height: 28px;
    min-height: 28px;
    background: var(--bg-statusbar);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 14px;
    font-size: 11px;
    color: var(--text-muted);
    gap: 16px;
    z-index: 100;
    font-family: var(--font);
}
.statusbar__item {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: default;
    transition: var(--transition);
    white-space: nowrap;
}
.statusbar__item:hover {
    color: var(--text-secondary);
}
.statusbar__spacer {
    flex: 1;
}

/* ===== TOOLTIP ===== */
.tooltip {
    position: absolute;
    padding: 6px 10px;
    background: #3a3a3a;
    color: #ddd;
    font-size: 11px;
    border-radius: 5px;
    pointer-events: none;
    z-index: 200;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.15s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
.tooltip.visible {
    opacity: 1;
}

/* ===== PROJECTS PAGE ===== */
.projects-container {
    /* position: absolute; */
    /* top: 0;
    left: 0; */
    width: 50%;
    height: 100%;
    margin: 0 auto;
    overflow-y: auto;
    padding: 32px 40px;
    display: none;
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
    transition: width 0.3s ease;
}
.projects-container.active {
    display: block;
}
.projects-container::-webkit-scrollbar {
    width: 5px;
}
.projects-container::-webkit-scrollbar-track {
    background: transparent;
}
.projects-container::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 10px;
}

.projects-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.project-card {
    display: flex;
    /* gap: 24px; */
    background: var(--bg-node);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    cursor: pointer;
    /* overflow: hidden; */
    /* position: relative; */
    /* flex-grow: 1; */
    min-height: 100px; /* ← ДОБАВЬТЕ минимальную высоту */
    justify-content: space-between;
}
.project-card:hover {
    border-color: var(--accent);
    background: var(--bg-node-hover);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.project-card__info {
    /* flex: 1; */
    min-width: 0;
    z-index: 2;
    display: flex; /* ← ДОБАВЬТЕ */
    flex-direction: column; /* ← ДОБАВЬТЕ */
    justify-content: space-between; /* ← ДОБАВЬТЕ */
}

.project-card__title {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.project-card__description {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
}

.project-card__meta {
    display: flex;
    flex-direction: column;
    /* align-items: center;
    gap: 12px;
    flex-wrap: wrap;*/
    justify-content: space-between; 
    flex-grow: 1; 
    /* height: fit-content */
}

.project-card__date {
    font-size: 13px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.project-card__tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.project-tag {
    padding: 3px 10px;
    background: rgba(127, 109, 242, 0.15);
    color: var(--accent);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.project-status {
    padding: 3px 10px;
    color: var(--accent);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    align-self: center;
}

.project-status-active {
    background: rgba(109, 242, 180, 0.15);
    color: rgb(59, 212, 138);
}

.project-status-frozen {
    background: rgba(109, 178, 242, 0.15);
    color: rgb(92, 171, 235);
}

.project-status-archived {
    background: rgba(177, 177, 177, 0.15);
    color: rgb(167, 167, 167);
}

.project-card__preview {
    width: 280px;
    min-width: 280px;
    height: 160px;
    border-radius: 9px;
    overflow: hidden;
    position: relative;
    z-index: 1;
    /* border: none; */
    isolation: isolate;
    background: linear-gradient(90deg, var(--bg-node), transparent)
}

.project-card__preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border: none;
    outline: none;
    background: linear-gradient(90deg, var(--bg-node), transparent);
    border-radius: 12px;
}

/* Градиентное затухание превью слева направо */
.project-card__preview::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--bg-node), transparent);
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.project-card:hover .project-card__preview::after {
    opacity: 0.3;
}

/* Адаптивность */
@media (max-width: 1500px) {
    .projects-container {
        width: 70%;
    }
}

@media (max-width: 1000px) {
    .projects-container {
        padding: 20px 16px;
    }
    .project-card {
        flex-direction: column;
    }
    .project-card__meta {
        gap: 10px;
        margin-bottom: 10px;
    }
    .project-card__preview {
        width: 100%;
        min-width: 100%;
        height: 180px;
    }
    .project-card__preview::after {
        background: linear-gradient(to bottom, 
            var(--bg-node) 0%, 
            transparent 60%
        );
    }

    /* .sidebar {
        width: 220px;
        min-width: 220px;
    }
    .sidebar.collapsed {
        margin-left: -220px;
    } */
    .node {
        width: 200px;
        padding: 12px 14px;
    }
    .node__title {
        font-size: 13px;
    }
    .node__body {
        font-size: 11px;
    }
}

@media (max-width: 750px) {
    .projects-container {
        width: 100%;
    }
}