*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}
*::selection,
*::-moz-selection {
    background: transparent;
    color: inherit;
}
*:focus {
    outline: none;
}
input, textarea {
    -webkit-user-select: text;
    user-select: text;
}

/* display:flex/grid on components overrides the bare [hidden] attribute without this */
[hidden] {
    display: none !important;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    max-height: 100%;
    width: 100%;
    overflow: hidden;
    background: #0b0d12;
    color: #f3f4f6;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.45;
    -webkit-tap-highlight-color: transparent;
}

@supports (height: 100svh) {
    html,
    body {
        height: 100svh;
        max-height: 100svh;
    }
}

html[dir="rtl"] {
    direction: rtl;
}

button,
input {
    font: inherit;
}

.video-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    background: #0b0d12;
    color: #f3f4f6;
}

@supports (height: 100svh) {
    .video-page {
        height: 100svh;
        max-height: 100svh;
    }
}

.video-page-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    padding-top: max(10px, env(safe-area-inset-top, 0px));
    background: #12151c;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    z-index: 8;
}

.video-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: #f8fafc;
    font-size: 1.2rem;
    cursor: pointer;
    flex-shrink: 0;
    text-decoration: none;
}

.video-header-center {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.video-header-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.video-header-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex-shrink: 0;
    background: transparent;
}

.video-header-site {
    font-weight: 700;
    font-size: 1.05rem;
    color: #f8fafc;
    line-height: 1.1;
    white-space: nowrap;
}

.video-header-site-accent {
    color: #54a0ff;
}

.video-page-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
    color: #f8fafc;
    line-height: 1.2;
}

.video-page-title[hidden] {
    display: none !important;
}

.video-draft-bar {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 0;
    width: 100%;
    text-align: center;
}

.video-draft-bar[hidden] {
    display: none !important;
}

.video-draft-bar-text {
    font-size: 0.86rem;
    font-weight: 600;
    color: #e8f1ff;
    text-align: center;
}

.video-draft-bar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-left: 0;
}

.video-wizard-footer-nav {
    flex: 1 1 auto;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
    min-width: 0;
    width: 100%;
}

.video-wizard-footer-nav #video-step-prev,
.video-wizard-footer-nav #video-step-next {
    flex: 1 1 0;
}

.video-wizard-footer-nav[hidden] {
    display: none !important;
}

.video-wizard-footer.is-draft .video-wizard-footer-nav {
    display: none !important;
}

.video-step-dots {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.video-step-dots::-webkit-scrollbar {
    display: none;
}

.video-step-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.45);
    border-radius: 999px;
    padding: 4px 8px 4px 4px;
    font-size: 0.68rem;
    font-weight: 700;
    cursor: default;
    flex-shrink: 0;
}

.video-step-pill span {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.65rem;
}

.video-step-pill em {
    font-style: normal;
    display: none;
}

.video-step-pill.is-active {
    color: #fff;
    border-color: rgba(84, 160, 255, 0.5);
    background: rgba(84, 160, 255, 0.16);
}

.video-step-pill.is-active span,
.video-step-pill.is-done span {
    background: #54a0ff;
    color: #fff;
}

.video-step-pill.is-done {
    color: rgba(255, 255, 255, 0.7);
}

@media (min-width: 420px) {
    .video-step-pill em {
        display: inline;
    }
}

