:root {
    --accent: #00b3ff;
    --bg: #0a0a0a;
    --btn-bg: #1e1e1e;
}

.avp-player-wrapper {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: #fff;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
    position: relative;
}

.main-wrapper,
.upload-ui,
.controls-container {
    content-visibility: auto;
    contain-intrinsic-size: 500px;
}

.avp-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 10, 0.95);
    z-index: 100;
    border-radius: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.avp-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: avp-spin 1s linear infinite;
    margin-bottom: 15px;
}

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

.avp-player-wrapper.avp-ready .avp-loader {
    opacity: 0;
    pointer-events: none;
}

.main-wrapper {
    position: relative;
    background: #000;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    overflow: hidden;
}

.video-container {
    position: relative;
    width: 100% !important;
    height: 0 !important;
    padding-bottom: 56.25% !important;
    margin: 0 !important;
    background: #000;
}

.vPlayer,
.youtube-player {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    z-index: 1;
}

.vPlayer {
    pointer-events: auto !important;
}
.youtube-player {
    pointer-events: auto !important;
}

.youtube-player {
    display: none;
}

.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 10;
}

.play-button {
    font-size: 60px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    outline: none;
}

.play-button:hover {
    background: var(--accent);
    color: #000;
}

.sound-toggle {
    /* все стили заданы инлайн */
}

.upload-ui,
.controls-container,
.status-bar {
    margin-left: 10px;
    margin-right: 10px;
}

.upload-ui {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    background: #161616;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 15px;
    border: 1px solid #333;
}

@media (min-width: 768px) {
    .upload-ui {
        grid-template-columns: 1fr 1fr;
    }
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-group label {
    font-size: 14px;
    color: #ccc;
}

.input-row {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: wrap;
}

.input-row input {
    flex: 1 1 180px;
    min-width: 0;
}

input,
select {
    padding: 10px;
    background: #222;
    border: 1px solid #333;
    color: #ffffff !important;
    border-radius: 6px;
    font-size: 14px;
    box-sizing: border-box;
}

input::placeholder {
    color: #888;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-small {
    padding: 8px 10px;
    background: var(--btn-bg);
    border: 1px solid #333;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    transition: all 0.2s;
    flex-shrink: 0;
}

@media (min-width: 500px) {
    .btn-small {
        padding: 10px 12px;
        font-size: 13px;
    }
}

.btn-small:hover {
    background: var(--accent);
    color: #000;
}

.stream-badge {
    display: inline-block;
    background: var(--accent);
    color: #000;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    margin-left: 8px;
    font-weight: bold;
}

/* ===== НОВЫЙ БЛОК СУБТИТРОВ (10 строк, на всю ширину) ===== */
.subtitles-viewport {
    width: 100%;
    margin: 0;
    padding: 10px 0;
    box-sizing: border-box;
    background: #000;
    border: none;
    border-radius: 0;
    height: 15em;              /* 10 строк * 1.5em */
    line-height: 1.5em;
    overflow-y: auto;
    font-size: 18px;
    user-select: text;
    text-align: center;
    display: block;
}

.subtitles-list {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 100%;
    width: 100%;
}

.subtitle-line {
    padding: 0 10px;
    white-space: pre-wrap;
    cursor: default;
    transition: background 0.2s;
    font-size: inherit;
    line-height: inherit;
    text-shadow: 1px 1px 2px #000;
}

.subtitle-line.active {
    background: rgba(0, 179, 255, 0.15);
    font-weight: bold;
}

.subtitle-line .word {
    display: inline;
    padding: 0 1px;
    border-radius: 2px;
    cursor: pointer;          /* чтобы показать, что слово интерактивно */
}

.subtitle-line .word:hover {
    background: rgba(255, 255, 0, 0.3);
}

.subtitle-line .word.active-word {
    background: yellow;
    color: #000;
}

/* ===== УПРАВЛЕНИЕ (4 ряда) ===== */
.controls-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #161616;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #333;
    width: 100%;
    box-sizing: border-box;
}

.progress-container .time-current,
.progress-container .time-duration {
    font-size: 12px;
    color: #aaa;
    min-width: 40px;
    text-align: center;
}

.progress-bar {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #333;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

.progress-bar::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}

/* Ряды 2–4: кнопки */
.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}

