/* Subtitle-first library (stage A3). Uses the app theme variables. */

.hvsubs {
    --hvsubs-radius: 14px;
    max-width: 1180px;
    margin: 0 auto;
    color: var(--theme-text, #e5e7eb);
}

.hvsubs-head h2 {
    margin: 0 0 4px;
    font-size: 1.35rem;
}

.hvsubs-head p {
    margin: 0 0 18px;
    color: var(--theme-text2, #9ca3af);
    font-size: 0.88rem;
}

.hvsubs-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
}

.hvsubs-q {
    flex: 1 1 220px;
    min-width: 180px;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .3));
    background: var(--theme-card, rgba(255, 255, 255, .04));
    color: var(--theme-text, #e5e7eb);
    font-size: 0.9rem;
    outline: none;
}

.hvsubs-q:focus {
    border-color: var(--theme-accent, #6366f1);
}

#hvsubs-language {
    flex: 0 1 auto;
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.84rem;
    cursor: pointer;
}

.hvsubs-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.hvsubs-chip {
    padding: 7px 13px;
    border-radius: 999px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .3));
    background: transparent;
    color: var(--theme-text2, #9ca3af);
    font-size: 0.8rem;
    cursor: pointer;
}

.hvsubs-chip.active {
    background: var(--theme-accent, #6366f1);
    border-color: var(--theme-accent, #6366f1);
    color: #fff;
}

.hvsubs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
    gap: 14px;
}

.hvsubs-card {
    border-radius: var(--hvsubs-radius);
    overflow: hidden;
    background: var(--theme-card, rgba(255, 255, 255, .04));
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .18));
    cursor: pointer;
    transition: transform .15s ease, border-color .15s ease;
}

.hvsubs-card:hover,
.hvsubs-card:focus-visible {
    transform: translateY(-2px);
    border-color: var(--theme-accent, #6366f1);
    outline: none;
}

.hvsubs-poster {
    position: relative;
    aspect-ratio: 2 / 3;
    background: linear-gradient(135deg, rgba(99, 102, 241, .35), rgba(15, 23, 42, .9));
    background-size: cover;
    background-position: center;
}

.hvsubs-poster .hvsubs-initial {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.4rem;
    font-weight: 700;
    color: rgba(255, 255, 255, .55);
}

.hvsubs-poster .hvsubs-badge {
    position: absolute;
    left: 8px;
    bottom: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    background: rgba(15, 23, 42, .78);
    color: #e5e7eb;
    backdrop-filter: blur(4px);
}

.hvsubs-poster .hvsubs-rights {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.64rem;
    background: rgba(245, 158, 11, .9);
    color: #1f2937;
    font-weight: 700;
}

.hvsubs-card-body {
    padding: 9px 11px 12px;
}

.hvsubs-title {
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.2em;
}

.hvsubs-meta {
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--theme-text2, #9ca3af);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hvsubs-more {
    margin: 20px 0 10px;
    text-align: center;
}

.hvsubs-btn {
    padding: 9px 18px;
    border-radius: 999px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .3));
    background: var(--theme-card, rgba(255, 255, 255, .05));
    color: var(--theme-text, #e5e7eb);
    font-size: 0.85rem;
    cursor: pointer;
}

.hvsubs-btn.primary {
    background: var(--theme-accent, #6366f1);
    border-color: var(--theme-accent, #6366f1);
    color: #fff;
    font-weight: 600;
}

.hvsubs-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--theme-text2, #9ca3af);
}

/* ── modal ─────────────────────────────────────────────────────────────── */

.hvsubs-back {
    position: fixed;
    inset: 0;
    z-index: 100050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(2, 6, 23, .72);
    backdrop-filter: blur(4px);
}

.hvsubs-modal {
    position: relative;
    width: min(920px, 100%);
    max-height: min(88vh, 900px);
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    background: var(--theme-bg, #0f172a);
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .25));
    color: var(--theme-text, #e5e7eb);
    overflow: hidden;
}

.hvsubs-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    z-index: 2;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, .65);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

.hvsubs-modal-head {
    padding: 18px 56px 12px 20px;
    border-bottom: 1px solid var(--theme-border, rgba(148, 163, 184, .18));
}

.hvsubs-modal-head h3 {
    margin: 0 0 6px;
    font-size: 1.1rem;
    line-height: 1.3;
}

.hvsubs-modal-meta {
    font-size: 0.78rem;
    color: var(--theme-text2, #9ca3af);
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
}

.hvsubs-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 16px 0;
}

.hvsubs-tab {
    padding: 8px 16px;
    border-radius: 10px 10px 0 0;
    border: none;
    background: transparent;
    color: var(--theme-text2, #9ca3af);
    font-size: 0.85rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.hvsubs-tab.active {
    color: var(--theme-text, #e5e7eb);
    border-bottom-color: var(--theme-accent, #6366f1);
}

.hvsubs-panes {
    flex: 1;
    overflow: hidden;
    display: flex;
}

.hvsubs-pane {
    display: none;
    flex-direction: column;
    width: 100%;
    overflow: hidden;
}

.hvsubs-pane.active {
    display: flex;
}

.hvsubs-reader-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--theme-border, rgba(148, 163, 184, .12));
}

.hvsubs-reader-tools input {
    flex: 1 1 160px;
    min-width: 120px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .3));
    background: transparent;
    color: inherit;
    font-size: 0.82rem;
}

.hvsubs-fs {
    display: flex;
    gap: 4px;
}

.hvsubs-fs button {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .3));
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.hvsubs-cues {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px 28px;
    font-size: var(--hvsubs-fs, 16px);
    line-height: 1.55;
}

.hvsubs-cue {
    display: flex;
    gap: 12px;
    padding: 5px 8px;
    border-radius: 8px;
    cursor: pointer;
}

.hvsubs-cue:hover {
    background: rgba(99, 102, 241, .1);
}

.hvsubs-cue.active {
    background: rgba(99, 102, 241, .18);
}

.hvsubs-cue .ts {
    flex: 0 0 56px;
    color: var(--theme-text2, #9ca3af);
    font-variant-numeric: tabular-nums;
    font-size: 0.78em;
    padding-top: 0.25em;
}

.hvsubs-cue mark {
    background: rgba(250, 204, 21, .45);
    color: inherit;
    border-radius: 3px;
}

.hvsubs-cue.hidden {
    display: none;
}

.hvsubs-video-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.hvsubs-hint {
    color: var(--theme-text2, #9ca3af);
    font-size: 0.82rem;
    margin: 0 0 12px;
}

.hvsubs-sources {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}

.hvsubs-source {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .2));
    background: var(--theme-card, rgba(255, 255, 255, .03));
}

.hvsubs-source-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.hvsubs-source-title {
    font-size: 0.88rem;
    font-weight: 600;
    flex: 1 1 240px;
}

