:root {
    --bg: #0b0d10;
    --surface: #14181d;
    --surface-2: #1b2027;
    --border: #2a313a;
    --muted: #929ba6;
    --text: #f6f7f8;
    --accent: #bcc2ca;
    --accent-hover: #d8dce1;
    --accent-ink: #111419;
    --success: #36cc77;
}
* { box-sizing: border-box; }

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

body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    background:
        radial-gradient(circle at 80% -10%, rgba(192, 198, 206, .17), transparent 32rem),
        var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.login-card {
    width: min(100%, 25rem);
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    background: rgba(20, 24, 29, .94);
    box-shadow: 0 2rem 6rem rgba(0, 0, 0, .4);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 3.5rem;
    height: 3.5rem;
    margin-bottom: 1.25rem;
    border-radius: 1rem;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 1.7rem;
    font-weight: 900;
    letter-spacing: .04em;
}

.login-card h1 { font-weight: 800; }

.form-control {
    border-color: var(--border);
    background: #0f1216;
}

.form-control:focus {
    border-color: var(--accent);
    background: #0f1216;
    box-shadow: 0 0 0 .25rem rgba(192, 198, 206, .2);
}

.btn-accent {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 700;
}

.btn-accent:hover, .btn-accent:focus {
    border-color: var(--accent-hover);
    background: var(--accent-hover);
    color: var(--accent-ink);
}

.app-shell { padding-bottom: env(safe-area-inset-bottom); }

.app-header {
    position: sticky;
    z-index: 20;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(.85rem + env(safe-area-inset-top)) clamp(1rem, 4vw, 3rem) .85rem;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    background: rgba(11, 13, 16, .88);
    backdrop-filter: blur(18px);
}

.app-header h1 { margin: 0; font-size: 1.55rem; font-weight: 850; }
.eyebrow { color: var(--accent); font-size: .68rem; font-weight: 800; letter-spacing: .15em; }
.header-actions { display: flex; align-items: center; gap: .25rem; }
.content-wrap { max-width: 80rem; padding: 1.25rem clamp(1rem, 4vw, 3rem) 5rem; }

.upload-panel {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1.25rem;
    padding: clamp(1.25rem, 4vw, 2rem);
    border: 1px solid var(--border);
    border-radius: 1.5rem;
    background: linear-gradient(135deg, var(--surface), #17140f);
}

.upload-copy h2 { margin: 0 0 .3rem; font-size: 1.35rem; font-weight: 800; }
.upload-copy p { margin: 0; color: var(--muted); }
.upload-progress, .error-message { grid-column: 1 / -1; }
.progress { height: .5rem; background: #07090b; }
.progress-bar { width: 0; background: var(--accent); transition: width .2s ease; }
.error-message { color: #ff8b91; }
.download-notice { color: var(--muted); font-size: .82rem; }

.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr)); gap: 1rem; margin-top: 1.5rem; }
.load-more-wrap { display: flex; justify-content: center; margin-top: 1.5rem; }
.video-card { overflow: hidden; border: 1px solid var(--border); border-radius: 1.1rem; background: var(--surface); }

.thumbnail-button {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: #050607;
}

.video-thumbnail { width: 100%; height: 100%; object-fit: cover; }
.thumbnail-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #343b44; font-size: 2rem; }
.play-button { position: absolute; top: 50%; left: 50%; display: grid; place-items: center; width: 3.1rem; height: 3.1rem; padding-left: .2rem; border-radius: 50%; background: rgba(0, 0, 0, .72); color: #fff; transform: translate(-50%, -50%); backdrop-filter: blur(8px); }
.video-info { padding: 1rem; }
.video-heading { display: flex; align-items: start; justify-content: space-between; gap: .75rem; }
.video-name { margin: 0; overflow: hidden; font-size: 1rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.status-badge { flex: none; padding: .3rem .55rem; border-radius: 999px; background: #313842; color: #dce0e5; font-size: .68rem; font-weight: 800; text-transform: uppercase; }
.status-badge.processing { background: rgba(192, 198, 206, .15); color: #d8dce1; }
.status-badge.processed { background: rgba(54, 204, 119, .15); color: #66df99; }
.status-badge.failed { background: rgba(255, 93, 102, .15); color: #ff8b91; }
.video-meta { margin: .55rem 0 .9rem; color: var(--muted); font-size: .82rem; }
.video-error { color: #ff8b91; font-size: .8rem; white-space: pre-line; }
.video-actions { display: flex; gap: .5rem; }
.video-actions .btn { flex: 1; }

.empty-state { padding: 4rem 1rem; color: var(--muted); text-align: center; }
.empty-state h2 { color: #fff; font-size: 1.2rem; }
.empty-icon { margin-bottom: .8rem; font-size: 2rem; }

.player-overlay { position: fixed; z-index: 100; inset: 0; display: grid; grid-template-rows: auto 1fr; background: #000; }
.player-topbar { display: flex; align-items: center; justify-content: space-between; min-height: 4rem; padding: calc(.75rem + env(safe-area-inset-top)) 1rem .75rem; }
.player-topbar strong { max-width: calc(100vw - 5rem); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-overlay video { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.player-overlay img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }

.completion-popup {
    position: fixed;
    z-index: 120;
    right: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    left: 1rem;
    display: flex;
    max-width: 28rem;
    gap: .9rem;
    padding: 1rem 2.5rem 1rem 1rem;
    border: 1px solid rgba(54, 204, 119, .45);
    border-radius: 1rem;
    background: #16241c;
    box-shadow: 0 1rem 4rem rgba(0, 0, 0, .55);
}

.completion-popup p { margin: .15rem 0 .65rem; color: #b8c7bd; font-size: .85rem; }
.completion-icon { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; flex: none; border-radius: 50%; background: var(--success); color: #07140c; font-weight: 900; }
.popup-close { position: absolute; top: .2rem; right: .5rem; border: 0; background: transparent; color: #b8c7bd; font-size: 1.5rem; }

@media (min-width: 34rem) {
    .completion-popup { right: 1.5rem; bottom: 1.5rem; left: auto; width: 28rem; }
}

@media (max-width: 38rem) {
    .app-header { align-items: flex-start; }
    .header-actions { flex-direction: column; align-items: flex-end; }
    .upload-panel { grid-template-columns: 1fr; }
    .upload-button { width: 100%; }
    .upload-progress, .error-message { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
