/* ==========================================================
   R19.5 — Vault Full Interface Overhaul
   Final presentation layer: no functional changes
   ========================================================== */

:root {
    --r195-bg: #071321;
    --r195-panel: #0b1c30;
    --r195-panel-2: #0f2944;
    --r195-border: rgba(123, 173, 246, .20);
    --r195-border-strong: rgba(126, 183, 255, .36);
    --r195-text: #eef5ff;
    --r195-muted: #9bb4d5;
    --r195-blue: #76adff;
    --r195-blue-dark: #2c69bc;
    --r195-green: #62d7ad;
    --r195-purple: #c4abff;
    --r195-shadow: 0 16px 42px rgba(0, 0, 0, .24);
}

/* ---------- Project tree + file-section navigation ---------- */

.tree-head {
    display: flex !important;
    align-items: center;
    min-height: 42px;
    margin: 12px 0 7px;
    padding: 0 12px;
    border: 1px solid var(--r195-border);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(44, 105, 188, .25), rgba(11, 28, 48, .82));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}

.tree-head strong {
    color: var(--r195-text) !important;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .03em;
}

.tree-head small {
    margin-inline-start: auto;
    color: var(--r195-muted) !important;
    font-size: 10px;
    font-weight: 700;
}

.tree-link,
.tree-episode,
.tree-section {
    display: flex !important;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    margin: 4px 0;
    padding: 0 11px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: #bcd5f8 !important;
    background: rgba(8, 22, 39, .30);
    font-size: 12px;
    font-weight: 750;
    line-height: 1.15;
    text-decoration: none !important;
    transition: .16s ease;
}

.tree-link:hover,
.tree-episode:hover,
.tree-section:hover {
    border-color: rgba(121, 177, 255, .34);
    color: #ffffff !important;
    background: rgba(47, 106, 191, .22);
    transform: translateX(-2px);
}

.tree-link.active,
.tree-episode.active,
.tree-section.active {
    border-color: rgba(121, 185, 255, .55);
    color: #ffffff !important;
    background: linear-gradient(135deg, rgba(50, 119, 218, .40), rgba(28, 69, 125, .54));
    box-shadow: 0 7px 18px rgba(4, 18, 36, .24);
}

.tree-link span,
.tree-episode span,
.tree-section span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-section small {
    margin-inline-start: auto;
    color: #9dc7ff !important;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .08em;
}

.tree-episode {
    min-height: 33px;
    margin-inline-start: 15px;
    padding-inline-start: 16px;
    color: #a7c3e9 !important;
    font-size: 11px;
    background: rgba(18, 40, 66, .24);
}

.tree-episode::before {
    content: "↳";
    color: #83b6ff;
    font-size: 14px;
}

/* ---------- File panel and toolbar ---------- */

.vault-files-panel {
    margin-top: 18px;
    border: 1px solid var(--r195-border) !important;
    border-radius: 16px !important;
    background:
        linear-gradient(145deg, rgba(14, 40, 67, .94), rgba(6, 19, 35, .96)) !important;
    box-shadow: var(--r195-shadow);
    overflow: hidden;
}

.vault-files-panel > .panel-head,
.vault-files-panel > header,
.vault-files-panel > .vault-panel-head {
    padding: 17px 18px !important;
    border-bottom: 1px solid rgba(135, 182, 250, .14);
    background: linear-gradient(90deg, rgba(44, 102, 182, .18), rgba(7, 20, 36, .10));
}

.vault-files-panel h3 {
    margin: 2px 0 0 !important;
    color: var(--r195-text) !important;
    font-size: 19px !important;
}

.file-scope-pills {
    display: flex !important;
    flex-wrap: wrap;
    gap: 7px;
    margin: 14px 18px 4px;
}

.file-scope-pills a {
    display: inline-flex !important;
    align-items: center;
    min-height: 31px;
    padding: 0 12px;
    border: 1px solid rgba(129, 177, 248, .25);
    border-radius: 999px;
    color: #aec9ed !important;
    background: rgba(28, 62, 105, .18);
    font-size: 11px;
    font-weight: 850;
    text-decoration: none !important;
    transition: .16s ease;
}

.file-scope-pills a:hover {
    border-color: rgba(126, 183, 255, .50);
    color: #fff !important;
    background: rgba(56, 119, 211, .27);
}

