:root {
    --bg: #0B0B0C;
    --surface: #111113;
    --surface-elevated: #1a1a1d;
    --muted: #BFBFBF;
    --muted-light: #E8E8E8;
    --accent-red: #ED1C24;
    --accent-red-glow: rgba(237, 28, 36, 0.3);
    --accent-gold: #FFC90E;
    --accent-gold-glow: rgba(255, 201, 14, 0.25);
    --glass: rgba(255, 255, 255, 0.03);
    --glass-heavy: rgba(255, 255, 255, 0.06);
    --card: linear-gradient(135deg, rgba(255, 255, 255, 0.02)0%, rgba(0, 0, 0, 0.03)100%);
    --card-hover: linear-gradient(135deg, rgba(255, 255, 255, 0.04)0%, rgba(0, 0, 0, 0.05)100%);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --maxw: 1440px;
    --header-height: 80px;
    --footer-height: 50px;
}

/* === GLOBAL RESET & TYPOGRAPHY === */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    background: var(--bg);
    color: #F4F4F4;
    line-height: 1.6;
    font-family: 'Inter', system-ui, sans-serif;
    color-scheme: dark;
    overflow: hidden;
    /* Prevent body scroll */
}

body {
    background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(237, 28, 36, 0.15), transparent 50%), radial-gradient(ellipse 50% 30% at 100% 100%, rgba(255, 201, 14, 0.1), transparent 50%), linear-gradient(180deg, var(--bg)0%, #080809 100%);
    background-attachment: fixed;
    position: relative;
}

/* Subtle Dither Noise to prevent banding */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    opacity: 0.03;
    pointer-events: none;
    z-index: -1;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.site {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* === HEADER === */
header {
    height: var(--header-height);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    background: rgba(11, 11, 12, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform .2s;
    text-decoration: none;
    flex-shrink: 0;
}

.brand:hover {
    transform: translateX(2px);
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(237, 28, 36, 0.2), rgba(255, 201, 14, 0.15));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, .4);
    position: relative;
    overflow: hidden;
}

.logo-mark {
    font-weight: 800;
    font-size: 18px;
    color: var(--accent-red);
}

.logo-plus {
    color: var(--accent-gold);
    font-weight: 900;
    margin-left: 2px;
}

.address-bar-container {
    display: flex;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 2px;
    flex: 1;
    max-width: 600px;
    margin: 0 40px;
    transition: border-color 0.3s ease;
}

.address-bar-container:focus-within {
    border-color: var(--accent-red);
}

#video-url {
    background: transparent;
    border: none;
    color: #fff;
    padding: 8px 16px;
    flex: 1;
    outline: none;
    font-size: 13px;
}

#load-video-btn {
    background: linear-gradient(135deg, var(--accent-red), #d0181f);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 0 16px;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
}

/* === MAIN CONTENT === */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    /* Crucial for internal scrolling */
    min-height: 0;
}

/* Video Side */
.video-stage {
    flex: 1.4;
    /* Takes more space */
    background: #000;
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-width: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.03);
}

.player-container {
    width: 100%;
    max-width: 1100px;
    aspect-ratio: 16/9;
    background: #050505;
    border-radius: var(--radius-xl);
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-container.drag-over {
    border-color: var(--accent-gold);
    background: rgba(255, 201, 14, 0.05);
}

.placeholder-content {
    text-align: center;
    color: var(--muted);
    cursor: pointer;
}

.video-wrapper,
#player-container video,
#player-container iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    object-fit: contain;
}

.video-caption {
    margin-top: 32px;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
    max-width: 600px;
}

/* Controls Side */
.control-sidebar {
    width: 380px;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
    padding: 24px 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--accent-gold);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-scroll-panel {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    scroll-behavior: smooth;
}

/* Master Toggle Styles */
.master-toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.toggle-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--accent-gold);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
}

input:checked+.slider {
    background-color: var(--accent-red);
}

input:checked+.slider:before {
    transform: translateX(14px);
}

.slider.round {
    border-radius: 20px;
}

.slider.round:before {
    border-radius: 50%;
}

