:root {
    --bg: #0f1115;
    --bg-elevated: #161922;
    --bg-hover: #1e2230;
    --border: #262b3a;
    --text: #e4e6eb;
    --text-dim: #8b91a5;
    --accent: #5b8cff;
    --accent-dim: #5b8cff33;
    --radius: 10px;
    --shadow: 0 8px 24px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

html {
    background: var(--bg);
}

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    color: var(--text);
    min-height: 100vh;
}

#app {
    max-width: 960px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

#topbar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    animation: fade-in-down 0.4s ease;
}

#topbar h1 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.02em;
}

#breadcrumb {
    font-size: 0.85rem;
    color: var(--text-dim);
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
}

#breadcrumb a {
    color: var(--text-dim);
    text-decoration: none;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}

#breadcrumb a:hover {
    background: var(--bg-hover);
    color: var(--text);
}

#breadcrumb .sep {
    opacity: 0.4;
}

#breadcrumb .current {
    color: var(--text);
    font-weight: 600;
    padding: 0.15rem 0.4rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

thead th {
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    padding: 0.85rem 1rem;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border);
    transition: color 0.15s ease;
}

thead th:hover { color: var(--text); }

thead th .indicator::after {
    content: '';
    margin-left: 4px;
}

thead th.sort-asc .indicator::after { content: '\2191'; }
thead th.sort-desc .indicator::after { content: '\2193'; }

tbody tr {
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.12s ease;
    animation: fade-in 0.25s ease both;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--bg-hover); }

tbody tr:active { background: var(--accent-dim); }

td {
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

td.col-name {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    white-space: normal;
    word-break: break-word;
}

.icon {
    flex: none;
    width: 1.1rem;
    height: 1.1rem;
    opacity: 0.85;
}

.col-size, .col-mtime {
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
}

tr.is-dir .col-size {
    color: var(--text-dim);
    opacity: 0.5;
}

.col-actions {
    width: 2.5rem;
    text-align: right;
}

.copy-link {
    display: none;
}

@media (hover: hover) and (pointer: fine) {
    .copy-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1.8rem;
        height: 1.8rem;
        padding: 0;
        border: none;
        border-radius: 6px;
        background: transparent;
        color: var(--text-dim);
        opacity: 0;
        cursor: pointer;
        transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
    }

    tr:hover .copy-link {
        opacity: 1;
    }

    .copy-link:hover {
        background: var(--bg-hover);
        color: var(--text);
    }

    .copy-link.copied {
        opacity: 1;
        color: #4ade80;
    }

    .copy-link svg {
        width: 1rem;
        height: 1rem;
    }
}

td.empty {
    text-align: center;
    color: var(--text-dim);
    font-style: italic;
    padding: 3rem 0;
    cursor: default;
}

td.empty:hover { background: transparent; }

@keyframes fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in-down {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
    #app {
        padding: 1.5rem 0.75rem 3rem;
    }

    #topbar h1 {
        font-size: 1.2rem;
    }

    thead {
        display: none;
    }

    table, tbody, tr, td {
        display: block;
        width: 100%;
    }

    tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        column-gap: 0.5rem;
        row-gap: 0.15rem;
        padding: 0.75rem 1rem;
    }

    td {
        padding: 0;
        border: none;
    }

    td.col-name {
        order: 1;
        flex: 0 0 100%;
        font-size: 0.95rem;
        margin-bottom: 0.1rem;
    }

    td.col-size, td.col-mtime {
        order: 2;
        font-size: 0.75rem;
        white-space: normal;
    }

    td.col-mtime::before {
        content: '\2022';
        margin-right: 0.5rem;
        opacity: 0.6;
    }

    td.col-actions {
        display: none;
    }

    td.empty {
        padding: 2.5rem 1rem;
    }
}

/* login page */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    animation: fade-in 0.3s ease;
}

.login-box h1 {
    margin: 0 0 0.4rem;
    font-size: 1.1rem;
    text-align: center;
}

.login-box input[type="password"],
.login-box button {
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    cursor: pointer;
}

.remember-me input {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
}

.login-box button {
    background: var(--accent);
    border: none;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s ease;
}

.login-box button:hover { filter: brightness(1.1); }
