/* Explorer Layout */
:root {
    --sidebar-w: 260px;
    --detail-w: 320px;
    --header-h: 60px;
    --bg-dark: #020504;
    --bg-panel: #050a08;
    --border: #13432c;
    --accent: #3fffb0;
    --text-main: #d0fff0;
    --text-dim: #7fcfaa;
}

body {
    margin: 0;
    height: 100vh;
    background: var(--bg-dark);
    color: var(--text-main);
    font-family: "SFMono-Regular", Consolas, Menlo, monospace;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Layout Grid */
.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar (Tree) */
.sidebar {
    width: var(--sidebar-w);
    background: rgba(2, 9, 6, 0.95);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.brand {
    height: var(--header-h);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    font-weight: bold;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
}

.tree-view {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.tree-node {
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-dim);
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
}

.tree-node:hover {
    background: rgba(63, 255, 176, 0.1);
    color: #fff;
}

.tree-node.active {
    background: rgba(63, 255, 176, 0.2);
    color: var(--accent);
}

/* Main Content (List) */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    min-width: 0;
}

.toolbar {
    height: var(--header-h);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
    background: var(--bg-panel);
}

.breadcrumbs {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumbs span:hover {
    color: var(--accent);
}

.search-box {
    width: 250px;
    background: #000;
    border: 1px solid var(--border);
    color: var(--accent);
    padding: 6px 10px;
    border-radius: 4px;
    font-family: inherit;
}

.filters {
    display: flex;
    gap: 0.5rem;
}

.filter-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 4px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    border-radius: 4px;
    text-transform: uppercase;
}

.filter-btn.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    font-weight: bold;
}

.file-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    align-content: start;
}

/* File Card */
.file-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    cursor: pointer;
    position: relative;
    transition: transform 0.1s, border-color 0.1s;
}

.file-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.file-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.thumb-preview {
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--text-dim);
}

.thumb-preview img,
.thumb-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-preview .text-snippet {
    font-size: 0.5rem;
    padding: 4px;
    text-align: left;
    width: 100%;
    height: 100%;
    overflow: hidden;
    opacity: 0.7;
}

.file-info {
    font-size: 0.8rem;
    overflow: hidden;
}

.file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: bold;
    margin-bottom: 2px;
}

.file-meta {
    font-size: 0.7rem;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
}

/* Detail Pane */
.detail-pane {
    width: var(--detail-w);
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
}

.preview-stage {
    flex: 1;
    background: #000;
    border: 1px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    min-height: 200px;
}

.preview-stage img,
.preview-stage video {
    max-width: 100%;
    max-height: 100%;
}

.preview-stage pre {
    padding: 1rem;
    font-size: 0.7rem;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-main);
    max-height: 100%;
    overflow: auto;
}

.meta-info {
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #111;
    padding-bottom: 4px;
}

.meta-label {
    color: var(--text-dim);
}

.actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    flex: 1;
    padding: 8px;
    background: #062;
    border: 1px solid #0c5;
    color: #fff;
    cursor: pointer;
    border-radius: 4px;
    text-align: center;
}

.action-btn:hover {
    background: #084;
}

.action-btn.secondary {
    background: transparent;
    border-color: var(--text-dim);
    color: var(--text-dim);
}

.action-btn.secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Responsive */
@media (max-width: 900px) {
    .detail-pane {
        display: none;
    }

    .detail-pane.open {
        display: flex;
        position: absolute;
        right: 0;
        top: var(--header-h);
        bottom: 0;
        width: 300px;
        z-index: 20;
        border-left: 1px solid var(--accent);
        shadow: -5px 0 15px rgba(0, 0, 0, 0.5);
    }
}

@media (max-width: 600px) {
    .sidebar {
        display: none;
    }
}

/* Login Gate */
#login-gate {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-family: var(--font-mono);
}

.login-box {
    background: var(--bg-panel);
    border: 1px solid var(--accent);
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 0 20px rgba(63, 255, 176, 0.2);
    width: 90%;
    max-width: 320px;
}

.login-title {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

#passwordInput {
    background: #000;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.8rem;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 0.2em;
    margin-bottom: 1rem;
    outline: none;
}

#passwordInput:focus {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(63, 255, 176, 0.3);
}

.login-btn {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 0.8rem 1.5rem;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    text-transform: uppercase;
}

.login-btn:hover {
    background: #fff;
}

.hidden {
    display: none !important;
}