:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(17, 24, 39, 0.85);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(56, 189, 248, 0.15);
    --primary-color: #38bdf8;
    --primary-hover: #0ea5e9;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --accent-red: #ef4444;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.7), 0 0 15px rgba(56, 189, 248, 0.15);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-body);
    height: 100vh;
    overflow: hidden;
}


.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}


.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 1.5rem;
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #38bdf8 0%, #1d4ed8 100%);
    border-radius: 8px;
    color: white;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.logo-icon i {
    width: 16px;
    height: 16px;
}

.logo-text h1 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.5px;
    background: linear-gradient(to right, #ffffff, #93c5fd);
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text span {
    font-size: 0.65rem;
    color: var(--text-muted);
}


.mode-selector {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    padding: 3px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 20px;
    transition: var(--transition-smooth);
}

.mode-btn i {
    width: 14px;
    height: 14px;
}

.mode-btn:hover {
    color: var(--text-main);
}

.mode-btn.active {
    background: var(--primary-color);
    color: #0b0f19;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}


.action-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.8rem;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border-radius: 8px;
    font-family: var(--font-heading);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.1);
}

.action-btn i {
    width: 14px;
    height: 14px;
    color: var(--primary-color);
}

.action-btn.primary-action {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.4);
    color: var(--primary-color);
}

.action-btn.primary-action:hover {
    background: var(--primary-color);
    color: #0b0f19;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}


.control-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 1.5rem;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color);
    z-index: 90;
    transition: var(--transition-smooth);
}

.control-bar-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.selector-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.selector-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.source-dropdown {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    padding: 0.3rem 1.75rem 0.3rem 0.6rem;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: var(--transition-smooth);
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
}

.source-dropdown:hover {
    border-color: var(--primary-color);
    background-color: rgba(255, 255, 255, 0.08);
}

.source-dropdown:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.2);
}

.source-dropdown option {
    background-color: #111827;
    color: #f3f4f6;
}

.swap-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.swap-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: rgba(56, 189, 248, 0.1);
    transform: rotate(180deg);
}

.swap-btn i {
    width: 14px;
    height: 14px;
}

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




.brand-small {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    user-select: none;
}

.brand-icon {
    width: 18px;
    height: 18px;
    color: var(--primary-color);
}

.brand-small span {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
    background: linear-gradient(to right, #ffffff, #93c5fd);
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.vertical-divider {
    width: 1px;
    height: 18px;
    background-color: var(--border-color);
    margin: 0 0.5rem;
}


.help-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.help-icon-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.help-icon-btn i {
    width: 16px;
    height: 16px;
}



.action-btn.primary-action i {
    color: inherit;
}


.main-content {
    flex: 1;
    position: relative;
    width: 100vw;
    background-color: #05070c;
}

.mode-container {
    display: none;
    width: 100%;
    height: 100%;
}

.mode-container.active {
    display: block;
}


#iframeModeContainer {
    position: relative;
    width: 100%;
    height: 100%;
}

.video-wrapper {
    width: 100%;
    height: 100%;
    background-color: black;
}

.main-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}


.iframe-sync-layout {
    display: block;
    width: 100%;
    height: 100%;
    transition: var(--transition-smooth);
}

.iframe-box {
    width: 100%;
    height: 100%;
    position: relative;
    background-color: #000;
}

.iframe-box iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}


.audio-box {
    position: absolute;
    width: 1px;
    height: 1px;
    left: -9999px;
    top: -9999px;
    opacity: 0;
    pointer-events: none;
}


.is-sync-mode .iframe-sync-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 12px;
    height: calc(100% - 60px);
}

.is-sync-mode .iframe-box {
    position: relative;
    left: auto;
    top: auto;
    width: 100%;
    height: 100%;
    opacity: 1;
    pointer-events: auto;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-premium);
    transition: var(--transition-smooth);
}

.is-sync-mode .video-box {
    border-color: rgba(56, 189, 248, 0.4);
}

.is-sync-mode .audio-box {
    border-color: rgba(168, 85, 247, 0.4);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.7), 0 0 15px rgba(168, 85, 247, 0.15);
}


.sync-banner {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 60;
}

.is-sync-mode .sync-banner {
    display: flex;
}

.sync-banner-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.sync-banner-content i {
    width: 16px;
    height: 16px;
    color: var(--primary-color);
}