.hvsubs-conf {
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
}

.hvsubs-conf.high { background: rgba(34, 197, 94, .2); color: #4ade80; }
.hvsubs-conf.mid { background: rgba(245, 158, 11, .2); color: #fbbf24; }
.hvsubs-conf.low { background: rgba(148, 163, 184, .2); color: #cbd5e1; }
.hvsubs-conf.mismatch { background: rgba(239, 68, 68, .18); color: #f87171; }

.hvsubs-source-why {
    font-size: 0.72rem;
    color: var(--theme-text2, #9ca3af);
}

/* ── iframe overlay ────────────────────────────────────────────────────── */

.hvsubs-frame-back {
    position: fixed;
    inset: 0;
    z-index: 100070;
    background: rgba(0, 0, 0, .85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.hvsubs-frame-box {
    position: relative;
    width: min(1100px, 100%);
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
}

.hvsubs-frame-box iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.hvsubs-frame-close {
    position: absolute;
    top: -44px;
    right: 0;
    padding: 6px 14px;
    border-radius: 999px;
    border: none;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    cursor: pointer;
}

@media (max-width: 620px) {
    .hvsubs-back { padding: 0; align-items: stretch; }
    .hvsubs-modal {
        max-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
        border: none;
    }
    .hvsubs-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
    .hvsubs-cue { gap: 8px; }
    .hvsubs-cue .ts { flex-basis: 48px; }
    .hvsubs-frame-back { padding: 0; }
    .hvsubs-frame-box { border-radius: 0; }
    .hvsubs-frame-close { top: 8px; right: 8px; }
}

/* Text-only subtitle cards: no poster available → compact tile. */
.hvsubs-poster--text {
    aspect-ratio: auto;
    height: 76px;
    background: linear-gradient(135deg, rgba(99, 102, 241, .28), rgba(15, 23, 42, .75));
}
.hvsubs-poster--text .hvsubs-initial {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, .7);
}
.hvsubs-poster--text .hvsubs-badge {
    bottom: 6px;
}

.hvsubs-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── collections ───────────────────────────────────────────────────────── */

.hvsubs-collections-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
}

.hvcol-card {
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .2));
    background: var(--theme-card, rgba(255, 255, 255, .04));
    cursor: pointer;
    transition: border-color .15s ease, transform .15s ease;
}

.hvcol-card:hover,
.hvcol-card:focus-visible {
    border-color: var(--theme-accent, #6366f1);
    transform: translateY(-2px);
    outline: none;
}

.hvcol-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hvcol-card-meta {
    font-size: 0.78rem;
    color: var(--theme-text2, #9ca3af);
}

.hvcol-card-date {
    margin-top: 4px;
    font-size: 0.7rem;
    color: var(--theme-text2, #9ca3af);
}

.hvcol-detail-head h3 {
    margin: 10px 0 4px;
    font-size: 1.15rem;
}

.hvcol-detail-meta {
    font-size: 0.8rem;
    color: var(--theme-text2, #9ca3af);
    margin-bottom: 10px;
}

.hvcol-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.hvcol-item {
    position: relative;
}

.hvcol-remove {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, .72);
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s ease;
}

.hvcol-item:hover .hvcol-remove {
    opacity: 1;
}

.hvsubs-modal-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.hvsubs-run-label {
    font-size: 0.75rem;
    color: var(--theme-text2, #9ca3af);
}

.hvcol-form,
.hvcol-picker {
    padding: 14px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

.hvcol-textarea {
    min-height: 70px;
    resize: vertical;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .3));
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.86rem;
}

.hvcol-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.84rem;
    color: var(--theme-text2, #9ca3af);
}

.hvcol-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.hvcol-picker-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .2));
    background: transparent;
    color: inherit;
    font-size: 0.86rem;
    cursor: pointer;
    text-align: left;
}

.hvcol-picker-row:hover {
    border-color: var(--theme-accent, #6366f1);
}

.hvcol-picker-count {
    font-size: 0.75rem;
    color: var(--theme-text2, #9ca3af);
}

.hvcol-picker-new {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.hvcol-picker-new .hvsubs-q {
    flex: 1;
}

/* ── My Day blocks ─────────────────────────────────────────────────────── */

.hvsubs-myday {
    margin: 0 0 18px;
    max-width: none;
}

.hvsubs-row {
    margin-bottom: 16px;
}

.hvsubs-row-head {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.hvsubs-hrow {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}

.hvsubs-hcard {
    flex: 0 0 210px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .22));
    background: var(--theme-card, rgba(255, 255, 255, .05));
    cursor: pointer;
    transition: border-color .15s ease;
}

.hvsubs-hcard:hover,
.hvsubs-hcard:focus-visible {
    border-color: var(--theme-accent, #6366f1);
    outline: none;
}

.hvsubs-hcard-title {
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hvsubs-hcard-meta {
    margin-top: 4px;
    font-size: 0.72rem;
    color: var(--theme-text2, #9ca3af);
}

.hvsubs-progress {
    height: 3px;
    margin-top: 8px;
    border-radius: 2px;
    background: rgba(148, 163, 184, .25);
    overflow: hidden;
}

.hvsubs-progress span {
    display: block;
    height: 100%;
    background: var(--theme-accent, #6366f1);
}

/* ── film club (subtitle-first blocks) ─────────────────────────────────── */

.hvsubs-filmclub {
    margin: 0 0 18px;
    max-width: none;
}

.hvfc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.hvfc-card {
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .22));
    background: var(--theme-card, rgba(255, 255, 255, .05));
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hvfc-kicker {
    font-size: 0.7rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--theme-text2, #9ca3af);
}

.hvfc-title {
    font-size: 1rem;
    font-weight: 700;
}

.hvfc-cues {
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--theme-text2, #9ca3af);
}

.hvfc-quote {
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.4;
    font-style: italic;
}

.hvfc-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hvfc-option {
    text-align: left;
    font-size: 0.82rem;
}

.hvfc-option:disabled {
    opacity: .55;
    cursor: default;
}

.hvfc-result {
    font-size: 0.85rem;
}

@media (max-width: 760px) {
    .hvfc-grid { grid-template-columns: 1fr; }
}

/* ── discussion ────────────────────────────────────────────────────────── */

.hvsubs-comments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.hvsubs-comment {
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(148, 163, 184, .09);
}

.hvsubs-comment.reply {
    margin-left: 18px;
    margin-top: 8px;
    background: rgba(148, 163, 184, .05);
}

.hvsubs-comment-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--theme-text2, #9ca3af);
}

.hvsubs-comment-head b {
    font-size: 0.8rem;
    color: var(--theme-text, #111);
}

.hvsubs-comment-text {
    margin-top: 4px;
    font-size: 0.86rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.hvsubs-comment-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hvsubs-comment-form textarea {
    min-height: 72px;
    max-height: 180px;
    resize: vertical;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .3));
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.86rem;
}

.hvsubs-comment-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* Full-text search snippet on subtitle cards */
.hvsubs-snippet {
    margin-top: 6px;
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--theme-text2, #9ca3af);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hvsubs-snippet mark {
    background: rgba(250, 204, 21, .5);
    color: inherit;
    border-radius: 3px;
    padding: 0 1px;
}

/* Reader language / export controls */
.hvsubs-lang {
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .3));
    background: var(--theme-card, rgba(255, 255, 255, .06));
    color: var(--theme-text, #111);
    font-size: 0.78rem;
}

.hvsubs-fs-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .3));
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.hvsubs-comment-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.hvsubs-comment-action {
    border: none;
    background: transparent;
    padding: 0;
    font-size: 0.72rem;
    color: var(--theme-text2, #9ca3af);
    cursor: pointer;
}

.hvsubs-comment-action.active {
    color: var(--theme-accent, #6366f1);
    font-weight: 700;
}

.hvcol-move {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 3px;
    opacity: 0;
    transition: opacity .15s ease;
}

.hvcol-item:hover .hvcol-move {
    opacity: 1;
}

.hvcol-move button {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: none;
    background: rgba(15, 23, 42, .72);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
}

/* ── Grouped series / talk-show cards ── */
.hvsubs-card--group .hvsubs-poster {
    position: relative;
}

.hvsubs-count {
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 2;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(15, 23, 42, .82);
    color: #e2e8f0;
    font-size: 0.7rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
}

.hvsubs-episodes {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 4px 2px 8px;
}

.hvsubs-episode {
    display: grid;
    grid-template-columns: 58px 1fr auto;
    gap: 10px;
    align-items: center;
    width: 100%;
    padding: 9px 12px;
    border-radius: 9px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .22));
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
    font: inherit;
}

.hvsubs-episode:hover {
    background: rgba(99, 102, 241, .12);
    border-color: var(--theme-accent, #6366f1);
}

.hvsubs-episode-num {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--theme-accent, #818cf8);
    white-space: nowrap;
}

.hvsubs-episode-title {
    font-size: 0.84rem;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.hvsubs-episode-meta {
    font-size: 0.72rem;
    color: var(--theme-text2, #94a3b8);
    white-space: nowrap;
}

.hvsubs-back-group {
    margin: 0 0 8px;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .3));
    background: transparent;
    color: var(--theme-text2, #cbd5e1);
    font-size: 0.78rem;
    cursor: pointer;
}

.hvsubs-back-group:hover {
    color: var(--theme-text, #fff);
    border-color: var(--theme-accent, #6366f1);
}

@media (max-width: 640px) {
    .hvsubs-episode {
        grid-template-columns: 48px 1fr;
    }
    .hvsubs-episode-meta {
        grid-column: 2;
        justify-self: start;
    }
}

/* ── subtitle-first film club layout ───────────────────────────────────── */
.fc-hero {
    min-height: 0;
    background:
        radial-gradient(900px 380px at 12% 0%, rgba(99, 102, 241, .22), transparent 62%),
        radial-gradient(720px 360px at 95% 10%, rgba(6, 182, 212, .16), transparent 60%),
        var(--theme-bg, #0f172a);
    border-bottom: 1px solid var(--theme-border, rgba(148, 163, 184, .18));
}

.fc-hero-inner {
    min-height: 0;
    padding: 18px clamp(18px, 4vw, 54px) 28px;
}

.fc-hero-main {
    display: grid;
    grid-template-columns: minmax(150px, 200px) minmax(0, 1fr);
    gap: clamp(16px, 3vw, 28px);
    align-items: start;
    margin-top: 14px;
}

.fc-hero-poster {
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 16px;
    overflow: hidden;
    background: var(--theme-bg2, #1e293b);
    box-shadow: 0 18px 50px rgba(2, 6, 23, .35);
}

.fc-hero-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.fc-hero-poster.fc-hero-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    background: linear-gradient(145deg, rgba(99, 102, 241, .35), rgba(15, 23, 42, .9));
}

.fc-hero-content {
    margin: 0;
    padding: 0;
    max-width: none;
}

.fc-hero-title {
    max-width: none;
    font-size: clamp(1.5rem, 3.2vw, 2.5rem);
    margin: 8px 0 10px;
}

.fc-hero-desc {
    max-width: 72ch;
}

.fc-hero-actions {
    margin-top: 14px;
}

.fc-hero .fc-watch-btn,
.fc-hero .fc-secondary-btn {
    white-space: normal;
    line-height: 1.2;
    text-align: center;
}

.hvsubs-filmclub {
    padding: 4px 2px 2px;
    margin-bottom: 16px;
}

.hvfc-grid {
    align-items: stretch;
}

.hvfc-card {
    min-width: 0;
}

@media (max-width: 760px) {
    .fc-hero-main {
        grid-template-columns: 112px minmax(0, 1fr);
        gap: 12px;
    }
    .fc-hero-title {
        font-size: 1.3rem;
    }
    .fc-hero-desc {
        -webkit-line-clamp: 3;
    }
    .fc-hero-inner {
        padding: 14px 16px 22px;
    }
}

/* Long labels inside modal actions must wrap instead of being clipped. */
.udm-btn {
    white-space: normal;
    text-align: center;
    max-width: 100%;
}

@media (max-width: 640px) {
    .udm-hero-actions .udm-btn.primary {
        max-width: 100%;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        line-height: 1.2;
    }
    #hvsubs-find-video {
        max-width: 100%;
        white-space: normal;
        line-height: 1.2;
    }
}

/* ── unify the legacy UDM modal with the subtitle modal ─────────────────── */
#udm-modal .modal-content {
    max-width: 920px;
    border-radius: 18px;
    background: var(--theme-bg, #0f172a);
}

#udm-modal .udm-hero {
    height: auto;
    min-height: 0;
    background:
        radial-gradient(700px 300px at 10% 0%, rgba(99, 102, 241, .22), transparent 62%),
        var(--theme-bg, #0f172a);
    border-bottom: 1px solid var(--theme-border, rgba(148, 163, 184, .2));
}

#udm-modal .udm-hero-bg,
#udm-modal .udm-hero-grad {
    display: none !important;
}

#udm-modal .udm-hero-content {
    position: static;
    padding: 18px 56px 12px 20px;
    align-items: flex-start;
    gap: 16px;
}

#udm-modal .udm-hero-title {
    color: var(--theme-text, #e5e7eb);
    text-shadow: none;
    font-size: clamp(1.15rem, 2.2vw, 1.45rem);
}

#udm-modal .udm-hero-meta {
    color: var(--theme-text2, #94a3b8);
    text-shadow: none;
}

#udm-modal .udm-close {
    background: rgba(15, 23, 42, .08);
    color: var(--theme-text, #e5e7eb);
}

#udm-modal .udm-body {
    padding: 16px 20px 22px;
}

body:not(.dark-theme) #udm-modal .udm-btn.ghost {
    background: rgba(15, 23, 42, .06);
    border-color: var(--theme-border, rgba(148, 163, 184, .3));
    color: var(--theme-text, #0f172a);
}

@media (max-width: 640px) {
    #udm-modal .udm-hero-content {
        padding: 14px 48px 10px 14px;
    }
    #udm-modal .udm-body {
        padding: 14px 14px 18px;
    }
}

/* Inline video player inside the unified subtitle modal */
.hvsubs-video-player {
    margin: 0 0 12px;
}

.hvsubs-video-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .25));
}

