:root {
    color-scheme: dark;
    --bg: #0a0d12;
    --surface: #121721;
    --surface-2: #171e2a;
    --line: #293140;
    --text: #f5f7fb;
    --muted: #9ca7b8;
    --accent: #7c5cff;
    --accent-2: #9b87ff;
    --danger: #ff8c9b;
    --success: #79d6aa;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 15% 0%, rgba(124, 92, 255, 0.18), transparent 35rem),
        var(--bg);
}

a {
    color: inherit;
}

button,
input,
select {
    font: inherit;
}

button,
.button-link {
    min-height: 2.75rem;
    border: 1px solid transparent;
    border-radius: 0.75rem;
    padding: 0.65rem 1rem;
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
    transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

button:hover:not(:disabled),
.button-link:hover {
    transform: translateY(-1px);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.primary {
    background: var(--accent);
}

.primary:hover:not(:disabled) {
    background: var(--accent-2);
}

.secondary {
    border-color: var(--line);
    background: var(--surface-2);
}

.quiet {
    border-color: var(--line);
    background: transparent;
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

input,
select {
    width: 100%;
    min-height: 2.9rem;
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    outline: none;
    padding: 0.7rem 0.8rem;
    color: var(--text);
    background: #0e131b;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
    border-color: var(--accent-2);
    outline: 3px solid rgba(124, 92, 255, 0.25);
    outline-offset: 2px;
}

label {
    display: block;
    margin: 0.9rem 0 0.4rem;
    color: #d7dce5;
    font-size: 0.92rem;
    font-weight: 650;
}

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

h1 {
    margin-bottom: 0.75rem;
    font-size: clamp(2rem, 7vw, 4.5rem);
    letter-spacing: -0.055em;
    line-height: 0.98;
}

h2 {
    margin-bottom: 1.1rem;
    font-size: 1.15rem;
}

.eyebrow {
    margin-bottom: 0.65rem;
    color: var(--accent-2);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.lede {
    max-width: 42rem;
    color: var(--muted);
    font-size: 1.05rem;
    line-height: 1.6;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 4.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    padding: 0 5vw;
    backdrop-filter: blur(14px);
    background: rgba(10, 13, 18, 0.72);
}

.topbar form {
    margin: 0;
}

.brand {
    text-decoration: none;
    font-weight: 850;
    letter-spacing: -0.03em;
}

.page-shell,
.room-shell {
    width: min(1120px, 90vw);
    margin: 0 auto;
    padding: 4.5rem 0 6rem;
}

.hero {
    padding: 3rem 0 4rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.panel,
.player-panel {
    border: 1px solid var(--line);
    border-radius: 1.15rem;
    padding: 1.35rem;
    background: linear-gradient(145deg, rgba(23, 30, 42, 0.96), rgba(15, 20, 29, 0.96));
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
}

.panel form button {
    width: 100%;
    margin-top: 1rem;
}

.room-list {
    margin-top: 1rem;
}

.room-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--line);
    padding: 1rem 0;
    color: var(--muted);
    text-decoration: none;
}

.room-row:hover strong {
    color: var(--accent-2);
}

.room-row span:first-child {
    display: grid;
    gap: 0.3rem;
}

.room-row strong {
    color: var(--text);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.room-row small {
    color: var(--muted);
}

.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 1rem;
}

.auth-card {
    width: min(27rem, 100%);
    border: 1px solid var(--line);
    border-radius: 1.25rem;
    padding: 2rem;
    background: rgba(18, 23, 33, 0.96);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

.auth-card h1 {
    font-size: 2.6rem;
}

.auth-card form button {
    width: 100%;
    margin-top: 1rem;
}

.auth-help {
    margin: 1rem 0 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
}

.auth-help code,
.auth-card .lede code {
    color: #d9d1ff;
}

.notice {
    border: 1px solid currentColor;
    border-radius: 0.7rem;
    margin: 1rem 0;
    padding: 0.75rem;
    font-size: 0.9rem;
}

.notice.error,
.field-error {
    color: var(--danger);
}

.notice.success {
    color: var(--success);
}

.field-error {
    min-height: 1rem;
    margin: 0.45rem 0 0;
    font-size: 0.85rem;
}

.room-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.room-heading h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 3.6rem);
}

.room-heading-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.signed-in-badge {
    border: 1px solid rgba(121, 214, 170, 0.35);
    border-radius: 999px;
    padding: 0.48rem 0.75rem;
    color: var(--success);
    background: rgba(121, 214, 170, 0.08);
    font-size: 0.78rem;
    font-weight: 750;
}

#room-id {
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    text-transform: none;
}

.player-panel {
    padding: 0;
    overflow: hidden;
    background: #05070a;
}

.video-shell {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 1.1rem 1.1rem 0 0;
    background: #030405;
    outline: none;
}

.video-shell:focus-visible {
    box-shadow: inset 0 0 0 3px var(--accent-2);
}

.video-shell video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #030405;
}