.sync-banner-content strong {
    color: var(--text-main);
}


.success-btn {
    padding: 0.5rem 1.25rem;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
    transition: var(--transition-smooth);
}

.success-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.3);
}

.success-btn i {
    width: 16px;
    height: 16px;
}


#hlsModeContainer {
    padding: 1.5rem;
    overflow-y: auto;
}

.hls-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
    height: 100%;
}

.player-column {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.video-player-card {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #000;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.video-player-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.1);
}

.video-player-card video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}


.player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: var(--transition-smooth);
}

.video-player-card:hover .player-overlay {
    opacity: 1;
}

.overlay-play-icon {
    width: 64px;
    height: 64px;
    color: white;
    background: var(--primary-color);
    border-radius: 50%;
    padding: 16px;
    box-shadow: 0 0 20px var(--primary-color);
    transform: scale(0.9);
    transition: var(--transition-smooth);
}

.video-player-card:hover .overlay-play-icon {
    transform: scale(1);
}


.controls-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.control-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: var(--transition-smooth);
}

.control-card.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.control-card h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.control-card h3 i {
    width: 18px;
    height: 18px;
    color: var(--primary-color);
}


.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    font-weight: 500;
}

.input-with-icon {
    position: relative;
    width: 100%;
}

.input-with-icon i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.input-with-icon input {
    width: 100%;
    padding: 0.65rem 0.65rem 0.65rem 2.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.85rem;
    transition: var(--transition-smooth);
}

.input-with-icon input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.1);
}


.primary-btn {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
    color: #0b0f19;
    border: none;
    border-radius: 8px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.2);
    transition: var(--transition-smooth);
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(56, 189, 248, 0.3);
}

.primary-btn:active {
    transform: translateY(0);
}

.primary-btn i {
    width: 18px;
    height: 18px;
}


.delay-display {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.75rem;
}

.delay-label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.delay-value {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}


.slider-container {
    margin-bottom: 1.25rem;
}

.slider-container input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.08);
    height: 6px;
    border-radius: 3px;
    outline: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color);
    cursor: pointer;
    transition: transform 0.1s;
}

.slider-container input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

.slider-container input[type="range"]:disabled {
    opacity: 0.5;
}

.slider-container input[type="range"]:disabled::-webkit-slider-thumb {
    background: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}


.nudge-controls {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
}

.nudge-btn {
    flex: 1;
    padding: 0.4rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.nudge-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
}

.nudge-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nudge-btn.reset {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
}

.nudge-btn.reset:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--accent-red);
}


.sync-actions {
    display: flex;
    gap: 0.75rem;
}

.sync-action-btn {
    flex: 1;
    padding: 0.65rem;
    background: var(--primary-color);
    color: #0b0f19;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: var(--transition-smooth);
}

.sync-action-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

.sync-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sync-action-btn i {
    width: 16px;
    height: 16px;
}

.sync-action-btn.secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.sync-action-btn.secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-main);
}


.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    z-index: 200;
    transition: opacity 0.3s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 650px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 30px rgba(56, 189, 248, 0.1);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.close-modal {
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.close-modal:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.close-modal i {
    width: 20px;
    height: 20px;
}

.modal-body {
    padding: 1.5rem;
}

.guide-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.tab-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition-smooth);
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    background: rgba(56, 189, 248, 0.1);
    color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.guide-intro {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 1.25rem;
}

.guide-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.guide-list li {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.step-num {
    background: rgba(56, 189, 248, 0.1);
    color: var(--primary-color);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.guide-list li p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.guide-list li p strong {
    color: var(--text-main);
}

.inline-icon {
    width: 14px;
    height: 14px;
    display: inline-block;
    vertical-align: middle;
    color: var(--primary-color);
    margin: 0 2px;
}

code {
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--primary-color);
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.modal-footer .primary-btn {
    width: auto;
    padding: 0.6rem 2rem;
}


@media (max-width: 1024px) {
    .hls-layout {
        grid-template-columns: 1fr;
    }

    .controls-column {
        grid-template-columns: 1fr 1fr;
        display: grid;
    }
}

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .controls-column {
        grid-template-columns: 1fr;
    }

    .floating-panel {
        width: calc(100% - 40px);
        left: 20px;
        right: 20px;
        bottom: 20px;
    }
}


body.is-dragging iframe,
body.is-resizing iframe {
    pointer-events: none !important;
}