.hvsubs-video-frame iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.hvsubs-video-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    background: rgba(2, 6, 23, .72);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.hvsubs-video-close:hover {
    background: rgba(2, 6, 23, .9);
}

/* Rich modal headers: AI poster or theme gradient */
.hvsubs-modal-head--hero {
    position: relative;
    min-height: 190px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background-size: cover;
    background-position: center 28%;
    background-repeat: no-repeat;
    padding: 18px 56px 14px 20px;
}

.hvsubs-modal-head--hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(2, 6, 23, .08), rgba(2, 6, 23, .42) 45%, rgba(2, 6, 23, .82));
}

.hvsubs-modal-head--hero > * {
    position: relative;
    z-index: 1;
}

.hvsubs-modal-head--hero h3 {
    color: #fff;
    font-size: clamp(1.15rem, 2.4vw, 1.4rem);
    text-shadow: 0 2px 12px rgba(0, 0, 0, .65);
}

.hvsubs-modal-head--hero .hvsubs-modal-meta {
    color: rgba(255, 255, 255, .86);
    text-shadow: 0 1px 6px rgba(0, 0, 0, .6);
}

.hvsubs-modal-head--hero .hvsubs-btn {
    background: rgba(15, 23, 42, .58);
    border-color: rgba(255, 255, 255, .26);
    color: #fff;
}