.btn-row .btn {
    flex: 1 0 calc(25% - 8px);
    min-width: 0;
    padding: 10px 5px;
    background: var(--btn-bg);
    border: 1px solid #333;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    color: #fff;
    font-size: 14px;
    text-align: center;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-row .btn:hover {
    background: var(--accent);
    color: #000;
}

/* Ряд 4: скорость + YouTube Subs + built-in subs + Chapters */
.btn-row-3 {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
}

.btn-row-3 > * {
    flex: 1 0 calc(25% - 8px);  /* теперь 4 элемента в ряду */
    min-width: 0;
}

.speed-control select {
    width: 100%;
    padding: 8px;
    background: var(--btn-bg);
    border: 1px solid #333;
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    height: 100%;
    min-height: 40px;
}

.speed-control select:hover {
    background: var(--accent);
    color: #000;
}

.btn-row-3 .yt-subs-wrapper,
.btn-row-3 .choice-wrapper,
.btn-row-3 .chapters-wrapper {
    flex: 1 0 calc(25% - 8px);
    min-width: 0;
}

.btn-row-3 .btn-youtube-subs,
.btn-row-3 .btn-choice,
.btn-row-3 .btn-chapters {
    width: 100%;
    padding: 10px 5px;
    background: var(--btn-bg);
    border: 1px solid #333;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    color: #fff;
    font-size: 14px;
    text-align: center;
    transition: all 0.2s;
    white-space: nowrap;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-row-3 .btn-youtube-subs:hover,
.btn-row-3 .btn-choice:hover,
.btn-row-3 .btn-chapters:hover {
    background: var(--accent);
    color: #000;
}

.btn-youtube-subs {
    background: #ff0000;
    color: #fff;
}
.btn-youtube-subs:hover {
    background: #cc0000 !important;
    color: #fff !important;
}
.btn-choice {
    background: #8e44ad;
    color: #fff;
}
.btn-choice:hover {
    background: #9b59b6 !important;
    color: #fff !important;
}
.btn-chapters {
    background: #2ecc71;
    color: #fff;
}
.btn-chapters:hover {
    background: #27ae60 !important;
    color: #fff !important;
}

.choice-wrapper,
.yt-subs-wrapper,
.chapters-wrapper {
    position: relative;
    display: inline-block;
    overflow: visible;
}

.choice-menu,
.yt-subs-menu,
.chapters-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    z-index: 99999 !important;
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 5px 0;
    margin: 0 0 5px 0;
    list-style: none;
    min-width: 180px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.8);
}

.choice-menu li,
.yt-subs-menu li,
.chapters-menu li {
    padding: 8px 15px;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: background 0.2s;
}

.choice-menu li:hover,
.yt-subs-menu li:hover,
.chapters-menu li:hover {
    background: var(--accent);
    color: #000;
}

.choice-menu.visible,
.yt-subs-menu.visible,
.chapters-menu.visible {
    display: block;
}

.yt-subs-menu,
.chapters-menu {
    max-height: 300px;
    overflow-y: auto;
}

/* Полноэкранные элементы */
.fs-overlay {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    width: 90%;
    font-size: 24px;
    text-align: center;
    display: none;
    pointer-events: none;
}

.fs-overlay .sub-text-node {
    background: rgba(0, 0, 0, 0.8);
    border-radius: 10px;
    padding: 10px 20px;
    pointer-events: auto;
}

.fs-controls {
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    background: rgba(20, 20, 20, 0.9);
    padding: 10px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
}

.main-wrapper:fullscreen .fs-overlay,
.main-wrapper:fullscreen .fs-controls {
    display: grid;
}

.main-wrapper:-webkit-full-screen .fs-overlay,
.main-wrapper:-webkit-full-screen .fs-controls {
    display: grid;
}

.main-wrapper:fullscreen .video-container {
    padding-bottom: 0 !important;
    height: 100vh !important;
}

.ui-hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
}

.status-bar {
    margin-top: 10px;
    padding: 8px 15px;
    background: #1a1a1a;
    border-radius: 8px;
    font-size: 13px;
    color: #aaa;
    border-left: 3px solid var(--accent);
}

.security-warning,
.error-message {
    padding: 8px;
    border-radius: 6px;
    font-size: 12px;
    margin-top: 10px;
    display: none;
}

.security-warning {
    background: #ff6600;
    color: #000;
}

.error-message {
    background: #ff4444;
    color: #fff;
    text-align: center;
}

.custom-file-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.custom-file-wrapper input[type="file"] {
    position: absolute !important;
    width: 0.1px !important;
    height: 0.1px !important;
    opacity: 0 !important;
    overflow: hidden !important;
    z-index: -1 !important;
}

.custom-file-button {
    padding: 8px 14px;
    background: var(--btn-bg);
    border: 1px solid #555;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    white-space: nowrap;
    transition: background 0.2s;
}

.custom-file-button:hover {
    background: var(--accent);
    color: #000;
}

.custom-file-label {
    font-size: 13px;
    color: #aaa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* Адаптивность */
@media (max-width: 768px) {
    .btn-row .btn {
        flex: 1 0 calc(50% - 8px);
        font-size: 12px;
        padding: 8px 4px;
    }
    .btn-row-3 > * {
        flex: 1 0 calc(50% - 8px);
    }
    .btn-row-3 .speed-control {
        flex: 1 0 100%;
    }
    .btn-row-3 .yt-subs-wrapper,
    .btn-row-3 .choice-wrapper,
    .btn-row-3 .chapters-wrapper {
        flex: 1 0 calc(50% - 8px);
    }
    .btn-row-3 .btn-youtube-subs,
    .btn-row-3 .btn-choice,
    .btn-row-3 .btn-chapters {
        font-size: 12px;
        padding: 8px 4px;
        min-height: 36px;
    }
    .speed-control select {
        font-size: 12px;
        padding: 6px;
        min-height: 36px;
    }
    .progress-container {
        padding: 4px 8px;
    }
    .progress-container .time-current,
    .progress-container .time-duration {
        font-size: 10px;
        min-width: 30px;
    }
    .subtitles-viewport {
        font-size: 16px;
        height: 15em;
        line-height: 1.5em;
    }
    .upload-ui {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    .btn-row .btn {
        font-size: 10px;
        padding: 6px 2px;
    }
    .btn-row-3 .btn-youtube-subs,
    .btn-row-3 .btn-choice,
    .btn-row-3 .btn-chapters {
        font-size: 10px;
        padding: 6px 2px;
        min-height: 32px;
    }
    .speed-control select {
        font-size: 10px;
        padding: 4px;
        min-height: 32px;
    }
    .subtitles-viewport {
        font-size: 14px;
        height: 15em;
        line-height: 1.5em;
    }
}