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

:root {
    --bg-color: #0a0e17;
    --card-bg: #1a1f2e;
    --card-hover: #21283b;
    --card-border: #2a3246;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-color: #8b5cf6;
    --accent-hover: #7c3aed;
    --accent-light: rgba(139, 92, 246, 0.1);
    --modal-bg: rgba(10, 14, 23, 0.92);
    --success-color: #10b981;
    --spacing-xs: 6px;
    --spacing-sm: 12px;
    --spacing-md: 10px;
    --spacing-lg: 32px;
    --spacing-xl: 48px;
    --border-radius-sm: 8px;
    --border-radius: 12px;
    --border-radius-lg: 16px;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 20px 40px -10px rgba(0, 0, 0, 0.4);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --gradient-primary: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    --gradient-secondary: linear-gradient(135deg, #1a1f2e 0%, #2a3246 100%);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.7;
    padding: var(--spacing-md);
    min-height: 100vh;

    background-image:
        radial-gradient(ellipse 70% 40% at 50% 0%,
            rgba(255, 255, 255, 0.07) 0%,
            rgba(139, 92, 246, 0.04) 40%,
            transparent 70%),
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(99, 102, 241, 0.05) 0%, transparent 20%);

    background-repeat: no-repeat;
}


.container {
    max-width: 1400px;
    margin: 0 auto;
}

/*============== Header ============*/
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-lg, 20px);
    padding: var(--spacing-lg) 0;
    position: relative;
}

.header-left {
    flex: 0 0 auto;
    text-align: left;
    width: 250px;
}

.header-center {
    flex: 1 1 auto;
    text-align: center;
}

.header-right {
    flex: 0 0 auto;
    text-align: right;
    width: 250px;
}

.header h1 {
    font-size: 24px;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin: 0;
    letter-spacing: -0.5px;
    white-space: nowrap;
}

.sub-header {
    position: relative;
    text-align: center;
    margin-bottom: 70px;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.45;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #f5f3ff 0%, #e0e7ff 50%, #dbeafe 100%);
    filter: drop-shadow(0 4px 20px rgba(139, 92, 246, 0.5));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.sub-header::after {
    content: '';
    height: 2px;
    background: var(--gradient-primary);
    border-radius: 2px;
    display: block;
    width: 360px;
    margin: 10px auto 0 auto;
}
/*============== / Header ============*/

.masonry-container {
    column-count: 3;
    column-gap: var(--spacing-lg);
    margin: 0 auto;
}

.category-card {
    break-inside: avoid;
    background: var(--gradient-secondary);
    border-radius: var(--border-radius);
    border: 1px solid var(--card-border);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.category-card-selectable {
    cursor: pointer;
}

.category-card-mini {
    padding: 10px;
}

.category-card-selectable::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition);
}

.category-card-selectable:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--accent-color);
}

.category-card-selectable:hover::before {
    opacity: 1;
}

.category-card-selectable .category-header {
    margin-bottom: 0;
}

.folder-header {
    position: relative;
    padding-bottom: 10px;
}

.category-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--card-border);
}

.category-icon {
    width: 48px;
    height: 48px;
    background: var(--gradient-primary);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.category-title-wrapper {
    flex: 1;
}

.category-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
}

.category-count {
    color: var(--accent-color);
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--accent-light);
    padding: 4px 12px;
    border-radius: 20px;
    display: inline-block;
}

.links-list {
    list-style-type: none;
    padding: 0;
}

.link-item {
    margin-bottom: 3px;
}

.link-item:hover .child-links::before {
    opacity: 0.3;
}

.link-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: 1px 10px;
    background-color: rgba(42, 50, 70, 0.5);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.link-title:hover {
    background-color: var(--accent-light);
    border-color: var(--accent-color);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

.link-icon {
    width: 36px;
    height: 36px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-color);
    font-size: 1rem;
    flex-shrink: 0;
    transition: var(--transition);
}

.link-title:hover .link-icon {
    background: var(--gradient-primary);
    color: white;
    transform: scale(1.1);
}

.link-content {
    flex: 1;
    min-width: 0;
}

.link-title-text {
    font-weight: 600;
    margin-bottom: 4px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-file {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: 'Monaco', 'Consolas', monospace;
}

.link-arrow {
    color: var(--text-secondary);
    font-size: 1.1rem;
    transition: var(--transition);
    flex-shrink: 0;
}

.link-title:hover .link-arrow {
    color: var(--accent-color);
    transform: translateX(3px);
}

.child-links {
    margin-left: 10px;
    margin-top: var(--spacing-sm);
    padding-left: var(--spacing-md);
    border-left: 2px dashed var(--card-border);
    position: relative;
}

.child-links::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--modal-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: var(--spacing-md);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
}

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

.modal-content {
    background: var(--modal-bg);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 800px;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--card-border);
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-content:has(table),
.modal-content:has(img) {
    max-width: 1200px;
}

.modal-content img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
}

.modal-content a, .modal-content a:visited {
    color: var(--text-secondary);
}