.hvsubs-modal-head--themed {
    position: relative;
    min-height: 128px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background:
        radial-gradient(520px 200px at 8% 0%, color-mix(in srgb, var(--theme-accent, #6366f1) 34%, transparent), transparent 68%),
        radial-gradient(420px 180px at 100% 100%, color-mix(in srgb, var(--theme-accent, #06b6d4) 22%, transparent), transparent 70%),
        var(--theme-bg, #0f172a);
}

.hvcol-form-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 20px 16px;
    margin: 0 0 4px;
    background:
        radial-gradient(380px 170px at 0% 0%, color-mix(in srgb, var(--theme-accent, #6366f1) 32%, transparent), transparent 70%),
        radial-gradient(320px 160px at 100% 100%, color-mix(in srgb, var(--theme-accent, #06b6d4) 20%, transparent), transparent 72%);
    border-bottom: 1px solid var(--theme-border, rgba(148, 163, 184, .22));
}

.hvcol-form-hero-icon {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    font-size: 1.4rem;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .18);
}

.hvcol-form-hero h3 {
    margin: 0 0 3px;
    font-size: 1.05rem;
}

.hvcol-form-hero p {
    margin: 0;
    font-size: .76rem;
    color: var(--theme-text2, #94a3b8);
}

.hvcol-detail-head--hero {
    padding: 16px 18px;
    border-radius: 14px;
    background:
        radial-gradient(500px 180px at 0% 0%, color-mix(in srgb, var(--theme-accent, #6366f1) 24%, transparent), transparent 70%),
        var(--theme-card, rgba(255, 255, 255, .05));
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .22));
    margin-bottom: 14px;
}

@media (max-width: 640px) {
    .hvsubs-modal-head--hero {
        min-height: 150px;
        padding: 14px 48px 12px 14px;
    }
}


.hvcol-form > .hvsubs-q {
    flex: 0 0 auto;
    width: 100%;
    border-radius: 10px;
}

.hvsubs-modal {
    background:
        radial-gradient(680px 280px at 100% 0%, color-mix(in srgb, var(--theme-accent, #6366f1) 7%, transparent), transparent 66%),
        var(--theme-bg, #0f172a);
}

.hvsubs-cues {
    background: color-mix(in srgb, var(--theme-accent, #6366f1) 3%, transparent);
}

.hvsubs-modal-desc {
    margin: 8px 0 0;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--theme-text2, #94a3b8);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
    max-width: 74ch;
}

.hvsubs-modal-head--hero .hvsubs-modal-desc {
    color: rgba(255, 255, 255, .78);
    text-shadow: 0 1px 6px rgba(0, 0, 0, .55);
}

.hvsubs-modal-desc.open {
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
}

/* Own player inside the subtitle modal */
.hvsubs-own-player {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .25));
}

.hvsubs-own-player video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}

.hvsubs-video-cue {
    position: absolute;
    left: 7%;
    right: 7%;
    bottom: 62px;
    z-index: 2;
    text-align: center;
    font-weight: 700;
    line-height: 1.3;
    text-shadow: 0 2px 8px #000, 0 0 3px #000;
    pointer-events: none;
    white-space: pre-wrap;
}

.hvsubs-video-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 8px;
    background: rgba(2, 6, 23, .78);
    overflow-x: auto;
}

.hvsubs-video-controls button {
    flex: 0 0 auto;
    min-width: 34px;
    height: 30px;
    padding: 0 8px;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .08);
    color: #e2e8f0;
    font-size: 0.74rem;
    cursor: pointer;
}

.hvsubs-video-controls button:hover,
.hvsubs-video-controls button.active {
    border-color: var(--theme-accent, #6366f1);
    color: #fff;
}

.hvsubs-video-time {
    margin-left: auto;
    color: #cbd5e1;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.hvsubs-own-player:fullscreen,
.hvsubs-own-player:-webkit-full-screen {
    border-radius: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.hvsubs-own-player:fullscreen video,
.hvsubs-own-player:-webkit-full-screen video {
    flex: 1;
    aspect-ratio: auto;
    height: 100%;
    object-fit: contain;
}

.hvsubs-own-player iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    background: #000;
}

.hvsubs-own-player:fullscreen iframe,
.hvsubs-own-player:-webkit-full-screen iframe {
    flex: 1;
    aspect-ratio: auto;
    height: 100%;
}

.hvsubs-modal-hero-main {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    width: 100%;
    min-width: 0;
}

.hvsubs-modal-poster {
    width: 96px;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .18);
    box-shadow: 0 10px 28px rgba(0, 0, 0, .45);
    flex: 0 0 auto;
    background: #0f172a;
}

.hvsubs-modal-hero-copy {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

@media (max-width: 640px) {
    .hvsubs-modal-poster {
        width: 72px;
    }
    .hvsubs-modal-hero-main {
        gap: 10px;
        align-items: flex-start;
    }
}

/* ===== Player: stage, gestures, subtitle style panel ===== */
.hvsubs-video-stage {
    position: relative;
    width: 100%;
    background: #000;
    overflow: hidden;
}

.hvsubs-video-stage iframe,
.hvsubs-video-stage video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    background: #000;
}

.hvsubs-own-player iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    background: #000;
}

.hvsubs-video-cue {
    left: 50%;
    right: auto;
    bottom: 48px;
    transform: translateX(-50%);
    width: max-content;
    max-width: 86%;
    z-index: 4;
}

.hvsubs-tap-zone {
    position: absolute;
    top: 0;
    bottom: 34%;
    width: 17%;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.hvsubs-tap-zone--left { left: 0; }
.hvsubs-tap-zone--right { right: 0; }

.hvsubs-seek-hint {
    opacity: 0;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(2, 6, 23, .78);
    border: 1px solid rgba(255, 255, 255, .2);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    transition: opacity .15s ease;
    pointer-events: none;
}

.hvsubs-seek-hint.show { opacity: 1; }

.hvsubs-video-close,
.hvsubs-video-minimize {
    position: absolute;
    top: 8px;
    z-index: 6;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .22);
    background: rgba(2, 6, 23, .72);
    color: #fff;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.hvsubs-video-close { right: 8px; }
.hvsubs-video-minimize { right: 46px; }

.hvsubs-run-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 6;
    width: 34px;
    height: 54px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .2);
    background: rgba(2, 6, 23, .55);
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.hvsubs-run-arrow--prev { left: 8px; }
.hvsubs-run-arrow--next { right: 8px; }

.hvsubs-run-counter {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(2, 6, 23, .65);
    color: #e2e8f0;
    font-size: 0.7rem;
    font-variant-numeric: tabular-nums;
}

.hvsubs-video-minimize { display: none; }

@media (max-width: 900px) {
    .hvsubs-video-minimize { display: flex; }
    .hvsubs-run-arrow { display: none; }
}

.hvsubs-mini-bar {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 7px 8px 7px 12px;
    background: #0b1220;
    color: #e2e8f0;
}

.hvsubs-mini-title {
    flex: 1;
    min-width: 0;
    font-size: 0.76rem;
    font-weight: 600;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.hvsubs-mini-bar button {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .08);
    color: #e2e8f0;
    cursor: pointer;
}

/* ===== Subtitles style panel ===== */
.hvsubs-style-panel {
    border-top: 1px solid rgba(148, 163, 184, .2);
    background: rgba(2, 6, 23, .97);
    color: #cbd5e1;
    padding: 12px 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 46vh;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
}

.hvsubs-style-panel[hidden] { display: none; }

.hvsubs-style-head {
    font-size: 0.8rem;
    font-weight: 700;
    color: #f1f5f9;
}

.hvsubs-style-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
    width: 100%;
    min-width: 0;
}

.hvsubs-style-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.76rem;
    min-width: 0;
}

.hvsubs-style-row > span {
    min-width: 76px;
    color: #94a3b8;
}

.hvsubs-style-row input[type="range"] {
    flex: 1;
    min-width: 50px;
    accent-color: var(--theme-accent, #6366f1);
}

.hvsubs-style-row input[type="color"] {
    width: 34px;
    height: 26px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
}

.hvsubs-style-row select {
    flex: 1;
    min-width: 0;
    height: 28px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, .18);
    background: rgba(15, 23, 42, .9);
    color: #e2e8f0;
    font-size: 0.76rem;
    padding: 0 6px;
}

.hvsubs-style-row.hvsubs-style-check > span { min-width: auto; }
.hvsubs-style-row.hvsubs-style-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--theme-accent, #6366f1);
}

.hvsubs-style-preview {
    text-align: center;
    background: #0b1220;
    border: 1px solid rgba(148, 163, 184, .16);
    border-radius: 8px;
    padding: 14px 8px;
    overflow: hidden;
}

.hvsubs-style-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

@media (max-width: 640px) {
    .hvsubs-style-grid { grid-template-columns: 1fr; gap: 10px; }
    .hvsubs-style-row { flex-wrap: wrap; gap: 5px 8px; }
    .hvsubs-style-row > span { min-width: 100%; font-size: 0.72rem; }
    .hvsubs-style-row input[type="range"] { flex: 1 1 100%; }
    .hvsubs-style-row select { flex: 1 1 100%; }
    .hvsubs-style-row input[type="color"] { width: 44px; height: 30px; }
    .hvsubs-style-row.hvsubs-style-check { flex-wrap: nowrap; }
    .hvsubs-style-row.hvsubs-style-check > span { min-width: auto; }
}

/* ===== Collapsible source results ===== */
.hvsubs-sources-box {
    margin-top: 14px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .2));
    border-radius: 12px;
    background: var(--theme-card, rgba(255, 255, 255, .03));
    overflow: hidden;
}

.hvsubs-sources-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border: 0;
    background: transparent;
    color: #e2e8f0;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

.hvsubs-sources-caret {
    transition: transform .18s ease;
    color: #94a3b8;
}

.hvsubs-sources-box--collapsed .hvsubs-sources { display: none; }
.hvsubs-sources-box--collapsed .hvsubs-sources-caret { transform: rotate(-90deg); }

.hvsubs-sources-box .hvsubs-sources {
    margin-top: 0;
    padding: 0 12px 12px;
}

/* ===== Minimized player ===== */
#hvsubs-back.hvsubs-mini {
    background: transparent;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 14px;
    pointer-events: none;
}

#hvsubs-back.hvsubs-mini .hvsubs-modal {
    pointer-events: auto;
    width: min(360px, 92vw);
    max-width: min(360px, 92vw);
    height: auto;
    max-height: none;
    margin: 0;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .65);
}

#hvsubs-back.hvsubs-mini .hvsubs-modal-head,
#hvsubs-back.hvsubs-mini .hvsubs-tabs,
#hvsubs-back.hvsubs-mini .hvsubs-back-group,
#hvsubs-back.hvsubs-mini .hvsubs-modal-close,
#hvsubs-back.hvsubs-mini .hvsubs-pane[data-pane="text"],
#hvsubs-back.hvsubs-mini .hvsubs-pane[data-pane="discussion"],
#hvsubs-back.hvsubs-mini .hvsubs-sources-box,
#hvsubs-back.hvsubs-mini #hvsubs-find-hint,
#hvsubs-back.hvsubs-mini #hvsubs-find-video,
#hvsubs-back.hvsubs-mini .hvsubs-style-panel,
#hvsubs-back.hvsubs-mini .hvsubs-video-controls,
#hvsubs-back.hvsubs-mini .hvsubs-run-arrow,
#hvsubs-back.hvsubs-mini .hvsubs-run-counter,
#hvsubs-back.hvsubs-mini .hvsubs-video-close,
#hvsubs-back.hvsubs-mini .hvsubs-video-minimize {
    display: none !important;
}

#hvsubs-back.hvsubs-mini .hvsubs-panes {
    display: block;
    overflow: visible;
}

#hvsubs-back.hvsubs-mini .hvsubs-pane[data-pane="video"] {
    display: block !important;
}

#hvsubs-back.hvsubs-mini .hvsubs-video-wrap {
    padding: 0;
    overflow: visible;
}

#hvsubs-back.hvsubs-mini .hvsubs-mini-bar { display: flex; }
#hvsubs-back.hvsubs-mini .hvsubs-video-cue { bottom: 14px; font-size: 14px !important; }

.hvsubs-own-player:fullscreen .hvsubs-video-stage,
.hvsubs-own-player:-webkit-full-screen .hvsubs-video-stage {
    flex: 1;
    min-height: 0;
}

.hvsubs-own-player:fullscreen .hvsubs-video-stage iframe,
.hvsubs-own-player:-webkit-full-screen .hvsubs-video-stage iframe,
.hvsubs-own-player:fullscreen .hvsubs-video-stage video,
.hvsubs-own-player:-webkit-full-screen .hvsubs-video-stage video {
    height: 100%;
    aspect-ratio: auto;
}

/* Compact action row in the modal header */
.hvsubs-modal-actions--compact {
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
    margin-top: 10px;
    padding-bottom: 2px;
    overflow: visible;
    align-items: center;
}

.hvsubs-modal-actions--compact .hvsubs-btn {
    flex: 0 1 auto;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 9px;
    font-size: 0.77rem;
    border-radius: 9px;
    white-space: nowrap;
    line-height: 1.2;
}

.hvsubs-modal-actions--compact .hvsubs-btn .hv-icon {
    flex: 0 0 auto;
}

.hvsubs-modal-actions--compact .hvsubs-btn.active {
    border-color: var(--theme-accent, #6366f1);
    color: #fff;
    background: color-mix(in srgb, var(--theme-accent, #6366f1) 30%, transparent);
}

.hvsubs-btn-count {
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    font-size: 0.66rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hvsubs-btn-count[hidden] { display: none; }

.hvsubs-modal-actions--compact .hvsubs-run-next {
    padding: 6px 11px;
    font-size: 0.77rem;
    border-radius: 9px;
}

@media (max-width: 980px) {
    .hvsubs-modal-actions--compact { gap: 4px; }
    .hvsubs-modal-actions--compact .hvsubs-btn { padding: 6px 8px; }
    .hvsubs-modal-actions--compact .hvsubs-btn .hv-icon { width: 16px; height: 16px; }
    .hvsubs-modal-actions--compact .hvsubs-btn-label { display: none; }
    .hvsubs-modal-actions--compact .hvsubs-run-label { display: none; }
    .hvsubs-modal-actions--compact .hvsubs-run-next-label { display: none; }
}
@media (max-width: 640px) {
    .hvsubs-modal-actions--compact {
        gap: 3px;
        margin-top: 8px;
    }
    .hvsubs-modal-actions--compact .hvsubs-btn {
        padding: 6px 5px;
    }
    .hvsubs-modal-actions--compact .hvsubs-btn .hv-icon { width: 15px; height: 15px; }
}

/* Auto-hiding player controls (modal and fullscreen) */
.hvsubs-own-player .hvsubs-video-controls,
.hvsubs-own-player .hvsubs-video-close,
.hvsubs-own-player .hvsubs-video-minimize,
.hvsubs-own-player .hvsubs-run-arrow,
.hvsubs-own-player .hvsubs-run-counter {
    transition: opacity .24s ease, visibility .24s ease;
}

.hvsubs-own-player.hvsubs-controls-hidden .hvsubs-video-controls,
.hvsubs-own-player.hvsubs-controls-hidden .hvsubs-video-close,
.hvsubs-own-player.hvsubs-controls-hidden .hvsubs-video-minimize,
.hvsubs-own-player.hvsubs-controls-hidden .hvsubs-run-arrow,
.hvsubs-own-player.hvsubs-controls-hidden .hvsubs-run-counter {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* First tap/click while controls are hidden reveals them, then the catcher
   disappears so the next tap reaches the RuTube iframe or HLS video. */
.hvsubs-controls-catcher {
    position: absolute;
    inset: 0;
    z-index: 9;
    display: none;
    cursor: pointer;
}

.hvsubs-own-player.hvsubs-controls-hidden .hvsubs-controls-catcher {
    display: block;
}

#hvsubs-back.hvsubs-mini .hvsubs-controls-catcher {
    display: none !important;
}

/* Episode navigation buttons in the player control bar */
.hvsubs-video-controls .hvsubs-run-btn {
    padding: 0 10px;
    font-weight: 600;
    border-color: color-mix(in srgb, var(--theme-accent, #6366f1) 55%, transparent);
    background: color-mix(in srgb, var(--theme-accent, #6366f1) 18%, transparent);
}

.hvsubs-video-controls .hvsubs-run-btn:hover {
    background: color-mix(in srgb, var(--theme-accent, #6366f1) 30%, transparent);
}

/* The modal is a sheet: a downward drag at the top closes/minimizes it and
   must not trigger browser pull-to-refresh. */
#hvsubs-back,
.hvsubs-modal,
.hvsubs-cues,
.hvsubs-video-wrap {
    overscroll-behavior: contain;
    overscroll-behavior-y: contain;
}

/* Desktop: the video pane must fit inside the modal without scrolling. */
@media (min-width: 769px) {
    .hvsubs-modal {
        max-height: min(92vh, 1000px);
    }

    .hvsubs-modal.hvsubs-playing .hvsubs-pane[data-pane="video"] #hvsubs-find-hint,
    .hvsubs-modal.hvsubs-playing .hvsubs-pane[data-pane="video"] #hvsubs-find-video {
        display: none;
    }

    .hvsubs-modal.hvsubs-playing .hvsubs-video-wrap {
        display: flex;
        flex-direction: column;
        padding-top: 12px;
    }

    .hvsubs-modal.hvsubs-playing .hvsubs-video-player {
        flex: 0 0 auto;
        margin-bottom: 8px;
    }

    /* Reserve room for the header, tabs, controls and the collapsed sources
       bar; the 16:9 player scales down to the remaining height. */
    .hvsubs-modal.hvsubs-playing .hvsubs-video-player .hvsubs-own-player {
        width: min(100%, calc((92vh - 400px) * 16 / 9));
        max-width: 100%;
        margin: 0 auto;
    }

    .hvsubs-modal.hvsubs-playing .hvsubs-sources-box {
        margin-top: 6px;
    }
}

/* iPhone / WebViews without Element.requestFullscreen: fixed pseudo-fullscreen
   that keeps our subtitle overlay and player controls. */
body.hvsubs-pseudo-fs {
    overflow: hidden;
}

.hvsubs-own-player.hvsubs-pseudo-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 100300;
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    background: #000;
}

.hvsubs-own-player.hvsubs-pseudo-fullscreen .hvsubs-video-stage {
    flex: 1;
    min-height: 0;
}

.hvsubs-own-player.hvsubs-pseudo-fullscreen .hvsubs-video-stage iframe,
.hvsubs-own-player.hvsubs-pseudo-fullscreen .hvsubs-video-stage video {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    object-fit: contain;
}

.hvsubs-own-player.hvsubs-pseudo-fullscreen .hvsubs-video-controls {
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
}

@media (orientation: portrait) {
    .hvsubs-own-player.hvsubs-pseudo-fullscreen::after {
        content: 'Поверните телефон — так видео шире';
        position: absolute;
        top: calc(10px + env(safe-area-inset-top, 0px));
        left: 50%;
        transform: translateX(-50%);
        z-index: 20;
        padding: 6px 12px;
        border-radius: 999px;
        background: rgba(2, 6, 23, .78);
        border: 1px solid rgba(255, 255, 255, .18);
        color: #e2e8f0;
        font-size: 0.72rem;
        white-space: nowrap;
        pointer-events: none;
        animation: hvsubs-fs-hint 4.5s ease forwards;
    }
}

@keyframes hvsubs-fs-hint {
    0%, 70% { opacity: 1; }
    100% { opacity: 0; }
}

/* Mini player: keep the app usable behind it (no dim/blur). */
#hvsubs-back.hvsubs-mini {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#hvsubs-back.hvsubs-mini .hvsubs-mini-bar {
    touch-action: none;
    cursor: grab;
}

#hvsubs-back.hvsubs-mini .hvsubs-mini-bar:active {
    cursor: grabbing;
}

/* Compact mini mode for reading/messaging while the video keeps playing. */
#hvsubs-back.hvsubs-mini.hvsubs-mini-compact .hvsubs-modal {
    width: min(220px, 64vw);
    max-width: min(220px, 64vw);
}

#hvsubs-back.hvsubs-mini.hvsubs-mini-compact .hvsubs-mini-title {
    font-size: 0.68rem;
}

#hvsubs-back.hvsubs-mini.hvsubs-mini-compact .hvsubs-video-cue {
    bottom: 8px;
    font-size: 12px !important;
}

/* Playlist, video and watch-party dialogs must sit above the mini player. */
#series-playlist-modal,
#playlist-detail-modal,
#watch-party-modal,
#udm-modal,
#exp-modal {
    z-index: 100200;
}

/* "Choose another video" preview while the mini player keeps running. */
.hvsubs-preview-back {
    position: fixed;
    inset: 0;
    z-index: 100210;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(2, 6, 23, .72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.hvsubs-preview-back .hvsubs-modal {
    width: min(560px, 100%);
    max-height: min(88vh, 860px);
}

.hvsubs-preview-body {
    padding: 12px 20px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hvsubs-preview-hint {
    padding: 9px 11px;
    border-radius: 9px;
    border: 1px solid rgba(34, 211, 238, .28);
    background: rgba(34, 211, 238, .08);
    color: #a5f3fc;
    font-size: 0.78rem;
    line-height: 1.45;
}

.hvsubs-preview-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 45vh;
    overflow-y: auto;
}

.hvsubs-preview-list .hvsubs-source {
    margin: 0;
}

#series-playlist-modal .modal-content,
#spm-episodes,
#playlist-detail-modal .modal-content {
    overscroll-behavior: contain;
    overscroll-behavior-y: contain;
}

/* Unified file modal: dark header even without a poster, light reader body. */
#hvfile-back .hvsubs-modal-head--themed {
    background:
        radial-gradient(700px 300px at 10% 0%, rgba(99, 102, 241, .22), transparent 62%),
        radial-gradient(420px 220px at 100% 100%, rgba(6, 182, 212, .16), transparent 70%),
        #0f172a;
    color: #fff;
}
#hvfile-back .hvsubs-modal-head--themed h3,
#hvfile-back .hvsubs-modal-head--themed .hvsubs-modal-meta { color: #fff; }
#hvfile-back .hvsubs-modal-head--themed .hvsubs-modal-meta { color: rgba(255,255,255,.82); }
#hvfile-back .hvsubs-modal-head--themed .hvsubs-btn {
    background: rgba(15, 23, 42, .58);
    border-color: rgba(255, 255, 255, .22);
    color: #fff;
}
#hvfile-back .hvfile-comments {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 52vh;
    overflow-y: auto;
    margin-bottom: 12px;
}
#hvfile-back .hvfile-comment {
    padding: 10px 12px;
    border: 1px solid var(--theme-border, #e5e7eb);
    border-radius: 10px;
    background: var(--theme-card, #fff);
    color: var(--theme-text, #111827);
}
#hvfile-back .hvfile-comment-head { display: flex; justify-content: space-between; gap: 8px; font-size: .78rem; }
#hvfile-back .hvfile-comment-head span { color: var(--theme-text2, #6b7280); }
#hvfile-back .hvfile-comment-text { font-size: .86rem; margin-top: 5px; white-space: pre-wrap; }
#hvfile-back .hvfile-comment-meta { font-size: .7rem; color: var(--theme-text2, #6b7280); margin-top: 4px; }
#hvfile-back .hvfile-comment-form { display: flex; gap: 8px; align-items: flex-end; }
#hvfile-back .hvfile-comment-form textarea {
    flex: 1;
    min-height: 44px;
    max-height: 100px;
    padding: 8px 10px;
    border-radius: 9px;
    border: 1px solid var(--theme-border, #d1d5db);
    background: var(--theme-input-bg, #fff);
    color: var(--theme-text, #111827);
    resize: vertical;
    font: inherit;
    font-size: .86rem;
}
#hvfile-gen-card {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    text-align: center;
}

/* File modal: compact icon tiles with captions, meta editing and player tools. */
#hvfile-back .hvsubs-modal-actions--compact { flex-wrap: wrap; gap: 3px; }
#hvfile-back .hvfile-action {
    position: relative;
    width: 38px;
    min-width: 38px;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 2px;
    padding: 6px 2px 4px;
}
#hvfile-back .hvfile-action .hv-icon { width: 16px; height: 16px; }
#hvfile-back .hvfile-action-label {
    display: block;
    font-size: .48rem;
    line-height: 1.05;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 36px;
}
#hvfile-back .hvfile-action .hvsubs-btn-count {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 14px;
    height: 14px;
    font-size: .55rem;
}
@media (max-width: 360px) {
    #hvfile-back .hvfile-action { width: 29px; min-width: 29px; padding: 5px 1px 3px; }
    #hvfile-back .hvfile-action .hv-icon { width: 14px; height: 14px; }
    #hvfile-back .hvfile-action-label { font-size: .42rem; max-width: 27px; }
}
@media (min-width: 980px) {
    #hvfile-back .hvfile-action { width: 50px; min-width: 50px; padding: 7px 3px 5px; }
    #hvfile-back .hvfile-action .hv-icon { width: 18px; height: 18px; }
    #hvfile-back .hvfile-action-label { font-size: .56rem; max-width: 48px; }
}
#hvfile-back .hvfile-title-edit {
    background: transparent;
    border: none;
    color: #7dd3fc;
    cursor: pointer;
    font-size: .8rem;
    padding: 0 2px;
    vertical-align: middle;
}
#hvfile-back .hvfile-meta-edit {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.2);
    color: #fff;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: .66rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
}
#hvfile-back .hvfile-meta-form {
    display: none;
    gap: 6px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-top: 8px;
    width: 100%;
    max-width: 520px;
}
#hvfile-back .hvfile-meta-form input,
#hvfile-back .hvfile-meta-form textarea {
    flex: 1 1 100%;
    padding: 7px 9px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.2);
    background: rgba(2,6,23,.6);
    color: #fff;
    font: inherit;
    font-size: .82rem;
    box-sizing: border-box;
}
#hvfile-back .hvfile-meta-form textarea { min-height: 60px; resize: vertical; }
#hvfile-back .hvfile-meta-form button {
    padding: 5px 10px;
    border-radius: 8px;
    border: none;
    background: var(--theme-accent, #06b6d4);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    cursor: pointer;
}
#hvfile-back .hvfile-meta-form button.secondary {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.2);
}
#hvfile-back .hvfile-video-wrap { position: relative; }
#hvfile-back .hvfile-player-btn {
    position: absolute;
    top: 8px;
    z-index: 5;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,.22);
    background: rgba(2,6,23,.66);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
