:root {
    --fg: #e6e6e6;
    --bg: #121212;
    --surface: #1e1e1e;
    --muted: #9aa0a6;
    --accent: #3b82f6;
    --error: #f87171;
    --border: #333333;
}

* { box-sizing: border-box; }

/* FocusOnNavigate moves keyboard focus to the page <h1> after each navigation
   (good for screen-reader/keyboard users). Suppress the visible focus ring so a
   heading that was focused programmatically doesn't show a rounded outline box. */
h1:focus, h1:focus-visible { outline: none; }

html { color-scheme: dark; }

body {
    margin: 0;
    font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--fg);
    background: var(--bg);
}

.page { display: flex; flex-direction: column; min-height: 100vh; }

.top-bar {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--fg);
}
.brand-logo { height: 32px; width: auto; display: block; }
.brand-name { font-size: 1.1rem; }

.nav-menu { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.nav-menu a { color: var(--fg); text-decoration: none; }
.nav-menu a:hover, .nav-menu a.active { color: var(--accent); }

.logout-form { display: inline; margin: 0; }
.link-button {
    background: none; border: none; padding: 0; cursor: pointer;
    color: var(--fg); font: inherit;
}
.link-button:hover { color: var(--accent); }

.content { padding: 1rem; max-width: 1200px; width: 100%; margin: 0 auto; }

.form-row { display: block; margin-bottom: 1rem; }
.form-row label { display: block; font-weight: 500; }
.form-row input, .form-row textarea {
    display: block;
    width: 100%;
    max-width: 520px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font: inherit;
    background: var(--surface);
    color: var(--fg);
}

button, .btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font: inherit;
}
button:disabled { opacity: 0.6; cursor: not-allowed; }
button.danger { background: var(--error); }
.btn-link {
    background: none;
    border: none;
    padding: 0;
    border-radius: 0;
    color: var(--accent);
    text-decoration: none;
    margin-left: 1rem;
    font: inherit;
    cursor: pointer;
    display: inline;
    vertical-align: baseline;
}
.btn-link:hover { text-decoration: underline; }

.error { color: var(--error); }
.hint { color: var(--muted); font-size: 0.9em; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table .thumb-cell { width: 120px; }
.list-thumb {
    display: block;
    width: 100px;
    max-width: 100px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
    background: #000;
    border: 1px solid var(--border);
}
.list-thumb--placeholder {
    background: repeating-linear-gradient(
        45deg,
        var(--border),
        var(--border) 6px,
        transparent 6px,
        transparent 12px
    );
}

.video-grid {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.video-card a {
    display: block;
    color: var(--fg);
    text-decoration: none;
}
.video-card img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background: #000;
    border-radius: 6px;
}
.video-title {
    display: block;
    margin-top: 0.5rem;
    font-weight: 500;
}

.thumb-wrap {
    position: relative;
    display: block;
}
.private-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.45rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    color: #fff;
    background: rgba(0, 0, 0, 0.72);
    border-radius: 4px;
    pointer-events: none;
}

.visibility-tag {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 4px;
    white-space: nowrap;
}
.visibility-tag--public {
    color: #0a7d33;
    background: rgba(10, 125, 51, 0.14);
}
.visibility-tag--private {
    color: #b26a00;
    background: rgba(178, 106, 0, 0.16);
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}
.action {
    background: none;
    border: 1px solid var(--border, rgba(128, 128, 128, 0.4));
    color: var(--fg);
    padding: 0.2rem 0.55rem;
    border-radius: 5px;
    font-size: 0.8rem;
    line-height: 1.4;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    font: inherit;
    font-size: 0.8rem;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.action:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(128, 128, 128, 0.08);
}
.action--danger:hover {
    border-color: var(--error);
    color: var(--error);
}

.player-wrapper {
    max-width: 1280px;
    margin: 0 auto;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
}

.player-wrapper .plyr {
    --plyr-color-main: var(--accent);
}

/* Buffering spinner overlay (used on both the watch page and the embed iframe). */
.video-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 3;
}

.video-spinner.is-visible {
    opacity: 1;
}

.video-spinner__ring {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    animation: video-spinner-rotate 0.8s linear infinite;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
}

@keyframes video-spinner-rotate {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .video-spinner__ring {
        animation-duration: 2s;
    }
}

.player-actions {
    max-width: 1280px;
    margin: 0.75rem auto 0;
    display: flex;
    gap: 0.5rem;
}

.btn-secondary {
    background: transparent;
    color: var(--fg);
    border: 1px solid var(--border);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font: inherit;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.embed-panel {
    max-width: 1280px;
    margin: 0.75rem auto 0;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.embed-panel textarea {
    width: 100%;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85em;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    resize: vertical;
    background: var(--bg);
    color: var(--fg);
}

.embed-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.login-page {
    max-width: 360px;
    margin: 5rem auto;
    padding: 1rem;
}

.login-page form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.login-page label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-weight: 500;
}

.login-page input[type="text"],
.login-page input[type="password"],
.login-page input:not([type]) {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font: inherit;
    background: var(--surface);
    color: var(--fg);
}

.login-page button {
    align-self: flex-start;
}

#blazor-error-ui {
    background: #4a3f1a;
    color: #f5f5f5;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.5);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
