:root {
    color-scheme: light;
    --ink: #15161a;
    --muted: #626772;
    --paper: #f7f4ed;
    --surface: #ffffff;
    --line: #d8d3c8;
    --brand: #b8362f;
    --brand-dark: #7f241f;
    --blue: #285f8f;
    --green: #2d6b4f;
    --shadow: 0 24px 70px rgba(21, 22, 26, 0.14);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        linear-gradient(135deg, rgba(184, 54, 47, 0.11), transparent 34%),
        linear-gradient(225deg, rgba(40, 95, 143, 0.13), transparent 30%),
        var(--paper);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
    font: inherit;
}

button:not(.plyr__control),
.logout-link {
    border: 0;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    min-height: 44px;
    padding: 12px 18px;
    text-decoration: none;
    transition: background 160ms ease;
}

button:not(.plyr__control):disabled {
    cursor: wait;
    opacity: 0.72;
    transform: none;
}

button:not(.plyr__control):hover,
.logout-link:hover {
    background: var(--brand-dark);
}

input[type='text'],
input[type='password'],
input[type='file'],
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    min-height: 46px;
    padding: 11px 12px;
}

input:focus {
    border-color: var(--blue);
    outline: 3px solid rgba(40, 95, 143, 0.18);
}

select:focus {
    border-color: var(--blue);
    outline: 3px solid rgba(40, 95, 143, 0.18);
}

.app-shell {
    width: min(100% - 32px, 460px);
    margin: 0 auto;
    padding: 48px 0;
}

.app-shell-wide {
    width: min(100% - 32px, 1180px);
}

.auth-panel,
.upload-panel,
.management-panel,
.empty-state,
.video-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow);
}

.auth-panel {
    margin-top: 8vh;
    padding: 32px;
}

.eyebrow {
    color: var(--brand);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    margin: 0 0 10px;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1;
    margin-bottom: 14px;
}

.auth-panel h1 {
    font-size: clamp(2rem, 8vw, 3rem);
}

h2 {
    font-size: 1.35rem;
    margin-bottom: 6px;
}

h3 {
    font-size: 1rem;
    line-height: 1.3;
    margin-bottom: 6px;
    overflow-wrap: anywhere;
}

.lede,
.upload-panel p,
.video-info p,
.empty-state p,
.library-heading span,
.account-line,
.section-heading p,
.checkbox-fieldset p {
    color: var(--muted);
}

.account-line {
    margin: 8px 0 0;
}

.stack-form {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

.stack-form label {
    color: var(--muted);
    display: grid;
    font-size: 0.95rem;
    font-weight: 700;
    gap: 8px;
}

.notice {
    border-radius: 8px;
    font-weight: 700;
    margin: 18px 0;
    padding: 13px 14px;
}

.notice p {
    margin: 0;
}

.notice-success {
    background: rgba(45, 107, 79, 0.12);
    color: var(--green);
}

.notice-error {
    background: rgba(184, 54, 47, 0.12);
    color: var(--brand-dark);
}

.topbar {
    align-items: center;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin-bottom: 24px;
}

.topbar h1 {
    margin-bottom: 0;
}

.upload-panel,
.management-panel {
    align-items: end;
    display: grid;
    gap: 20px;
    grid-template-columns: minmax(220px, 0.8fr) minmax(280px, 1.2fr);
    margin-bottom: 30px;
    padding: 22px;
}

.management-panel {
    align-items: stretch;
    grid-template-columns: 1fr;
}

.section-heading {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
}

.user-form {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(130px, 1fr)) auto;
}

.user-form label {
    color: var(--muted);
    display: grid;
    font-size: 0.9rem;
    font-weight: 700;
    gap: 7px;
}

.user-list {
    display: grid;
    gap: 10px;
}

.user-row {
    align-items: center;
    background: rgba(247, 244, 237, 0.72);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 12px;
}

.user-row div {
    display: grid;
    gap: 4px;
}

.user-row span {
    color: var(--muted);
    font-size: 0.88rem;
    text-transform: capitalize;
}

.upload-form {
    align-items: center;
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr auto;
}

.upload-form .checkbox-fieldset {
    grid-column: 1 / -1;
}

.upload-status {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    border-radius: 8px;
    bottom: 18px;
    box-shadow: var(--shadow);
    display: none;
    font-weight: 800;
    left: 50%;
    max-width: min(440px, calc(100% - 28px));
    padding: 16px;
    position: fixed;
    transform: translateX(-50%);
    width: 100%;
    z-index: 20;
}

.upload-status.is-active {
    display: grid;
    gap: 12px;
}

.upload-progress {
    background: #ece7dc;
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
}

.upload-progress span {
    animation: uploadBar 1.1s ease-in-out infinite;
    background: linear-gradient(90deg, var(--brand), var(--blue));
    border-radius: inherit;
    display: block;
    height: 100%;
    width: 45%;
}