.video-header-actions {
    margin-left: auto;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.video-header-actions[hidden] {
    display: none !important;
}

.video-undo-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.video-undo-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.video-download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 999px;
    padding: 8px 12px;
    background: linear-gradient(145deg, #2e86de, #54a0ff);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

@media (max-width: 640px) {
    .video-download-btn span,
    .video-play-btn--header span {
        display: none;
    }
    .video-download-btn,
    .video-play-btn--header {
        width: 40px;
        height: 40px;
        padding: 0;
        min-width: 40px;
    }
}

.video-page-body {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #0b0d12;
}

.video-wizard {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.video-page--studio .video-wizard {
    display: none !important;
}

.video-wizard-slides {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    width: 100%;
    position: relative;
}

.video-wizard-track {
    display: flex;
    height: 100%;
    width: 500%;
    transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
}

html[dir="rtl"] .video-wizard-track {
    direction: ltr;
}

html[dir="rtl"] .video-step {
    direction: rtl;
}

.video-step {
    flex: 0 0 20%;
    width: 20%;
    max-width: 20%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 16px 16px 0;
    overflow: hidden;
    pointer-events: none;
}

.video-step.is-active {
    pointer-events: auto;
}

.video-welcome {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 16px;
    padding: 8px 0 20px;
    overflow: auto;
}

.video-welcome-hero {
    position: relative;
    overflow: hidden;
    text-align: center;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: #141821;
    padding: 28px 20px 22px;
}

.video-welcome-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='%2354a0ff' fill-opacity='0.35'%3E%3Ccircle cx='12' cy='8' r='1'/%3E%3Ccircle cx='45' cy='23' r='0.6'/%3E%3Ccircle cx='78' cy='5' r='1.2'/%3E%3Ccircle cx='95' cy='40' r='0.7'/%3E%3Ccircle cx='5' cy='55' r='0.6'/%3E%3Ccircle cx='33' cy='72' r='1'/%3E%3Ccircle cx='62' cy='88' r='0.6'/%3E%3Ccircle cx='88' cy='65' r='0.7'/%3E%3Ccircle cx='18' cy='95' r='0.6'/%3E%3Ccircle cx='125' cy='18' r='0.6'/%3E%3Ccircle cx='52' cy='42' r='0.5'/%3E%3Ccircle cx='72' cy='58' r='0.8'/%3E%3Ccircle cx='112' cy='82' r='0.6'/%3E%3Ccircle cx='138' cy='45' r='0.5'/%3E%3Ccircle cx='28' cy='128' r='0.7'/%3E%3Ccircle cx='145' cy='115' r='0.5'/%3E%3C/g%3E%3C/svg%3E");
    background-size: 160px 160px;
    opacity: 0.9;
    pointer-events: none;
}

.video-welcome-logo,
.video-welcome-site {
    position: relative;
    z-index: 1;
}

.video-welcome-logo {
    display: block;
    width: 96px;
    max-width: 28%;
    height: auto;
    margin: 0 auto 10px;
    background: transparent;
}

.video-welcome-site {
    display: block;
    font-weight: 700;
    font-size: 1.7rem;
    color: #fff;
}

.video-welcome-site-accent {
    color: #54a0ff;
}

.video-welcome-lead {
    margin: 0;
    text-align: center;
    font-size: 0.95rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.72);
    padding: 0 8px;
}

.video-welcome-hints {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.video-welcome-hints li {
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: #141821;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.88);
}

@media (prefers-reduced-motion: reduce) {
    .video-wizard-track {
        transition: none;
    }
}

.video-step-head {
    margin-bottom: 14px;
    flex-shrink: 0;
}

.video-step-kicker {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #54a0ff;
    margin-bottom: 6px;
}

.video-step-head h2 {
    margin: 0 0 4px;
    font-size: 1.35rem;
    color: #fff;
}

.video-step-head p {
    margin: 0;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.9rem;
}

.video-search-wrap {
    position: relative;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.video-search-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.35);
    pointer-events: none;
}

html[dir="rtl"] .video-search-wrap i {
    left: auto;
    right: 12px;
}

.video-search {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #171a22;
    color: #fff;
    border-radius: 12px;
    padding: 12px 12px 12px 38px;
    font-size: 0.95rem;
}

html[dir="rtl"] .video-search {
    padding: 12px 38px 12px 12px;
}

.video-option-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
}

.video-option-group {
    padding: 10px 4px 4px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    gap: 6px;
}

.video-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: #141821;
    color: #fff;
    border-radius: 14px;
    padding: 12px 14px;
    cursor: pointer;
}

html[dir="rtl"] .video-option {
    text-align: right;
}

.video-option.is-selected {
    border-color: rgba(84, 160, 255, 0.55);
    background: linear-gradient(145deg, rgba(84, 160, 255, 0.16), rgba(46, 134, 222, 0.1));
}

.video-option-num {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    font-weight: 800;
    flex-shrink: 0;
}

.video-option-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.08);
}

.video-option-avatar--init {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
    color: #fff;
    background: #2563eb;
}

.video-option-flag {
    font-size: 1.15rem;
    line-height: 1;
    flex-shrink: 0;
}

.video-option-group .video-option-flag {
    font-size: 0.95rem;
    margin-right: 6px;
}

.video-option-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.video-subtabs {
    display: grid;
    gap: 0;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    overflow: hidden;
}

.video-subtabs--3 {
    grid-template-columns: repeat(3, 1fr);
}