.video-shell video::cue {
    color: white;
    background: rgba(0, 0, 0, 0.8);
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 1.1rem;
}

.status {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
    z-index: 3;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    padding: 0.4rem 0.7rem;
    color: #e7e9ee;
    background: rgba(4, 6, 9, 0.72);
    backdrop-filter: blur(8px);
    font-size: 0.75rem;
    transition: opacity 180ms ease;
}

.center-play {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    display: grid;
    width: 4.5rem;
    height: 4.5rem;
    min-height: 0;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    padding: 0 0 0 0.25rem;
    place-items: center;
    color: white;
    background: rgba(8, 10, 14, 0.74);
    backdrop-filter: blur(10px);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
    transform: translate(-50%, -50%);
    transition: opacity 180ms ease, transform 180ms ease, background 180ms ease;
}

.center-play:hover:not(:disabled) {
    background: var(--accent);
    transform: translate(-50%, -50%) scale(1.06);
}

.video-shell[data-playing="true"] .center-play {
    opacity: 0;
    pointer-events: none;
}

.video-shell[data-playing="true"][data-playback-blocked="true"] .center-play {
    opacity: 1;
    pointer-events: auto;
}

.player-chrome {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 4;
    padding: 3rem 1rem 0.75rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.88));
    transition: opacity 180ms ease, transform 180ms ease;
}

.video-shell.controls-hidden {
    cursor: none;
}

.video-shell.controls-hidden .player-chrome,
.video-shell.controls-hidden .status {
    opacity: 0;
    pointer-events: none;
    transform: translateY(0.5rem);
}

.timeline {
    padding: 0 0 0.35rem;
}

.timeline input,
.volume {
    --progress: 0%;
    width: 100%;
    height: 0.25rem;
    min-height: auto;
    border: 0;
    border-radius: 999px;
    padding: 0;
    appearance: none;
    background: linear-gradient(to right, var(--accent) 0 var(--progress), rgba(255, 255, 255, 0.28) var(--progress) 100%);
    cursor: pointer;
}

.timeline input::-webkit-slider-thumb,
.volume::-webkit-slider-thumb {
    width: 0.85rem;
    height: 0.85rem;
    border: 0;
    border-radius: 50%;
    appearance: none;
    background: white;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

.timeline input::-moz-range-thumb,
.volume::-moz-range-thumb {
    width: 0.85rem;
    height: 0.85rem;
    border: 0;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

.controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
}

.icon-button {
    display: grid;
    width: 2.65rem;
    min-width: 2.65rem;
    min-height: 2.5rem;
    border: 0;
    border-radius: 50%;
    padding: 0;
    place-items: center;
    color: white;
    background: transparent;
    font-size: 1.15rem;
    font-weight: 800;
}

.icon-button:hover:not(:disabled),
.icon-button.active {
    background: rgba(255, 255, 255, 0.16);
}

.play-toggle .pause-icon {
    display: none;
    letter-spacing: -0.16rem;
}

.video-shell[data-playing="true"] .play-toggle .play-icon {
    display: none;
}

.video-shell[data-playing="true"] .play-toggle .pause-icon {
    display: inline;
}

.text-icon {
    font-size: 0.72rem;
    letter-spacing: -0.03em;
}

.volume {
    width: 5.5rem;
    margin: 0 0.45rem 0 0;
}

.player-time {
    color: white;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-size: 0.78rem;
}

.control-spacer {
    flex: 1;
}

.settings-menu {
    position: absolute;
    right: 1rem;
    bottom: 4.7rem;
    z-index: 6;
    width: min(21rem, calc(100% - 2rem));
    max-height: calc(100% - 6rem);
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 0.9rem;
    padding: 1rem;
    background: rgba(13, 16, 22, 0.96);
    backdrop-filter: blur(16px);
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
}

.settings-menu[hidden] {
    display: none;
}

.settings-menu h2 {
    margin-bottom: 0.8rem;
}

.settings-menu label {
    margin-top: 0.65rem;
    font-size: 0.78rem;
}

.settings-menu select {
    min-height: 2.35rem;
    padding: 0.45rem 0.6rem;
    font-size: 0.85rem;
}

.settings-menu small {
    display: block;
    margin-top: 0.65rem;
    color: var(--muted);
    line-height: 1.35;
}

.subtitle-file-button {
    display: block;
    border: 1px solid var(--line);
    border-radius: 0.65rem;
    padding: 0.6rem 0.75rem;
    color: var(--text);
    background: var(--surface-2);
    cursor: pointer;
    text-align: center;
}

.player-note {
    margin: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    padding: 0.75rem 1rem;
    color: var(--muted);
    background: var(--surface);
    font-size: 0.78rem;
}

.peer-stream,
.media-source {
    margin-top: 1rem;
}

.peer-stream > p,
.media-source p {
    color: var(--muted);
}

.peer-stream-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 0.45rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 0.8rem;
    padding: 1rem;
}