.is-uploading::after {
    background: rgba(21, 22, 26, 0.2);
    content: '';
    inset: 0;
    pointer-events: none;
    position: fixed;
    z-index: 10;
}

@keyframes uploadBar {
    0% {
        transform: translateX(-105%);
    }
    100% {
        transform: translateX(235%);
    }
}

.checkbox-fieldset {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin: 0;
    padding: 12px;
}

.checkbox-fieldset legend {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 800;
    padding: 0 6px;
}

.checkbox-fieldset label {
    align-items: center;
    display: inline-flex;
    gap: 6px;
    min-height: 28px;
}

.checkbox-fieldset input {
    accent-color: var(--brand);
}

.library-heading {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
}

.video-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.video-card {
    overflow: hidden;
}

.video-placeholder {
    aspect-ratio: 1 / 1;
    background:
        linear-gradient(180deg, #303030, #111111);
    background-position: center;
    background-size: cover;
    display: grid;
    overflow: hidden;
    position: relative;
}

.video-placeholder.has-poster {
    background-image:
        linear-gradient(180deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.3)),
        var(--poster-image);
}

.video-placeholder::before {
    background: radial-gradient(circle, rgba(255, 255, 255, 0.16), transparent 42%);
    content: '';
    grid-area: 1 / 1;
    opacity: 0.7;
    pointer-events: none;
    z-index: 1;
}

.video-placeholder.is-playing::before {
    display: none;
}

.video-placeholder video {
    background: #0b0c0f;
    display: block;
    grid-area: 1 / 1;
    height: 100%;
    object-fit: contain;
    width: 100%;
}

.video-placeholder .plyr {
    --plyr-color-main: var(--brand);
    grid-area: 1 / 1;
    height: 100%;
    width: 100%;
    z-index: 2;
}

.video-placeholder .plyr video {
    background: #000;
    height: 100%;
    object-fit: contain;
    width: 100%;
}

.video-placeholder .plyr__poster {
    background-size: contain;
}

.video-placeholder video:fullscreen,
.video-placeholder video:-webkit-full-screen,
.video-placeholder video:-moz-full-screen,
.video-placeholder video:-ms-fullscreen {
    background: #000;
    height: 100vh;
    object-fit: contain;
    width: 100vw;
}

.video-placeholder .plyr:fullscreen video,
.video-placeholder .plyr:-webkit-full-screen video,
.video-placeholder .plyr:-moz-full-screen video,
.video-placeholder .plyr:-ms-fullscreen video {
    background: #000;
    object-fit: contain;
}

.video-placeholder:not(.is-playing) video {
    opacity: 0;
}

button.play-placeholder {
    align-items: center;
    background: rgba(255, 255, 255, 0);
    border: 3px solid var(--brand);
    border-radius: 50%;
    color: var(--brand);
    display: inline-flex;
    height: 64px;
    justify-content: center;
    left: 50%;
    min-height: 64px;
    padding: 0;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    z-index: 3;
}

button.play-placeholder:hover {
    background: rgba(184, 54, 47, 0.1);
    color: var(--brand);
}

button.play-placeholder[hidden],
.video-placeholder.is-playing .play-placeholder {
    display: none;
}

.play-icon {
    display: block;
    fill: var(--brand);
    height: 34px;
    margin-left: 3px;
    width: 34px;
}

.video-card video {
    aspect-ratio: 16 / 9;
    background: #0b0c0f;
    display: block;
    width: 100%;
}

.video-info {
    align-items: start;
    display: grid;
    gap: 14px;
    grid-template-columns: 1fr auto;
    padding: 16px;
}

.thumbnail-form {
    align-items: end;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr auto;
    padding: 16px;
}

.thumbnail-form label {
    color: var(--muted);
    display: grid;
    font-size: 0.9rem;
    font-weight: 800;
    gap: 7px;
}

.danger-button {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--brand-dark);
    min-height: 38px;
    padding: 8px 12px;
}

.secondary-button {
    background: var(--blue);
}

.secondary-button:hover {
    background: #1d486e;
}

.visibility-form {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 12px;
    padding: 0 16px 16px;
}

.danger-button:hover {
    background: rgba(184, 54, 47, 0.1);
    color: var(--brand-dark);
}

.empty-state {
    padding: 28px;
    text-align: center;
}

@media (max-width: 760px) {
    .app-shell {
        padding: 24px 0;
        width: min(100% - 22px, 460px);
    }

    .app-shell-wide {
        width: min(100% - 22px, 1180px);
    }

    .auth-panel {
        margin-top: 3vh;
        padding: 24px;
    }

    .topbar,
    .library-heading,
    .upload-panel,
    .management-panel,
    .upload-form,
    .user-form,
    .thumbnail-form,
    .video-info {
        align-items: stretch;
        grid-template-columns: 1fr;
    }

    .topbar,
    .library-heading {
        display: grid;
    }

    .logout-link,
    .upload-form button {
        text-align: center;
        width: 100%;
    }
}