.video-subtabs--4 {
    grid-template-columns: repeat(4, 1fr);
}

.video-subtab {
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.14);
    background: #141821;
    color: rgba(255, 255, 255, 0.55);
    border-radius: 0;
    padding: 10px 8px;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
}

.video-subtab:last-child {
    border-right: none;
}

.video-subtab.is-active {
    background: rgba(84, 160, 255, 0.16);
    color: #54a0ff;
    box-shadow: inset 0 0 0 1px #54a0ff;
}

.video-base-panel[hidden] {
    display: none !important;
}

.video-option-list--compact {
    max-height: min(42vh, 280px);
    flex: 0 0 auto;
    padding-bottom: 4px;
    margin-top: 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.video-option-list--compact::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.video-base-panel {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.video-base-panel::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

#video-editor-reciter-list,
#video-editor-translation-list {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#video-editor-reciter-list::-webkit-scrollbar,
#video-editor-translation-list::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.video-option-main strong {
    font-size: 0.95rem;
}

.video-option-main small {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.78rem;
}

.video-ayah-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
    flex-shrink: 0;
}

.video-chip-btn {
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-radius: 999px;
    padding: 7px 11px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.video-range-mini {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.5);
}

.video-num-input {
    width: 58px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #171a22;
    color: #fff;
    border-radius: 8px;
    padding: 6px 8px;
}

.video-ayah-grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
    gap: 8px;
    padding-bottom: 8px;
}