.peer-stream-form label,
.peer-stream-form input,
.peer-stream-form small {
    grid-column: 1;
}

.peer-stream-form button {
    grid-column: 2;
    grid-row: 1 / span 3;
}

.peer-stream-form small,
.stream-status {
    color: var(--muted);
}

.stream-status {
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
}

.media-library {
    margin-top: 1rem;
}

.media-library > p,
.empty-library,
.upload-form small,
.media-list span {
    color: var(--muted);
}

.success-message {
    color: var(--success) !important;
}

.upload-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 0.45rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 0.8rem;
    padding: 1rem;
}

.upload-form label,
.upload-form small {
    grid-column: 1;
}

.upload-form input {
    grid-column: 1;
}

.upload-form button {
    grid-column: 2;
    grid-row: 1 / span 3;
    width: auto !important;
    margin: 0 !important;
}

.upload-feedback {
    display: grid;
    grid-column: 1 / -1;
    gap: 0.4rem;
    margin-top: 0.45rem;
    color: var(--muted);
    font-size: 0.8rem;
}

.upload-feedback[hidden] {
    display: none;
}

.upload-feedback progress {
    width: 100%;
    height: 0.55rem;
    accent-color: var(--accent);
}

.media-list {
    display: grid;
    gap: 0;
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;
}

.media-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-top: 1px solid var(--line);
    padding: 0.9rem 0;
}

.media-list li > div {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
}

.media-list strong {
    overflow-wrap: anywhere;
}

.media-list span {
    font-size: 0.8rem;
}

.media-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.media-delete-form {
    margin: 0;
}

.danger-button {
    border-color: rgba(255, 140, 155, 0.45);
    color: var(--danger);
    background: rgba(255, 140, 155, 0.08);
}

.danger-button:hover:not(:disabled) {
    background: rgba(255, 140, 155, 0.16);
}

.inline-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.65rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

@media (max-width: 700px) {
    .page-shell,
    .room-shell {
        width: min(94vw, 42rem);
        padding-top: 2rem;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .room-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .room-heading-actions,
    .media-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .video-shell {
        border-radius: 0.9rem 0.9rem 0 0;
    }

    .player-chrome {
        padding-right: 0.5rem;
        padding-left: 0.5rem;
    }

    .volume {
        width: 3.8rem;
        margin-right: 0.1rem;
    }

    .peer-stream-form {
        grid-template-columns: 1fr;
    }

    .peer-stream-form button {
        grid-column: 1;
        grid-row: auto;
    }

    .player-time {
        font-size: 0.68rem;
    }

    .settings-menu {
        right: 0.5rem;
        bottom: 4.4rem;
        width: calc(100% - 1rem);
    }

    .inline-form {
        grid-template-columns: 1fr;
    }

    .upload-form {
        grid-template-columns: 1fr;
    }

    .upload-form button {
        grid-column: 1;
        grid-row: auto;
        width: 100% !important;
        margin-top: 0.5rem !important;
    }

    .media-list li {
        align-items: stretch;
        flex-direction: column;
    }

    .center-play {
        width: 3.8rem;
        height: 3.8rem;
    }
}

@media (max-width: 480px) {
    .volume {
        display: none;
    }

    #picture-in-picture {
        display: none;
    }

    .icon-button {
        width: 2.35rem;
        min-width: 2.35rem;
    }
}
