:root {
    --bg: #111418;
    --panel: #1e242c;
    --panel-hover: #2a323d;
    --text: #e8ecf1;
    --muted: #8a94a3;
    --accent: #7cc4ff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a {
    color: var(--accent);
    text-decoration: none;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 14px 16px;
    background: rgba(17, 20, 24, 0.92);
    border-bottom: 1px solid var(--panel);
    backdrop-filter: blur(6px);
}

.crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 16px;
}

.crumbs span {
    color: var(--muted);
}

.page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
}

h1 {
    margin: 8px 0 20px;
    font-size: 28px;
}

h1 small,
.tile small {
    color: var(--muted);
    font-size: 14px;
    font-weight: 400;
}

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.tile {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    min-height: 100px;
    padding: 18px;
    border-radius: 12px;
    background: var(--panel);
    color: var(--text);
    font-size: 20px;
    font-weight: 600;
}

.tile:hover {
    background: var(--panel-hover);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 6px;
}

.thumb {
    display: block;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 6px;
    background: var(--panel);
}

.thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.15s ease;
}

.thumb:hover img {
    transform: scale(1.05);
}

.video-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 100%;
    padding: 8px;
    color: var(--text);
    font-size: 36px;
    text-align: center;
}

.video-tile small {
    max-width: 100%;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty {
    padding: 40px 0;
    color: var(--muted);
    text-align: center;
}

/* Visionneuse */
body.viewer-active {
    overflow: hidden;
}

.viewer {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.94);
}

.viewer-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 56px 72px;
}

.viewer-stage img,
.viewer-stage video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.viewer-close,
.viewer-prev,
.viewer-next {
    position: absolute;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.viewer-close:hover,
.viewer-prev:hover,
.viewer-next:hover {
    background: rgba(255, 255, 255, 0.28);
}

.viewer-close {
    top: 12px;
    right: 12px;
}

.viewer-prev,
.viewer-next {
    top: 50%;
    transform: translateY(-50%);
}

.viewer-prev {
    left: 12px;
}

.viewer-next {
    right: 12px;
}

.viewer-prev:disabled,
.viewer-next:disabled {
    opacity: 0.25;
    cursor: default;
}

.viewer-original {
    position: absolute;
    top: 22px;
    left: 16px;
    font-size: 13px;
}

.viewer-info {
    position: absolute;
    right: 0;
    bottom: 12px;
    left: 0;
    display: flex;
    justify-content: center;
    gap: 16px;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 600px) {
    .viewer-stage {
        padding: 56px 8px;
    }

    .viewer-prev,
    .viewer-next {
        display: none;
    }

    .grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }

    h1 {
        font-size: 24px;
    }
}

.tabs {
    display: flex;
    gap: 8px;
    margin: 0 0 20px;
}

.tab {
    padding: 8px 16px;
    background: var(--panel);
    border-radius: 999px;
    color: var(--text);
}

.tab:hover {
    background: var(--panel-hover);
}

.tab.active {
    background: var(--accent);
    color: var(--bg);
    font-weight: 600;
}

.video-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.video-list a {
    display: block;
    padding: 10px 14px;
    background: var(--panel);
    border-radius: 8px;
    word-break: break-all;
}

.video-list a:hover {
    background: var(--panel-hover);
}

.login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.login-box {
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 28px;
    background: var(--panel);
    border-radius: 12px;
}

.login-box h1 {
    margin: 0;
    font-size: 1.5rem;
}

.login-hint {
    margin: 0;
    color: var(--muted);
}

.login-error {
    margin: 0;
    color: #ff8a8a;
}

.login-box input {
    padding: 10px 12px;
    font-size: 1rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--panel-hover);
    border-radius: 8px;
}

.login-box button {
    padding: 10px 12px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--bg);
    background: var(--accent);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}