.video-ayah-pick {
    height: 42px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #141821;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.video-ayah-pick.is-selected {
    background: linear-gradient(145deg, #2e86de, #54a0ff);
    border-color: transparent;
}

.video-ayah-hint {
    margin: 8px 0 0;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.8rem;
    flex-shrink: 0;
    padding-bottom: 8px;
}

.video-ayah-pick.is-disabled {
    opacity: 0.28;
    pointer-events: none;
    cursor: not-allowed;
    filter: grayscale(0.4);
    pointer-events: none;
    cursor: not-allowed;
}

.video-wizard-footer {
    flex: 0 0 auto;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 16px max(12px, env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: #12151c;
    z-index: 20;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.28);
    position: relative;
    bottom: auto;
    min-height: 64px;
}

.video-btn {
    flex: 0 1 auto;
    min-width: 110px;
    border: none;
    border-radius: 14px;
    padding: 13px 14px;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
}

.video-btn-primary {
    background: linear-gradient(145deg, #2e86de, #54a0ff);
    color: #fff;
}

.video-wizard-footer-nav .video-btn-primary {
    margin-left: 0;
    margin-right: 0;
}

.video-draft-bar-actions .video-btn-primary,
.video-wizard-footer.is-draft .video-btn-primary {
    margin-left: 0;
}

html[dir="rtl"] .video-wizard-footer-nav .video-btn-primary {
    margin-left: 0;
    margin-right: 0;
}

.video-btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.video-btn-ghost {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    flex: 0 0 auto;
    min-width: 96px;
}

.video-studio {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.video-workspace {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    overflow: hidden;
    background: radial-gradient(600px 240px at 50% 0%, rgba(84, 160, 255, 0.12), transparent 60%), #0b0d12;
    position: relative;
}

.video-undo-btn--stage {
    position: absolute;
    left: 10px;
    bottom: 10px;
    z-index: 4;
}

.video-stage {
    position: relative;
    background: #000;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    max-width: 100%;
    max-height: 100%;
}

.video-stage[data-format="vertical"],
.video-stage[data-format="9:16"],
.video-stage[data-format="4:5"],
.video-stage[data-format="3:4"],
.video-stage[data-format="2:3"] {
    aspect-ratio: 9 / 16;
    height: 100%;
    width: auto;
    max-height: 100%;
    max-width: min(260px, 100%);
}

.video-stage[data-format="4:5"] { aspect-ratio: 4 / 5; }
.video-stage[data-format="3:4"] { aspect-ratio: 3 / 4; }
.video-stage[data-format="2:3"] { aspect-ratio: 2 / 3; }

.video-stage[data-format="1:1"] {
    aspect-ratio: 1 / 1;
    width: auto;
    height: auto;
    max-width: min(360px, 100%);
    max-height: 100%;
}

.video-stage[data-format="horizontal"],
.video-stage[data-format="16:9"],
.video-stage[data-format="4:3"],
.video-stage[data-format="3:2"],
.video-stage[data-format="21:9"],
.video-stage.is-landscape {
    aspect-ratio: 16 / 9;
    width: min(100%, 560px);
    height: auto;
    max-height: 100%;
}

.video-stage[data-format="4:3"] { aspect-ratio: 4 / 3; }
.video-stage[data-format="3:2"] { aspect-ratio: 3 / 2; }
.video-stage[data-format="21:9"] { aspect-ratio: 21 / 9; width: min(100%, 640px); }

.video-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.video-stage-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 999px;
}

.video-timeline {
    flex: 0 0 auto;
    padding: 8px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: #10131a;
}

.video-timeline-track {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

.video-slide-thumb {
    flex: 0 0 auto;
    width: 54px;
    height: 72px;
    border-radius: 10px;
    border: 2px solid transparent;
    background: linear-gradient(160deg, #1f2937, #111827);
    color: #fff;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    padding: 0;
}

.video-slide-thumb.is-active {
    border-color: #54a0ff;
}

.video-slide-thumb-canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-slide-num {
    position: absolute;
    left: 6px;
    bottom: 6px;
    font-size: 0.72rem;
    font-weight: 800;
    background: rgba(0, 0, 0, 0.45);
    padding: 1px 5px;
    border-radius: 6px;
    z-index: 1;
}

.video-editor {
    flex: 0 1 auto;
    background: #12151c;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    max-height: min(46vh, calc(100svh - 220px));
    min-height: 0;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
}

.video-editor-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.video-tab {
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.14);
    background: #141821;
    color: rgba(255, 255, 255, 0.5);
    padding: 8px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 0.62rem;
    font-weight: 800;
    cursor: pointer;
    min-height: 52px;
    border-radius: 0;
}

.video-tab:last-child {
    border-right: none;
}

.video-tab i {
    font-size: 0.95rem;
}

.video-tab.is-active {
    color: #54a0ff;
    background: rgba(84, 160, 255, 0.16);
    box-shadow: inset 0 0 0 1px #54a0ff;
}

.video-editor-panels {
    overflow: auto;
    padding: 8px 0 16px;
    min-height: 120px;
}

.video-editor-panels .video-panel-label,
.video-editor-panels .video-panel-hint,
.video-editor-panels .video-search-wrap,
.video-editor-panels .video-option-list,
.video-editor-panels .video-color-row,
.video-editor-panels .video-toggle-row,
.video-editor-panels .video-apply-all,
.video-editor-panels .video-theme-row,
.video-editor-panels .video-bg-presets,
.video-editor-panels .video-media-row,
.video-editor-panels .video-color-presets {
    padding-left: 14px;
    padding-right: 14px;
    box-sizing: border-box;
}

.video-editor-panels .video-subtabs,
.video-editor-panels .video-excel-grid,
.video-editor-panels .video-bg-source-tabs,
.video-editor-panels .video-style-row,
.video-editor-panels .video-anim-grid,
.video-editor-panels .video-format-toggle {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
}

.video-panel-section {
    background: none;
    border: none;
    border-radius: 0;
    padding: 12px 0 14px;
    margin: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.video-panel-section:first-child {
    padding-top: 4px;
}

.video-panel-section:last-child {
    border-bottom: none;
}

.video-panel-label {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
    margin: 0 0 8px;
}

.video-panel-hint {
    margin: 10px 0 0;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.78rem;
    line-height: 1.35;
}

.video-panel-hint--top {
    margin: -2px 0 10px;
}

.video-panel-hint code {
    font-size: 0.72rem;
    color: #93c5fd;
    background: rgba(84, 160, 255, 0.12);
    padding: 1px 6px;
    border-radius: 6px;
}

.video-bg-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.video-bg-swatch {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    border: 2px solid transparent;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.video-bg-swatch.is-active {
    border-color: #fff;
    box-shadow: 0 0 0 2px #54a0ff;
}

.video-media-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.video-media-empty {
    width: 100%;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.35);
    padding: 8px 0;
}

.video-media-thumb {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 12px;
    border: 2px solid transparent;
    padding: 0;
    overflow: hidden;
    cursor: pointer;
    background: #0b0d12;
}

.video-media-thumb img,
.video-media-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-media-thumb span {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.28);
    color: #fff;
    font-size: 1rem;
    pointer-events: none;
}

.video-media-thumb.is-active {
    border-color: #fff;
    box-shadow: 0 0 0 2px #54a0ff;
}

.video-style-row,
.video-anim-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    margin-bottom: 10px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    overflow: hidden;
}

.video-style-chip,
.video-anim-chip {
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.14);
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    background: #141821;
    color: #fff;
    border-radius: 0;
    padding: 10px 8px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
}

.video-style-row .video-style-chip:nth-child(3n),
.video-anim-grid .video-anim-chip:nth-child(3n) {
    border-right: none;
}

.video-style-chip.is-active,
.video-anim-chip.is-active {
    background: rgba(84, 160, 255, 0.16);
    color: #54a0ff;
    box-shadow: inset 0 0 0 1px #54a0ff;
}

.video-color-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 10px;
}

