:root {
    --bg: #000;
    --surface: #0f0f0f;
    --text: #ededed;
    --muted: #8a8a8a;
    --faint: #4a4a4a;
    --line: #262626;
    --dim: #3a3a3a;
    --gutter: 28px;
    --sans: "Geist", system-ui, -apple-system, sans-serif;
    --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    background: var(--bg);
    color-scheme: dark;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 1px solid var(--text);
    outline-offset: 2px;
}

.icon {
    display: block;
    flex-shrink: 0;
}

.icon-lg {
    width: 22px;
    height: 22px;
}

.meta {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.03em;
    color: var(--muted);
}

/* Page */

.page {
    max-width: 560px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(48px, env(safe-area-inset-top)) 0 calc(120px + var(--safe-bottom));
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    padding: 0 14px 0 var(--gutter);
}

.icon-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
}

.icon-btn-muted {
    color: var(--muted);
}

.icon-btn .when-open,
.icon-btn[aria-expanded="true"] .when-closed {
    display: none;
}

.icon-btn[aria-expanded="true"] .when-open {
    display: block;
}

/* Lists & swipe rows */

.list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 22px;
}

.list-tight {
    gap: 0;
}

.row {
    position: relative;
    overflow: hidden;
    transition: height 0.28s var(--ease), opacity 0.28s var(--ease);
}

.row-under {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--gutter);
    background: var(--surface);
    color: var(--text);
    opacity: 0;
}

.row.swiping .row-under,
.row.revealed .row-under,
.row.committed .row-under {
    opacity: 1;
}

.row-under .row-icon-start,
.row-under .row-icon-end {
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s var(--ease);
}

.row[data-dir="right"] .row-icon-start,
.row[data-dir="left"] .row-icon-end {
    opacity: 0.45;
}

.row.armed .row-icon-start,
.row.armed .row-icon-end {
    transform: scale(1.15);
}

.row.armed[data-dir="right"] .row-icon-start,
.row.armed[data-dir="left"] .row-icon-end,
.row.revealed .row-icon-end {
    opacity: 1;
}

.row-under .row-icon-end {
    margin-left: auto;
}

.row-action {
    width: 76px;
    height: 100%;
    margin-right: calc(-1 * var(--gutter));
    display: flex;
    align-items: center;
    justify-content: center;
}

.row-body {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px var(--gutter);
    background: var(--bg);
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    will-change: transform;
}

.row.settling .row-body {
    transition: transform 0.3s var(--ease);
}

.row-compact .row-body {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
}

.row-title {
    font-size: 19px;
    line-height: 1.3;
    font-weight: 500;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
}

.row-meta {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    font-family: var(--mono);
    font-size: 11.5px;
    letter-spacing: 0.02em;
    color: var(--muted);
}

.row-meta > span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-meta > span:last-child {
    flex-shrink: 0;
}

.row-progress {
    display: block;
    height: 1px;
    background: var(--line);
}

.row-progress > span {
    display: block;
    height: 100%;
    background: var(--text);
}

/* Empty */

.empty {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
}

.empty-ring {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid var(--text);
}

/* Forms */

.inline-form {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 14px var(--gutter) 0;
}

.inline-form-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.input {
    flex: 1;
    min-width: 0;
    height: 44px;
    padding: 0;
    border: none;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font-family: var(--sans);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.input-mono {
    font-family: var(--mono);
    font-size: 14px;
    letter-spacing: 0.02em;
}

.input::placeholder {
    color: var(--faint);
}

.input:focus {
    border-bottom-color: var(--muted);
}

/* Round buttons */

.round-btn {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    flex-shrink: 0;
    transition: transform 0.15s var(--ease), opacity 0.2s;
}

.round-btn:active {
    transform: scale(0.94);
}

.round-btn-solid {
    border-color: var(--text);
    background: var(--text);
    color: var(--bg);
}

.inline-form .round-btn {
    width: 44px;
    height: 44px;
}

.round-btn:disabled {
    opacity: 0.4;
}

/* Nav */

.nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    gap: 28px;
    padding: 40px 0 calc(24px + var(--safe-bottom));
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0), var(--bg) 55%);
    pointer-events: none;
    z-index: 10;
}