.control-scroll-panel::-webkit-scrollbar {
    width: 6px;
}

.control-scroll-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

/* Enhancement Cards */
.card {
    background: var(--glass);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
    transition: border-color 0.3s;
}

.card:hover {
    border-color: rgba(237, 28, 36, 0.15);
}

.card h3 {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--accent-gold);
    margin: 0 0 20px 0;
    opacity: 0.8;
}

.row {
    margin-bottom: 20px;
}

.row:last-child {
    margin-bottom: 0;
}

.row label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted-light);
    margin-bottom: 8px;
}

.row input[type="range"] {
    width: 100%;
    cursor: pointer;
    accent-color: var(--accent-red);
}

.value-display {
    display: block;
    text-align: right;
    font-size: 10px;
    color: var(--accent-gold);
    font-family: monospace;
    margin-top: 4px;
}

/* Sub-controls indentation */
.row.sub-control {
    margin-left: 15px;
    margin-top: -10px;
    margin-bottom: 12px;
    opacity: 0.8;
}

.row.sub-control label {
    font-size: 11px;
    color: var(--accent-gold);
}

/* === FOOTER === */
footer {
    height: var(--footer-height);
    background: var(--bg);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    font-size: 11px;
    color: var(--muted);
    flex-shrink: 0;
}

.footer-links a {
    color: var(--muted);
    text-decoration: none;
    margin-left: 20px;
}

.footer-links a:hover {
    color: #fff;
}

/* Seek Bar */
.seek-container {
    position: relative;
    height: 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
}
.seek-bar {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
    margin: 0;
}
.seek-track {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
    overflow: hidden;
    transition: height 0.15s;
}
.seek-container:hover .seek-track {
    height: 6px;
}
.seek-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-red);
    border-radius: 4px;
    transition: width 0.1s linear;
}
.seek-thumb {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 12px;
    height: 12px;
    background: var(--accent-red);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.15s;
    box-shadow: 0 0 6px rgba(237,28,36,0.5);
    pointer-events: none;
}
.seek-container:hover .seek-thumb {
    opacity: 1;
}

/* Controls Row */
.controls-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.ctrl-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 16px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
.ctrl-btn:hover {
    background: rgba(255,255,255,0.12);
}
.ctrl-btn:active {
    background: rgba(255,255,255,0.2);
}



/* Time Display */
.time-display {
    font-size: 12px;
    font-family: monospace;
    color: rgba(255,255,255,0.85);
    white-space: nowrap;
    min-width: 80px;
    user-select: none;
}

.spacer {
    flex: 1;
}

/* Browse button in placeholder */
.browse-btn {
    margin-top: 16px;
    background: var(--surface-elevated);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.browse-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: var(--accent-red);
}

#player-container:fullscreen {
    max-width: none;
    aspect-ratio: auto;
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 0;
    border: none;
}

#player-container.fs-sidebar-mode .control-sidebar.fs-active {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 380px;
    z-index: 9999;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
    border-left: none;
    border-radius: 16px 0 0 16px;
    box-shadow: -8px 0 30px rgba(0,0,0,0.5);
}
#player-container.fs-sidebar-mode .control-sidebar.fs-active.fs-visible {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

/* === RESPONSIVE === */

/* Medium screens / tablet portrait (≤1024px) */
@media (max-width: 1024px) {
    header { padding: 0 20px; }
    .address-bar-container { margin: 0 20px; }
    .video-stage { padding: 20px; }
    .control-sidebar { width: 320px; }
    .sidebar-header { padding: 20px 24px; }
    .control-scroll-panel { padding: 24px; }
}