#hvfile-back .hvfile-player-btn.left { left: 8px; }
#hvfile-back .hvfile-player-btn.right { right: 8px; }
#hvfile-back .hvfile-subtitle-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 18%;
    text-align: center;
    pointer-events: none;
    z-index: 4;
}
#hvfile-back .hvfile-subtitle-text {
    display: none;
    background: rgba(0,0,0,.75);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: clamp(14px, 2vw, 24px);
    max-width: 80%;
    margin: 0 auto;
    line-height: 1.3;
}

/* Never let the cookie banner swallow clicks on cards underneath it. */
#cookie-banner { pointer-events: none !important; }
#cookie-banner button,
#cookie-banner a,
#cookie-banner input,
#cookie-banner [role="button"] { pointer-events: auto !important; }

/* TV action: green indicator when a TV is already paired. */
.hvsubs-btn--action { position: relative; }
.hvsubs-btn--action.tv-connected,
.hvfile-action.tv-connected {
    color: #22c55e !important;
    border-color: rgba(34, 197, 94, .55) !important;
    background: rgba(34, 197, 94, .14) !important;
}
.hvsubs-btn--action.tv-connected .hvsubs-btn-label,
.hvfile-action.tv-connected .hvfile-action-label { color: #22c55e !important; }
.hvsubs-btn--action.tv-connected::after,
.hvfile-action.tv-connected::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 2px #0f172a;
    pointer-events: none;
}