.file-scope-pills a.active {
    border-color: rgba(125, 189, 255, .66);
    color: #fff !important;
    background: linear-gradient(135deg, #3477d7, #23549a);
    box-shadow: 0 7px 14px rgba(16, 63, 125, .28);
}

.filter-bar {
    display: grid !important;
    grid-template-columns: minmax(220px, 1.6fr) repeat(3, minmax(145px, 1fr)) auto;
    align-items: end;
    gap: 10px;
    margin: 13px 18px 18px !important;
    padding: 13px !important;
    border: 1px solid rgba(128, 178, 250, .16) !important;
    border-radius: 12px !important;
    background: rgba(3, 13, 27, .45) !important;
}

.filter-bar input,
.filter-bar select {
    min-height: 39px !important;
    border-radius: 8px !important;
}

.filter-bar button,
.filter-clear {
    min-height: 39px !important;
    border-radius: 8px !important;
}

.filter-clear {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 11px;
    border: 1px solid rgba(246, 145, 145, .32);
    color: #ffc4c4 !important;
    background: rgba(176, 55, 55, .13);
    font-size: 11px;
    font-weight: 850;
    text-decoration: none !important;
}

/* ---------- Upload area ---------- */

#upload-file.vault-form-panel {
    margin-top: 20px !important;
    border-color: rgba(101, 203, 165, .23) !important;
    background:
        linear-gradient(145deg, rgba(12, 48, 53, .52), rgba(7, 21, 35, .95)) !important;
}

#upload-file .panel-head,
#upload-file > header {
    border-bottom-color: rgba(99, 210, 167, .15) !important;
}

#upload-file .primary-button {
    min-width: 160px;
}

/* ---------- Recursive workflow tree ---------- */

.recursive-workflow-tree {
    margin-top: 20px;
}

.recursive-workflow-tree .vault-file-tree-list {
    padding: 12px;
    border: 1px solid var(--r195-border);
    border-radius: 16px;
    background: rgba(4, 15, 29, .52);
}

.recursive-workflow-tree .file-tree-section {
    margin: 10px 0;
    border: 1px solid rgba(109, 169, 248, .26);
    border-radius: 12px;
    background: linear-gradient(145deg, rgba(15, 44, 76, .82), rgba(5, 19, 34, .94));
    overflow: hidden;
}

.recursive-workflow-tree .file-tree-section > summary {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 15px;
    min-height: 58px;
    padding: 9px 14px;
    cursor: pointer;
    list-style: none;
    background: linear-gradient(90deg, rgba(46, 107, 194, .26), rgba(9, 28, 49, .10));
}

.recursive-workflow-tree .file-tree-section > summary::-webkit-details-marker,
.recursive-workflow-tree .file-tree-group > summary::-webkit-details-marker,
.recursive-workflow-tree .recursive-tree-node > summary::-webkit-details-marker {
    display: none;
}

.recursive-workflow-tree .file-tree-section > summary:hover,
.recursive-workflow-tree .recursive-tree-node > summary:hover {
    background: rgba(59, 129, 226, .16);
}

.recursive-workflow-tree .file-tree-summary-title,
.recursive-workflow-tree .file-tree-section-actions {
    display: flex !important;
    align-items: center;
}

.recursive-workflow-tree .file-tree-summary-title {
    min-width: 0;
    gap: 9px;
}

.recursive-workflow-tree .file-tree-summary-title strong {
    display: block;
    color: var(--r195-text) !important;
    font-size: 14px;
}

.recursive-workflow-tree .file-tree-summary-title small {
    display: block;
    margin-top: 3px;
    color: #91bbf8 !important;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .08em;
}

.recursive-workflow-tree .file-tree-chevron,
.recursive-workflow-tree .recursive-tree-chevron {
    display: inline-block;
    flex: 0 0 auto;
    color: #a8caff !important;
    font-size: 20px;
    line-height: 1;
    transition: transform .18s ease;
}

.recursive-workflow-tree .file-tree-section[open] > summary .file-tree-chevron,
.recursive-workflow-tree .recursive-tree-node[open] > summary .recursive-tree-chevron {
    transform: rotate(90deg);
}

.recursive-workflow-tree .file-tree-section-actions,
.recursive-workflow-tree .recursive-tree-actions {
    flex: 0 0 auto;
    gap: 6px;
}

.recursive-workflow-tree .file-tree-count,
.recursive-workflow-tree .file-tree-add,
.recursive-workflow-tree .recursive-count {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0 9px;
    border-radius: 7px;
    font-size: 10px;
    font-weight: 900;
    text-decoration: none !important;
    white-space: nowrap;
}

.recursive-workflow-tree .file-tree-count,
.recursive-workflow-tree .recursive-count {
    border: 1px solid rgba(130, 181, 250, .28);
    color: #cfe2ff !important;
    background: rgba(62, 119, 202, .16);
}

.recursive-workflow-tree .file-tree-add {
    border: 1px solid rgba(99, 217, 174, .35);
    color: #d6ffec !important;
    background: rgba(31, 160, 116, .16);
}

.recursive-workflow-tree .file-tree-section-body {
    padding: 8px 14px 14px 28px;
}

.recursive-workflow-tree .file-tree-group {
    border-left: 1px dashed rgba(135, 185, 255, .28);
}