/* Small screen landscape: keep side-by-side, compact */
@media (max-width: 900px) and (orientation: landscape) {
    :root { --header-height: 48px; --footer-height: 0px; }

    header { padding: 0 12px; }
    header > div:last-child { display: none; }
    .brand .logo-text { display: none; }
    .brand .logo { width: 28px; height: 28px; }
    .brand .logo-mark { font-size: 12px; }
    .address-bar-container { margin: 0 10px; max-width: none; }
    #video-url { font-size: 11px; padding: 4px 8px; }
    #load-video-btn { font-size: 11px; padding: 0 8px; }

    .video-stage { padding: 6px; }
    #player-container { max-width: none; }
    .video-caption { display: none; }

    .control-sidebar { width: 250px; }
    .sidebar-header { padding: 8px 12px; }
    .sidebar-header h2 { font-size: 12px; }
    .control-scroll-panel { padding: 8px 12px; }
    .card { padding: 8px; margin-bottom: 8px; }
    .card h3 { font-size: 8px; margin-bottom: 6px; }
    .row { margin-bottom: 6px; }
    .row label { font-size: 10px; }
    .seek-container { height: 24px; }
    .ctrl-btn { width: 28px; height: 28px; font-size: 12px; }
    .time-display { font-size: 10px; min-width: 55px; }

    footer { display: none; }
}

/* Phone portrait: stack vertically, video pinned at top, sidebar scrolls below */
@media (max-width: 768px) and (orientation: portrait) {
    :root { --header-height: 52px; --footer-height: 0px; }

    header { padding: 0 10px; gap: 6px; }
    .brand .logo-text { display: none; }
    .brand .logo { width: 30px; height: 30px; }
    .brand .logo-mark { font-size: 12px; }
    header > div:last-child { display: none; }
    .address-bar-container { margin: 0; max-width: none; }
    #video-url { font-size: 12px; padding: 4px 10px; }
    #load-video-btn { font-size: 12px; padding: 0 10px; }

    .main-content {
        flex-direction: column;
        overflow: hidden;
    }

    .video-stage {
        flex: none;
        padding: 10px;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.05);
    }
    .player-container { max-width: none; }
    .video-caption { margin-top: 8px; font-size: 10px; }

    .control-sidebar {
        width: 100%;
        flex: 1;
        min-height: 0;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.05);
    }
    .sidebar-header { padding: 12px 16px; }
    .sidebar-header h2 { font-size: 13px; }
    .control-scroll-panel { padding: 12px 16px; }
    .card { padding: 12px; margin-bottom: 12px; }
    .card h3 { font-size: 9px; margin-bottom: 10px; }
    .row { margin-bottom: 10px; }
    .row label { font-size: 11px; }

    footer { display: none; }
}

/* Very small portrait phones */
@media (max-width: 480px) and (orientation: portrait) {
    :root { --header-height: 46px; }
    header { padding: 0 6px; }
    .brand .logo { width: 26px; height: 26px; }
    .brand .logo-mark { font-size: 10px; }
    #video-url { font-size: 11px; padding: 3px 8px; }
    #load-video-btn { font-size: 11px; padding: 0 8px; }
    .video-stage { padding: 6px; }
    .video-caption { font-size: 9px; }
    .card { padding: 8px; margin-bottom: 8px; }
    .control-scroll-panel { padding: 8px 12px; }
    .sidebar-header { padding: 8px 12px; }
    .ctrl-btn { width: 28px; height: 28px; font-size: 12px; }
    .time-display { font-size: 10px; min-width: 55px; }
    .browse-btn { font-size: 11px; padding: 5px 12px; }
    #player-container.fs-sidebar-mode .control-sidebar.fs-active { width: 240px; }
}

/* Short screens: hide caption, tighter cards */
@media (max-height: 520px) {
    .video-caption { display: none; }
    .card { padding: 6px; margin-bottom: 6px; }
    .card h3 { font-size: 8px; margin-bottom: 6px; }
    .row { margin-bottom: 4px; }
    .row label { font-size: 9px; }
    .control-scroll-panel { padding-left: 8px; padding-right: 8px; }
    .sidebar-header { padding-top: 6px; padding-bottom: 6px; }
}

/* Touch: always show seek thumb, bigger targets */
@media (hover: none) and (pointer: coarse) {
    .seek-container { height: 28px; }
    .seek-track { height: 5px; }
    .seek-thumb { opacity: 1; width: 16px; height: 16px; }
    .ctrl-btn { width: 40px; height: 40px; font-size: 18px; }
    .row input[type="range"] { height: 24px; }
}
