/* ====================================================================
   tree-styles.css — стили дерева законов и связанных модалок.
   Подключается на серверно-рендеренной странице с законами.
   Базовые body/container/search/stats-bar — теперь в шаблоне index.js
   и theme.css (тут не дублируются).
   ==================================================================== */

/* ============ TREE CONTAINER ============ */
.file-tree {
    margin-top: 8px;
    padding: 0;
    min-height: 200px;
}

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

/* ============ DIRECTORY ============ */
.directory {
    margin-bottom: 8px;
    background: var(--t-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--t-border, #e3ecf5);
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.directory:hover {
    border-color: var(--t-primary-light, #68a5db);
    box-shadow: 0 4px 14px rgba(44, 126, 192, 0.1);
}

.directory-header {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    cursor: pointer;
    user-select: none;
    background: var(--t-bg-soft, #f5f9fd);
    transition: background 0.2s ease;
}
.directory-header:hover {
    background: var(--t-bg-soft-2);
}
.directory.expanded .directory-header {
    background: linear-gradient(to right, rgba(44, 126, 192, 0.08), rgba(104, 165, 219, 0.04));
    border-left: 3px solid var(--t-primary, #2c7ec0);
}

.directory .icon {
    margin-right: 12px;
    color: var(--t-accent, #ffb347);
    width: 22px;
    text-align: center;
    font-size: 16px;
}

.directory-name {
    flex: 1;
    font-weight: 700;
    color: var(--t-text, #1a2332);
    font-size: 15px;
    letter-spacing: -0.2px;
}

.file-count {
    background: linear-gradient(135deg, var(--t-primary, #2c7ec0), var(--t-primary-light, #68a5db));
    color: #fff;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    margin: 0 12px;
    box-shadow: 0 2px 6px rgba(44, 126, 192, 0.25);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
}

.expand-icon {
    color: var(--t-primary, #2c7ec0);
    transition: transform 0.3s ease;
    font-size: 12px;
    width: 18px;
    text-align: center;
}
.directory.expanded .expand-icon { transform: rotate(90deg); }

/* Nested levels: уменьшаем отступы внутри */
.directory > ul {
    padding-left: 8px !important;
    margin: 6px 0 6px 10px !important;
    border-left: 1px solid rgba(44, 126, 192, 0.2);
    display: none;
    list-style: none;
}
.directory.expanded > ul { display: block; }
.directory > ul > .directory > ul {
    padding-left: 6px !important;
    margin-left: 8px !important;
    border-left: 1px dashed rgba(44, 126, 192, 0.18);
}
.directory > ul > .directory > ul > .directory > ul {
    padding-left: 4px !important;
    margin-left: 6px !important;
    border-left: 1px dotted rgba(44, 126, 192, 0.15);
}

/* По уровням */
.directory[data-level="1"] .directory-header { padding: 11px 16px; }
.directory[data-level="2"] .directory-header { padding: 9px 14px; }
.directory[data-level="3"] .directory-header { padding: 7px 12px; }

.directory[data-level="2"] .directory-name { font-size: 14px; }
.directory[data-level="3"] .directory-name { font-size: 13px; }

.directory[data-level="1"] .icon { font-size: 15px; width: 20px; margin-right: 10px; }
.directory[data-level="2"] .icon { font-size: 14px; width: 18px; margin-right: 8px; }
.directory[data-level="3"] .icon { font-size: 13px; width: 16px; margin-right: 6px; }

.directory[data-level="1"] .file-count { font-size: 11px; padding: 2px 8px; margin: 0 10px; }
.directory[data-level="2"] .file-count { font-size: 10px; padding: 2px 6px; margin: 0 8px; }
.directory[data-level="3"] .file-count { font-size: 9px;  padding: 1px 5px; margin: 0 6px; }

/* ============ LAW ITEM ============ */
.law-item {
    margin: 8px 0;
    background: var(--t-bg);
    border-radius: 10px;
    border: 1px solid var(--t-border, #e3ecf5);
    overflow: hidden;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.law-item:hover {
    border-color: var(--t-primary-light, #68a5db);
    box-shadow: 0 6px 18px rgba(44, 126, 192, 0.12);
    transform: translateY(-2px);
}

.law-header {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    gap: 14px;
}

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

.law-name {
    font-weight: 600;
    color: var(--t-text, #1a2332);
    margin-bottom: 4px;
    font-size: 15px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    letter-spacing: -0.1px;
}

.law-meta {
    font-size: 12px;
    color: var(--t-muted, #6b7c8f);
    background: var(--t-bg-soft, #f5f9fd);
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-block;
    font-weight: 500;
    border: 1px solid var(--t-border, #e3ecf5);
}

.law-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.law-item:hover .law-actions { opacity: 1; }

.law-item .icon {
    color: #16a34a;
    font-size: 16px;
    min-width: 22px;
}

.open-file-btn,
.expand-law-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--t-primary, #2c7ec0), var(--t-primary-dark, #1a5c92));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(44, 126, 192, 0.3);
}
.open-file-btn:hover,
.expand-law-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 14px rgba(44, 126, 192, 0.4);
}

.loading-spinner {
    color: var(--t-primary, #2c7ec0);
    animation: tree-spin 1s linear infinite;
}
@keyframes tree-spin { to { transform: rotate(360deg); } }

.law-content {
    padding: 0;
    background: var(--t-bg-soft, #f5f9fd);
    border-top: 1px solid var(--t-border, #e3ecf5);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}
.law-item.expanded .law-content {
    padding: 14px;
    max-height: 500px;
    overflow-y: auto;
}
.law-item.expanded .law-content::-webkit-scrollbar { width: 6px; }
.law-item.expanded .law-content::-webkit-scrollbar-track { background: rgba(44,126,192,0.06); border-radius: 3px; }
.law-item.expanded .law-content::-webkit-scrollbar-thumb { background: rgba(44,126,192,0.3); border-radius: 3px; }
.law-item.expanded .law-content::-webkit-scrollbar-thumb:hover { background: var(--t-primary, #2c7ec0); }

.law-item .expand-law-btn i { transition: transform 0.3s; }
.law-item.expanded .expand-law-btn i { transform: rotate(180deg); }

/* Уплотнение по уровням */
.directory[data-level="1"] .law-header { gap: 12px; padding: 12px 14px; }
.directory[data-level="2"] .law-header { gap: 10px; padding: 10px 12px; }
.directory[data-level="3"] .law-header { gap: 8px;  padding: 9px 10px; }

.directory[data-level="1"] .law-name { font-size: 14px; }
.directory[data-level="2"] .law-name { font-size: 13px; }
.directory[data-level="3"] .law-name { font-size: 13px; -webkit-line-clamp: 3; }

.directory[data-level="1"] .law-item .icon { font-size: 14px; min-width: 18px; }
.directory[data-level="2"] .law-item .icon { font-size: 13px; min-width: 16px; }
.directory[data-level="3"] .law-item .icon { font-size: 12px; min-width: 14px; }

.directory[data-level="1"] .open-file-btn,
.directory[data-level="1"] .expand-law-btn { width: 30px; height: 30px; font-size: 11px; }
.directory[data-level="2"] .open-file-btn,
.directory[data-level="2"] .expand-law-btn { width: 28px; height: 28px; font-size: 10px; }
.directory[data-level="3"] .open-file-btn,
.directory[data-level="3"] .expand-law-btn { width: 26px; height: 26px; font-size: 10px; }

.directory[data-level="1"] .law-meta { font-size: 11px; padding: 2px 6px; }
.directory[data-level="2"] .law-meta { font-size: 10px; padding: 2px 5px; }
.directory[data-level="3"] .law-meta { font-size: 10px; padding: 1px 4px; }

/* ============ STATES ============ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--t-muted, #6b7c8f);
}
.empty-state i {
    font-size: 56px;
    margin-bottom: 18px;
    color: rgba(44, 126, 192, 0.25);
}
.empty-state span {
    display: block;
    font-size: 16px;
    margin-top: 8px;
    font-weight: 500;
    color: var(--t-text-soft, #2c3e50);
}

.error-state {
    text-align: center;
    padding: 60px 20px;
    color: #e63939;
}
.error-state i {
    font-size: 56px;
    margin-bottom: 18px;
    color: var(--t-danger, #ff6b6b);
}

/* ============ MODAL (общая) ============ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 26, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.modal-content {
    background: var(--t-bg);
    border-radius: 20px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 80px rgba(10, 14, 26, 0.4);
    animation: tree-modal-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes tree-modal-in {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 26px;
    border-bottom: 1px solid var(--t-border, #e3ecf5);
    background: linear-gradient(135deg, var(--t-bg-soft, #f5f9fd), #fff);
    border-radius: 20px 20px 0 0;
}
.modal-title {
    margin: 0;
    color: var(--t-text, #1a2332);
    font-size: 19px;
    flex: 1;
    font-weight: 800;
    letter-spacing: -0.3px;
}
.modal-close {
    background: linear-gradient(135deg, var(--t-primary, #2c7ec0), var(--t-primary-dark, #1a5c92));
    border: none;
    font-size: 16px;
    color: #fff;
    cursor: pointer;
    padding: 0;
    border-radius: 10px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 12px rgba(44, 126, 192, 0.3);
}
.modal-close:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(44, 126, 192, 0.4);
}

.modal-body {
    flex: 1;
    padding: 22px 26px;
    overflow-y: auto;
}
.modal-footer {
    padding: 16px 26px;
    border-top: 1px solid var(--t-border, #e3ecf5);
    text-align: right;
    background: var(--t-bg-soft, #f5f9fd);
    border-radius: 0 0 20px 20px;
}
.modal-footer button {
    padding: 10px 22px;
    background: linear-gradient(135deg, var(--t-primary, #2c7ec0), var(--t-primary-dark, #1a5c92));
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(44, 126, 192, 0.3);
}
.modal-footer button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(44, 126, 192, 0.4);
}

/* ============ CONTENT ITEMS ============ */
.content-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.content-item {
    margin: 6px 0;
    padding: 9px 12px;
    background: var(--t-bg);
    border-radius: 8px;
    border: 1px solid var(--t-border, #e3ecf5);
    transition: border-color 0.2s ease, background 0.2s ease;
}
.content-item:hover {
    border-color: var(--t-primary-light, #68a5db);
    background: rgba(44, 126, 192, 0.04);
}
/* В тёмной теме hover-подсветка статьи тёмная (не светлое свечение),
   чтобы .content-name не выглядел слишком светлым. */
:root.theme-dark .content-item:hover {
    background: var(--t-bg-soft, #111a2e);
    border-color: var(--t-primary, #4f7cf0);
}

.content-header {
    display: flex;
    align-items: center;
    gap: 10px;
}
.content-icon {
    color: var(--t-primary, #2c7ec0);
    width: 16px;
    font-size: 13px;
}
.content-name {
    flex: 1;
    font-size: 13px;
    color: var(--t-text-soft, #2c3e50);
    font-weight: 500;
}

.content-children {
    padding-left: 14px !important;
    margin-top: 4px;
    display: none;
}
.content-children .content-children { padding-left: 12px !important; }
.content-children .content-children .content-children { padding-left: 10px !important; }

/* Внутри law-item */
.law-content .content-list { margin: 0; }
.law-content .content-item { margin: 4px 0; padding: 8px 11px; }
.law-content .content-header { gap: 8px; }
.law-content .content-name { font-size: 12px; }
.law-content .content-icon { font-size: 12px; width: 14px; }

/* ============ ARTICLE ============ */
.article-content {
    padding: 14px;
    background: var(--t-bg);
    border-radius: 10px;
    border: 1px solid var(--t-border, #e3ecf5);
    margin-top: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.article-text h4 {
    margin: 0 0 10px 0;
    color: var(--t-text, #1a2332);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.2px;
}
.article-body {
    color: var(--t-text, #1a2332);
    line-height: 1.65;
    font-size: 14px;
}

.error {
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--t-danger, #ff6b6b), #e63939);
    color: #fff;
    border-radius: 10px;
    text-align: center;
    border: none;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.25);
}

.loading {
    text-align: center;
    padding: 24px 18px;
    color: var(--t-primary, #2c7ec0);
    font-size: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.loading i { font-size: 22px; }

.hidden { display: none !important; }

/* ============ CURSORS ============ */
.directory-header,
.directory-header *,
.law-header,
.law-header *,
.expand-law-btn,
.open-file-btn,
.content-header.clickable,
.content-header.clickable *,
.content-item.has-children .content-header,
.content-item.has-children .content-header *,
.modal-close,
.modal-footer button,
.directory .icon,
.directory-name,
.file-count,
.law-info,
.law-name,
.law-meta,
.content-name,
.content-icon,
.law-actions button,
.law-actions button *,
.expand-icon { cursor: pointer !important; }

.file-tree,
.law-content,
.content-children,
.article-content,
.article-text,
.article-body,
.modal-body { cursor: default; }

.law-item:hover,
.directory:hover,
.content-item:hover { cursor: pointer; }

.law-item.loading .law-header,
.directory.loading .directory-header,
.content-item.loading .content-header { cursor: wait !important; }

/* ============ DEEP NESTING (4-6) ============ */
.directory[data-level="4"] > ul,
.directory[data-level="5"] > ul,
.directory[data-level="6"] > ul {
    padding-left: 6px !important;
    margin-left: 5px !important;
    border-left: none;
}
.directory[data-level="4"] .directory-header,
.directory[data-level="5"] .directory-header,
.directory[data-level="6"] .directory-header {
    padding: 6px 10px;
    background: rgba(44, 126, 192, 0.04);
}
.directory[data-level="4"] .directory-name,
.directory[data-level="5"] .directory-name,
.directory[data-level="6"] .directory-name { font-size: 12px; }
.directory[data-level="4"] .icon,
.directory[data-level="5"] .icon,
.directory[data-level="6"] .icon {
    font-size: 11px; width: 14px; margin-right: 4px;
}
.directory[data-level="4"] .file-count,
.directory[data-level="5"] .file-count,
.directory[data-level="6"] .file-count {
    font-size: 9px; padding: 1px 4px; margin: 0 4px;
}

/* ============ ARTICLE MODAL ============ */
.article-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 26, 0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
}
.article-modal-overlay.active { opacity: 1; visibility: visible; }

.article-modal {
    background: var(--t-bg);
    border-radius: 16px;
    max-width: 90vw;
    max-height: 90vh;
    width: auto;
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(10, 14, 26, 0.45);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}
.article-modal-overlay.active .article-modal { transform: scale(1); }

.article-modal-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--t-primary-dark, #1a5c92), var(--t-primary, #2c7ec0));
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}
.article-modal-header h3 {
    margin: 0;
    font-weight: 700;
    font-size: 16px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
    letter-spacing: -0.2px;
}
.article-modal-close {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.25s ease;
    margin-left: 14px;
    flex-shrink: 0;
}
.article-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.article-modal-content {
    padding: 24px 26px;
    overflow-y: auto;
    flex: 1;
    font-size: 15px;
    line-height: 1.7;
    color: var(--t-text, #1a2332);
}
.article-modal-content h1,
.article-modal-content h2,
.article-modal-content h3,
.article-modal-content h4 {
    margin-top: 1.5em;
    margin-bottom: 0.6em;
    color: var(--t-text, #1a2332);
    letter-spacing: -0.3px;
}
.article-modal-content h1 {
    font-size: 1.6em;
    border-bottom: 2px solid var(--t-primary, #2c7ec0);
    padding-bottom: 0.3em;
    font-weight: 800;
}
.article-modal-content h2 { font-size: 1.35em; font-weight: 700; }
.article-modal-content h3 { font-size: 1.15em; font-weight: 700; }
.article-modal-content p  { margin-bottom: 1.1em; }
.article-modal-content ul,
.article-modal-content ol { margin-bottom: 1.1em; padding-left: 2em; }
.article-modal-content li { margin-bottom: 0.4em; }
.article-modal-content code {
    background: var(--t-bg-soft, #f5f9fd);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.88em;
    color: var(--t-primary, #2c7ec0);
    border: 1px solid var(--t-border, #e3ecf5);
}
.article-modal-content pre {
    background: var(--t-bg-soft, #f5f9fd);
    padding: 14px 16px;
    border-radius: 10px;
    overflow-x: auto;
    margin-bottom: 1.1em;
    border-left: 3px solid var(--t-primary, #2c7ec0);
}
.article-modal-content blockquote {
    border-left: 3px solid var(--t-primary-light, #68a5db);
    padding-left: 14px;
    margin-left: 0;
    color: var(--t-muted, #6b7c8f);
    font-style: italic;
}
.article-modal-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.2em;
}
.article-modal-content table th {
    background: var(--t-bg-soft, #f5f9fd);
    font-weight: 700;
    color: var(--t-text, #1a2332);
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
}
.article-modal-content table th,
.article-modal-content table td {
    padding: 10px 12px;
    border: 1px solid var(--t-border, #e3ecf5);
    text-align: left;
}

/* ============ ARTICLE LINK ============ */
.article-link {
    color: var(--t-primary, #2c7ec0);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
    border-bottom: 1px dotted var(--t-primary-light, #68a5db);
    padding-bottom: 1px;
}
.article-link:hover {
    color: var(--t-primary-dark, #1a5c92);
    border-bottom-style: solid;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .directory > ul { padding-left: 6px !important; margin-left: 8px !important; }
    .directory > ul > .directory > ul { padding-left: 4px !important; margin-left: 6px !important; }
    .directory > ul > .directory > ul > .directory > ul { padding-left: 3px !important; margin-left: 4px !important; }

    /* Глубокие уровни на мобилках — почти без отступа */
    .directory[data-level="4"] > ul,
    .directory[data-level="5"] > ul,
    .directory[data-level="6"] > ul {
        padding-left: 2px !important;
        margin-left: 2px !important;
        border-left: none !important;
    }
    .directory[data-level="4"] .directory-header,
    .directory[data-level="5"] .directory-header,
    .directory[data-level="6"] .directory-header {
        padding: 5px 6px;
    }
    .directory[data-level="4"] .icon,
    .directory[data-level="5"] .icon,
    .directory[data-level="6"] .icon {
        margin-right: 3px;
        width: 12px;
        font-size: 11px;
    }
    .directory[data-level="4"] .file-count,
    .directory[data-level="5"] .file-count,
    .directory[data-level="6"] .file-count {
        margin: 0 3px;
        padding: 1px 4px;
    }
    .directory[data-level="4"] .law-header,
    .directory[data-level="5"] .law-header,
    .directory[data-level="6"] .law-header {
        gap: 5px;
        padding: 7px 6px;
    }

    .directory[data-level="1"] .directory-header { padding: 9px 13px; }
    .directory[data-level="2"] .directory-header { padding: 7px 11px; }
    .directory[data-level="3"] .directory-header { padding: 6px 9px; }

    .law-header { flex-wrap: wrap; gap: 10px; padding: 12px; }
    .law-actions {
        opacity: 1;
        order: 3;
        width: 100%;
        justify-content: flex-end;
        margin-top: 6px;
    }
    .law-name { font-size: 14px; }
    .open-file-btn, .expand-law-btn { width: 34px; height: 34px; }

    .directory-header { padding: 10px 12px; }

    .modal-content { width: 95%; margin: 10px; }

    .directory[data-level="1"] .law-header { gap: 10px; padding: 11px; }
    .directory[data-level="2"] .law-header { gap: 8px;  padding: 10px; }
    .directory[data-level="3"] .law-header { gap: 6px;  padding: 8px; }

    .directory[data-level="1"] .law-name { font-size: 13px; }
    .directory[data-level="2"] .law-name { font-size: 12px; }
    .directory[data-level="3"] .law-name { font-size: 12px; }

    .article-modal { max-width: 95vw; max-height: 95vh; }
    .article-modal-header { padding: 12px 14px; }
    .article-modal-header h3 { font-size: 14px; }
    .article-modal-content { padding: 16px 18px; font-size: 14px; }
}

/* Узкие экраны — максимальное уплотнение */
@media (max-width: 480px) {
    .directory > ul { padding-left: 4px !important; margin-left: 5px !important; }
    .directory > ul > .directory > ul { padding-left: 3px !important; margin-left: 3px !important; }
    .directory > ul > .directory > ul > .directory > ul { padding-left: 2px !important; margin-left: 2px !important; }
    .directory[data-level="4"] > ul,
    .directory[data-level="5"] > ul,
    .directory[data-level="6"] > ul {
        padding-left: 0 !important;
        margin-left: 0 !important;
    }
    .directory[data-level="4"] .directory-header,
    .directory[data-level="5"] .directory-header,
    .directory[data-level="6"] .directory-header {
        padding: 4px 5px;
    }
    .directory.expanded .directory-header { border-left-width: 2px; }
    .directory[data-level="4"].expanded .directory-header,
    .directory[data-level="5"].expanded .directory-header,
    .directory[data-level="6"].expanded .directory-header { border-left-width: 0; }
}

/* ============ LOADING INDICATORS ============ */
.loading-indicator {
    display: inline-block;
    margin-left: 8px;
    color: var(--t-muted, #6b7c8f);
    font-size: 0.85em;
}
.loading-dots {
    display: inline-block;
    position: relative;
    width: 20px;
    height: 20px;
}
.loading-dots::after {
    content: '...';
    position: absolute;
    animation: tree-loading-dots 1.5s infinite;
    white-space: nowrap;
}
@keyframes tree-loading-dots {
    0%, 20%   { content: '.'; }
    40%       { content: '..'; }
    60%, 100% { content: '...'; }
}
.enhanced-spinner {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85em;
    color: var(--t-muted, #6b7c8f);
}
.enhanced-spinner .dots { animation: tree-loading-dots 1.5s infinite; }

.content-loading {
    margin-left: 8px;
    color: var(--t-muted, #6b7c8f);
    font-size: 0.8em;
}
.loading-content,
.loading-article {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    color: var(--t-muted, #6b7c8f);
    font-style: italic;
}
.loading-article .loading-dots { margin-left: 4px; }

.law-item.loading .law-header,
.content-item.loading .content-header { opacity: 0.7; }

/* Top global loading bar */
body.loading::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--t-primary, #2c7ec0), var(--t-accent, #ffb347), var(--t-primary, #2c7ec0));
    background-size: 200% 100%;
    animation: tree-loading-bar 1.5s infinite;
    z-index: 9999;
}
@keyframes tree-loading-bar {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Утилиты вложенности */
.no-left-border > ul { border-left: none !important; margin-left: 5px !important; }
.ultra-compact .directory > ul { padding-left: 4px !important; margin-left: 6px !important; }
.ultra-compact .directory-header { padding: 7px 10px; }
.ultra-compact .law-header { padding: 9px 11px; }
.ultra-compact .directory-name,
.ultra-compact .law-name { font-size: 12px; }

.tree ul { transition: all 0.3s ease; }
.directory > ul {
    transition: padding-left 0.3s ease, margin-left 0.3s ease;
    animation: tree-slide-down 0.3s ease-out;
}
.directory[data-level] > ul { min-width: 0; overflow: hidden; }
@keyframes tree-slide-down {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =====================================================
   Фикс: кнопки (.law-actions) внутри .law-item должны быть
   в одной строке с названием закона, а не уезжать вниз.
   .law-page-header переопределяется по вложенности (сильнее,
   чем заголовок страницы в index.js).
   ===================================================== */
.law-item .law-page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    text-align: left;
    margin-bottom: 0;
}
.law-item .law-page-header .law-info {
    flex: 1;
    min-width: 0;
}
.law-item .law-page-header .law-actions {
    margin-left: auto;
    flex-shrink: 0;
}
.law-item .law-page-header .law-actions .open-file-btn,
.law-item .law-page-header .law-actions .expand-law-btn {
    width: 34px;
    height: 34px;
}

/* ===== Фикс мобильной раскладки карточек законов =====
   Медиа-запрос (max-width:768px) ставит `.law-actions { width: 100% }`,
   из-за чего в flex-row карточки `.law-info` (название закона) сжимается
   до ширины 0 и название не видно (остаётся только код). Возвращаем
   карточкам списка правильную flex-row раскладку: кнопки прижаты вправо,
   а название занимает оставшееся место. */
@media (max-width: 768px) {
  .law-item .law-page-header {
    flex-wrap: nowrap;
  }
  .law-item .law-page-header .law-actions {
    width: auto;
    order: 0;
    margin-top: 0;
    flex-shrink: 0;
  }
}