.recursive-workflow-tree .file-tree-group > summary {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
    padding: 7px 10px;
    color: #d8e8ff !important;
    cursor: pointer;
    list-style: none;
    font-size: 12px;
    font-weight: 900;
}

.recursive-workflow-tree .recursive-tree-root-list {
    padding: 0 0 8px 13px;
}

.recursive-workflow-tree .recursive-tree-node {
    margin: 7px 0;
    border: 1px solid rgba(111, 170, 246, .20);
    border-radius: 10px;
    background: rgba(3, 14, 27, .62);
    overflow: hidden;
}

.recursive-workflow-tree .recursive-tree-node > summary {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 13px;
    min-height: 55px;
    padding: 8px 11px;
    cursor: pointer;
    list-style: none;
}

.recursive-workflow-tree .recursive-tree-title {
    display: flex !important;
    align-items: center;
    min-width: 0;
    gap: 8px;
}

.recursive-workflow-tree .recursive-tree-kind {
    display: inline-flex !important;
    align-items: center;
    flex: 0 0 auto;
    min-height: 20px;
    padding: 0 6px;
    border: 1px solid rgba(143, 187, 251, .22);
    border-radius: 5px;
    color: #a8cdff !important;
    background: rgba(60, 120, 205, .11);
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .07em;
}

.recursive-workflow-tree .recursive-tree-name {
    min-width: 0;
}

.recursive-workflow-tree .recursive-tree-name strong {
    display: block;
    max-width: 570px;
    overflow: hidden;
    color: #f4f8ff !important;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recursive-workflow-tree .recursive-tree-name small {
    display: block;
    max-width: 620px;
    margin-top: 3px;
    overflow: hidden;
    color: #9db5d8 !important;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recursive-workflow-tree .recursive-tree-actions {
    display: inline-flex !important;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.recursive-workflow-tree .recursive-tree-actions a {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    padding: 0 7px;
    border: 1px solid rgba(100, 214, 172, .30);
    border-radius: 6px;
    color: #d9ffed !important;
    background: rgba(28, 153, 112, .15);
    font-size: 9px;
    font-weight: 900;
    text-decoration: none !important;
    white-space: nowrap;
}

.recursive-workflow-tree .recursive-tree-actions a:hover {
    border-color: rgba(132, 255, 204, .62);
    color: #fff !important;
    background: rgba(39, 183, 137, .28);
}

.recursive-workflow-tree .recursive-tree-actions .recursive-action-translation {
    border-color: rgba(177, 143, 255, .38);
    color: #e6dcff !important;
    background: rgba(119, 77, 202, .19);
}

.recursive-workflow-tree .recursive-tree-children {
    margin: 0 12px 11px 29px;
    padding-left: 12px;
    border-left: 1px dashed rgba(138, 187, 253, .30);
}

.recursive-workflow-tree .recursive-tree-empty {
    margin: 0 12px 11px 29px;
    padding: 9px 11px;
    border-left: 1px dashed rgba(138, 187, 253, .22);
    color: #8fa9ce !important;
    font-size: 11px;
}

/* ---------- File list cards ---------- */

.file-card,
.vault-file-card {
    border-color: rgba(125, 177, 250, .18) !important;
    background: rgba(6, 20, 36, .66) !important;
}

.file-card:hover,
.vault-file-card:hover {
    border-color: rgba(125, 185, 255, .40) !important;
    transform: translateY(-1px);
}

/* ---------- Mobile ---------- */

@media (max-width: 1080px) {
    .filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-bar button,
    .filter-clear {
        width: 100%;
    }
}

@media (max-width: 720px) {
    .tree-link,
    .tree-episode,
    .tree-section {
        min-height: 36px;
        font-size: 11px;
    }

    .vault-files-panel h3 {
        font-size: 17px !important;
    }

    .filter-bar {
        grid-template-columns: 1fr;
        margin-inline: 11px !important;
    }

    .file-scope-pills {
        margin-inline: 11px;
    }

    .recursive-workflow-tree .file-tree-section > summary,
    .recursive-workflow-tree .recursive-tree-node > summary {
        align-items: flex-start !important;
        flex-direction: column;
    }

    .recursive-workflow-tree .file-tree-section-actions,
    .recursive-workflow-tree .recursive-tree-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .recursive-workflow-tree .file-tree-section-body {
        padding-left: 11px;
    }

    .recursive-workflow-tree .recursive-tree-root-list {
        padding-left: 0;
    }

    .recursive-workflow-tree .recursive-tree-children,
    .recursive-workflow-tree .recursive-tree-empty {
        margin-left: 8px;
        padding-left: 7px;
    }

    .recursive-workflow-tree .recursive-tree-name strong,
    .recursive-workflow-tree .recursive-tree-name small {
        max-width: 260px;
    }
}