.video-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
    padding: 0;
}

.video-color-swatch.is-active {
    border-color: #fff;
    box-shadow: 0 0 0 2px #54a0ff;
}

.video-color-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.video-color-row input[type="color"] {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    padding: 0;
}

.video-range-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.video-range-caption {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 700;
}

.video-color-row input[type="range"] {
    width: 100%;
}

.video-color-row > span {
    min-width: 28px;
    text-align: right;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.video-theme-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.video-theme-chip {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: #1a1f2b;
    color: #fff;
    border-radius: 999px;
    padding: 6px 10px 6px 6px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.video-theme-chip i {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: block;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.video-theme-chip.is-active {
    border-color: #54a0ff;
    background: rgba(84, 160, 255, 0.18);
    color: #54a0ff;
}

.video-toggle-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.video-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.88);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 10px 12px;
    flex: 1 1 140px;
}

.video-check input {
    width: 16px;
    height: 16px;
    accent-color: #54a0ff;
}

.video-format-toggle,
.video-excel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: transparent;
    overflow: hidden;
}

.video-excel-grid--3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.video-excel-grid--2 {
    grid-template-columns: 1fr 1fr;
}

.video-format-btn,
.video-export-opt {
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.14);
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    background: #141821;
    color: #fff;
    border-radius: 0;
    padding: 10px 6px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 42px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    line-height: 1.15;
}

.video-excel-grid .video-format-btn:nth-child(2n),
.video-excel-grid--2 .video-format-btn:nth-child(2n),
.video-excel-grid--2 .video-export-opt:nth-child(2n) {
    border-right: none;
}

.video-excel-grid--3 .video-format-btn:nth-child(2n) {
    border-right: 1px solid rgba(255, 255, 255, 0.14);
}

.video-excel-grid--3 .video-format-btn:nth-child(3n) {
    border-right: none;
}

.video-excel-grid--2 .video-format-btn:nth-last-child(-n+2),
.video-excel-grid--3 .video-format-btn:nth-last-child(-n+3) {
    border-bottom: none;
}

.video-format-btn small,
.video-export-opt small {
    font-size: 0.58rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.42);
    letter-spacing: 0;
    text-transform: none;
}

.video-format-btn.is-active small,
.video-export-opt.is-active small {
    color: rgba(84, 160, 255, 0.85);
}

.video-format-btn.is-active,
.video-export-opt.is-active {
    border-color: rgba(84, 160, 255, 0.45);
    background: rgba(84, 160, 255, 0.16);
    color: #54a0ff;
    box-shadow: inset 0 0 0 1px #54a0ff;
}

.video-export-opt--wide {
    grid-column: 1 / -1;
    border-right: none;
    border-bottom: none;
}

.video-export-size {
    margin: 8px 0 0;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.45);
}

.video-base-panel .video-panel-label {
    margin-top: 14px;
}

.video-base-panel .video-panel-label:first-child {
    margin-top: 0;
}

.video-apply-all {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 12px;
    border: 1px solid rgba(84, 160, 255, 0.45);
    background: rgba(84, 160, 255, 0.16);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
    padding: 12px 14px;
    border-radius: 14px;
    min-height: 46px;
    -webkit-tap-highlight-color: transparent;
}

.video-apply-all:active {
    background: rgba(84, 160, 255, 0.28);
}

.video-bg-source-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    overflow: hidden;
}

.video-bg-source-tab {
    border: none;
    border-right: 1px solid rgba(255, 255, 255, 0.14);
    background: #141821;
    color: rgba(255, 255, 255, 0.55);
    border-radius: 0;
    padding: 10px 4px;
    font-size: 0.75rem;
    font-weight: 800;
    cursor: pointer;
}