/* Compact floating state for the unified file modal. */
#hvfile-back .hvfile-minimize { right: 52px; }
#hvfile-back .hvfile-mini-bar { display: none; }
#hvfile-back .hvfile-mini-bar button {
    background: transparent;
    border: 1px solid rgba(255,255,255,.2);
    color: #fff;
    border-radius: 7px;
    width: 24px;
    height: 24px;
    padding: 0;
    cursor: pointer;
    line-height: 1;
}
#hvfile-back .hvfile-mini-bar span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#hvfile-back.hvfile-mini {
    align-items: flex-end;
    justify-content: flex-end;
    padding: 12px;
    background: transparent;
    pointer-events: none;
}
#hvfile-back.hvfile-mini .hvsubs-modal {
    width: min(320px, 86vw);
    height: auto !important;
    max-height: calc(100vh - 24px) !important;
    pointer-events: auto;
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(0,0,0,.6);
}
#hvfile-back.hvfile-mini .hvsubs-modal > * { display: none !important; }
#hvfile-back.hvfile-mini .hvsubs-modal > .hvfile-mini-bar {
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    background: rgba(2,6,23,.94);
    color: #fff;
    font-size: .78rem;
}
#hvfile-back.hvfile-mini .hvsubs-modal > .hvsubs-panes { display: block !important; }
#hvfile-back.hvfile-mini .hvsubs-panes > .hvsubs-pane { display: none !important; }
#hvfile-back.hvfile-mini .hvsubs-panes > .hvsubs-pane[data-pane="video"] { display: block !important; flex: 0 0 auto !important; }
#hvfile-back.hvfile-mini .hvsubs-modal > .hvsubs-panes { flex: 0 0 auto !important; }
#hvfile-back.hvfile-mini .hvsubs-pane[data-pane="video"] .hvsubs-video-wrap { padding: 0; flex: 0 0 auto !important; }
#hvfile-back.hvfile-mini #hvfile-video { max-height: 180px; border-radius: 0 0 14px 14px; }
#hvfile-back.hvfile-mini .hvfile-player-btn { display: none; }


/* Inline subtitle-style editor shown under the video in player modals. */
.sub-style-inline {
    display: none;
    background: var(--theme-card, #0f172a);
    color: var(--theme-text, #e5e7eb);
    border-top: 1px solid var(--theme-border, rgba(148, 163, 184, .22));
}
.sub-style-inline.open { display: block; }
.sub-style-inline-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: .9rem;
    font-weight: 700;
    border-bottom: 1px solid var(--theme-border, rgba(148, 163, 184, .18));
}
.sub-style-inline-close {
    margin-left: auto;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--theme-border, rgba(148, 163, 184, .3));
    background: transparent;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.sub-style-inline-body { padding: 0; }
.sub-style-inline .sse-root { padding: 12px !important; }
/* Keep the picture (and the live subtitle preview) visible while the editor
   is open below it. */
body.hv-inline-style-open #exp-modal-video,
body.hv-inline-style-open #hvfile-video,
body.hv-inline-style-open #url-player,
body.hv-inline-style-open #v2-public-video {
    max-height: 38vh !important;
}
.sub-style-inline .sse-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
}
@media (max-width: 360px) {
    .sub-style-inline .sse-grid { grid-template-columns: 1fr !important; }
}