.nav-link {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.nav-dash {
    width: 6px;
    height: 2px;
    border-radius: 1px;
    background: var(--faint);
    transition: width 0.25s var(--ease), background 0.25s;
}

.nav-link.active .nav-dash {
    width: 18px;
    background: var(--text);
}

.nav-dot {
    position: absolute;
    top: 12px;
    left: 50%;
    width: 3px;
    height: 3px;
    margin-left: -1.5px;
    border-radius: 50%;
    background: var(--text);
}

/* Watch */

.page-watch {
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
}

.player {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--surface);
    transition: opacity 0.3s;
}

.player video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #000;
}

.player.fullscreen {
    aspect-ratio: auto;
    width: 100%;
    height: 100%;
    background: #000;
}

/* Player controls */

.player-overlay {
    position: absolute;
    inset: 0;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.player-play,
.player-bar {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.controls-visible .player-play,
.controls-visible .player-bar {
    opacity: 1;
    pointer-events: auto;
}

.player.fullscreen:not(.controls-visible) {
    cursor: none;
}

.player-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 64px;
    height: 64px;
    margin: -32px 0 0 -32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    color: var(--text);
}

.player-play .when-playing,
.paused .player-play .when-paused {
    display: block;
}

.player-play .when-paused,
.paused .player-play .when-playing {
    display: none;
}

.buffering:not(.paused) .player-play {
    opacity: 0;
}

.player-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 24px 12px 4px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
}

.player-progress {
    position: relative;
    height: 24px;
    margin: 0 4px;
    cursor: pointer;
    touch-action: none;
}

.player-track {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 3px;
    margin-top: -1.5px;
    background: rgba(255, 255, 255, 0.2);
    overflow: hidden;
    transition: height 0.15s, margin-top 0.15s;
}

.scrubbing .player-track {
    height: 5px;
    margin-top: -2.5px;
}

.player-buffered,
.player-played,
.player-segment {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
}

.player-buffered {
    background: rgba(255, 255, 255, 0.25);
}

.player-played {
    background: var(--text);
}

.player-segment {
    background: var(--muted);
    opacity: 0.6;
}

.player-thumb {
    position: absolute;
    top: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 50%;
    background: var(--text);
    pointer-events: none;
    transition: transform 0.15s var(--ease);
}

.scrubbing .player-thumb {
    transform: scale(1.3);
}

.player-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.player-time {
    padding: 0 4px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.02em;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.player-buttons {
    display: flex;
    align-items: center;
}

.player-btn {
    min-width: 44px;
    height: 40px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--muted);
}

.player-btn.active {
    color: var(--text);
}

.player-speed {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text);
}

.player-lang {
    font-family: var(--mono);
    font-size: 11px;
    text-transform: uppercase;
}

.player-lang:empty {
    display: none;
}

.player-theater {
    display: none;
}

.player-btn .when-fullscreen,
.fullscreen .player-btn .when-windowed {
    display: none;
}

.fullscreen .player-btn .when-fullscreen {
    display: block;
}

.player-flash {
    position: absolute;
    top: 50%;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.02em;
    color: var(--text);
    transform: translate(-50%, -50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.player-flash[data-side="left"] { left: 22%; }
.player-flash[data-side="center"] { left: 50%; top: 22%; }
.player-flash[data-side="right"] { left: 78%; }

.player-flash.visible {
    opacity: 1;
}

.player-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--text);
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    animation: player-spin 0.8s linear infinite;
}

.buffering:not(.paused) .player-spinner {
    opacity: 1;
}

@keyframes player-spin {
    to { transform: rotate(360deg); }
}

.player-status {
    position: absolute;
    inset: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.02em;
    color: var(--muted);
}

.watch-info {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 32px var(--gutter) 0;
}

.watch-title {
    margin: 0;
    font-size: 26px;
    line-height: 1.22;
    font-weight: 500;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
    transition: color 0.3s;
}