.video-bg-source-tab:last-child {
    border-right: none;
}

.video-bg-source-tab.is-active {
    background: rgba(84, 160, 255, 0.16);
    color: #54a0ff;
    box-shadow: inset 0 0 0 1px #54a0ff;
}

.video-bg-source-panel {
    margin-bottom: 4px;
}

.video-bg-source-panel[hidden] {
    display: none !important;
}

.video-excel-grid.video-watermark-toggle {
    grid-template-columns: repeat(6, 1fr);
}

.video-excel-grid.video-watermark-toggle .video-format-btn {
    font-size: 0.72rem;
    padding: 8px 6px;
    border-right: 1px solid rgba(255, 255, 255, 0.14);
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.video-excel-grid.video-watermark-toggle .video-format-btn:nth-child(-n+3) {
    grid-column: span 2;
}

.video-excel-grid.video-watermark-toggle .video-format-btn:nth-child(n+4) {
    grid-column: span 3;
    border-bottom: none;
}

.video-excel-grid.video-watermark-toggle .video-format-btn:nth-child(3),
.video-excel-grid.video-watermark-toggle .video-format-btn:nth-child(5) {
    border-right: none;
}

.video-slide-thumb.is-special .video-slide-num {
    left: 4px;
    right: 4px;
    font-size: 0.58rem;
    text-align: center;
}

.video-play-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 999px;
    padding: 8px 12px;
    background: #fff;
    color: #111;
    font-weight: 800;
    font-size: 0.8rem;
    cursor: pointer;
}

.video-play-btn--header {
    flex-shrink: 0;
}

.video-preview-overlay {
    position: fixed;
    inset: 0;
    z-index: 950;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(12px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px));
}

.video-preview-overlay[hidden] {
    display: none !important;
}

.video-preview-close {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.video-preview-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: min(100%, 520px);
    max-height: 100%;
}

.video-preview-stage {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: 100%;
}

.video-preview-stage[data-format="vertical"],
.video-preview-stage[data-format="9:16"],
.video-preview-stage[data-format="4:5"],
.video-preview-stage[data-format="3:4"],
.video-preview-stage[data-format="2:3"] {
    aspect-ratio: 9 / 16;
    height: min(78dvh, calc(100dvh - 140px));
    width: auto;
    max-width: min(100%, calc(78dvh * 9 / 16));
}

.video-preview-stage[data-format="4:5"] { aspect-ratio: 4 / 5; }
.video-preview-stage[data-format="3:4"] { aspect-ratio: 3 / 4; }
.video-preview-stage[data-format="2:3"] { aspect-ratio: 2 / 3; }

.video-preview-stage[data-format="1:1"] {
    aspect-ratio: 1 / 1;
    width: auto;
    height: min(72dvh, calc(100dvh - 140px));
    max-width: min(100%, 72dvh);
}

.video-preview-stage[data-format="horizontal"],
.video-preview-stage[data-format="16:9"],
.video-preview-stage[data-format="4:3"],
.video-preview-stage[data-format="3:2"],
.video-preview-stage[data-format="21:9"] {
    aspect-ratio: 16 / 9;
    width: min(96vw, 900px);
    height: auto;
    max-height: min(70dvh, calc(100dvh - 140px));
}

.video-preview-stage[data-format="4:3"] { aspect-ratio: 4 / 3; }
.video-preview-stage[data-format="3:2"] { aspect-ratio: 3 / 2; }
.video-preview-stage[data-format="21:9"] { aspect-ratio: 21 / 9; }

.video-preview-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.video-preview-controls {
    width: min(100%, 420px);
    padding: 10px 12px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
}

.video-preview-seek {
    width: 100%;
    accent-color: #54a0ff;
    cursor: pointer;
}

.video-preview-seek-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.7);
}

.video-export-modal {
    position: fixed;
    inset: 0;
    z-index: 800;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.video-export-modal.is-open {
    opacity: 1;
    visibility: visible;
}

.video-export-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.video-export-sheet {
    position: relative;
    width: min(100%, 480px);
    background: #171a22;
    border-radius: 18px 18px 0 0;
    padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    color: #fff;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35);
}

.video-export-handle {
    width: 42px;
    height: 4px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 auto 12px;
}

.video-export-sheet h3 {
    margin: 0 0 14px;
    font-size: 1.1rem;
}

.video-export-duration {
    margin: -6px 0 10px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.72);
}