.modal-content h2:first-of-type {
    margin-top: 0 !important;
}

.modal-content table {
    width: 100%;
    border-collapse: collapse;
    border-bottom: 1px solid var(--text-secondary);
    font-size: 14px;
    margin-bottom: 10px;
}

.modal-content thead {
    border-bottom: 1px solid var(--text-secondary);
}

.modal-content th,
.modal-content td {
    padding: 12px 16px;
}

.modal-content th {
    text-align: left;
    font-weight: bold;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--card-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(26, 31, 46, 0.9);
    position: relative;
}

.modal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
}

.modal-title-wrapper {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.modal-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 700;
}

.modal-path {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.close-button {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 12px;
    font-weight: 400;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 12px;
    display: inline-block;
    transform: translateY(-11px);
}

.close-button:hover {
    background: rgba(239, 68, 68, 0.2);
}

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
    flex-grow: 1;
    /*scrollbar-width: thin;*/
    /*scrollbar-color: var(--accent-color) transparent;*/
}

/*.modal-body::-webkit-scrollbar {*/
/*    width: 6px;*/
/*}*/

/*.modal-body::-webkit-scrollbar-track {*/
/*    background: transparent;*/
/*}*/

/*.modal-body::-webkit-scrollbar-thumb {*/
/*    background-color: var(--accent-color);*/
/*    border-radius: 3px;*/
/*}*/

.markdown-content {
    font-size: 1.05rem;
    line-height: 1.8;
}

.markdown-content h1 {
    font-size: 2rem;
    margin: 1.5em 0 0.8em;
    padding-bottom: 0.4em;
    border-bottom: 3px solid var(--accent-color);
    color: var(--text-primary);
    font-weight: 800;
}

.markdown-content h2 {
    font-size: 1.6rem;
    margin: 1.3em 0 0.6em;
    padding-bottom: 0.3em;
    /*border-bottom: 2px solid var(--card-border);*/
    color: var(--text-primary);
    font-weight: 700;
}

.markdown-content h3 {
    font-size: 1.3rem;
    margin: 1.1em 0 0.5em;
    color: var(--text-primary);
    font-weight: 600;
}

.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    font-size: 1.1rem;
    margin: 1em 0 0.5em;
    color: var(--text-primary);
    font-weight: 600;
}

.markdown-content p {
    margin-bottom: 1.2em;
    color: var(--text-secondary);
}

.markdown-content code {
    background-color: rgba(139, 92, 246, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
    font-family: 'Monaco', 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: var(--accent-color);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.markdown-content pre {
    background-color: rgba(15, 20, 35, 0.8);
    padding: 10px;
    border-radius: var(--border-radius-sm);
    overflow-x: auto;
    margin: 1.2em 0;
}

.markdown-content pre code {
    background: none;
    padding: 0;
    border: none;
    color: var(--text-primary);
}

.markdown-content ul,
.markdown-content ol {
    margin-left: 1.5em;
    margin-bottom: 1.2em;
    color: var(--text-secondary);
}

.markdown-content li {
    margin-bottom: 0.5em;
}

.markdown-content blockquote {
    border-left: 4px solid var(--accent-color);
    padding-left: var(--spacing-md);
    margin: 1.5em 0;
    color: var(--text-muted);
    font-style: italic;
    background: rgba(139, 92, 246, 0.05);
    padding: var(--spacing-md);
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}

.loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--spacing-xl);
    color: var(--text-secondary);
    gap: var(--spacing-md);
}

.loading-spinner {
    border: 4px solid rgba(139, 92, 246, 0.1);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font-size: 1.1rem;
    font-weight: 500;
}

.error-message {
    text-align: center;
    padding: var(--spacing-xl);
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.error-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
    color: #ef4444;
}

.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--spacing-xl);
    padding: var(--spacing-md);
    background: rgba(26, 31, 46, 0.8);
    border-radius: var(--border-radius);
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ===== SCROLLBAR ====*/
/* Для браузеров на WebKit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: rgba(15, 20, 35, 0);
  border-radius: 4px;
  transition: all 0.3s ease;
}

/* Стили при наведении на контейнер */
:hover::-webkit-scrollbar-thumb {
  background-color: rgba(15, 20, 35, 0.8);
}

/* СКРЫВАЕМ СТРЕЛОЧКИ ВСЕГДА */
::-webkit-scrollbar-button {
  display: none !important;
  width: 0;
  height: 0;
}

/* Увеличение толщины при наведении */
:hover::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

:hover::-webkit-scrollbar-thumb {
  border-radius: 5px;
}

/* Для Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

:hover {
  scrollbar-color: rgba(15, 20, 35, 0.8) transparent;
}
/* ===== SCROLLBAR ====*/


@media (max-width: 1200px) {
    .masonry-container {
        column-count: 2;
    }
}

@media (max-width: 768px) {
    .masonry-container {
        column-count: 1;
    }

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

    .header h1 {
        font-size: 2.2rem;
    }

    .category-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }

    .category-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}