.watch-title button {
    text-align: left;
    font-weight: inherit;
    letter-spacing: inherit;
    line-height: inherit;
}

.watch-info .meta {
    margin: 0;
    transition: color 0.3s;
}

.watch-channel {
    text-decoration: line-through;
    text-decoration-color: transparent;
    text-decoration-thickness: 1px;
    transition: color 0.3s, text-decoration-color 0.3s;
}

.watch-tools {
    display: flex;
    align-items: center;
    margin: -4px 0 0 -12px;
    transition: opacity 0.3s;
}

.watch-youtube {
    margin-left: auto;
    margin-right: -12px;
}

.watch-actions {
    position: sticky;
    bottom: 0;
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 40px 24px calc(40px + var(--safe-bottom)) 16px;
    background: var(--bg);
}

.watch-back {
    transition: opacity 0.3s;
}

.watch-buttons {
    display: flex;
    align-items: center;
    gap: 14px;
}

.watch-buttons .round-btn:not(.hold-btn) {
    transition: opacity 0.3s, transform 0.15s var(--ease);
}

.hold-btn {
    color: var(--muted);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s var(--ease);
}

.hold-ring {
    position: absolute;
    inset: -5px;
    width: calc(100% + 10px);
    height: calc(100% + 10px);
    transform: rotate(-90deg);
    pointer-events: none;
}

.hold-ring-progress {
    fill: none;
    stroke: var(--text);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    opacity: 0;
    transition: stroke-dashoffset 0.25s var(--ease), opacity 0.2s;
}

.holding .hold-btn {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
}

.holding .hold-ring-progress {
    opacity: 1;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset var(--hold-duration, 1.2s) linear, opacity 0.1s;
}

.holding .player {
    opacity: 0.35;
}

.holding .watch-title,
.holding .watch-info .meta {
    color: var(--dim);
}

.holding .watch-channel {
    color: var(--text);
    text-decoration-color: var(--text);
}

.holding .watch-back,
.holding .watch-tools,
.holding .watch-buttons .round-btn:not(.hold-btn) {
    opacity: 0.2;
}

/* Toast */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(96px + var(--safe-bottom));
    max-width: calc(100% - 2 * var(--gutter));
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--line);
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 0.02em;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transform: translate(-50%, 8px);
    transition: opacity 0.25s, transform 0.25s var(--ease);
    pointer-events: none;
    z-index: 20;
}

.toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* Desktop watch page: wider player, info and actions side by side, theater mode */

@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
    .page-watch {
        --watch-width: min(1120px, calc(100vw - 160px), calc((100dvh - 220px) * 16 / 9));
        max-width: none;
        display: grid;
        grid-template-columns: 1fr minmax(0, calc(var(--watch-width) - 280px)) 280px 1fr;
        align-content: start;
        padding: 40px 0 64px;
    }

    .page-watch .player {
        grid-column: 2 / 4;
    }

    .page-watch.theater {
        padding-top: 0;
    }

    .page-watch.theater .player:not(.fullscreen) {
        grid-column: 1 / -1;
        aspect-ratio: auto;
        height: min(56.25vw, calc(100dvh - 160px));
    }

    .watch-info {
        grid-column: 2;
        padding: 28px 32px 0 0;
    }

    .watch-title {
        font-size: 28px;
    }

    .watch-youtube {
        margin: 0;
    }

    .watch-actions {
        grid-column: 3;
        position: static;
        margin-top: 0;
        padding: 28px 0 0;
        align-self: start;
        justify-content: flex-end;
        gap: 14px;
        background: none;
    }

    .watch-back {
        position: fixed;
        top: 20px;
        left: 20px;
        z-index: 5;
    }

    .theater .watch-back {
        opacity: 0;
    }

    .theater .watch-back:hover,
    .theater .watch-back:focus-visible {
        opacity: 1;
    }

    .player-theater {
        display: flex;
    }

    .theater .player-theater {
        color: var(--text);
    }
}

@media (hover: hover) {
    .row-body:hover .row-title {
        color: #fff;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
    }
}