.video-export-format-hint {
    margin: -4px 0 12px;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.45);
}

.video-export-section {
    margin-bottom: 14px;
}

.video-export-progress {
    margin: 8px 0 14px;
}

.video-progress-track {
    height: 8px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.video-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #2e86de, #54a0ff);
    transition: width 0.25s ease;
}

.video-progress-text {
    margin: 8px 0 0;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.55);
}

.video-export-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.video-export-actions .video-btn {
    flex: 1 1 auto;
    min-width: 110px;
}

.video-toast {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%) translateY(10px);
    background: rgba(15, 23, 42, 0.95);
    color: #fff;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    opacity: 0;
    pointer-events: none;
    transition: 0.2s;
    z-index: 9999;
}

.video-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.video-home-link {
    display: none;
}

@media (min-width: 900px) {
    .video-studio {
        display: grid;
        grid-template-columns: minmax(0, 1.2fr) 92px minmax(300px, 0.95fr);
        grid-template-rows: minmax(0, 1fr);
        align-items: stretch;
    }

    .video-workspace {
        grid-column: 1;
        grid-row: 1;
        min-height: 0;
        overflow: hidden;
    }

    .video-stage[data-format="vertical"],
    .video-stage[data-format="9:16"],
    .video-stage[data-format="4:5"],
    .video-stage[data-format="3:4"],
    .video-stage[data-format="2:3"] {
        max-width: min(360px, 100%);
        max-height: 100%;
        height: 100%;
        width: auto;
    }

    .video-stage[data-format="1:1"] {
        max-width: min(420px, 100%);
    }

    .video-timeline {
        grid-column: 2;
        grid-row: 1;
        border-top: none;
        border-left: 1px solid rgba(255, 255, 255, 0.06);
        border-right: 1px solid rgba(255, 255, 255, 0.06);
        max-height: none;
        height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 10px 8px;
        background: #0e1118;
    }

    .video-timeline-track {
        flex-direction: column;
        align-items: stretch;
        overflow: visible;
        gap: 8px;
        padding-bottom: 0;
    }

    .video-slide-thumb {
        width: 100%;
        height: auto;
        aspect-ratio: 9 / 16;
        max-height: 128px;
    }

    .video-studio[data-format="horizontal"] .video-slide-thumb,
    .video-studio[data-format="16:9"] .video-slide-thumb,
    .video-studio[data-format="4:3"] .video-slide-thumb,
    .video-studio[data-format="3:2"] .video-slide-thumb,
    .video-studio[data-format="21:9"] .video-slide-thumb,
    .video-slide-thumb.is-horizontal,
    .video-slide-thumb.is-landscape {
        aspect-ratio: 16 / 9;
        max-height: 64px;
    }

    .video-studio[data-format="1:1"] .video-slide-thumb {
        aspect-ratio: 1 / 1;
        max-height: 88px;
    }

    .video-studio[data-format="4:5"] .video-slide-thumb { aspect-ratio: 4 / 5; }
    .video-studio[data-format="3:4"] .video-slide-thumb { aspect-ratio: 3 / 4; }
    .video-studio[data-format="2:3"] .video-slide-thumb { aspect-ratio: 2 / 3; }
    .video-studio[data-format="4:3"] .video-slide-thumb { aspect-ratio: 4 / 3; }
    .video-studio[data-format="3:2"] .video-slide-thumb { aspect-ratio: 3 / 2; }
    .video-studio[data-format="21:9"] .video-slide-thumb { aspect-ratio: 21 / 9; max-height: 48px; }

    .video-editor {
        grid-column: 3;
        grid-row: 1;
        max-height: none;
        height: 100%;
        min-height: 0;
        overflow: hidden;
        border-top: none;
        border-left: none;
        padding-bottom: 0;
    }

    .video-editor-panels {
        flex: 1 1 auto;
        min-height: 0;
    }

    .video-export-modal {
        align-items: center;
    }

    .video-export-sheet {
        border-radius: 18px;
        margin: 16px;
    }
}

@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
    html,
    body,
    .video-page {
        height: 100svh;
        max-height: 100svh;
    }

    .video-wizard-footer {
        padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    }

    .video-editor {
        max-height: min(42svh, calc(100svh - 240px));
        padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
    }
}
